public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object result; if (value is string) { string serialization = value as string; Configuration configuration = new Configuration(); if (!string.IsNullOrEmpty(serialization)) { using (StringReader stringReader = new StringReader((string)value)) { using (XmlTextReader reader = new XmlTextReader(stringReader)) { reader.Read(); SerializationServices.Deserialize(configuration.GetType(), reader, false); } } } result = configuration; } else { result = base.ConvertFrom(context, culture, value); } return result; }
public static IExpression Expression(this IExpressionsManager manager, XElement element) { Configuration config = new Configuration(); IConfigurationElement configElement = config.AddSection("expression extensions").AddElement("expression"); configElement.ReadXml(element.CreateReader()); IExpression expression = manager.Token(configElement.GetAttributeReference("type").Value.ToString()) as IExpression; if (null != expression) expression.Make(configElement, manager); return expression; }
public static void FromXml(this IExpression expression, XElement element, IExpressionsManager expressionsManager) { if (null == expression) throw new ArgumentNullException("expression"); if (null == element) throw new ArgumentNullException("element"); if (null == expressionsManager) throw new ArgumentNullException("expressionsManager"); Configuration config = new Configuration(); IConfigurationElement configElement = config.AddSection("expression extensions").AddElement("expression"); configElement.ReadXml(element.CreateReader()); expression.Make(configElement, expressionsManager); }
public IConfiguration Clone() { Configuration clone = new Configuration(this.ConfigKey); clone.Sections = this.Sections.Clone(clone); return clone; }
public static void ToXml(this IExpression expression, XmlTextWriter writer) { if (null == expression) throw new ArgumentNullException("expression"); if (null == writer) throw new ArgumentNullException("writer"); Configuration config = new Configuration(); IConfigurationElement configElement = config.AddSection("expression extensions").AddElement("expression"); expression.ToConfiguration(configElement); configElement.WriteXml(writer); }