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


C# JsonObject.SetNamedValue方法代码示例

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


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

示例1: ApiGetConfiguration

        public virtual JsonObject ApiGetConfiguration()
        {
            var configuration = new JsonObject();
            configuration.SetNamedValue("id", JsonValue.CreateStringValue(Id));
            configuration.SetNamedValue("type", JsonValue.CreateStringValue(GetType().FullName));

            return configuration;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:8,代码来源:ActuatorBase.cs

示例2: ToJsonObject

 public JsonObject ToJsonObject()
 {
     JsonObject schoolobj = new JsonObject();
     schoolobj.SetNamedValue("name", JsonValue.CreateStringValue(Schoolname));
     schoolobj.SetNamedValue("rank", JsonValue.CreateStringValue(Rank.ToString()));
     JsonObject jsonObject = new JsonObject();
     jsonObject.SetNamedValue("school", schoolobj);
     return jsonObject;
 }
开发者ID:Iamnvincible,项目名称:csharppractice,代码行数:9,代码来源:Data.cs

示例3: CreateDataPackage

        private JsonObject CreateDataPackage(string actuatorId, EventType eventType)
        {
            JsonObject data = new JsonObject();
            data.SetNamedValue("timestamp", JsonValue.CreateStringValue(DateTime.Now.ToString("O")));
            data.SetNamedValue("type", JsonValue.CreateStringValue(eventType.ToString()));
            data.SetNamedValue("actuator", JsonValue.CreateStringValue(actuatorId));

            return data;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:9,代码来源:AzureEventHubPublisher.cs

示例4: ApiGet

        public JsonObject ApiGet()
        {
            var result = new JsonObject();
            result.SetNamedValue("temperature", JsonValue.CreateNumberValue(Temperature.Value));
            result.SetNamedValue("humidity", JsonValue.CreateNumberValue(Humidity.Value));

            result.SetNamedValue("lastFetched",
                _lastFetched.HasValue ? JsonValue.CreateStringValue(_lastFetched.Value.ToString("O")) : JsonValue.CreateNullValue());

            result.SetNamedValue("sunrise", JsonValue.CreateStringValue(_sunrise.ToString()));
            result.SetNamedValue("sunset", JsonValue.CreateStringValue(_sunset.ToString()));

            return result;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:14,代码来源:OWMWeatherStation.cs

示例5: HandleApiRead

 private void HandleApiRead(HttpContext httpContext)
 {
     JsonObject activity = new JsonObject();
     byte[] bytes = _x10Controller.GetBytes();
     activity.SetNamedValue("data", JsonValue.CreateStringValue(Encoding.ASCII.GetString(bytes)));
     httpContext.Response.Body = new JsonBody(activity);
 }
开发者ID:RodneyWimberly,项目名称:X10SerialSlave,代码行数:7,代码来源:WebServer.cs

示例6: ApiGet

        public JsonObject ApiGet()
        {
            var status = new JsonObject();

            status.SetNamedValue("timerMin",
                _minTimerDuration.HasValue ? JsonValue.CreateNumberValue(_minTimerDuration.Value) : JsonValue.CreateNullValue());

            status.SetNamedValue("timerMax",
                _maxTimerDuration.HasValue ? JsonValue.CreateNumberValue(_maxTimerDuration.Value) : JsonValue.CreateNullValue());

            status.SetNamedValue("timerAverage",
                _averageTimerDuration.HasValue ? JsonValue.CreateNumberValue(_averageTimerDuration.Value) : JsonValue.CreateNullValue());

            status.SetNamedValue("uptime", JsonValue.CreateStringValue((DateTime.Now - _startedDate).ToString()));

            return status;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:17,代码来源:HealthMonitor.cs

示例7: ApiGet

        public override void ApiGet(ApiRequestContext context)
        {
            var state = new JsonObject();
            foreach (var casement in _casements)
            {
                state.SetNamedValue(casement.Id, JsonValue.CreateStringValue(casement.State.ToString()));
            }            

            context.Response.SetNamedValue("state", state);
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:10,代码来源:Window.cs

示例8: GetStatusAsJSON

        private JsonObject GetStatusAsJSON()
        {
            var result = new JsonObject();
            foreach (var actuator in Actuators.Values)
            {
                var context = new ApiRequestContext(new JsonObject(), new JsonObject());
                actuator.ApiGet(context);

                result.SetNamedValue(actuator.Id, context.Response);
            }

            if (WeatherStation != null)
            {
                result.SetNamedValue("weatherStation", WeatherStation.ApiGet());
            }

            return result;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:18,代码来源:Home.cs

示例9: GetConfigurationAsJSON

        private JsonObject GetConfigurationAsJSON()
        {
            JsonObject state = new JsonObject();
            foreach (var room in _rooms.Values)
            {
                JsonObject roomConfiguration = room.GetConfigurationAsJSON();
                state.SetNamedValue(room.Id, roomConfiguration);
            }

            return state;
        }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:11,代码来源:Home.cs

示例10: GetJson

        public static string GetJson(this object obj)
        {
            var typeInfo = obj.GetType().GetTypeInfo();
            var props = typeInfo.DeclaredProperties;

            JsonObject jo = new JsonObject();

            foreach (var item in props)
            {
                var propTypeStr = item.PropertyType.ToString();//获取属性类型字符串,进行switch
                var propName = item.Name;//获取属性名称
                IJsonValue jsonValue = null;//精简代码。简单工厂
                switch (propTypeStr)
                {
                    case "System.String":
                        jsonValue = JsonValue.CreateStringValue(item.GetValue(obj).ToString());
                        break;
                    case "System.Double":
                        jsonValue = JsonValue.CreateNumberValue((double)item.GetValue(obj));
                        break;
                    case "System.Int32":
                        jsonValue = JsonValue.CreateNumberValue((int)item.GetValue(obj));
                        break;
                    case "System.Boolean":
                        jsonValue = JsonValue.CreateBooleanValue((bool)item.GetValue(obj));
                        break;
                    default:
                        break;
                }
                jo.SetNamedValue(propName, jsonValue);
            }
            return jo.Stringify();
        }
开发者ID:fqncom,项目名称:tomcraporigami,代码行数:33,代码来源:MainPage.xaml.cs

示例11: ExceptionToJson

 private JsonObject ExceptionToJson(Exception exception)
 {
     var root = new JsonObject();
     root.SetNamedValue("type", JsonValue.CreateStringValue(exception.GetType().Name));
     root.SetNamedValue("message", JsonValue.CreateStringValue(exception.Message));
     root.SetNamedValue("stackTrace", JsonValue.CreateStringValue(exception.StackTrace));
     root.SetNamedValue("source", JsonValue.CreateStringValue(exception.Source));
     return root;
 }
开发者ID:rishabhbanga,项目名称:CK.HomeAutomation,代码行数:9,代码来源:HttpServer.cs

示例12: AddWebsiteAndSave

        public static IAsyncOperation<BindableWebsite> AddWebsiteAndSave(BindableWebsiteOption websiteOption)
        {
            return AsyncInfo.Run(async (cancellationToken) =>
            {
                const int websitesLimit = 10;

                CheckSettingsAreLoaded();

                string websiteSiteUrl = websiteOption.SiteUrl;

                JsonObject roamingWebsiteObject = null;
                if (roamingWebsites.ContainsKey(websiteSiteUrl))
                {
                    // We already have this website. Nothing to do.
                    roamingWebsiteObject = roamingWebsites.GetNamedObject(websiteSiteUrl);
                }
                else if (roamingWebsites.Count < websitesLimit)
                {
                    roamingWebsiteObject = new JsonObject();
                    roamingWebsiteObject.SetNamedValue("Tags", new JsonObject());
                    roamingWebsiteObject.SetNamedValue("Name", JsonValue.CreateStringValue(websiteOption.ToString()));
                    roamingWebsiteObject.SetNamedValue("ApiSiteParameter", JsonValue.CreateStringValue(websiteOption.ApiSiteParameter));
                    roamingWebsiteObject.SetNamedValue("IconUrl", JsonValue.CreateStringValue(websiteOption.IconUrl));
                    roamingWebsiteObject.SetNamedValue(FaviconUrlKey, JsonValue.CreateStringValue(websiteOption.FaviconUrl));
                    roamingWebsites.SetNamedValue(websiteSiteUrl, roamingWebsiteObject);

                    JsonObject localWebsiteObject = new JsonObject();
                    localWebsites.SetNamedValue(websiteSiteUrl, localWebsiteObject);

                    SaveRoaming();
                    SaveLocal();
                }
                else
                {
                    MessageDialog dialog = new MessageDialog(
                        String.Format("Only {0} websites allowed.", websitesLimit),
                        "Oops.");
                    await dialog.ShowAsync();

                    // Make sure to return null.
                    return null;
                }

                return new BindableWebsite(websiteSiteUrl, roamingWebsiteObject);
            });
        }
开发者ID:kiewic,项目名称:Questions,代码行数:46,代码来源:SettingsManager.cs

示例13: RegisterClient

        private static async void RegisterClient(string channelUriString)
        {
            // Send passcode and channel URI to server.
            Uri registerUri = new Uri(serverUriString + "/register");

            JsonObject registerObject = new JsonObject();
            registerObject.SetNamedValue(ChannelUriKey, JsonValue.CreateStringValue(channelUriString));
            registerObject.SetNamedValue(PasscodeKey, JsonValue.CreateStringValue(PasscodeManager.Passcode));
            HttpStringContent content = new HttpStringContent(registerObject.Stringify());

            HttpResponseMessage response = await client.PostAsync(registerUri, content);
            string jsonString = await response.Content.ReadAsStringAsync();

            JsonObject jsonObject;
            if (!JsonObject.TryParse(jsonString, out jsonObject))
            {
                // Wrong formatted response.
                Debug.WriteLine("No JSON format. Swallowing error.");
                return;
            }

            // TODO: Verify the response is successful.
        }
开发者ID:kiewic,项目名称:WindowsStoreApps,代码行数:23,代码来源:ChannelManager.cs

示例14: ExecuteCreateTile

        private async void ExecuteCreateTile()
        {
            var tile = new SecondaryTile();
            var ja = new JsonObject();
            ja.SetNamedValue("url", JsonValue.CreateStringValue(m_action));
            tile.Arguments = ja.Stringify();
            tile.DisplayName = TileTitle;
            tile.RoamingEnabled = true;
            tile.TileOptions = TileOptions.CopyOnDeployment;
            tile.TileId = "Run_" + m_id.Replace("\\", "_");

            tile.VisualElements.BackgroundColor = Colors.Black;
            tile.VisualElements.ForegroundText = (m_useDarkText ? ForegroundText.Dark : ForegroundText.Light);
            tile.VisualElements.ShowNameOnSquare150x150Logo = m_logoImage.ShowTitle;
            tile.VisualElements.ShowNameOnSquare310x310Logo = m_largeImage.ShowTitle;
            tile.VisualElements.ShowNameOnWide310x150Logo = m_wideImage.ShowTitle;
            
            var id = m_id.Substring(m_id.IndexOf('\\') + 1);
            var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(m_id.Substring(0, m_id.IndexOf('\\')), CreationCollisionOption.OpenIfExists);

            var uri = await GetLocalUriForTileImage(m_largeImage.ImageSource, folder, id + "_l");
            if (uri != null) tile.VisualElements.Square310x310Logo = uri;
            uri = await GetLocalUriForTileImage(m_logoImage.ImageSource, folder, id + "_m");
            if (uri != null) tile.VisualElements.Square150x150Logo = uri;
            uri = await GetLocalUriForTileImage(m_wideImage.ImageSource, folder, id + "_w");
            if (uri != null) tile.VisualElements.Wide310x150Logo = uri;
            uri = await GetLocalUriForTileImage(m_smallImage.ImageSource, folder, id + "_s");
            if (uri != null) tile.VisualElements.Square70x70Logo = uri;

            await tile.RequestCreateAsync();
        }
开发者ID:999eagle,项目名称:StartMenuTiles,代码行数:31,代码来源:CreateTilePageViewModel.cs

示例15: onDataRequested

        private void onDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
        {
            e.Request.Data.SetDataProvider("pay",
                    new DataProviderHandler(onDeferredReqHdlr));

            string dataPackageFormat = "pay";
            DataPackage requestData = e.Request.Data;
            requestData.Properties.Title = "支付宝";

            // The description is optional.
            string dataPackageDescription = "发送给支付宝的付款订单";
            if (dataPackageDescription != null)
            {
                requestData.Properties.Description = dataPackageDescription;
            }

            PackageId packageId = Package.Current.Id;
            string name = this.ProtocolName;

            JsonObject obj = new JsonObject();
            obj.SetNamedValue("protname", JsonValue.CreateStringValue(name));
            obj.SetNamedValue("cticode", JsonValue.CreateStringValue(mCtiCode));
            obj.SetNamedValue("order", JsonValue.CreateStringValue(mCurOrder));
            string data = obj.Stringify();
            requestData.SetData(dataPackageFormat, data);
        }
开发者ID:jingwang109,项目名称:mobile-sdk,代码行数:26,代码来源:AlipaySdk.cs


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