当前位置: 首页>>代码示例>>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;未经允许,请勿转载。