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


C# JArray.OfType方法代码示例

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


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

示例1: ValidateValues

 /// <summary>
 /// The validate values.
 /// </summary>
 /// <param name="controls">
 /// The controls.
 /// </param>
 /// <param name="data">
 /// The data.
 /// </param>
 /// <param name="errorList">
 /// The errorList.
 /// </param>
 private static void ValidateValues(JArray controls, JObject data, List<ValidationError> errorList)
 {
     foreach (JObject child in controls.OfType<JObject>())
     {
         IDynamicControl control = BaseControl.CreateControl(child);
         IDynamicValueControl valueControl = control as IDynamicValueControl;
         JProperty dataValue = null;
         if (valueControl != null)
         {
             dataValue = data.Children<JProperty>().FirstOrDefault(p => p.Name == child.Value<string>("name"));
             if (dataValue != null)
             {
                 JObject dataObject = dataValue.First as JObject;
                 if (dataObject != null)
                 {
                     JObject roles = child["checkedRoles"] as JObject;
                     if (roles != null)
                     {
                         if (roles.Value<bool>("required") && string.IsNullOrEmpty(dataObject.Value<string>("value")))
                         {
                             errorList.Add(new RequiredDataError(child.Value<string>("name")));
                         }
                     }
                     dataObject.Add(new JProperty("checked", true));
                 }
             }
             else
             {
                 errorList.Add(new MissingDataError(child.Value<string>("name")));
             }
         }
         IDynamicParentControl parentControl = control as IDynamicParentControl;
         if (parentControl != null)
         {
             JArray children = child.Value<JArray>("childs");
             if (children != null)
             {
                 JObject anyChildren = children.OfType<JObject>().FirstOrDefault(c => c.Value<string>("key") == "any");
                 if (anyChildren != null)
                 {
                     ValidateValues(anyChildren.Value<JArray>("controls"), data, errorList);
                 }
                 if (valueControl != null && dataValue != null)
                 {
                     JObject valueChildren = children.OfType<JObject>().FirstOrDefault(c => c.Value<string>("key") == dataValue.First.Value<string>("value"));
                     if (valueChildren != null)
                     {
                         ValidateValues(valueChildren.Value<JArray>("controls"), data, errorList);
                     }
                 }
             }
         }
     }
 }
开发者ID:UCASoft,项目名称:DynamicControls,代码行数:66,代码来源:DynamicValidator.cs

示例2: ConvertToValues

        private static Lut ConvertToValues(JArray obj) {
            var values = new Lut();
            if (obj == null) return values;

            foreach (var entry in obj.OfType<JArray>()) {
                double x, y;
                if (FlexibleParser.TryParseDouble(Convert.ToString(entry[0], CultureInfo.InvariantCulture), out x) &&
                        FlexibleParser.TryParseDouble(Convert.ToString(entry[1], CultureInfo.InvariantCulture), out y)) {
                    values.Add(new LutPoint(x, y));
                }
            }

            return values;
        }
开发者ID:gro-ove,项目名称:actools,代码行数:14,代码来源:GraphData.cs

示例3: SetCalculatedData

        public void SetCalculatedData(JArray calculatedData)
        {
            //.Where(p=>!((new int[]{5,3}).Contains((int)p["ParameterType"])))
            OutputParameters = calculatedData.OfType<JObject>().Where(ShowOutputParameter).Select(p => new EffectsOutputParameterViewModel() {Data = p});

            Contours = new GraphicCollection(calculatedData.OfType<JObject>().Where(IsContourParameter).Select(p=>((string)p["Data"]["Value"]).ToGraphic(new SpatialReference(28992), new SpatialReference(28992))));
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:7,代码来源:EffectsModelSettingsViewModel.cs

示例4: SetModelData

 public void SetModelData(JArray modelData)
 {
     Models.Clear();
     foreach (
         var model in modelData.OfType<JObject>().Select(model => new ModelSelectionViewModel() {Data = model}))
     {
         Models.Add(model);
     }
 }
开发者ID:TNOCS,项目名称:csTouch,代码行数:9,代码来源:EffectsModelSettingsViewModel.cs

示例5: GetColumnsFromItems

        internal IDictionary<string, Column> GetColumnsFromItems(JArray items)
        {
            Contract.Requires(items != null, "item cannot be null");

            IDictionary<string, Column> cols = new Dictionary<string, Column>();

            IEnumerator<IDictionary<string, JToken>> objects = items.OfType<IDictionary<string, JToken>>().GetEnumerator();
            objects.MoveNext();
            ICollection<string> columnsToDetermine = objects.Current.Keys;

            do
            {
                IList<string> nullColumns = new List<string>();
                foreach (var key in columnsToDetermine)
                {
                    JToken token;
                    if(defaultColumns.ContainsKey(key))
                    {
                        cols.Add(key, defaultColumns[key]);
                    }
                    else if (objects.Current.TryGetValue(key, out token))
                    {
                        JValue val = token as JValue;
                        if (val != null)
                        {
                            if (val.Value == null)
                            {
                                nullColumns.Add(key);
                            }
                            else
                            {
                                cols.Add(key, new Column(key, ColumnTypeHelper.GetColumnTypeForClrType(val.Value.GetType()), true));
                            }
                        }
                    }
                }
                columnsToDetermine = nullColumns;
            }
            while (columnsToDetermine.Count > 0 && objects.MoveNext());

            return cols;
        }
开发者ID:jlaanstra,项目名称:azure-mobile-services,代码行数:42,代码来源:SQLiteStructuredStorage.cs

示例6: RemoveArrayElements

        private static void RemoveArrayElements(JArray array, string currentPath, Func<string, bool> shouldSerialize, Dictionary<string, bool> cache)
        {
            array.OfType<JObject>()
                .ToList()
                .ForEach(childObject => RemoveObjectProperties(childObject, currentPath, shouldSerialize, cache));

            RemoveArrayIfEmpty(array);
        }
开发者ID:ath2o,项目名称:PartialResponse,代码行数:8,代码来源:PartialJsonMediaTypeFormatterUtilities.cs


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