示例#1
0
        private static SettingDictionary DBMapping(DBSettingCollection dbCollection)
        {
            if (dbCollection == null)
            {
                return(null);
            }

            var dictionary = new SettingDictionary();

            foreach (var dbItem in dbCollection)
            {
                var item = DBMapping(dbItem);
                dictionary.Add(item.Name.ToLowerInvariant(), item);
            }

            return(dictionary);
        }
示例#2
0
        internal static SettingDictionary?ParametersToSettings(RuntimeDefinedParameterDictionary?parameters)
        {
            if (parameters == null)
            {
                return(null);
            }

            var result = new SettingDictionary();

            foreach (var parameter in parameters.Where(p => p.Value.IsSet))
            {
                result.Add(parameter.Key,
                           parameter.Value.ParameterType == typeof(SwitchParameter)
                        ? true
                        : parameter.Value.Value);
            }
            return(result);
        }
示例#3
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var result = new SettingDictionary();

            reader.Read();
            while (reader.TokenType == JsonToken.PropertyName)
            {
                var propertyName = (string)reader.Value;

                reader.Read();
                var value = reader.TokenType == JsonToken.Integer
                    ? Convert.ToInt32(reader.Value, NumberFormatInfo.InvariantInfo)
                    : serializer.Deserialize(reader);
                result.Add(propertyName, value);

                reader.Read();
            }

            return(result);
        }