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


C# JsonObject.SetValue方法代码示例

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


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

示例1: GenerateHtml

        public override void GenerateHtml()
        {
            JsonObject output = new JsonObject();
            string sProfile = Hm.Request("profile");
            if (!Str.IsEmpty(sProfile))
            {
                CCProfile prf = CC.Current.Profiles[sProfile];
                if (prf != null)
                {
                    JsonArray sarr = output.SetArray("Scopes") as JsonArray;
                    foreach (CCScope scope in prf.Scopes)
                    {
                        sarr.EltAdd(scope.Name);
                    }


                    JsonArray arr = output.SetArray("MetaDataKeys") as JsonArray;
                    List<XDoc> MetaDataKeys = prf.Doc.EltList("MetaDataDef");
                    foreach (XDoc metakey in MetaDataKeys)
                    {
                        if (bool.Parse(metakey.Value("Active")))
                        {
                            JsonObject key = arr.EltAddObject() as JsonObject;

                            key.Set("Name", metakey.Value("EntityName"));
                            key.Set("MaxDisplay", int.Parse(metakey.Value("Max")));
                            key.Set("MinimumOccurrence", int.Parse(metakey.Value("Threshold")));
                        }
                    }

                    JsonArray relatedarr = output.SetArray("RelatedTerms") as JsonArray;
                    List<XDoc> RelatedKeys = prf.Doc.EltList("RelatedTermsDef");
                    foreach (XDoc metakey in RelatedKeys)
                    {
                        if (bool.Parse(metakey.Value("Active")))
                        {
                            JsonObject key = relatedarr.EltAddObject() as JsonObject;

                            key.Set("Name", metakey.Value("EntityName"));
                            key.Set("MaxDisplay", int.Parse(metakey.Value("Max")));
                            key.Set("MinimumOccurrence", int.Parse(metakey.Value("Threshold")));
                        }
                    }

                    JsonArray peoplearr = output.SetArray("PeopleDataKeys") as JsonArray;
                    List<XDoc> PeopleDataKeys = prf.Doc.EltList("PeopleDataDef");
                    foreach (XDoc pmetakey in PeopleDataKeys)
                    {
                        if (bool.Parse(pmetakey.Value("Active")))
                        {
                            JsonObject key = peoplearr.EltAddObject() as JsonObject;

                            key.Set("Name", pmetakey.Value("EntityName"));
                            key.Set("MaxDisplay", int.Parse(pmetakey.Value("Max")));
                            key.Set("MinimumOccurrence", int.Parse(pmetakey.Value("Threshold")));
                        }
                    }

                    JsonArray langarr = output.SetArray("LanguageOptions") as JsonArray;
                    List<XDoc> Languages = prf.Doc.EltList("LanguageOptions");
                    foreach (XDoc metakey in Languages )
                    {
                        if (bool.Parse(metakey.Value("Active")))
                        {
                            JsonObject key = langarr.EltAddObject() as JsonObject;

                            key.Set("label", metakey.Value("LanguageName"));
                            key.Set("value", metakey.Value("LanguageValue"));
                        }
                    }
                }

                output.SetValue("ChatterPollID", prf.Doc.Value("ChatterPollID"));
                output.SetValue("FeedbackGroupId", prf.Doc.Value("FeedbackGroupID"));
                output.SetValue("BestBetGroupId", prf.Doc.Value("BestBetGroupID"));
                output.SetValue("MaxAuthors", prf.Doc.Value("MaxAuthors"));
                output.SetValue("SessionTimeout", prf.Doc.Value("SessionTimeOut"));
                output.SetValue("MaxRecentSearches", prf.Doc.Value("MaxRecentSearches"));
                
            }
            Hm.SetContentType("application/json");
            Hm.Write(Json.Serialize(output, true));
            if (!Str.IsEmpty(Hm.Request("callback")))
                Hm.Write(")");
        }
开发者ID:afoals,项目名称:als-prototype,代码行数:85,代码来源:AZ_SearchConfig.cs

示例2: CreateJsonRecords

        // Helper method to read the items in a dictionary and make a JSON object from them.
        private JsonObject[] CreateJsonRecords(Dictionary<string, double> inListDictionary)
        {
            JsonObject[] jsonRecordsArray = new JsonObject[inListDictionary.Count];
            int i = 0;
            // Loop through dictionary.
            foreach (KeyValuePair<string, double> kvp in inListDictionary)
            {
                // Get the current key and value.
                string currentKey = kvp.Key.ToString();
                string currentValue = kvp.Value.ToString();
                // Add the key and value to a JSON object.
                JsonObject currentKeyValue = new JsonObject();
                currentKeyValue.AddString(m_mapLayerNameToQuery, currentKey);
                currentKeyValue.AddString("value", currentValue);
                // Add the record object to an array.
                jsonRecordsArray.SetValue(currentKeyValue, i);
                i++;
            }

            return jsonRecordsArray;
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:22,代码来源:SpatialQueryREST.cs

示例3: GenerateHtml

        public override void GenerateHtml()
        {
            string _to = Hm.RequestForm("to");
            string _from = Hm.RequestForm("from");
            string _subject = Hm.RequestForm("subject");
            string _body = Hm.RequestForm("body");
            //string _index = Hm.Request("index");
            //string _status = Hm.Request("status");
            //string _id = Hm.Request("id");

            //Query the Approvals Index
            //EngineClient client = EngineClientsPool.FromPoolByIndex(_index);
            //try
            //{
            //    string sql = Str.And("select * from ", _index, " where id = ", Str.SqlValue(_id));
            //    using (Cursor cursor = client.ExecCursor(sql))
            //    {
            //        while (!cursor.End())
            //        {
            //            _to = Str.IfEmpty(_to, AribaEmail);
            //            _from = Str.IfEmpty(_from, cursor.GetColumn("sourcevarchar3"));
            //            _subject = Str.IfEmpty(_subject, _status + " " + Str.Split(cursor.GetColumn("title"), ':')[0]);

            //            StringBuilder Body = new StringBuilder();
            //            Body.AppendLine("[:Begin Comments section. Enter your comments starting on the next line:]");
            //            Body.AppendLine("Submitted via the Approvals App");
            //            Body.AppendLine("[:End Comments section:]");
            //            Body.AppendLine("");
            //            Body.AppendLine("IMPORTANT: Send this message to approve this request.");
            //            Body.AppendLine("");
            //            Body.AppendLine("Do not edit or delete the text below this line.");

            //            if (_status.ToLower() != "deny")
                            //Approve URL
            //                Body.AppendLine("[x] " + cursor.GetColumn("sourcevarchar51"));
            //            else
                            //Deny URL
            //                Body.AppendLine("[x] " + cursor.GetColumn("sourcevarchar52"));

            //            _body = Body.ToString();
            //            cursor.MoveNext();
            //        }
            //    }
            //}
            //finally
            //{
            //    EngineClientsPool.ToPool(client);
            //}

            JsonObject output = new JsonObject();
            output.SetValue("To", _to);
            output.SetValue("From", _from);
            output.SetValue("Subject", _subject);
            output.SetValue("Body", _body);
            output.SetValue("Response", SendEmail(_to, _from, _subject, _body));

            Hm.SetContentType("application/json");
            Hm.Write(Json.Serialize(output, true));
            if (!Str.IsEmpty(Hm.Request("callback")))
                Hm.Write(")");
        }
开发者ID:afoals,项目名称:als-prototype,代码行数:61,代码来源:AZ_SendMail.cs


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