コード例 #1
0
        /// <summary>
        /// Convert this geometry to json format.
        /// </summary>
        /// <param name="format">True will result in formatted json, false will result in an unformatted json string.</param>
        /// <returns>The geometry as json.</returns>
        public override string ToJSON(bool format)
        {
            var serializationAdaptor = new GeometrySerializationAdaptor
            {
                Data = Data
            };

            return(JsonConvert.SerializeObject(serializationAdaptor, format == true ? Formatting.Indented : Formatting.None, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore
            }));
        }
コード例 #2
0
ファイル: Geometry.cs プロジェクト: wegiangb/ThreeLib
        /// <summary>
        /// Convert this geometry to json format.
        /// </summary>
        /// <param name="format">True will result in formatted json, false will result in an unformatted json string.</param>
        /// <returns>The geometry as json.</returns>
        public override string ToJSON(bool format)
        {
            var serializationAdaptor = new GeometrySerializationAdaptor
            {
                Data = Data
            };

            var serializerSettings = new JsonSerializerSettings
            {
                Formatting           = format == true ? Formatting.Indented : Formatting.None,
                DefaultValueHandling = DefaultValueHandling.Ignore,
                NullValueHandling    = NullValueHandling.Ignore,
                ContractResolver     = new CamelCaseCustomResolver()
            };

            return(JsonConvert.SerializeObject(serializationAdaptor, serializerSettings));
        }