|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Type for Application Settingsa type for an application setting. I can't get it to work! The IDE (Settings tab in Project Properties) always tells me "Cannot be converted to an instance of type EncryptedString". What am I missing? [Serializable] [XmlRootAttribute()] public class EncryptedString : IXmlSerializable { public string EncryptedValue = ""; public EncryptedString() { } public EncryptedString(string value) { EncryptedValue = Encryptor.RC2Encrypt(value); } public override string ToString() { return EncryptedValue; } public static implicit operator EncryptedString(string value) { return new EncryptedString(value); } public static implicit operator string(EncryptedString value) { return value.UnencryptedValue; } public string UnencryptedValue { get { return Encryptor.RC2Decrypt(EncryptedValue); } set { EncryptedValue = Encryptor.RC2Encrypt(value); } } #region IXmlSerializable Members public System.Xml.Schema.XmlSchema GetSchema() { return null; } public void ReadXml(System.Xml.XmlReader reader) { reader.MoveToContent(); if (reader.Read()) EncryptedValue = reader.Value; } public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteElementString("EncryptedValue", EncryptedValue); } #endregion } |
|||||||||||||||||||||||