當前位置: 首頁>>代碼示例>>C#>>正文


C# JsonWriter.StartObject方法代碼示例

本文整理匯總了C#中Newtonsoft.Json.JsonWriter.StartObject方法的典型用法代碼示例。如果您正苦於以下問題:C# JsonWriter.StartObject方法的具體用法?C# JsonWriter.StartObject怎麽用?C# JsonWriter.StartObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Newtonsoft.Json.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.StartObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var push = value as PushNotification;
            if (push == null)
            {
                writer.WriteNull();
                return;
            }

            writer.StartObject();
            // Write push type
            if (string.IsNullOrWhiteSpace(push.Query) == false)
                writer.WriteProperty("query", push.Query);
            else if( push.Channels.Count() > 0 )
                writer.WriteArray("channels", push.Channels);
            else if( push.DeviceIds.Count() > 0 )
                writer.WriteArray("deviceids", push.DeviceIds);
            else
                writer.WriteProperty("broadcast", true);
            // Write data
            WriteData(writer, push);
            // Write platform options
            WritePlatformOptions(writer, push.PlatformOptions);
            writer.EndObject();

        }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:26,代碼來源:PushNotificationConverter.cs

示例2: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var request = value as AuthenticateUserRequest;
            if (request == null)
            {
                writer.WriteNull();
                return;
            }

            writer
                .StartObject()
                .WithWriter(w =>
                {
                    if (string.IsNullOrWhiteSpace(request.Type) == false)
                        w.WriteProperty("type", request.Type);
                    if (request.MaxAttempts > 0)
                        w.WriteProperty("attempts").WriteValue(request.MaxAttempts);
                    if (request.TimeoutInSeconds > 0)
                        w.WriteProperty("expiry").WriteValue(request.TimeoutInSeconds);
                    if (request.CreateUserIfNotExists)
                        w.WriteProperty("createnew").WriteValue(request.CreateUserIfNotExists);
                    foreach (var key in request.Attributes.Keys)
                        w.WriteProperty(key, request[key]);
                })
                .EndObject();
        }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:26,代碼來源:AuthenticateUserRequestConverter.cs

示例3: WriteTileOptions

 private void WriteTileOptions(JsonWriter writer, TileNotification option)
 {
     writer.StartObject();
     writer.WriteProperty("notificationtype", "tile");
     WriteTile(writer, "wp8", option.WP8Tile);
     WriteTile(writer, "wp75", option.WP75Tile);
     WriteTile(writer, "wp7", option.WP7Tile);
     writer.EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:9,代碼來源:PushNotificationConverter.cs

示例4: WritePlatformOptions

 private void WritePlatformOptions(JsonWriter writer, PlatformOptions options)
 {
     if (options == null || options.IsEmpty == true ) return;
     writer.WriteProperty("platformoptions");
     writer.StartObject();
     if (options.iOS != null)
         WriteIosOptions(writer, options.iOS);
     if (options.Android != null)
         WriteAndroidOptions(writer, options.Android);
     if (options.WindowsPhone != null)
         WriteWpOptions(writer, options.WindowsPhone);
     writer.EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:13,代碼來源:PushNotificationConverter.cs

示例5: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var request = value as IObjectUpdateRequest;
     if (request == null)
     {
         writer.WriteNull();
         return;
     }
     
     writer
         .StartObject()
         // Write id
         .WriteProperty("__id", request.Id)
         // Write id
         .WriteProperty("__type", request.Type)
         // Write properties
         .WithWriter( w => request.PropertyUpdates.For( p => WriteProperty(w, p.Key, p.Value)))
         // Write atttributes
         .WithWriter( w => 
             {
                 if (request.AttributeUpdates.Count > 0)
                 {
                     w.WriteProperty("__attributes")
                      .StartObject()
                      .WithWriter(w2 => request.AttributeUpdates.For(a => w2.WriteProperty(a.Key, a.Value)))
                      .EndObject();
                 }
             })
         // Write acls
         .WithWriter( w => 
             {
                 if (request.AllowClaims.Count == 0 && request.DenyClaims.Count == 0) return;
                 w.WritePropertyName("__acls");
                 WriteAcls(w, request.AllowClaims, request.DenyClaims, request.ResetClaims);
             })
         // Write add tags
         .WithWriter( w => 
             {
                 if (request.AddedTags.Count > 0)
                     w.WriteArray("__addtags", request.AddedTags);
             })
         // Write remove tags
         .WithWriter(w =>
         {
             if (request.RemovedTags.Count > 0)
                 w.WriteArray("__removetags", request.RemovedTags);
         })
         .EndObject();
 }
開發者ID:appacitive,項目名稱:appacitive-dotnet-sdk,代碼行數:49,代碼來源:UpdateObjectRequestConverter.cs

示例6: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            Entity entity = value as Entity;
            if (entity == null)
            {
                writer.WriteNull();
                return;
            }

            writer.StartObject();
            writer
                // Write id
                .WithWriter(w =>
                {
                    if (string.IsNullOrWhiteSpace(entity.Id) == false)
                        w.WriteProperty("__id", entity.Id);
                })
                // Write created by
                .WriteProperty("__createdby", entity.CreatedBy)
                // Write properties
                .WithWriter(w =>
                {
                    
                    foreach (var property in entity.Properties)
                        w.WriteProperty(property.Key, property.Value);
                })
                .WithWriter( w => WriteJson(entity, w, serializer) )
                .WithWriter(w =>
                {
                    var attr = entity.Attributes.ToArray();
                    if (attr.Length > 0)
                    {
                        w.WriteProperty("__attributes")
                         .StartObject();
                        // Write attributes
                        for (int i = 0; i < attr.Length; i++)
                            w.WriteProperty(attr[i].Key, attr[i].Value);
                        w.EndObject();
                    }

                })
                .WithWriter(w =>
                {
                    if (entity.Tags.Count() > 0)
                        w.WriteArray("__tags", entity.Tags);
                });
            writer.EndObject();
        }
開發者ID:beer-bahadur,項目名稱:appacitive-dotnet-sdk,代碼行數:48,代碼來源:EntityConverter.cs

示例7: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     // Manage the open and closing of the object.
     // Write APObject specific content (e.g., acls)
     // Call appropriate helpers to write common stuff.
     APObject obj = value as APObject;
     if (obj == null)
     {
         writer.WriteNull();
         return;
     }
     writer.StartObject();
     EntityParser.WriteJson(writer, obj, serializer);
     AclParser.WriteAcl(writer, obj, serializer);
     writer.WriteEndObject();
 }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:16,代碼來源:ObjectConverter.cs

示例8: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     var request = value as UpdateConnectionRequest;
     if (request == null)
     {
         writer.WriteNull();
         return;
     }
     
     writer
         .StartObject()
         // Write id and type
         .WriteProperty("__id", request.Id)
         .WriteProperty("__relationtype", request.Type)
         // Write properties
         .WithWriter( w => request.PropertyUpdates.For( p => WriteProperty(w, p.Key, p.Value)))
         // Write atttributes
         .WithWriter( w => 
             {
                 if (request.AttributeUpdates.Count > 0)
                 {
                     w.WriteProperty("__attributes")
                      .StartObject()
                      .WithWriter(w2 => request.AttributeUpdates.For(a => w2.WriteProperty(a.Key, a.Value)))
                      .EndObject();
                 }
             })
         // Write add tags
         .WithWriter( w => 
             {
                 if (request.AddedTags.Count > 0)
                     w.WriteArray("__addtags", request.AddedTags);
             })
         // Write remove tags
         .WithWriter(w =>
         {
             if (request.RemovedTags.Count > 0)
                 w.WriteArray("__removetags", request.RemovedTags);
         })
         .EndObject();
 }
開發者ID:appacitive,項目名稱:appacitive-dotnet-sdk,代碼行數:41,代碼來源:UpdateConnectionRequestConverter.cs

示例9: WriteData

 private void WriteData(JsonWriter writer, PushNotification push)
 {
     writer.WritePropertyName("data");
     writer.StartObject();
     writer
         .WriteProperty("alert", push.Alert)
         .WriteProperty("badge", push.Badge, true);
     foreach (var key in push.Data.Keys)
     {
         if (key.Equals("alert", StringComparison.OrdinalIgnoreCase) == true ||
             key.Equals("badge", StringComparison.OrdinalIgnoreCase) == true)
             continue;
         writer.WriteProperty(key, push.Data[key]);
     }
     writer.EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:16,代碼來源:PushNotificationConverter.cs

示例10: WriteToastOptions

 private void WriteToastOptions(JsonWriter writer, ToastNotification option)
 {
     writer
         .StartObject()
         .WriteProperty("notificationtype", "toast")
         .WriteProperty("text1", option.Text1, true)
         .WriteProperty("text2", option.Text2, true)
         .WriteProperty("navigatepath", option.Path, true)
         .EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:10,代碼來源:PushNotificationConverter.cs

示例11: WriteRawOptions

 private void WriteRawOptions(JsonWriter writer, RawNotification option)
 {
     writer
         .StartObject()
         .WriteProperty("notificationtype", "raw")
         .WriteProperty("data", option.RawData, true)
         .EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:8,代碼來源:PushNotificationConverter.cs

示例12: WriteFlipTile

 private void WriteFlipTile(JsonWriter writer, FlipTile tile)
 {
     writer
         .StartObject()
         .WriteProperty("tiletemplate", "flip")
         .WriteProperty("tileid", tile.TileId, true)
         .WriteProperty("title", tile.FrontTitle, true)
         .WriteProperty("count", tile.FrontCount, true)
         .WriteProperty("backgroundimage", tile.FrontBackgroundImage, true)
         .WriteProperty("smallbackgroundimage", tile.SmallBackgroundImage, true)
         .WriteProperty("widebackgroundimage", tile.WideBackgroundImage, true)
         .WriteProperty("backtitle", tile.BackTitle, true)
         .WriteProperty("backbackgroundimage", tile.BackBackgroundImage, true)
         .WriteProperty("backcontent", tile.BackContent, true)
         .WriteProperty("widebackbackgroundimage", tile.WideBackBackgroundImage, true)
         .WriteProperty("widebackcontent", tile.WideBackContent, true)
         .EndObject();
 }
開發者ID:neilunadkat,項目名稱:appacitive-dotnet-sdk,代碼行數:18,代碼來源:PushNotificationConverter.cs

示例13: WriteJson

        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var email = value as Email;
            if (email == null)
            {
                writer.WriteNull();
                return;
            }

            writer
                .StartObject()
                // Write subject
                .WriteProperty("subject", email.Subject ?? string.Empty)
                // from
                .WithWriter( w => 
                    {
                        if (string.IsNullOrWhiteSpace(email.FromAddress) == false)
                            w.WriteProperty("from", email.FromAddress);
                    })
                // reply-to
                .WithWriter(w =>
                {
                    if (string.IsNullOrWhiteSpace(email.FromAddress) == false)
                        w.WriteProperty("replyto", email.ReplyTo);
                })
                // to
                .WriteArray("to", email.To)
                // cc
                .WriteArray("cc", email.Cc)
                // bcc
                .WriteArray("bcc", email.Bcc)
                // write body
                .WithWriter(w =>
                    {
                        if (email.Body is RawEmailBody)
                            WriteRawBody(w, email.Body as RawEmailBody);
                        else
                            WriteTemplateBody(w, email.Body as TemplateBody);
                    })
                // write smtp settings
                .WithWriter( w => WriteSmtp(w, email.Server))
                .EndObject();
        }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:43,代碼來源:EmailConverter.cs

示例14: WriteAttributes

 private static void WriteAttributes(JsonWriter writer, Entity entity, JsonSerializer serializer)
 {
     var attr = entity.Attributes.ToArray();
     if (attr.Length > 0)
     {
         writer.WriteProperty("__attributes");
         writer.StartObject();
         // Write attributes
         for (int i = 0; i < attr.Length; i++)
             writer.WriteProperty(attr[i].Key, attr[i].Value);
         writer.EndObject();
     }
 }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:13,代碼來源:ObjectConverter.cs

示例15: WriteJson

 public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
 {
     // Manage the open and closing of the object.
     // Write APConnection specific content (e.g., endpoints)
     // Call appropriate helpers to write common stuff.
     APConnection conn = value as APConnection;
     if (conn == null)
     {
         writer.WriteNull();
         return;
     }
     writer.StartObject();
     EntityParser.WriteJson(writer, conn, serializer);
     WriteEndpoints(writer, conn, serializer);
     writer.WriteEndObject();
 }
開發者ID:ytokas,項目名稱:appacitive-dotnet-sdk,代碼行數:16,代碼來源:ConnectionConverter.cs


注:本文中的Newtonsoft.Json.JsonWriter.StartObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。