/// <summary> /// Saves the configuration. /// </summary> /// <param name="name">The name.</param> /// <param name="obj">The obj.</param> /// <param name="userName">Name of the user.</param> /// <returns></returns> public virtual int SaveConfiguration(string name, object obj, string userName) { Validator.ValidateStringArgumentIsNotNullOrEmptyString(name, NAME); Validator.ValidateArgumentIsSerializable(obj, OBJ); Validator.ValidateStringArgumentIsNotNullOrEmptyString(userName, USERNAME); Serializer serializer = new Serializer(); string xml = serializer.SerializeObject(obj, obj.GetType()); ConfigurationDatum configurationDatum = new ConfigurationDatum(ConfigurationDatum.Columns.Name, name); configurationDatum.Name = name; configurationDatum.Type = obj.GetType().AssemblyQualifiedName; configurationDatum.ValueX = xml.Trim(); if (configurationDatum.ConfigurationDataId == 0) { configurationDatum.CreatedDate = DateTime.UtcNow; } else { configurationDatum.ModifiedDate = DateTime.UtcNow; } configurationDatum.Save(userName); return configurationDatum.ConfigurationDataId; }
/// <summary> /// To XML. /// </summary> /// <returns></returns> public string ToXml() { Serializer serializer = new Serializer(); return serializer.SerializeObject(this, typeof(ExtendedProperties)); }