当前位置: 首页>>代码示例>>C#>>正文


C# Scope.Set方法代码示例

本文整理汇总了C#中Scope.Set方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.Set方法的具体用法?C# Scope.Set怎么用?C# Scope.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scope的用法示例。


在下文中一共展示了Scope.Set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SupportDotedNamesForJson

        public void SupportDotedNamesForJson()
        {
            var cfg = new Scope();
            cfg.Set("a", new {b=1});
            var cfg2 = new Scope(cfg);
            cfg2.Set("a", new {b=3});

            Assert.AreEqual(3, cfg2.Get("a.b"));
            Assert.AreEqual(1, cfg2.Get(".a.b"));
        }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:10,代码来源:ScopeImprovementsTest.cs

示例2: BuildSelfParametesSource

		/// <summary>
		///     Метод построения собственного индекса параметров
		/// </summary>
		/// <returns></returns>
		private IScope BuildSelfParametesSource(){
			var result = new Scope();
			foreach (XAttribute a in Source.Attributes()){
				result.Set(a.Name.LocalName, a.Value);
			}
			return result;
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:11,代码来源:BSharpClass.cs

示例3: Assign

 public static void Assign(Scope scope) {
     scope.Set("abs", new FunctionValue(CommonFunctions.FunctionAbsolute), ScopeMode.Closest);
     scope.Set("add", new FunctionValue(CommonFunctions.FunctionAdd), ScopeMode.Closest);
     scope.Set("and", new FunctionValue(CommonFunctions.FunctionAnd), ScopeMode.Closest);
     scope.Set("cat", new FunctionValue(CommonFunctions.FunctionCat), ScopeMode.Closest);
     scope.Set("char", new FunctionValue(CommonFunctions.FunctionChar), ScopeMode.Closest);
     scope.Set("cmp", new FunctionValue(CommonFunctions.FunctionCompare), ScopeMode.Closest);
     scope.Set("cross", new FunctionValue(CommonFunctions.FunctionCross), ScopeMode.Closest);
     scope.Set("default", new FunctionValue(CommonFunctions.FunctionDefault), ScopeMode.Closest);
     scope.Set("div", new FunctionValue(CommonFunctions.FunctionDiv), ScopeMode.Closest);
     scope.Set("eq", new FunctionValue(CommonFunctions.FunctionEqual), ScopeMode.Closest);
     scope.Set("except", new FunctionValue(CommonFunctions.FunctionExcept), ScopeMode.Closest);
     scope.Set("find", new FunctionValue(CommonFunctions.FunctionFind), ScopeMode.Closest);
     scope.Set("flip", new FunctionValue(CommonFunctions.FunctionFlip), ScopeMode.Closest);
     scope.Set("ge", new FunctionValue(CommonFunctions.FunctionGreaterEqual), ScopeMode.Closest);
     scope.Set("gt", new FunctionValue(CommonFunctions.FunctionGreater), ScopeMode.Closest);
     scope.Set("has", new FunctionValue(CommonFunctions.FunctionHas), ScopeMode.Closest);
     scope.Set("include", new FunctionValue(CommonFunctions.FunctionInclude), ScopeMode.Closest);
     scope.Set("join", new FunctionValue(CommonFunctions.FunctionJoin), ScopeMode.Closest);
     scope.Set("lcase", new FunctionValue(CommonFunctions.FunctionLowerCase), ScopeMode.Closest);
     scope.Set("le", new FunctionValue(CommonFunctions.FunctionLowerEqual), ScopeMode.Closest);
     scope.Set("len", new FunctionValue(CommonFunctions.FunctionLength), ScopeMode.Closest);
     scope.Set("lt", new FunctionValue(CommonFunctions.FunctionLower), ScopeMode.Closest);
     scope.Set("map", new FunctionValue(CommonFunctions.FunctionMap), ScopeMode.Closest);
     scope.Set("match", new FunctionValue(CommonFunctions.FunctionMatch), ScopeMode.Closest);
     scope.Set("max", new FunctionValue(CommonFunctions.FunctionMaximum), ScopeMode.Closest);
     scope.Set("min", new FunctionValue(CommonFunctions.FunctionMinimum), ScopeMode.Closest);
     scope.Set("mod", new FunctionValue(CommonFunctions.FunctionMod), ScopeMode.Closest);
     scope.Set("mul", new FunctionValue(CommonFunctions.FunctionMul), ScopeMode.Closest);
     scope.Set("not", new FunctionValue(CommonFunctions.FunctionNot), ScopeMode.Closest);
     scope.Set("or", new FunctionValue(CommonFunctions.FunctionOr), ScopeMode.Closest);
     scope.Set("ord", new FunctionValue(CommonFunctions.FunctionOrd), ScopeMode.Closest);
     scope.Set("rand", new FunctionValue(CommonFunctions.FunctionRandom), ScopeMode.Closest);
     scope.Set("slice", new FunctionValue(CommonFunctions.FunctionSlice), ScopeMode.Closest);
     scope.Set("sort", new FunctionValue(CommonFunctions.FunctionSort), ScopeMode.Closest);
     scope.Set("split", new FunctionValue(CommonFunctions.FunctionSplit), ScopeMode.Closest);
     scope.Set("sub", new FunctionValue(CommonFunctions.FunctionSub), ScopeMode.Closest);
     scope.Set("ucase", new FunctionValue(CommonFunctions.FunctionUpperCase), ScopeMode.Closest);
     scope.Set("union", new FunctionValue(CommonFunctions.FunctionUnion), ScopeMode.Closest);
     scope.Set("when", new FunctionValue(CommonFunctions.FunctionWhen), ScopeMode.Closest);
     scope.Set("xor", new FunctionValue(CommonFunctions.FunctionXor), ScopeMode.Closest);
     scope.Set("count", new FunctionValue(CommonFunctions.FunctionCount), ScopeMode.Closest);
     //scope.Set("where", new FunctionValue(CommonFunctions.FunctionWhere), ScopeMode.Closest);
 }
开发者ID:WMeszar,项目名称:Cottle,代码行数:44,代码来源:CommonFunctions.cs

示例4: Set

 public bool Set(Scope scope, Value value, ScopeMode mode)
 {
     return scope.Set (this.name, value, mode);
 }
开发者ID:WMeszar,项目名称:Cottle,代码行数:4,代码来源:NameExpression.cs

示例5: PrepareDataSource

 private IScope PrepareDataSource(XElement source, IScope parent) {
     var result = new Scope();
     if (null != parent) {
         result.SetParent(parent);
     }
     foreach (var a in source.Attributes()) {
         result.Set(a.Name.LocalName, a.Value);
     }
     result.Set("this", source);
     return result;
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:11,代码来源:XmlInterpolation.cs

示例6: ProcessRepeat

        private XElement[] ProcessRepeat(XElement source, IScope datasource) {
            var a = GetDataSource(source, datasource);
            if (0 == a.Length) {
                return null;
            }


            var result = new List<XElement>();

            var scope = source.Attr("xi-scope");
            var scope2 = "";

            var expand = source.Attr("xi-expand").ToBool();
            var rep = source.Attr("xi-repeat");
            if (rep.Contains(" in ")) {
                scope2 = Regex.Match(rep, @"^([\s\S]+?)\s+in").Groups[1].Value;
                if (scope2.EndsWith("+")) {
                    expand = true;
                    scope2 = scope2.Substring(0, scope2.Length - 1);
                }
            }
            
            var i = 0;

            foreach (var o in a) {
                var dict = o.ToDict();
                var cfg = new Scope();
                if (!string.IsNullOrWhiteSpace(scope)) {
                    cfg[scope] = dict;
                }
                if (!string.IsNullOrWhiteSpace(scope2)) {
                    cfg[scope2] = dict;
                }
                if (expand) {
                    foreach (var p in dict) {
                        cfg[p.Key] = p.Value;
                    }
                }

                var clone = new XElement(source);
                cfg.Set("this", clone);
                cfg.Set("parent", source);
                cfg.SetParent(datasource);
                cfg.Set("_idx", i);
                cfg.Set("_num", i + 1);
                cfg.Set("_i", dict);
                if (!MatchCondition(clone, cfg, "where")) {
                    continue;
                }

                clone.SetAttributeValue("xi-repeat", null);
                clone.SetAttributeValue("xi-scope", null);
                clone.SetAttributeValue("xi-expand", null);
                clone = Interpolate(clone, cfg);
                if (null != clone) {
                    if (clone.Attr("xi-body").ToBool()) {
                        foreach (var element in clone.Elements()) {
                            result.Add(element);
                        }
                    }
                    else {
                        result.Add(clone);
                    }
                }
                i++;
            }
            return result.ToArray();
        }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:68,代码来源:XmlInterpolation.cs

示例7: Interpolate

 /// <summary>
 ///     Интерполирует исходный элемет в целевой
 /// </summary>
 /// <param name="source"></param>
 /// <param name="baseelement"></param>
 /// <returns></returns>
 public XElement Interpolate(XElement source, XElement baseelement) {
     var datasources = baseelement.AncestorsAndSelf().Reverse().ToArray();
     Scope cfg = null;
     foreach (var element in datasources) {
         cfg = new Scope(cfg);
         foreach (var attribute in element.Attributes()) {
             cfg.Set(attribute.Name.LocalName, attribute.Value);
         }
         var selftext = string.Join(Environment.NewLine, element.Nodes().OfType<XText>().Select(_ => _.Value));
         if (!string.IsNullOrWhiteSpace(selftext) && !cfg.ContainsOwnKey("__value")) {
             cfg.Set("__value", selftext);
         }
     }
     return Interpolate(source, cfg);
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:21,代码来源:XmlInterpolation.cs


注:本文中的Scope.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。