示例#1
0
 /// <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));
 }
示例#2
0
 /// <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);
     }
 }
示例#3
0
        /// <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;
            }
        }
示例#4
0
 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());
         }
 }
示例#5
0
 /// <summary>
 /// Returns a new <see cref="Item"/> with the AML body.
 /// </summary>
 /// <param name="aml">AML to populate the item with</param>
 public Item newItemFromAml(IAmlNode aml)
 {
     return(newItemFromAml(aml.ToAml));
 }