/// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 /// <param name="shellVersion">The version of the shell to target.</param>
 public JsonWriterSettings(bool closeOutput, Encoding encoding, GuidRepresentation guidRepresentation, bool indent, string indentChars, string newLineChars, JsonOutputMode outputMode, Version shellVersion)
     : base(guidRepresentation)
 {
     this.closeOutput  = closeOutput;
     this.encoding     = encoding;
     this.indent       = indent;
     this.indentChars  = indentChars;
     this.newLineChars = newLineChars;
     this.outputMode   = outputMode;
     this.shellVersion = shellVersion;
 }
 /// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 /// <param name="shellVersion">The version of the shell to target.</param>
 public JsonWriterSettings(bool closeOutput, Encoding encoding, GuidRepresentation guidRepresentation, bool indent, string indentChars, string newLineChars, JsonOutputMode outputMode, Version shellVersion)
     : base(guidRepresentation)
 {
     _closeOutput = closeOutput;
     _encoding = encoding;
     _indent = indent;
     _indentChars = indentChars;
     _newLineChars = newLineChars;
     _outputMode = outputMode;
     _shellVersion = shellVersion;
 }
        public static string ToJson <T>(this ProjectionDefinition <T> projection, JsonOutputMode outputMode = JsonOutputMode.Strict)
        {
            if (projection == null)
            {
                return(string.Empty);
            }
            var projectionToBson = projection.RenderToBsonDocument();

            return(projectionToBson.ToJson(new JsonWriterSettings {
                OutputMode = outputMode
            }));
        }
        public static string ToJson <T>(this SortDefinition <T> sortDefinition, JsonOutputMode outputMode = JsonOutputMode.Strict)
        {
            if (sortDefinition == null)
            {
                return(string.Empty);
            }
            var sortToBson = sortDefinition.RenderToBsonDocument();

            return(sortToBson.ToJson(new JsonWriterSettings {
                OutputMode = outputMode
            }));
        }
        public static string ToJson <T>(this FilterDefinition <T> filter, JsonOutputMode outputMode = JsonOutputMode.Strict)
        {
            if (filter == null)
            {
                return("{}");
            }
            var filterToBson = filter.RenderToBsonDocument();

            return(filterToBson.ToJson(new JsonWriterSettings {
                OutputMode = outputMode
            }));
        }
        public static string ToJson <T>(this UpdateDefinition <T> updateDefinition, JsonOutputMode outputMode = JsonOutputMode.Strict)
        {
            if (updateDefinition == null)
            {
                return(string.Empty);
            }
            var serializerRegistry = BsonSerializer.SerializerRegistry;
            var documentSerializer = serializerRegistry.GetSerializer <T>();
            var bson = updateDefinition.Render(documentSerializer, serializerRegistry);

            return(bson.ToJson(new JsonWriterSettings {
                OutputMode = outputMode
            }));
        }
 /// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 public JsonWriterSettings(
     bool closeOutput,
     Encoding encoding,
     bool indent,
     string indentChars,
     string newLineChars,
     JsonOutputMode outputMode
 ) {
     this.closeOutput = closeOutput;
     this.encoding = encoding;
     this.indent = indent;
     this.indentChars = indentChars;
     this.newLineChars = newLineChars;
     this.outputMode = outputMode;
 }
 /// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 public JsonWriterSettings(
     bool closeOutput,
     Encoding encoding,
     bool indent,
     string indentChars,
     string newLineChars,
     JsonOutputMode outputMode
     )
 {
     this.closeOutput  = closeOutput;
     this.encoding     = encoding;
     this.indent       = indent;
     this.indentChars  = indentChars;
     this.newLineChars = newLineChars;
     this.outputMode   = outputMode;
 }
 /// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 public JsonWriterSettings(
     bool closeOutput,
     Encoding encoding,
     GuidRepresentation guidRepresentation,
     bool indent,
     string indentChars,
     string newLineChars,
     JsonOutputMode outputMode
 ) 
     : base(guidRepresentation) {
     this.closeOutput = closeOutput;
     this.encoding = encoding;
     this.indent = indent;
     this.indentChars = indentChars;
     this.newLineChars = newLineChars;
     this.outputMode = outputMode;
 }
Exemple #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            JsonOutputMode opt      = JsonOutputMode.Strict;
            var            settings = new JsonWriterSettings();

            settings.OutputMode = opt;
            myDevSite           = _devSite.FindAll().ToList();
            string mySite = myDevSite.ToJson(settings);



            if (mySite.Count() > 0)
            {
                context.Response.Write(mySite);
            }
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the JsonWriterSettings class.
 /// </summary>
 /// <param name="closeOutput">Whether to close the output when the writer is closed.</param>
 /// <param name="encoding">The output Encoding.</param>
 /// <param name="guidRepresentation">The representation for Guids.</param>
 /// <param name="indent">Whether to indent the output.</param>
 /// <param name="indentChars">The indentation characters.</param>
 /// <param name="newLineChars">The new line characters.</param>
 /// <param name="outputMode">The output mode.</param>
 /// <param name="shellVersion">The version of the shell to target.</param>
 /// <param name="useISO8601DateFormat">Use the ISO-8601 date format </param>
 public JsonWriterSettings(
     bool closeOutput,
     Encoding encoding,
     GuidRepresentation guidRepresentation,
     bool indent,
     string indentChars,
     string newLineChars,
     JsonOutputMode outputMode,
     Version shellVersion,
     bool useISO8601DateFormat)
     : base(guidRepresentation)
 {
     _closeOutput          = closeOutput;
     _encoding             = encoding;
     _indent               = indent;
     _indentChars          = indentChars;
     _newLineChars         = newLineChars;
     _outputMode           = outputMode;
     _shellVersion         = shellVersion;
     _useISO8601DateFormat = useISO8601DateFormat;
 }
Exemple #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            //接收参数locateID
            string CompName = HttpUtility.UrlDecode(context.Request.QueryString["CompName"]);

            Expression <Func <DevInfo, bool> > ex = p => p.CompName == CompName;

            //按照类型不同来排序,降序
            devInfoes = _devInfo.FindBy(ex).OrderByDescending(p => p.Type).ToList();


            JsonOutputMode     opt      = JsonOutputMode.Strict;
            JsonWriterSettings settings = new JsonWriterSettings();

            settings.OutputMode = opt;

            string outJson = devInfoes.ToJson(settings);

            context.Response.Write(outJson);
        }
        public static string ToJson <T, TOutput>(this PipelineDefinition <T, TOutput> aggregate, JsonOutputMode outputMode = JsonOutputMode.Strict)
        {
            var docs = RenderToBsonDocumentsList(aggregate);

            return(docs.Count > 0
                ? docs.ToJson(new JsonWriterSettings {
                OutputMode = outputMode
            })
                : string.Empty);
        }