/// <summary> /// Converts an AML node into a query which can be converted to other forms (e.g. SQL, OData, ...) /// </summary> /// <param name="node">XML data</param> /// <param name="context">Localization context for parsing and formating data</param> public static QueryItem FromXml(IAmlNode node, IServerContext context = null) { context = context ?? (node as IReadOnlyElement)?.AmlContext.LocalizationContext ?? ElementFactory.Local.LocalizationContext; return(FromXml(w => node.ToAml(w, new AmlWriterSettings()), context)); }
/// <summary>Return a result from a <see cref="IAmlNode"/></summary> /// <param name="aml">XML data</param> public IResult FromXml(IAmlNode aml) { using (var writer = new ResultWriter(this, null, null, false)) { aml.ToAml(writer, new AmlWriterSettings()); return(writer.Result); } }
/// <summary> /// Creates an AML command that will be sent to the server from an <see cref="IAmlNode"/> /// </summary> /// <param name="aml">The AML object (e.g. <see cref="IReadOnlyItem"/>) that you want to create /// the command with</param> public Command(IAmlNode aml) : this(aml.ToAml()) { var elem = aml as IReadOnlyElement; if (elem != null && elem.Name == "AML" && elem.Elements().Count() > 1) { this.Action = CommandAction.ApplyAML; } }
private static string ToAmlString(IAmlNode node) { using (var writer = new StringWriter()) using (var xml = XmlWriter.Create(writer, new XmlWriterSettings() { OmitXmlDeclaration = true, Indent = true, IndentChars = " " })) { node.ToAml(xml); xml.Flush(); return(writer.ToString()); } }