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


C# JObject.Remove方法代码示例

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


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

示例1: Remove

    public void Remove()
    {
      JObject o = new JObject();
      o.Add("PropertyNameValue", new JValue(1));
      Assert.AreEqual(1, o.Children().Count());

      Assert.AreEqual(false, o.Remove("sdf"));
      Assert.AreEqual(false, o.Remove(null));
      Assert.AreEqual(true, o.Remove("PropertyNameValue"));

      Assert.AreEqual(0, o.Children().Count());
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:12,代码来源:JObjectTests.cs

示例2: TestObject

 private static void TestObject(JObject expected, JsonReader reader, string path)
 {
     reader.MoveToContent();
     Assert.AreEqual(reader.Token, JsonToken.Object);
     
     while (reader.ReadToken() != JsonToken.EndObject)
     {
         Assert.AreEqual(JsonToken.Member, reader.Token);
         
         string name = reader.Text;
         object value = expected[name];
         expected.Remove(name);
         TestValue(value, reader, path + "/" + name);
     }
     
     Assert.AreEqual(0, expected.Count);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:17,代码来源:TestComponentFormatter.cs

示例3: IListRemoveAt

        public void IListRemoveAt()
        {
            JProperty p1 = new JProperty("Test1", 1);
            JProperty p2 = new JProperty("Test2", "Two");
            IList l = new JObject(p1, p2);

            // won't do anything
            l.RemoveAt(0);

            l.Remove(p1);
            Assert.Equal(1, l.Count);

            l.Remove(p2);
            Assert.Equal(0, l.Count);
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:15,代码来源:JObjectTests.cs

示例4: IListRemove

        public void IListRemove()
        {
            JProperty p1 = new JProperty("Test1", 1);
            JProperty p2 = new JProperty("Test2", "Two");
            IList l = new JObject(p1, p2);

            JProperty p3 = new JProperty("Test3", "III");

            // won't do anything
            l.Remove(p3);
            Assert.Equal(2, l.Count);

            l.Remove(p1);
            Assert.Equal(1, l.Count);
            Assert.False(l.Contains(p1));
            Assert.True(l.Contains(p2));

            l.Remove(p2);
            Assert.Equal(0, l.Count);
            Assert.False(l.Contains(p2));
            Assert.Equal(null, p2.Parent);
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:22,代码来源:JObjectTests.cs

示例5: EmptyObjectDeepEquals

        public void EmptyObjectDeepEquals()
        {
            Assert.True(JToken.DeepEquals(new JObject(), new JObject()));

            JObject a = new JObject();
            JObject b = new JObject();

            b.Add("hi", "bye");
            b.Remove("hi");

            Assert.True(JToken.DeepEquals(a, b));
            Assert.True(JToken.DeepEquals(b, a));
        }
开发者ID:extesla,项目名称:OpenGamingLibrary,代码行数:13,代码来源:JObjectTests.cs

示例6: GenericListJTokenRemoveAt

    public void GenericListJTokenRemoveAt()
    {
      JProperty p1 = new JProperty("Test1", 1);
      JProperty p2 = new JProperty("Test2", "Two");
      IList<JToken> l = new JObject(p1, p2);

      // won't do anything
      l.RemoveAt(0);

      l.Remove(p1);
      Assert.AreEqual(1, l.Count);

      l.Remove(p2);
      Assert.AreEqual(0, l.Count);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:15,代码来源:JObjectTests.cs

示例7: GenericListJTokenRemove

    public void GenericListJTokenRemove()
    {
      JProperty p1 = new JProperty("Test1", 1);
      JProperty p2 = new JProperty("Test2", "Two");
      IList<JToken> l = new JObject(p1, p2);

      JProperty p3 = new JProperty("Test3", "III");

      // won't do anything
      Assert.IsFalse(l.Remove(p3));
      Assert.AreEqual(2, l.Count);

      Assert.IsTrue(l.Remove(p1));
      Assert.AreEqual(1, l.Count);
      Assert.IsFalse(l.Contains(p1));
      Assert.IsTrue(l.Contains(p2));

      Assert.IsTrue(l.Remove(p2));
      Assert.AreEqual(0, l.Count);
      Assert.IsFalse(l.Contains(p2));
      Assert.AreEqual(null, p2.Parent);
    }
开发者ID:bitpusher,项目名称:Newtonsoft.Json4,代码行数:22,代码来源:JObjectTests.cs

示例8: MapArguments

        public static object[] MapArguments(IRpcMethodDescriptor method, object argsObject)
        {
            object[] args;
            IDictionary argsMap = argsObject as IDictionary;

            if (argsMap != null)
            {
                JObject namedArgs = new JObject(argsMap);
                
                IRpcParameterDescriptor[] parameters = method.GetParameters();
                args = new object[parameters.Length];

                for (int i = 0; i < parameters.Length; i++)
                {
                    args[i] = namedArgs[parameters[i].Name];
                    namedArgs.Remove(parameters[i].Name);
                }

                foreach (DictionaryEntry entry in namedArgs)
                {
                    if (entry.Key == null)
                        continue;

                    string key = entry.Key.ToString();
                    
                    char ch1;
                    char ch2;

                    if (key.Length == 2)
                    {
                        ch1 = key[0];
                        ch2 = key[1];
                    }
                    else if (key.Length == 1)
                    {
                        ch1 = '0';
                        ch2 = key[0];
                    }
                    else
                    {
                        continue;
                    }

                    if (ch1 >= '0' && ch1 < '9' &&
                        ch2 >= '0' && ch2 < '9')
                    {
                        int index = int.Parse(key, NumberStyles.Number, CultureInfo.InvariantCulture);
                        
                        if (index < parameters.Length)
                            args[index] = entry.Value;
                    }
                }

                return args;
            }
            else
            {
                args = CollectionHelper.ToArray((ICollection) argsObject);
            }

            return JsonRpcServices.TransposeVariableArguments(method, args);
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:62,代码来源:JsonRpcServices.cs


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