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


C# JObject.GetId方法代码示例

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


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

示例1: UpdateFields

		public static void UpdateFields(this JObject to, JObject from)
		{
			var id = from.GetId();
			var key = from.GetKey();
			var revision = from.GetRevision();

			JToken jtoken;

			if (from.TryGetValue(IdField, out jtoken))
			{
				to.SetId(id);
			}

			if (from.TryGetValue(KeyField, out jtoken))
			{
				to.SetKey(key);
			}

			if (from.TryGetValue(RevisionField, out jtoken))
			{
				to.SetRevision(revision);
			}
		}
开发者ID:bbqchickenrobot,项目名称:ArangoDB.Api,代码行数:23,代码来源:ArangoConventions.cs

示例2: RetreiveObjectFromRow

        private JObject RetreiveObjectFromRow(DataRow row, bool diffOnly = false)
        {
            int? pk = row.Field<int?>(this.Table.Columns[KeyColumn]);
            string modelName = row.Field<string>(this.Table.Columns[ModelColumn]);

            JObject obj = new JObject();
            obj.Add(FieldsField, new JObject());

            if (pk != null)
                obj.SetId(pk ?? 0);

            if (modelName == null)
                throw new Exception("Error, model must be set for data field");

            obj.SetModel(modelName);

            if (this.ModelMappings.ContainsKey(modelName))
            {
                Dictionary<string, string> tableToModel = this.ModelMappings[modelName].TableToModel;
                EntityModel model = DonationModels.GetModel(modelName);

                foreach (string col in this.Columns)
                {
                    JObject found = null;

                    if (obj.GetId() != null)
                        this.CachedObjectTable.TryGetValue(new Tuple<string, int?>(obj.GetModel(), obj.GetId()), out found);

                    string fieldName = tableToModel[col];
                    string value = row[this.TrueColumnName(col)] == null ? null : row[this.TrueColumnName(col)].ToString();

                    if (!model.GetField(fieldName).ReadOnly && (!diffOnly || found == null || !Util.EqualsEx(found.GetField(fieldName), value)))
                        obj.SetField(fieldName, value);
                }

                return obj;
            }
            else
                throw new Exception("Model mapping for " + modelName + " unregistered");
        }
开发者ID:CyberBotX,项目名称:sda-donation-tracker,代码行数:40,代码来源:TableBinding.cs

示例3: AddRow

        public void AddRow(JObject dataObj)
        {
            int? primaryKey = dataObj.GetId();
            string modelName = dataObj.GetModel();

            if (primaryKey != null)
            {
                foreach (DataRow row in this.Table.Rows)
                {
                    if (row[ModelColumn].ToString().IEquals(modelName) && row[KeyColumn].ToString().Equals(primaryKey.ToString()))
                    {
                        this.FillObjectToRow(row, dataObj);
                        return;
                    }
                }
            }

            DataRow newRow = this.Table.Rows.Add(primaryKey, modelName);

            this.FillObjectToRow(newRow, dataObj);
        }
开发者ID:CyberBotX,项目名称:sda-donation-tracker,代码行数:21,代码来源:TableBinding.cs

示例4: FillObjectToRow

        private void FillObjectToRow(DataRow row, JObject dataObj)
        {
            int? primaryKey = dataObj.GetId();
            string modelName = dataObj.GetModel();
            EntityModel model = DonationModels.GetModel(modelName);

            if (this.ModelMappings.ContainsKey(modelName))
            {
                Dictionary<string,string> tableToModel = this.ModelMappings[modelName].TableToModel;

                foreach (string col in this.Columns)
                {
                    string trueColumn = this.TrueColumnName(col);
                    FieldModel field = model.GetField(tableToModel[col]);

                    string trueValue = dataObj.GetField(tableToModel[col]);
                    row[trueColumn] = trueValue;

                    if (field is EntityFieldModel)
                    {
                        EntityFieldModel entityField = field as EntityFieldModel;
                        EntitySelectionCache cache = this.Context.GetEntitySelectionCache(entityField.ModelName);

                        cache.RequestRefresh(EntitySelectionCacheRefreshType.Strong);

                        var mapping = cache.GetLatestCache();

                        if (trueValue != null)
                        {
                            int fk = int.Parse(trueValue);

                            string name;
                            if (mapping.TryGetLeftToRight(fk, out name))
                                row[col] = name;
                            else
                                row[col] = row[trueColumn];
                        }
                        else
                        {
                            row[col] = "";
                        }
                    }
                    else
                    {
                        row[col] = trueValue;
                    }

                }
            }
            else
                throw new Exception("Model mapping for " + modelName + " unregistered");
        }
开发者ID:CyberBotX,项目名称:sda-donation-tracker,代码行数:52,代码来源:TableBinding.cs


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