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


C# JObject.Get方法代码示例

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


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

示例1: GenerateReport

        public JObject GenerateReport(
            JObject source,
            string outgoingNum = "...",
            string date = "...",
            string uniqueNum = "",
            string caseManagement = "",
            string directorName = "[ДИРЕКТОР]",
            string coordinatorName = "",
            string coordinatorPosition = "",
            string madeByName = "",
            string madeByPosition = ""
            )
        {
            var json = new
            {
                outgoingNum = outgoingNum,
                date = date,
                uniqueNum = uniqueNum,
                caseManagement = caseManagement,
                paragraph1 = this.GetParagraph1(source.Get<JObject>("paragraph1")),
                paragraph2 = this.GetParagraph2(source.Get<JObject>("paragraph2")),
                paragraph3 = this.GetParagraph3(source.Get<JObject>("paragraph3")),
                paragraph4 = this.GetParagraph4(source.Get<JObject>("paragraph4")),
                paragraph6 = this.GetParagraph6(source.Get<JObject>("paragraph6")),
                paragraph7 = this.GetParagraph7(source.Get<JObject>("paragraph7")),
                paragraph8 = this.GetParagraph8(source.Get<JObject>("paragraph8")),
                director = new { name = directorName },
                coordinators = new object[]
                {
                    new { name = coordinatorName, position = coordinatorPosition }
                },
                madeBy = new
                {
                    name = madeByName,
                    position = madeByPosition
                }
            };

            return JObject.FromObject(json);
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:40,代码来源:DataGenerator.cs

示例2: GenerateNote

        public JObject GenerateNote(
            JObject source,
            string outgoingNum = "...",
            string date = "...",
            string secretaryName = "[СЕКРЕТАР]",
            string secretaryPosition = "/Определен със Заповед № .................../",
            string coordinatorName = "",
            string coordinatorPosition = "",
            string madeByName = "",
            string madeByPosition = ""
            )
        {
            var json = new
            {
                outgoingNum = outgoingNum,
                date = date,
                paragraph1 = this.GetParagraph1(source.Get<JObject>("paragraph1")),
                paragraph2 = this.GetParagraph2(source.Get<JObject>("paragraph2")),
                paragraph3 = this.GetParagraph3(source.Get<JObject>("paragraph3")),
                paragraph4 = this.GetParagraph4(source.Get<JObject>("paragraph4")),
                paragraph6 = this.GetParagraph6(source.Get<JObject>("paragraph6")),
                paragraph7 = this.GetParagraph7(source.Get<JObject>("paragraph7")),
                paragraph8 = this.GetParagraph8(source.Get<JObject>("paragraph8")),
                secretary = new { name = secretaryName, position = secretaryPosition },
                coordinators = new object[]
                {
                    new { name = coordinatorName, position = coordinatorPosition }
                },
                madeBy = new
                {
                    name = madeByName,
                    position = madeByPosition
                }
            };

            return JObject.FromObject(json);
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:37,代码来源:DataGenerator.cs

示例3: CreateServiceConfiguration

 private ServiceConfiguration CreateServiceConfiguration(JObject jConfig)
 {
     var configuration = ServiceConfiguration.CreateSilently(
         jConfig.Get("Name"), jConfig.Get("BaseUri"),
         _navigationService, _invokerFactory);
     var actionGroups = jConfig.GetJArray("ActionGroups").Select(j => CreateActionGroup(j, configuration));
     configuration.ActionGroups.AddRange(actionGroups);
     return configuration;
 }
开发者ID:johanclasson,项目名称:Rester,代码行数:9,代码来源:Serializer.cs

示例4: GetUriFragment

        /// <summary>
        /// Get a uri fragment representing the resource corresponding to the
        /// given instance in the table.
        /// </summary>
        /// <param name="tableName">The name of the table.</param>
        /// <param name="instance">The instance.</param>
        /// <returns>A URI fragment representing the resource.</returns>
        private static string GetUriFragment(string tableName, JObject instance)
        {
            Debug.Assert(!string.IsNullOrEmpty(tableName),
                "tableName should not be null or empty!");

            // Get the value of the object (as a primitive JSON type)
            object id = null;
            if (!instance.Get(IdPropertyName).TryConvert(out id) || id == null)
            {
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.IdNotFoundExceptionMessage,
                        IdPropertyName),
                    "instance");
            }

            return GetUriFragment(tableName, id);
        }
开发者ID:xqiu,项目名称:azure-mobile-services,代码行数:26,代码来源:MobileServiceTable.cs

示例5: SendInsertAsync

        /// <summary>
        /// Insert a new object into a table.
        /// </summary>
        /// <param name="instance">
        /// The instance to insert into the table.
        /// </param>
        /// <returns>
        /// A task that will complete when the insert finishes.
        /// </returns>
        internal async Task<JToken> SendInsertAsync(JObject instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            // Make sure the instance doesn't have its ID set for an insertion
            if (instance.Get(IdPropertyName) != null)
            {
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.CannotInsertWithExistingIdMessage,
                        IdPropertyName),
                    "instance");
            }

            string url = GetUriFragment(this.TableName);
            JToken response = await this.MobileServiceClient.RequestAsync("POST", url, instance);
            JToken patched = Patch(instance, response);
            return patched;
        }
开发者ID:xqiu,项目名称:azure-mobile-services,代码行数:32,代码来源:MobileServiceTable.cs

示例6: TrySet

        public void TrySet()
        {
            JObject obj = null;
            Assert.IsFalse(obj.TrySet("fail", null));

            obj = new JObject();

            Assert.IsTrue(obj.TrySet("x", null));
            Assert.IsTrue(obj.Get("x").IsNull());

            Assert.IsTrue(obj.TrySet("x", true));
            Assert.AreEqual(true, obj.Get("x").AsBool());

            Assert.IsTrue(obj.TrySet("x", 1));
            Assert.AreEqual(1.0, obj.Get("x").AsNumber());

            Assert.IsTrue(obj.TrySet("x", 1.0));
            Assert.AreEqual(1.0, obj.Get("x").AsNumber());

            Assert.IsTrue(obj.TrySet("x", 1.0f));
            Assert.AreEqual(1.0, obj.Get("x").AsNumber());

            Assert.IsTrue(obj.TrySet("x", 'x'));
            Assert.AreEqual("x", obj.Get("x").AsString());

            Assert.IsTrue(obj.TrySet("x", "abc"));
            Assert.AreEqual("abc", obj.Get("x").AsString());

            DateTime now = DateTime.Now;
            Assert.IsTrue(obj.TrySet("x", now));
            Assert.AreEqual(
                now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", CultureInfo.InvariantCulture),
                obj.Get("x").AsString());

            DateTimeOffset offset = DateTimeOffset.Now;
            Assert.IsTrue(obj.TrySet("x", offset));
            Assert.AreEqual(
                offset.DateTime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK", CultureInfo.InvariantCulture),
                obj.Get("x").AsString());

            Assert.IsFalse(obj.TrySet("x", new Uri("http://www.microsoft.com")));
        }
开发者ID:xqiu,项目名称:azure-mobile-services,代码行数:42,代码来源:JsonExtensions.Test.cs

示例7: Set

        public void Set()
        {
            JObject value = null;
            value.Set("silent", "fail");

            value = new JObject();
            
            value.Set("b", true);
            Assert.AreEqual(true, value.Get("b").AsBool());

            value.Set("c", 12);
            Assert.AreEqual(12, value.Get("c").AsInteger());

            value.Set("d", 12.2);
            Assert.AreEqual(12.2, value.Get("d").AsNumber());
            Assert.AreEqual(12, value.Get("d").AsInteger());

            value.Set("e", "abc");
            Assert.AreEqual("abc", value.Get("e").AsString());

            value.Set("f", new JObject());
            Assert.IsNotNull(value.Get("f"));
        }
开发者ID:xqiu,项目名称:azure-mobile-services,代码行数:23,代码来源:JsonExtensions.Test.cs

示例8: InsertAsync

        public async Task InsertAsync()
        {
            string appUrl = "http://www.test.com";
            string appKey = "secret...";
            string collection = "tests";

            TestServiceFilter hijack = new TestServiceFilter();
            MobileServiceClient service = new MobileServiceClient(appUrl, appKey)
                .WithFilter(hijack);
                
            JObject obj = new JObject().Set("value", "new") as JObject;
            hijack.Response.Content =
                new JObject().Set("id", 12).Set("value", "new").ToString();
            await service.GetTable(collection).InsertAsync(obj);

            Assert.AreEqual(12, obj.Get("id").AsInteger());
            Assert.Contains(hijack.Request.Uri.ToString(), collection);

            ThrowsAsync<ArgumentNullException>(
                async () => await service.GetTable(collection).InsertAsync(null));
            
            // Verify we throw if ID is set on both JSON and strongly typed
            // instances
            ThrowsAsync<ArgumentException>(
                async () => await service.GetTable(collection).InsertAsync(
                    new JObject().Set("id", 15) as JObject));
            ThrowsAsync<ArgumentException>(
                async () => await service.GetTable<Person>().InsertAsync(
                    new Person() { Id = 15 }));
        }
开发者ID:TroyBolton,项目名称:azure-mobile-services,代码行数:30,代码来源:ZumoService.Test.cs

示例9: GetParagraph8

        private object GetParagraph8(JObject paragraph8)
        {
            if (paragraph8 == null)
            {
                return null;
            }

            return new
            {
                additionalInfo = new
                {
                    text = paragraph8.Get<string>("additionalInfo")
                }
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:15,代码来源:DataGenerator.cs

示例10: GetParagraph6

        private object GetParagraph6(JObject paragraph6)
        {
            if (paragraph6 == null)
            {
                return null;
            }

            var table1Text = paragraph6.Get<string>("deadline.table1.findings");
            var table2Text = paragraph6.Get<string>("deadline.table2.findings");

            if (string.IsNullOrEmpty(table1Text) && string.IsNullOrEmpty(table2Text))
            {
                return null;
            }

            return new
            {
                deadline = new
                {
                    table1 = string.IsNullOrEmpty(table1Text) ? null : new { findings = table1Text },
                    table2 = string.IsNullOrEmpty(table2Text) ? null : new { findings = table2Text }
                }
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:24,代码来源:DataGenerator.cs

示例11: GetParagraph4

        private object GetParagraph4(JObject paragraph4)
        {
            if (paragraph4 == null)
            {
                return null;
            }

            var techniqueText = paragraph4.Get<string>("technique.table1.findings");
            if (string.IsNullOrEmpty(techniqueText))
            {
                return null;
            }

            return new
            {
                technique = new
                {
                    findings = techniqueText
                }
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:21,代码来源:DataGenerator.cs

示例12: GetParagraph3

        private object GetParagraph3(JObject paragraph3)
        {
            if (paragraph3 == null)
            {
                return null;
            }

            var decisionText = paragraph3.Get<string>("decision.table1.findings");
            if (string.IsNullOrEmpty(decisionText))
            {
                return null;
            }

            return new
            {
                decision = new
                {
                    findings = decisionText
                }
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:21,代码来源:DataGenerator.cs

示例13: GetParagraph2

        private object GetParagraph2(JObject paragraph2)
        {
            if (paragraph2 == null)
            {
                return null;
            }

            var notice = this.GetNotice(paragraph2.Get<JObject>("notice"));

            if (notice == null)
            {
                return null;
            }

            return new
            {
                notice = notice
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:19,代码来源:DataGenerator.cs

示例14: GetParagraph1

        private object GetParagraph1(JObject paragraph1)
        {
            var emplJObj = paragraph1 == null ? new JObject() : paragraph1.Get<JObject>("employer.table1");
            var procJObj = paragraph1 == null ? new JObject() : paragraph1.Get<JObject>("proc");

            return new
            {
                employer = this.GetEmployer(emplJObj),
                procedure = this.GetProcedure(procJObj)
            };
        }
开发者ID:MartinBG,项目名称:Gva,代码行数:11,代码来源:DataGenerator.cs

示例15: CreateActionGroup

 private ActionGroup CreateActionGroup(JObject jActionGroup, ServiceConfiguration configuration)
 {
     var actionGroup = ActionGroup.CreateSilently(jActionGroup.Get("Name"), configuration, _navigationService);
     actionGroup.Actions.AddRange(jActionGroup.GetJArray("Actions").Select(j => CreateAction(j, configuration)));
     return actionGroup;
 }
开发者ID:johanclasson,项目名称:Rester,代码行数:6,代码来源:Serializer.cs


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