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


C# JsonTextWriter.WriteProperty方法代码示例

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


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

示例1: ToJsonSafe

        /// <summary>
        ///     Converts current not to JSON according to the avro specification.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="seenSchemas">The seen schemas.</param>
        internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
        {
            if (seenSchemas.Contains(this))
            {
                writer.WriteValue(this.FullName);
                return;
            }

            seenSchemas.Add(this);
            writer.WriteStartObject();
            writer.WriteProperty("type", "fixed");
            writer.WriteProperty("name", this.FullName);
            writer.WriteOptionalProperty("aliases", this.Aliases);
            writer.WriteProperty("size", this.Size);
            writer.WriteEndObject();
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:21,代码来源:FixedSchema.cs

示例2: ToJsonString

        /// <summary>
        /// Serialize this phase to JSON.
        /// </summary>
        /// <returns>The phase as a JSON string.</returns>
        public string ToJsonString()
        {
            /*
             * NB: JsonTextWriter is guaranteed to close the StringWriter
             * https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/JsonTextWriter.cs#L150-L160
             */
            var sb = new StringBuilder();
            var sw = new StringWriter(sb);
            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.WriteStartObject();
                writer.WritePropertyName(PhaseType);

                // phase start
                writer.WriteStartObject();

                WriteJson(writer);
                writer.WriteProperty("keep", keep);
                writer.WriteEndObject();

                // phase end
                writer.WriteEndObject();
            }

            return sb.ToString();
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:30,代码来源:RiakPhase.cs

示例3: ToJsonSafe

 /// <summary>
 ///     Converts current not to JSON according to the avro specification.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="seenSchemas">The seen schemas.</param>
 internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
 {
     writer.WriteStartObject();
     writer.WriteProperty("type", "array");
     writer.WritePropertyName("items");
     this.itemSchema.ToJson(writer, seenSchemas);
     writer.WriteEndObject();
 }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:13,代码来源:ArraySchema.cs

示例4: ToJsonString

        public string ToJsonString()
        {
            var sb = new StringBuilder();

            using(var sw = new StringWriter(sb))
            using(JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.WriteStartObject();
                writer.WritePropertyName(PhaseType);

                // phase start
                writer.WriteStartObject();
                WriteJson(writer);
                writer.WriteProperty("keep", _keep);
                writer.WriteEndObject();
                // phase end

                writer.WriteEndObject();
            }

            return sb.ToString();
        }
开发者ID:remotex,项目名称:CorrugatedIron,代码行数:22,代码来源:RiakPhase.cs

示例5: ToJavaScript

        // Returns JavaScript representation of Ext.Direct API
        public string ToJavaScript(bool toJson)
        {
            var sb = new StringBuilder();
            var sw = new StringWriter(sb);

            using (JsonWriter jsonWriter = new JsonTextWriter(sw)) {
            #if DEBUG
                jsonWriter.Formatting = Formatting.Indented;
            #endif
                jsonWriter.WriteStartObject();
                jsonWriter.WriteProperty("url", this.Url);
                jsonWriter.WriteProperty("type", RemotingProvider);
                if (!String.IsNullOrEmpty(this.Namespace)) {
                    jsonWriter.WriteProperty("namespace", this.Namespace);
                }
                // for integration with the Ext Designer
                if (toJson) {
                    jsonWriter.WriteProperty("descriptor", this.Name);
                }
                if (this.Buffer.HasValue) {
                    jsonWriter.WriteProperty("enableBuffer", this.Buffer);
                }
                jsonWriter.WritePropertyName("actions");
                jsonWriter.WriteStartObject();
                foreach (var action in _actions.Values) {
                    action.WriteJson(jsonWriter);
                }
                jsonWriter.WriteEndObject();
                jsonWriter.WriteEndObject();
            }

            if (toJson) return sb.ToString();

            return String.Format("{0}={1};", this.Name, sb);
        }
开发者ID:xcrash,项目名称:ext-direct-mvc,代码行数:36,代码来源:DirectProvider.cs

示例6: ToJsonSafe

        /// <summary>
        ///     Converts current not to json according to the avro specification.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="seenSchemas">The seen schemas.</param>
        internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
        {
            if (seenSchemas.Contains(this))
            {
                writer.WriteValue(this.FullName);
                return;
            }

            seenSchemas.Add(this);
            writer.WriteStartObject();
            writer.WriteProperty("type", "record");
            writer.WriteProperty("name", this.FullName);
            writer.WriteOptionalProperty("doc", this.Doc);
            writer.WriteOptionalProperty("aliases", this.Aliases);
            writer.WritePropertyName("fields");
            writer.WriteStartArray();
            this.fields.ForEach(_ => _.ToJson(writer, seenSchemas));
            writer.WriteEndArray();
            writer.WriteEndObject();
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:25,代码来源:RecordSchema.cs

示例7: ToString

        public string ToString(bool json)
        {
            var config = ProviderConfiguration.GetConfiguration();
            var sb = new StringBuilder();
            var sw = new StringWriter(sb);

            using (var writer = new JsonTextWriter(sw)) {
            #if DEBUG
                writer.Formatting = Formatting.Indented;
            #else
                writer.Formatting = config.Debug ? Formatting.Indented : Formatting.None;
            #endif
                writer.WriteStartObject();
                writer.WriteProperty("type", "remoting");
                writer.WriteProperty("url", Url);
                if (json) {
                    writer.WriteProperty("descriptor", Name ?? config.Name);
                }
                if (!String.IsNullOrEmpty(config.Namespace)) {
                    writer.WriteProperty("namespace", config.Namespace);
                }
                if (config.Buffer.HasValue) {
                    writer.WriteProperty("enableBuffer", config.Buffer.Value);
                }
                if (config.MaxRetries.HasValue) {
                    writer.WriteProperty("maxRetries", config.MaxRetries.Value);
                }
                if (config.Timeout.HasValue) {
                    writer.WriteProperty("timeout", config.Timeout.Value);
                }
                writer.WritePropertyName("actions");
                writer.WriteStartObject();
                foreach (DirectAction action in _actions.Values) {
                    action.WriteJson(writer);
                }
                writer.WriteEndObject();
                writer.WriteEndObject();
            }

            string name = Name ?? config.Name;
            if (name.Contains('.')) {
                name = String.Format("Ext.ns(\"{0}\");\n{1}", name.Substring(0, name.LastIndexOf('.')), name);
            }

            return json ? sb.ToString() : String.Format("{0}={1};", name, sb);
        }
开发者ID:sijoyjohn,项目名称:ext-direct-mvc,代码行数:46,代码来源:DirectProvider.cs

示例8: ToJsonSafe

        /// <summary>
        ///     Converts current not to JSON according to the avro specification.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="seenSchemas">The seen schemas.</param>
        internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
        {
            if (seenSchemas.Contains(this))
            {
                writer.WriteValue(this.FullName);
                return;
            }

            seenSchemas.Add(this);
            writer.WriteStartObject();
            writer.WriteProperty("type", "enum");
            writer.WriteProperty("name", this.FullName);
            writer.WriteOptionalProperty("doc", this.Doc);
            writer.WritePropertyName("symbols");
            writer.WriteStartArray();
            this.symbols.ForEach(writer.WriteValue);
            writer.WriteEndArray();
            writer.WriteEndObject();
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:24,代码来源:EnumSchema.cs

示例9: Compile

        public void Compile()
        {
            System.Diagnostics.Debug.Assert(_inputs != null);
            if(!string.IsNullOrWhiteSpace(_query))
            {
                return;
            }

            var sb = new StringBuilder();

            using(var sw = new StringWriter(sb))
            using(JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.WriteStartObject();

                if(_inputs != null)
                {
                    _inputs.WriteJson(writer);
                }

                writer.WritePropertyName("query");

                writer.WriteStartArray();
                _phases.ForEach(p => writer.WriteRawValue(p.ToJsonString()));
                writer.WriteEndArray();

                if (Timeout.HasValue)
                {
                    writer.WriteProperty<int>("timeout", Timeout.Value);
                }

                writer.WriteEndObject();
            }

            _query = sb.ToString();
        }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:36,代码来源:RiakMapReduceQuery.cs

示例10: ToJsonSafe

 /// <summary>
 ///     Converts current not to JSON according to the avro specification.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="seenSchemas">The seen schemas.</param>
 internal override void ToJsonSafe(JsonTextWriter writer, HashSet<NamedSchema> seenSchemas)
 {
     writer.WriteStartObject();
     writer.WriteProperty("name", this.FullName);
     writer.WriteOptionalProperty("doc", this.Doc);
     writer.WriteOptionalProperty("aliases", this.Aliases);
     writer.WritePropertyName("type");
     this.TypeSchema.ToJson(writer, seenSchemas);
     writer.WriteEndObject();
 }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:15,代码来源:RecordField.cs

示例11: Compile

#pragma warning restore 618

        /// <summary>
        /// Compile the mapreduce query.
        /// </summary>
        public void Compile()
        {
            Debug.Assert(inputs != null, "Compile inputs must not be null");

            if (!string.IsNullOrWhiteSpace(query))
            {
                return;
            }

            var sb = new StringBuilder();

            using (var sw = new StringWriter(sb))
            {
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    writer.WriteStartObject();

                    if (inputs != null)
                    {
                        inputs.WriteJson(writer);
                    }

                    writer.WritePropertyName("query");

                    writer.WriteStartArray();
                    phases.ForEach(p => writer.WriteRawValue(p.ToJsonString()));
                    writer.WriteEndArray();

                    if (timeout.HasValue)
                    {
                        writer.WriteProperty<int>("timeout", timeout.Value);
                    }

                    writer.WriteEndObject();
                }
            }

            query = sb.ToString();
        }
开发者ID:josephjeganathan,项目名称:riak-dotnet-client,代码行数:44,代码来源:RiakMapReduceQuery.cs


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