示例#1
0
        public static void Reset()
        {
            foreach (var rawSerializeType in HasSerializeFn.ToArray())
            {
                Reset(rawSerializeType);
            }

            sModelFactory = ReflectionExtensions.GetConstructorMethodToCache;
            sTryToParsePrimitiveTypeValues          = null;
            sTryToParseNumericType                  = null;
            sConvertObjectTypesIntoStringDictionary = null;
            sIncludeNullValues            = null;
            sExcludeTypeInfo              = null;
            sEmitCamelCaseNames           = null;
            sEmitLowercaseUnderscoreNames = null;
            sDateHandler                 = null;
            sTimeSpanHandler             = null;
            sPreferInterfaces            = null;
            sThrowOnDeserializationError = null;
            sTypeAttr             = null;
            sJsonTypeAttrInObject = null;
            sJsvTypeAttrInObject  = null;
            sTypeWriter           = null;
            sTypeFinder           = null;
            sTreatEnumAsInteger   = null;
            sAlwaysUseUtc         = null;
            sAssumeUtc            = null;
            sEscapeUnicode        = null;
            sIncludePublicFields  = null;
            HasSerializeFn        = new HashSet <Type>();
            TreatValueAsRefTypes  = new HashSet <Type> {
                typeof(KeyValuePair <,>)
            };
            PropertyConvention = JsonPropertyConvention.ExactMatch;
        }
示例#2
0
        public static JsConfigScope With(
            bool? convertObjectTypesIntoStringDictionary = null,
            bool? tryToParsePrimitiveTypeValues = null,
			bool? tryToParseNumericType = null,
            bool? includeNullValues = null,
            bool? includeDefaultEnums = null,
            bool? excludeTypeInfo = null,
            bool? includeTypeInfo = null,
            bool? emitCamelCaseNames = null,
            bool? emitLowercaseUnderscoreNames = null,
            DateHandler? dateHandler = null,
            TimeSpanHandler? timeSpanHandler = null,
            PropertyConvention? propertyConvention = null,
            bool? preferInterfaces = null,
            bool? throwOnDeserializationError = null,
            string typeAttr = null,
            Func<Type, string> typeWriter = null,
            Func<string, Type> typeFinder = null,
			bool? treatEnumAsInteger = null,
            bool? alwaysUseUtc = null,
            bool? assumeUtc = null,
            bool? appendUtcOffset = null,
            bool? escapeUnicode = null,
            bool? includePublicFields = null,
            bool? reuseStringBuffer = null,
            int? maxDepth = null,
            EmptyCtorFactoryDelegate modelFactory = null,
            string[] excludePropertyReferences = null)
        {
            return new JsConfigScope {
                ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary,
                TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues,
                TryToParseNumericType = tryToParseNumericType ?? sTryToParseNumericType,
                IncludeNullValues = includeNullValues ?? sIncludeNullValues,
                IncludeDefaultEnums = includeDefaultEnums ?? sIncludeDefaultEnums,
                ExcludeTypeInfo = excludeTypeInfo ?? sExcludeTypeInfo,
                IncludeTypeInfo = includeTypeInfo ?? sIncludeTypeInfo,
                EmitCamelCaseNames = emitCamelCaseNames ?? sEmitCamelCaseNames,
                EmitLowercaseUnderscoreNames = emitLowercaseUnderscoreNames ?? sEmitLowercaseUnderscoreNames,
                DateHandler = dateHandler ?? sDateHandler,
                TimeSpanHandler = timeSpanHandler ?? sTimeSpanHandler,
                PropertyConvention = propertyConvention ?? sPropertyConvention,
                PreferInterfaces = preferInterfaces ?? sPreferInterfaces,
                ThrowOnDeserializationError = throwOnDeserializationError ?? sThrowOnDeserializationError,
                TypeAttr = typeAttr ?? sTypeAttr,
                TypeWriter = typeWriter ?? sTypeWriter,
                TypeFinder = typeFinder ?? sTypeFinder,
                TreatEnumAsInteger = treatEnumAsInteger ?? sTreatEnumAsInteger,
                AlwaysUseUtc = alwaysUseUtc ?? sAlwaysUseUtc,
                AssumeUtc = assumeUtc ?? sAssumeUtc,
                AppendUtcOffset = appendUtcOffset ?? sAppendUtcOffset,
                EscapeUnicode = escapeUnicode ?? sEscapeUnicode,
                IncludePublicFields = includePublicFields ?? sIncludePublicFields,
                ReuseStringBuffer = reuseStringBuffer ?? sReuseStringBuffer,
                MaxDepth = maxDepth ?? sMaxDepth,
                ModelFactory = modelFactory ?? ModelFactory,
                ExcludePropertyReferences = excludePropertyReferences ?? sExcludePropertyReferences
            };
        }
示例#3
0
文件: JsConfig.cs 项目: rebider/soa
 public static JsConfigScope With(
     bool?convertObjectTypesIntoStringDictionary = null,
     bool?tryToParsePrimitiveTypeValues          = null,
     bool?tryToParseNumericType            = null,
     bool?includeNullValues                = null,
     bool?includeDefaultEnums              = null,
     bool?excludeTypeInfo                  = null,
     bool?includeTypeInfo                  = null,
     bool?emitCamelCaseNames               = null,
     bool?emitLowercaseUnderscoreNames     = null,
     DateHandler?dateHandler               = null,
     TimeSpanHandler?timeSpanHandler       = null,
     PropertyConvention?propertyConvention = null,
     bool?preferInterfaces                 = null,
     bool?throwOnDeserializationError      = null,
     string typeAttr = null,
     Func <Type, string> typeWriter = null,
     Func <string, Type> typeFinder = null,
     bool?treatEnumAsInteger        = null,
     bool?alwaysUseUtc        = null,
     bool?assumeUtc           = null,
     bool?appendUtcOffset     = null,
     bool?escapeUnicode       = null,
     bool?includePublicFields = null,
     bool?reuseStringBuffer   = null,
     int?maxDepth             = null,
     EmptyCtorFactoryDelegate modelFactory = null,
     string[] excludePropertyReferences    = null)
 {
     return(new JsConfigScope {
         ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary,
         TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues,
         TryToParseNumericType = tryToParseNumericType ?? sTryToParseNumericType,
         IncludeNullValues = includeNullValues ?? sIncludeNullValues,
         IncludeDefaultEnums = includeDefaultEnums ?? sIncludeDefaultEnums,
         ExcludeTypeInfo = excludeTypeInfo ?? sExcludeTypeInfo,
         IncludeTypeInfo = includeTypeInfo ?? sIncludeTypeInfo,
         EmitCamelCaseNames = emitCamelCaseNames ?? sEmitCamelCaseNames,
         EmitLowercaseUnderscoreNames = emitLowercaseUnderscoreNames ?? sEmitLowercaseUnderscoreNames,
         DateHandler = dateHandler ?? sDateHandler,
         TimeSpanHandler = timeSpanHandler ?? sTimeSpanHandler,
         PropertyConvention = propertyConvention ?? sPropertyConvention,
         PreferInterfaces = preferInterfaces ?? sPreferInterfaces,
         ThrowOnDeserializationError = throwOnDeserializationError ?? sThrowOnDeserializationError,
         TypeAttr = typeAttr ?? sTypeAttr,
         TypeWriter = typeWriter ?? sTypeWriter,
         TypeFinder = typeFinder ?? sTypeFinder,
         TreatEnumAsInteger = treatEnumAsInteger ?? sTreatEnumAsInteger,
         AlwaysUseUtc = alwaysUseUtc ?? sAlwaysUseUtc,
         AssumeUtc = assumeUtc ?? sAssumeUtc,
         AppendUtcOffset = appendUtcOffset ?? sAppendUtcOffset,
         EscapeUnicode = escapeUnicode ?? sEscapeUnicode,
         IncludePublicFields = includePublicFields ?? sIncludePublicFields,
         ReuseStringBuffer = reuseStringBuffer ?? sReuseStringBuffer,
         MaxDepth = maxDepth ?? sMaxDepth,
         ModelFactory = modelFactory ?? ModelFactory,
         ExcludePropertyReferences = excludePropertyReferences ?? sExcludePropertyReferences
     });
 }
示例#4
0
        public static void Reset()
        {
            foreach (var rawSerializeType in HasSerializeFn.ToArray())
            {
                Reset(rawSerializeType);
            }
            foreach (var rawSerializeType in HasIncludeDefaultValue.ToArray())
            {
                Reset(rawSerializeType);
            }
            foreach (var uniqueType in __uniqueTypes.ToArray())
            {
                Reset(uniqueType);
            }

            sModelFactory = ReflectionExtensions.GetConstructorMethodToCache;
            sTryToParsePrimitiveTypeValues          = null;
            sTryToParseNumericType                  = null;
            sConvertObjectTypesIntoStringDictionary = null;
            sIncludeNullValues            = null;
            sExcludeTypeInfo              = null;
            sEmitCamelCaseNames           = null;
            sEmitLowercaseUnderscoreNames = null;
            sDateHandler                 = null;
            sTimeSpanHandler             = null;
            sPreferInterfaces            = null;
            sThrowOnDeserializationError = null;
            sTypeAttr              = null;
            sJsonTypeAttrInObject  = null;
            sJsvTypeAttrInObject   = null;
            sTypeWriter            = null;
            sTypeFinder            = null;
            sTreatEnumAsInteger    = null;
            sAlwaysUseUtc          = null;
            sAssumeUtc             = null;
            sAppendUtcOffset       = null;
            sEscapeUnicode         = null;
            sIncludePublicFields   = null;
            sReuseStringBuffer     = null;
            HasSerializeFn         = new HashSet <Type>();
            HasIncludeDefaultValue = new HashSet <Type>();
            TreatValueAsRefTypes   = new HashSet <Type> {
                typeof(KeyValuePair <,>)
            };
            sPropertyConvention        = null;
            sExcludePropertyReferences = null;
            sExcludeTypes = new HashSet <Type> {
                typeof(Stream)
            };
            __uniqueTypes = new HashSet <Type>();
            sMaxDepth     = 50;
            sParsePrimitiveIntegerTypes       = null;
            sParsePrimitiveFloatingPointTypes = null;
            PlatformExtensions.ClearRuntimeAttributes();
            ReflectionExtensions.Reset();
            JsState.Reset();
        }
示例#5
0
        public static JsConfigScope With(
            bool?convertObjectTypesIntoStringDictionary = null,
            bool?tryToParsePrimitiveTypeValues          = null,
            bool?includeNullValues              = null,
            bool?excludeTypeInfo                = null,
            bool?includeTypeInfo                = null,
            bool?emitCamelCaseNames             = null,
            bool?emitLowercaseUnderscoreNames   = null,
            JsonDateHandler?dateHandler         = null,
            JsonTimeSpanHandler?timeSpanHandler = null,
            bool?preferInterfaces               = null,
            bool?throwOnDeserializationError    = null,
            string typeAttr = null,
            Func <Type, string> typeWriter = null,
            Func <string, Type> typeFinder = null,
            bool?treatEnumAsInteger        = null,
            bool?alwaysUseUtc        = null,
            bool?escapeUnicode       = null,
            bool?includePublicFields = null,
            int?maxDepth             = null,
            EmptyCtorFactoryDelegate modelFactory = null)
#endif
        {
            return(new JsConfigScope
            {
                ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? sConvertObjectTypesIntoStringDictionary,
                TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? sTryToParsePrimitiveTypeValues,
                IncludeNullValues = includeNullValues ?? sIncludeNullValues,
                ExcludeTypeInfo = excludeTypeInfo ?? sExcludeTypeInfo,
                IncludeTypeInfo = includeTypeInfo ?? sIncludeTypeInfo,
                EmitCamelCaseNames = emitCamelCaseNames ?? sEmitCamelCaseNames,
                EmitLowercaseUnderscoreNames = emitLowercaseUnderscoreNames ?? sEmitLowercaseUnderscoreNames,
                DateHandler = dateHandler ?? sDateHandler,
                TimeSpanHandler = timeSpanHandler ?? sTimeSpanHandler,
                PreferInterfaces = preferInterfaces ?? sPreferInterfaces,
                ThrowOnDeserializationError = throwOnDeserializationError ?? sThrowOnDeserializationError,
                TypeAttr = typeAttr ?? sTypeAttr,
                TypeWriter = typeWriter ?? sTypeWriter,
                TypeFinder = typeFinder ?? sTypeFinder,
                TreatEnumAsInteger = treatEnumAsInteger ?? sTreatEnumAsInteger,
                AlwaysUseUtc = alwaysUseUtc ?? sAlwaysUseUtc,
                EscapeUnicode = escapeUnicode ?? sEscapeUnicode,
                IncludePublicFields = includePublicFields ?? sIncludePublicFields,
                MaxDepth = maxDepth ?? sMaxDepth,
                ModelFactory = modelFactory ?? ModelFactory,
            });
        }
示例#6
0
        public static void Reset()
        {
            foreach (var rawSerializeType in HasSerializeFn.ToArray())
            {
                Reset(rawSerializeType);
            }
            foreach (var uniqueType in __uniqueTypes.ToArray())
            {
                Reset(uniqueType);
            }

            sModelFactory = ReflectionExtensions.GetConstructorMethodToCache;
            sTryToParsePrimitiveTypeValues = null;
		    sTryToParseNumericType = null;
            sConvertObjectTypesIntoStringDictionary = null;
            sIncludeNullValues = null;
            sExcludeTypeInfo = null;
            sEmitCamelCaseNames = null;
            sEmitLowercaseUnderscoreNames = null;
            sDateHandler = null;
            sTimeSpanHandler = null;
            sPreferInterfaces = null;
            sThrowOnDeserializationError = null;
            sTypeAttr = null;
            sJsonTypeAttrInObject = null;
            sJsvTypeAttrInObject = null;
            sTypeWriter = null;
            sTypeFinder = null;
			sTreatEnumAsInteger = null;
            sAlwaysUseUtc = null;
            sAssumeUtc = null;
            sAppendUtcOffset = null;
            sEscapeUnicode = null;
            sIncludePublicFields = null;
            HasSerializeFn = new HashSet<Type>();
            TreatValueAsRefTypes = new HashSet<Type> { typeof(KeyValuePair<,>) };
            sPropertyConvention = null;
            sExcludePropertyReferences = null;
            sExcludeTypes = new HashSet<Type> { typeof(Stream) };
            __uniqueTypes = new HashSet<Type>();
	        sMaxDepth = 50;
        }
示例#7
0
        public static JsConfigScope With(
            bool?convertObjectTypesIntoStringDictionary = null,
            bool?tryToParsePrimitiveTypeValues          = null,
            bool?tryToParseNumericType = null,
            ParseAsType?parsePrimitiveFloatingPointTypes = null,
            ParseAsType?parsePrimitiveIntegerTypes       = null,
            bool?excludeDefaultValues            = null,
            bool?includeNullValues               = null,
            bool?includeNullValuesInDictionaries = null,
            bool?includeDefaultEnums             = null,
            bool?excludeTypeInfo                  = null,
            bool?includeTypeInfo                  = null,
            bool?emitCamelCaseNames               = null,
            bool?emitLowercaseUnderscoreNames     = null,
            DateHandler?dateHandler               = null,
            TimeSpanHandler?timeSpanHandler       = null,
            PropertyConvention?propertyConvention = null,
            bool?preferInterfaces                 = null,
            bool?throwOnDeserializationError      = null,
            string typeAttr                = null,
            string dateTimeFormat          = null,
            Func <Type, string> typeWriter = null,
            Func <string, Type> typeFinder = null,
            bool?treatEnumAsInteger        = null,
            bool?skipDateTimeConversion    = null,
            bool?alwaysUseUtc              = null,
            bool?assumeUtc           = null,
            bool?appendUtcOffset     = null,
            bool?escapeUnicode       = null,
            bool?includePublicFields = null,
            int?maxDepth             = null,
            EmptyCtorFactoryDelegate modelFactory = null,
            string[] excludePropertyReferences    = null,
            bool?useSystemParseMethods            = null) //Unused
        {
            return(new JsConfigScope
            {
                ConvertObjectTypesIntoStringDictionary = convertObjectTypesIntoStringDictionary ?? Config.Instance.ConvertObjectTypesIntoStringDictionary,
                TryToParsePrimitiveTypeValues = tryToParsePrimitiveTypeValues ?? Config.Instance.TryToParsePrimitiveTypeValues,
                TryToParseNumericType = tryToParseNumericType ?? Config.Instance.TryToParseNumericType,

                ParsePrimitiveFloatingPointTypes = parsePrimitiveFloatingPointTypes ?? Config.Instance.ParsePrimitiveFloatingPointTypes,
                ParsePrimitiveIntegerTypes = parsePrimitiveIntegerTypes ?? Config.Instance.ParsePrimitiveIntegerTypes,

                ExcludeDefaultValues = excludeDefaultValues ?? Config.Instance.ExcludeDefaultValues,
                IncludeNullValues = includeNullValues ?? Config.Instance.IncludeNullValues,
                IncludeNullValuesInDictionaries = includeNullValuesInDictionaries ?? Config.Instance.IncludeNullValuesInDictionaries,
                IncludeDefaultEnums = includeDefaultEnums ?? Config.Instance.IncludeDefaultEnums,
                ExcludeTypeInfo = excludeTypeInfo ?? Config.Instance.ExcludeTypeInfo,
                IncludeTypeInfo = includeTypeInfo ?? Config.Instance.IncludeTypeInfo,
                EmitCamelCaseNames = emitCamelCaseNames ?? Config.Instance.EmitCamelCaseNames,
                EmitLowercaseUnderscoreNames = emitLowercaseUnderscoreNames ?? Config.Instance.EmitLowercaseUnderscoreNames,
                DateHandler = dateHandler ?? Config.Instance.DateHandler,
                TimeSpanHandler = timeSpanHandler ?? Config.Instance.TimeSpanHandler,
                PropertyConvention = propertyConvention ?? Config.Instance.PropertyConvention,
                PreferInterfaces = preferInterfaces ?? Config.Instance.PreferInterfaces,
                ThrowOnError = throwOnDeserializationError ?? Config.Instance.ThrowOnError,
                DateTimeFormat = dateTimeFormat ?? Config.Instance.DateTimeFormat,
                TypeAttr = typeAttr ?? Config.Instance.TypeAttr,
                TypeWriter = typeWriter ?? Config.Instance.TypeWriter,
                TypeFinder = typeFinder ?? Config.Instance.TypeFinder,
                TreatEnumAsInteger = treatEnumAsInteger ?? Config.Instance.TreatEnumAsInteger,
                SkipDateTimeConversion = skipDateTimeConversion ?? Config.Instance.SkipDateTimeConversion,
                AlwaysUseUtc = alwaysUseUtc ?? Config.Instance.AlwaysUseUtc,
                AssumeUtc = assumeUtc ?? Config.Instance.AssumeUtc,
                AppendUtcOffset = appendUtcOffset ?? Config.Instance.AppendUtcOffset,
                EscapeUnicode = escapeUnicode ?? Config.Instance.EscapeUnicode,
                IncludePublicFields = includePublicFields ?? Config.Instance.IncludePublicFields,
                MaxDepth = maxDepth ?? Config.Instance.MaxDepth,
                ModelFactory = modelFactory ?? Config.Instance.ModelFactory,
                ExcludePropertyReferences = excludePropertyReferences ?? Config.Instance.ExcludePropertyReferences,
            });
        }
示例#8
0
/*
 *      public static JsConfigScope With(bool? convertObjectTypesIntoStringDictionary, bool? tryToParsePrimitiveTypeValues,
 *                                       bool? includeNullValues, bool? excludeTypeInfo, bool? includeTypeInfo,
 *                                       bool? emitCamelCaseNames, bool? emitLowercaseUnderscoreNames,
 *                                       JsonDateHandler? dateHandler, JsonTimeSpanHandler? timeSpanHandler,
 *                                       bool? preferInterfaces, bool? throwOnDeserializationError,
 *                                       string typeAttr, Func<Type, string> typeWriter, Func<string, Type> typeFinder,
 *                                       bool? treatEnumAsInteger, bool? alwaysUseUtc, bool? escapeUnicode)
 *      {
 *          return With(convertObjectTypesIntoStringDictionary, tryToParsePrimitiveTypeValues, includeNullValues,
 *                      excludeTypeInfo, includeTypeInfo, emitCamelCaseNames, emitLowercaseUnderscoreNames,
 *                      dateHandler, timeSpanHandler, preferInterfaces, throwOnDeserializationError,
 *                      typeAttr, typeWriter, typeFinder, treatEnumAsInteger, alwaysUseUtc,
 *                      escapeUnicode, null, null, null);
 *      }
 *
 *      public static JsConfigScope With(bool? convertObjectTypesIntoStringDictionary, bool? tryToParsePrimitiveTypeValues,
 *                                       bool? includeNullValues, bool? excludeTypeInfo, bool? includeTypeInfo,
 *                                       bool? emitCamelCaseNames, bool? emitLowercaseUnderscoreNames,
 *                                       JsonDateHandler? dateHandler, JsonTimeSpanHandler? timeSpanHandler,
 *                                       bool? preferInterfaces, bool? throwOnDeserializationError,
 *                                       string typeAttr, Func<Type, string> typeWriter, Func<string, Type> typeFinder,
 *                                       bool? treatEnumAsInteger, bool? alwaysUseUtc, bool? escapeUnicode,
 *                                       bool? includePublicFields)
 *      {
 *          return With(convertObjectTypesIntoStringDictionary, tryToParsePrimitiveTypeValues, includeNullValues,
 *                      excludeTypeInfo, includeTypeInfo, emitCamelCaseNames, emitLowercaseUnderscoreNames,
 *                      dateHandler, timeSpanHandler, preferInterfaces, throwOnDeserializationError,
 *                      typeAttr, typeWriter, typeFinder, treatEnumAsInteger, alwaysUseUtc,
 *                      escapeUnicode, includePublicFields, null, null);
 *      }
 *
 *      public static JsConfigScope With(bool? convertObjectTypesIntoStringDictionary, bool? tryToParsePrimitiveTypeValues,
 *                                       bool? includeNullValues, bool? excludeTypeInfo, bool? includeTypeInfo,
 *                                       bool? emitCamelCaseNames, bool? emitLowercaseUnderscoreNames,
 *                                       JsonDateHandler? dateHandler, JsonTimeSpanHandler? timeSpanHandler,
 *                                       bool? preferInterfaces, bool? throwOnDeserializationError,
 *                                       string typeAttr, Func<Type, string> typeWriter, Func<string, Type> typeFinder,
 *                                       bool? treatEnumAsInteger, bool? alwaysUseUtc, bool? escapeUnicode,
 *                                       bool? includePublicFields, int? maxDepth)
 *      {
 *          return With(convertObjectTypesIntoStringDictionary, tryToParsePrimitiveTypeValues, includeNullValues,
 *                      excludeTypeInfo, includeTypeInfo, emitCamelCaseNames, emitLowercaseUnderscoreNames,
 *                      dateHandler, timeSpanHandler, preferInterfaces, throwOnDeserializationError,
 *                      typeAttr, typeWriter, typeFinder, treatEnumAsInteger, alwaysUseUtc,
 *                      escapeUnicode, includePublicFields, maxDepth, null);
 *      }
 */
        public static JsConfigScope With(bool?convertObjectTypesIntoStringDictionary, bool?tryToParsePrimitiveTypeValues,
                                         bool?includeNullValues, bool?excludeTypeInfo, bool?includeTypeInfo, bool?emitCamelCaseNames,
                                         bool?emitLowercaseUnderscoreNames, JsonDateHandler?dateHandler, JsonTimeSpanHandler?timeSpanHandler,
                                         bool?preferInterfaces, bool?throwOnDeserializationError, string typeAttr,
                                         Func <Type, string> typeWriter, Func <string, Type> typeFinder, bool?treatEnumAsInteger,
                                         bool?alwaysUseUtc, bool?escapeUnicode, bool?includePublicFields, int?maxDepth, EmptyCtorFactoryDelegate modelFactory)