/// <summary> /// Initializes a new instance of the <see cref="KeyData"/> class /// from a previous instance of <see cref="KeyData"/>. /// </summary> /// <remarks> /// Data is deeply copied /// </remarks> /// <param name="ori"> /// The instance of the <see cref="KeyData"/> class /// used to create the new instance. /// </param> public KeyData(KeyData ori) { _value = ori._value; _keyName = ori._keyName; _comments = new List <string>(ori._comments); }
/// <summary> /// Gets configuration as collection of KeyData. /// Derived classes can replace this to customize what to save into configuration. /// </summary> /// <returns>Collection of KeyData</returns> public virtual IEnumerable<KeyData> GetConfiguration () { var sectionData = new List<KeyData>(); var configObject = this; if (configObject==null) { return sectionData; } foreach ( var prop in GetConfigurationProperties() ) { var name = prop.Name; var value = prop.GetValue( configObject ); var conv = TypeDescriptor.GetConverter( prop.PropertyType ); var keyData = new KeyData(name); keyData.Value = conv.ConvertToInvariantString( value ); sectionData.Add( keyData ); } return sectionData; }
/// <summary> /// Initializes a new instance of the <see cref="KeyData"/> class /// from a previous instance of <see cref="KeyData"/>. /// </summary> /// <remarks> /// Data is deeply copied /// </remarks> /// <param name="ori"> /// The instance of the <see cref="KeyData"/> class /// used to create the new instance. /// </param> public KeyData(KeyData ori) { _value = ori._value; _keyName = ori._keyName; _comments = new List<string>(ori._comments); }