This question already has answers here:
How do I get the local machine name in C#?
(5 answers)
Closed 8 years ago.
I'm building a web page with visual studio 2010. I want to used pass word recovery control. I need to find out what server Name is, so I can use SMTP setting to send emails to the user who forgets his pass word. I don't know how to get it. Does anybody know. I appreciate it very much.
My.Computer.Name should do the trick in VB. #Vache said that My.Computer does not exist in C#.
Or
System.Environment.MachineName, as pointed out by a commentor.
It looks like System.Environment.MachineName may be preferred, as that is a static method. My.Computer.Name seems to be added at the project level; when I just tried it in the Immediate Window within a solution that has numerous projects, the call was ambiguous. I had to fully qualify it by a project's namespace before I could get the value. E.g., MyNamespace.Project1.My.Computer.Name. However, you shouldn't have to qualify it if you call it from within a project instead of a global area like I did.
Poco supports HMACEngine with different hash functions. For example to create a HMAC-SHA1 function I can use HMACEngine<SHA1Engine> hmca_sha1("secret");
This works well with DigestEngine like SHA1Engine and MD5Engine that have a constructor without argument.
Is it possible to use HMACEngine with hash functions from OpenSSL as they are provided by Poco::Crypto::DigestEngine?
The problem is that these functions take a string parameter in their constructor that specifies which hashing algorithm to use. This means HMACEngine<Poco::Crypto:DigestEngine> hmca_xxx("secret"); wouldn't work.
Any idea how to do this?
I think it will require some coding on Poco side. HMAC is accepting any class as template argument, and hoping it is a Digest class ans using methods like digest() that may not even exist. The HMACEngine that instantiates the class as template, so you can´t passa anything to its constructor as it is. In fact I don´t think that is a good use of templates, while I´m not very familiar with using this C++ resource yet, I think one should not expect anything to be available from templated class.
Probably a new HMACEngine for the Crypto module (instead of Foundation module) would be good. But looks like an approach more like the Poco::Crypto::RSADigestEngine would be better than the current template based one. I´ve recently modified Poco::Crypto::RSADigestEngine to be based on Poco::Crypto::DigestEngine instead off old Foundation Poco::DigestEngine, and therefore for next release it will also support all hashes that OpenSSL support. Basically RSADigestEngine creates an instance of a Poco::Crypto::DigestEngine as base and uses it.
I could help on a patch proposal if you create one at github. Poco::Crypto does need some updates :)
I worked on DotNetNuke in some projects and I find very much interesting Custom Business Object Class which is named as CBO.vb in the DotNetNuke project.
So I want to use this helper class in my other project also which is not in DotNetNuke but in core asp.net projects.
So I read about some important methods of this class which are majority used by me are:
CBO.FillObject
FillCollection
Now I am searching what are issues in this class that can be improved by me before I am going to use this class.
So I search this and found an interesting topic on code project which point out several issues like:
business object and the fields in the database had to have the same name
FillCollection method returned an ArrayList
So my question is there any other thing which can be solved before use like
use reflection to create objects which are slower for that they give idea how to implement this by using The IHydratable Interface
You can find class here
CBO is a useful class. However if I were looking for a similar solution today, I would look to one of the new "Micro-ORMs" such as:
Massive
PetaPoco
Dapper
When applying such a light wrapper around the database, I am not sure that supporting different names in the DB and business objects is really a good idea. It is a likely source of confusion.
Also there are already generic overloads for the FillCollection method which return List<T>. The ArrayList versions are only there for backward compatibility, no one should write any new code with them.
what has to be done for including Localization Concepts?
may i get the source code for each & every steps to be done?
is it necessary to include the resource files?
what has to be entered in the String & in the Value column while creating the Resource File?
What has to be done for including Localization Concepts?
The first step is to actually understand these concepts... You may want to read about it here:
Effective Strategies for Localization in .NET
May I get the source code for each & every steps to be done?
Oh dear... Such question is too broad and could be closed as not answerable. You would found plenty of examples and tutorials online. Just read them and ask specific questions about things you do not understand. But first, please try to search these questions using your favorite search provider (most of them were answered, some probably multiple times).
Is it necessary to include the resource files?
It is not necessary. However, for most of applications it is both easiest and fastest method. And simply the best method. And the only one which is really easy.
What has to be entered in the String & in the Value column while creating the Resource File?
In the first column you would need to put resource identifier - unique key that would identify your translatable string. Depending on Localization method you would choose, it could have different forms (for implicit Localization it is best to keep it as control_identifier.property_name, where control_identifier is a string you put in ID attribute and property_name is name of the property you want to translate, i.e. lblName.Text). In the Value column you need to put your translatable string.
AMF3 specification defines use of so called "reference tables" (see Section 2.2 of this specification).
I implemented this behavior in my AMF3 encoder/decoder I developed in Erlang, but being not very experienced with Flash API, I can hardly find how can I easily force Flash to use these reference tables when serializing objects to AMF3; for example if I use ByteArray, it seems that it just repeats full object encodings
var ba:ByteArray = new ByteArray();
ba.writeObject("some string1");
ba.writeObject("some string1");
# =>
# <<6,25,115,111,109,101,32,115,116,114,105,110,103,49,
# 6,25,115,111,109,101,32,115,116,114,105,110,103,49>>
(which is clearly a repetition).
However, if these two strings are in a one single writeObject call, it does seem to use references:
ba.writeObject(["some string1", "some string1"]);
# => <<9,5,1,6,25,115,111,109,101,32,115,116,114,105,110,103,49,6,0>>
Socket seems to behave the same way.
So, can I make use of reference tables in Flash code? (provided I might have a non-standard protocol between Flash application and server )
Thank you!
I think the difference is that in the first example you're writing two string literals. In the second example you're writing an array (or Complex Object in Adobe's specs) that has a reference to two strings. So if you reference the string from an object or an array it will write it in the reference table.
This isn't necessarily a way to enforce it but it seems logical that the AMF serializer built into flash would serialize objects this way so it is probably a reliable way to get the behavior your want (reference table strings).
I hope that is helpful to you!
As per the final sentence of the AMF3 specification (AMF 3.0 Spec at Adobe.com):
Also note that ByteArray uses a new set of implicit reference tables for objects, object traits and strings for each readObject and writeObject call.
It appears that the intention with ByteArray.writeObject is to create a serialization which could be stored or recovered on a per-object basis.
The NetConnection object's behavior is similar to what you had hoped for.
When updating the string-references table, it is important to not add empty strings to the reference table.
When maintaining the object-references table, you may be able to implement defensive programming as follows: the object-references table is constructed recursively and at some times contains objects for which the traits are not yet completely known. If the table indices are not allocated in advance, the numbering will be inconsistent across applications. An AMF3 decoder should not use the traits from a partially-constructed object -- such input should be flagged as erroneous.
The strings-reference table is implemented at the encoder by 'tagging' in-memory string objects as they are serialized. Encoding two different string objects with the same content (matching strings) do not seem to be encoded with one string referencing the other. Both strings will be output and a string-by-reference will not be used.
There may be a solution to your original question. If you have a number of objects all belonging to the same class, and you would like to store those objects all in one storage, I suggest the following: Create a "parent object" with references to all the objects you intend to store. Then use ByteArray.writeObject to persist that parent object. AMF will encode all of the referenced objects and will represent the traits of repeated object classes in an efficient way.
Look at the last page of the official AMF3 spec and you will see that ByteArray is pretty much worthless. You will have to write your own AMF3 serializer/deserializer.