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


C# JObject.Property方法代码示例

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


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

示例1: FromJson

 public override void FromJson(JObject obj)
 {
     Id = (int)obj.Property("Id").Value;
     Name = (string)obj.Property("Name").Value;
     Category = (int)obj.Property("Category").Value;
     PointDataDto.FromJson((JObject)obj.Property("PointDataDto").Value);
 }
开发者ID:Teplitsa,项目名称:bezpregrad,代码行数:7,代码来源:PointDto.cs

示例2: btnNew_Click

        protected void btnNew_Click(object sender, EventArgs e)
        {
            object[] values = Grid1.DataKeys[Grid1.SelectedRowIndex];
            string roleid = values[0].ToString().Trim();

            string sqlstr = "delete RoleModule where RoleId='" + roleid + "'";
            DbHelperSQL.ExecuteSql(sqlstr);

            foreach (GridRow row in Grid2.Rows)
            {
                int rowIndex = row.RowIndex;
                int isread = 0;
                string others = "";
                object[] dataKeys = Grid2.DataKeys[rowIndex];
                // 当前行对应的模块名称
                //int moduleId = Convert.ToInt32(dataKeys[0]);
                string moduleName = dataKeys[0].ToString();
                AspNet.CheckBox ck_read = (AspNet.CheckBox)row.FindControl("CheckBox1");
                if (ck_read.Checked == true)
                {
                    isread = 1;
                }
                AspNet.CheckBoxList ddlOthers = (AspNet.CheckBoxList)row.FindControl("ddlOthers");
                JObject otherPowerObj = new JObject();
                foreach (AspNet.ListItem item in ddlOthers.Items)
                {
                    if (item.Selected)
                    {
                        otherPowerObj.Add(item.Value, true);
                    }
                    else
                    {
                        otherPowerObj.Add(item.Value, false);
                    }

                }
                //if (isread == 0)
                //{
                //    otherPowerObj.Property("New").Value = false;
                //    otherPowerObj.Property("Edit").Value = false;
                //    otherPowerObj.Property("Del").Value = false;
                //}

                if (otherPowerObj.Property("New").Value.ToString() == "True" || otherPowerObj.Property("Edit").Value.ToString() == "True" || otherPowerObj.Property("Del").Value.ToString() == "True")
                {
                    isread = 1;
                }
                sqlstr = "insert into RoleModule(RoleId,ModuleName,IsCanRead,Others) values('" + roleid + "','" + moduleName + "'," + isread + ",'" + otherPowerObj.ToString() + "')";
                int state = DbHelperSQL.ExecuteSql(sqlstr);

            }

            Grid2_databind();
            Alert.Show("更新成功!", "提示", Alert.DefaultMessageBoxIcon);
        }
开发者ID:mtxnyfz,项目名称:cw_sbzx,代码行数:55,代码来源:Role_module.aspx.cs

示例3: FromJson

 public override void FromJson(JObject obj)
 {
     JProperty jProperty = obj.Property("Points");
     var val = (JArray) jProperty.Value;
     var ps = new List<PointDto>();
     foreach (JObject jObj in val)
     {
         var point = new PointDto();
         point.FromJson(jObj);
         ps.Add(point);
     }
     Points = ps.ToArray();
     Message = (string) obj.Property("Message").Value;
 }
开发者ID:Teplitsa,项目名称:bezpregrad,代码行数:14,代码来源:PointsSetDto.cs

示例4: MergeTemplate

 private void MergeTemplate(JObject iTarget, JObject iTemplate, string iKnxReplace) {
     //solve nesting problem with templates: we write the right knx-address in all subtemplates without an own knx-address
     //JProperty lTemplate = iTarget.Property("$template");
     //if (lTemplate != null) {
     //    JObject lTemplateObject = lTemplate.Value as JObject;
     //    if (lTemplateObject.Property("knx") == null) lTemplateObject.Add("knx", iKnxReplace);
     //}
     JProperty lOverride = iTarget.Property("$override");
     foreach (var lTemplateProperty in iTemplate.Properties()) {
         var lTargetProperty = iTarget.Property(lTemplateProperty.Name);
         if (lTargetProperty == null || lOverride == null || lOverride.Value.Where(t => t.ToString() == lTemplateProperty.Name).Count() == 0) {
             if (lTemplateProperty.Value.Type == JTokenType.Object) {
                 //deep processing, all objects are parsed, all templates are replaced
                 bool lRemove = false;
                 if (lTargetProperty == null) {
                     //if there is no property in the target, a dummy will be created
                     iTarget.Add(lTemplateProperty.Name, new JObject(new JProperty("not-allowed-dummy-property", new JValue(false))));
                     lTargetProperty = iTarget.Property(lTemplateProperty.Name);
                     lRemove = true;
                 }
                 //else if ((lTargetProperty.Value as JObject).Property("delete") != null)
                 //{
                 //    iTarget.Remove(lTemplateProperty.Name);
                 //    lTargetProperty = null;
                 //}
                 if (lTargetProperty != null) {
                     MergeTemplate(lTargetProperty.Value as JObject, lTemplateProperty.Value as JObject, iKnxReplace);
                     //if there is a dummy, it will be deleted
                     if (lRemove) (lTargetProperty.Value as JObject).Remove("not-allowed-dummy-property");
                 }
             } else if (lTemplateProperty.Value.Type == JTokenType.Array && lTargetProperty != null && lTargetProperty.Value.Type == JTokenType.Array) {
                 //merging arrays
                 if (lTargetProperty == null) {
                     iTarget.Add(lTemplateProperty.Name, lTemplateProperty.Value);
                 } else {
                     MergeTemplate(lTargetProperty.Value as JArray, lTemplateProperty.Value as JArray);
                 }
             } else if (lTargetProperty == null) {
                 KnxMerge(lTemplateProperty, iKnxReplace);
                 iTarget.Add(lTemplateProperty.Name, lTemplateProperty.Value);
             } 
         }
         //else if (lTargetProperty.Value.ToString() == "delete")
         //{
         //    iTarget.Remove(lTargetProperty.Name);
         //}
     }
 }
开发者ID:ivan73,项目名称:json,代码行数:48,代码来源:MergeTemplate.cs

示例5: HasMatches

        public static bool HasMatches(string applyValue, JObject jObj)
        {
            if (applyValue == null) return false;
            if (jObj == null)       return false;

            logger.Debug($"Evaluating expression {applyValue}");
            string[] paramValuePair = applyValue.Split(':');

            if (paramValuePair.Length != 2)
            {
                string msg = $"Unexpected expression result. paramValue.Length != 2 (param, value)\n"
                           + $"Context:\n"
                           + $"Expression: <{applyValue}>\n"
                           + $"jObj: <{jObj.ToString(Formatting.Indented)}>";
                logger.Warn(msg);
            }

            var parameter = paramValuePair[0];
            var expectedValue = paramValuePair[1];

            JProperty property = jObj.Property(parameter);

            if (property != null)
            {
                string propValue = property.Value.ToString().ToLower().Trim();
                expectedValue = expectedValue.ToLower().Trim();
                bool result = (propValue == expectedValue);
                return result;
            }
            return false;
        }
开发者ID:sprasad18,项目名称:swd-recorder,代码行数:31,代码来源:BooleanFieldExpression.cs

示例6: Handle

 public void Handle(JObject command, IWebSocketWrapper wswrapper)
 {
     var expression = command.Property("filter");
     if (expression == null || expression.Value == null)
         return;
     wswrapper.Expression = new Regex(expression.Value.ToString());
 }
开发者ID:vtortola,项目名称:NLog.Contrib.Targets.WebSocketServer,代码行数:7,代码来源:FilterCommandHandler.cs

示例7: OnHandle

    public override void OnHandle(IStore store,
                                  string collection,
                                  JObject command,
                                  JObject document)
    {
      IObjectStore st = store.GetCollection(collection);

      if (document.Type == JTokenType.Array)
      {
        var documents = document.Values();
        if (documents != null)
          foreach (JObject d in documents)
          {
            var k = d.Property(DocumentMetadata.IdPropertyName);
            if (k != null)
              st.Set((string)k, d);
          }

      }
      else
      {
        var k = document.Property(DocumentMetadata.IdPropertyName);
        if (k != null)
          st.Set((string)k, document);
      }
    }
开发者ID:dronab,项目名称:DensoDB,代码行数:26,代码来源:SetManyHandler.cs

示例8: Load

 public void Load(JObject file)
 {
     JArray sheetsElem = file.Property("sheets").Value as JArray;
     for (int i = 0; i < sheetsElem.Count; ++i) {
     JObject sheet = sheetsElem[i] as JObject;
     string sheetName = sheet.Property("name").Value.ToString();
     if (sheetName.Equals("Test")) {
         JArray linesElem = sheet.Property("lines").Value as JArray;
         for (int j = 0; j < linesElem.Count; ++j) {
             Test val = new Test();
             val.Load(linesElem[j] as JObject);
             TestList.Add(val);
         }
     }
     else if (sheetName.Equals("SecondSheet")) {
         JArray linesElem = sheet.Property("lines").Value as JArray;
         for (int j = 0; j < linesElem.Count; ++j) {
             SecondSheet val = new SecondSheet();
             val.Load(linesElem[j] as JObject);
             SecondSheetList.Add(val);
         }
     }
     }
     for (int i = 0; i < TestList.Count; ++i)
     TestList[i].ResolveReferences(this);
     for (int i = 0; i < SecondSheetList.Count; ++i)
     SecondSheetList[i].ResolveReferences(this);
 }
开发者ID:JSandusky,项目名称:CastleDBGen,代码行数:28,代码来源:TestCode.cs

示例9: FindType

 StripeObject FindType(JObject jobj)
 {
     var type = (string) jobj.Property ("object");
     switch (type) {
     case "account":
         return new StripeAccount ();
     case "charge":
         return new StripeCharge ();
     case "event":
         return new StripeEvent ();
     case "discount":
         return new StripeDiscount ();
     case "dispute":
         return new StripeDispute ();
     case "coupon":
         return new StripeCoupon ();
     case "customer":
         return new StripeCustomer ();
     case "line_item":
         return new StripeLineItem ();
     case "plan":
         return new StripePlan ();
     case "token":
         return new StripeCreditCardToken ();
     case "subscription":
         return new StripeSubscription ();
     case "invoiceitem":
         return new StripeInvoiceItem ();
     case "invoice":
         return new StripeInvoice ();
     case "transfer":
         return new StripeTransfer ();
     }
     return new StripeObject ();
 }
开发者ID:brookit,项目名称:XamarinStripe,代码行数:35,代码来源:StripeObjectConverter.cs

示例10: FromJson

		/// <summary>
		/// Create an instance from a json object
		/// </summary>
		/// <param name="patchRequestJson">The patch request json.</param>
		public static PatchRequest FromJson(JObject patchRequestJson)
		{
			PatchRequest[] nested = null;
			var nestedJson = patchRequestJson.Value<JToken>("Nested");
            if (nestedJson != null && nestedJson.Type != JTokenType.Null)
                nested = patchRequestJson.Value<JArray>("Nested").Cast<JObject>().Select(FromJson).ToArray();

			return new PatchRequest
			{
				Type = (PatchCommandType)Enum.Parse(typeof(PatchCommandType), patchRequestJson.Value<string>("Type"), true),
				Name = patchRequestJson.Value<string>("Name"),
				Nested = nested,
				Position = patchRequestJson.Value<int?>("Position"),
				PrevVal = patchRequestJson.Property("PrevVal") == null ? null : patchRequestJson.Property("PrevVal").Value,
				Value = patchRequestJson.Property("Value") == null ? null : patchRequestJson.Property("Value").Value,
			};
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:21,代码来源:PatchRequest.cs

示例11: GetChild

        protected static JObject GetChild(JObject obj, string name)
        {
            JProperty jProperty = obj.Property(name);

            if (jProperty == null)
                return new JObject();

            return (JObject)jProperty.Value;
        }
开发者ID:Teplitsa,项目名称:bezpregrad,代码行数:9,代码来源:AbstractDto.cs

示例12: SetupLanguage

 internal static void SetupLanguage(this Context context, JObject localContext)
 {
     if (localContext.IsPropertySet(JsonLdProcessor.Language))
     {
         if (localContext.Property(JsonLdProcessor.Language).ValueEquals(null))
         {
             context.Language = null;
         }
         else if (!localContext.Property(JsonLdProcessor.Language).ValueIs<string>())
         {
             throw new InvalidOperationException("Invalid default language.");
         }
         else
         {
             context.Language = localContext.Property(JsonLdProcessor.Language).ValueAs<string>().ToLower();
         }
     }
 }
开发者ID:rafalrosochacki,项目名称:RomanticWeb,代码行数:18,代码来源:ContextExtensions.cs

示例13: Parent

    public void Parent()
    {
      JArray v = new JArray(new JConstructor("TestConstructor"), new JValue(new DateTime(2000, 12, 20)));

      Assert.AreEqual(null, v.Parent);

      JObject o =
        new JObject(
          new JProperty("Test1", v),
          new JProperty("Test2", "Test2Value"),
          new JProperty("Test3", "Test3Value"),
          new JProperty("Test4", null)
        );

      Assert.AreEqual(o.Property("Test1"), v.Parent);

      JProperty p = new JProperty("NewProperty", v);

      // existing value should still have same parent
      Assert.AreEqual(o.Property("Test1"), v.Parent);

      // new value should be cloned
      Assert.AreNotEqual(p.Value, v);

      Assert.AreEqual((DateTime)((JValue)p.Value[1]).Value, (DateTime)((JValue)v[1]).Value);

      Assert.AreEqual(v, o["Test1"]);

      XText t = new XText("XText");
      Assert.AreEqual(null, t.Parent);

      Assert.AreEqual(null, o.Parent);
      JProperty o1 = new JProperty("O1", o);
      Assert.AreEqual(o, o1.Value);

      Assert.AreNotEqual(null, o.Parent);
      JProperty o2 = new JProperty("O2", o);

      Assert.AreNotEqual(o1.Value, o2.Value);
      Assert.AreEqual(o1.Value.Children().Count(), o2.Value.Children().Count());
      Assert.AreEqual(false, JToken.DeepEquals(o1, o2));
      Assert.AreEqual(true, JToken.DeepEquals(o1.Value, o2.Value));
    }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:43,代码来源:JTokenTests.cs

示例14: HandleCommand

 public void HandleCommand(IStore store, JObject command)
 {
   var r = command.Property(CommandKeyword.Collection);
   if (r != null)
   {
     var cc = store.GetCollection(((string)r ?? string.Empty).ToString());
     if (cc != null)
       cc.Flush();
   }
 }
开发者ID:dronab,项目名称:DensoDB,代码行数:10,代码来源:CollectionFlushHandler.cs

示例15: Create

        /// <summary>
        /// Serialize <paramref name="jObject"/> into a strongly typed derivative of <paramref name="objectType"/>.
        /// </summary>
        /// <param name="objectType">The base type of the returned object.</param>
        /// <param name="jObject">The JSON object.</param>
        /// <returns>A strongly typed representation of <paramref name="jObject"/>.</returns>
        /// <exception cref="System.InvalidOperationException">No known type mapping could be found.</exception>
        private object Create(Type objectType, JObject jObject)
        {
            JsonKnownTypeAttribute knownType = this.GetKnownTypes(objectType).FirstOrDefault(k => JToken.EqualityComparer.Equals(jObject.Property(k.PropertyName), k.PropertyToken));
            if (knownType == null)
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.NoKnownType, jObject.ToString(Formatting.None)));
            }

            return Activator.CreateInstance(knownType.KnownType);
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:17,代码来源:JsonKnownTypeConverter.cs


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