Exemple #1
0
        internal JsConfigScope()
        {
            PclExport.Instance.BeginThreadAffinity();

            parent = head;
            head   = this;
        }
Exemple #2
0
        public void Dispose()
        {
            if (!disposed)
            {
                disposed = true;
                head     = parent;

                PclExport.Instance.EndThreadAffinity();
            }
        }
Exemple #3
0
        public static JsConfigScope CreateScope(string config, JsConfigScope scope = null)
        {
            if (string.IsNullOrEmpty(config))
            {
                return(scope);
            }

            if (scope == null)
            {
                scope = BeginScope();
            }

            var items = config.Split(',');

            foreach (var item in items)
            {
                var parts     = item.SplitOnFirst(':');
                var key       = parts[0].ToLower();
                var value     = parts.Length == 2 ? parts[1].ToLower() : null;
                var boolValue = parts.Length == 1 || (value != "false" && value != "0");

                switch (key)
                {
                case "cotisd":
                case "convertobjecttypesintostringdictionary":
                    scope.ConvertObjectTypesIntoStringDictionary = boolValue;
                    break;

                case "ttpptv":
                case "trytoparseprimitivetypevalues":
                    scope.TryToParsePrimitiveTypeValues = boolValue;
                    break;

                case "ttpnt":
                case "trytoparsenumerictype":
                    scope.TryToParseNumericType = boolValue;
                    break;

                case "edv":
                case "excludedefaultvalues":
                    scope.ExcludeDefaultValues = boolValue;
                    break;

                case "inv":
                case "includenullvalues":
                    scope.IncludeNullValues = boolValue;
                    break;

                case "invid":
                case "includenullvaluesindictionaries":
                    scope.IncludeNullValuesInDictionaries = boolValue;
                    break;

                case "ide":
                case "includedefaultenums":
                    scope.IncludeDefaultEnums = boolValue;
                    break;

                case "eti":
                case "excludetypeinfo":
                    scope.ExcludeTypeInfo = boolValue;
                    break;

                case "iti":
                case "includetypeinfo":
                    scope.IncludeTypeInfo = boolValue;
                    break;

                case "eccn":
                case "emitcamelcasenames":
                    scope.EmitCamelCaseNames = boolValue;
                    break;

                case "elun":
                case "emitlowercaseunderscorenames":
                    scope.EmitLowercaseUnderscoreNames = boolValue;
                    break;

                case "pi":
                case "preferinterfaces":
                    scope.PreferInterfaces = boolValue;
                    break;

                case "tode":
                case "throwondeserializationerror":
                    scope.ThrowOnDeserializationError = boolValue;
                    break;

                case "teai":
                case "treatenumasinteger":
                    scope.TreatEnumAsInteger = boolValue;
                    break;

                case "sdtc":
                case "skipdatetimeconversion":
                    scope.SkipDateTimeConversion = boolValue;
                    break;

                case "auu":
                case "alwaysuseutc":
                    scope.AlwaysUseUtc = boolValue;
                    break;

                case "au":
                case "assumeutc":
                    scope.AssumeUtc = boolValue;
                    break;

                case "auo":
                case "appendutcoffset":
                    scope.AppendUtcOffset = boolValue;
                    break;

                case "eu":
                case "escapeunicode":
                    scope.EscapeUnicode = boolValue;
                    break;

                case "ehc":
                case "escapehtmlchars":
                    scope.EscapeHtmlChars = boolValue;
                    break;

                case "ipf":
                case "includepublicfields":
                    scope.IncludePublicFields = boolValue;
                    break;

                case "dh":
                case "datehandler":
                    switch (value)
                    {
                    case "timestampoffset":
                    case "to":
                        scope.DateHandler = DateHandler.TimestampOffset;
                        break;

                    case "dcjsc":
                    case "dcjscompatible":
                        scope.DateHandler = DateHandler.DCJSCompatible;
                        break;

                    case "iso8601":
                        scope.DateHandler = DateHandler.ISO8601;
                        break;

                    case "iso8601do":
                    case "iso8601dateonly":
                        scope.DateHandler = DateHandler.ISO8601DateOnly;
                        break;

                    case "iso8601dt":
                    case "iso8601datetime":
                        scope.DateHandler = DateHandler.ISO8601DateTime;
                        break;

                    case "rfc1123":
                        scope.DateHandler = DateHandler.RFC1123;
                        break;

                    case "ut":
                    case "unixtime":
                        scope.DateHandler = DateHandler.UnixTime;
                        break;

                    case "utm":
                    case "unixtimems":
                        scope.DateHandler = DateHandler.UnixTimeMs;
                        break;
                    }
                    break;

                case "tsh":
                case "timespanhandler":
                    switch (value)
                    {
                    case "df":
                    case "durationformat":
                        scope.TimeSpanHandler = TimeSpanHandler.DurationFormat;
                        break;

                    case "sf":
                    case "standardformat":
                        scope.TimeSpanHandler = TimeSpanHandler.StandardFormat;
                        break;
                    }
                    break;

                case "pc":
                case "propertyconvention":
                    switch (value)
                    {
                    case "l":
                    case "lenient":
                        scope.PropertyConvention = PropertyConvention.Lenient;
                        break;

                    case "s":
                    case "strict":
                        scope.PropertyConvention = PropertyConvention.Strict;
                        break;
                    }
                    break;
                }
            }

            return(scope);
        }