コード例 #1
0
        public void Substitute_Cdata()
        {
            var sub = new ParameterSubstitution();

            sub.AddIndexedParameters(new object[] { "first & second > third", true, new DateTime(2015, 1, 1) });
            var newQuery = sub.Substitute("<Item><name><![CDATA[@0]]></name><is_current>${1}</is_current><date>${2}</date></Item>", ElementFactory.Local.LocalizationContext);

            Assert.AreEqual("<Item><name><![CDATA[first & second > third]]></name><is_current>1</is_current><date>2015-01-01T00:00:00</date></Item>", newQuery);
        }
コード例 #2
0
ファイル: QueryItem.cs プロジェクト: stinby/Innovator.Client
 /// <summary>
 /// Converts an AML node into a query which can be converted to other forms (e.g. SQL, OData, ...)
 /// </summary>
 /// <param name="xml">XML data</param>
 /// <param name="context">Localization context for parsing and formating data</param>
 /// <param name="args">Arguments to substitute into the query</param>
 public static QueryItem FromXml(string xml, IServerContext context, params object[] args)
 {
     return(FromXml(w =>
     {
         var sub = new ParameterSubstitution();
         sub.AddIndexedParameters(args);
         sub.Substitute(xml, context, w);
     }, context));
 }
コード例 #3
0
        public void Substitute_SavedSearchParameter()
        {
            var sub = new ParameterSubstitution();

            sub.AddIndexedParameters(new object[] { "first & second > third", true, new DateTime(2015, 1, 1) });
            var newQuery = sub.Substitute("<Item><name>@{0}</name><is_current>@{1}</is_current><date>@{2}</date></Item>", ElementFactory.Local.LocalizationContext);

            Assert.AreEqual("<Item><name>first &amp; second &gt; third</name><is_current>1</is_current><date>2015-01-01T00:00:00</date></Item>", newQuery);
        }
コード例 #4
0
        /// <summary>
        /// Returns a new <see cref="Item"/> with the AML body.
        /// </summary>
        /// <param name="aml">AML to populate the item with</param>
        /// <param name="args">Parameters to be injected into the query</param>
        public Item newItemFromAml(string aml, params object[] args)
        {
            var dom = NewXmlDocument();

            if (args?.Length > 0)
            {
                using (var writer = dom.CreateNavigator().AppendChild())
                {
                    var sub = new ParameterSubstitution();
                    sub.AddIndexedParameters(args);
                    sub.Substitute(aml, LocalizationContext, writer);
                }
            }
            else
            {
                dom.LoadXml(aml);
            }

            return(new Item(this, dom));
        }