Пример #1
0
        public object ParseReadValue(string readValue, Type destinationType, IniContext iniContext)
        {
            readValue = iniContext.IniParser.Read(iniContext.IniValue.Key, null);

            var splitReadValues = _readSectionsParser.Parse(readValue);

            var returnedDictionary = CreateDictionary(iniContext);

            foreach (var splitReadValue in splitReadValues)
            {
                var key   = _underlyingKeyTypeIniConverter.ParseReadValue(splitReadValue.Key, iniContext.TypeDetailsInformation.UnderlyingKeyTypeInformation.Type, iniContext);
                var value = _underlyingTypeIniConverter.ParseReadValue(splitReadValue.Value, iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type, iniContext);

                returnedDictionary.Add(key, value);
            }

            return(returnedDictionary);
        }
Пример #2
0
        public object ParseReadValue(string readValue, Type destinationType, IniContext iniContext)
        {
            if (string.IsNullOrEmpty(readValue))
            {
                return(null);
            }

            var genericType = iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type;

            if (iniContext.TypeDetailsInformation.UnderlyingTypeInformation.TypeCode == TypeCode.Nullable)
            {
                genericType = typeof(Nullable <>).MakeGenericType(iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type);
            }
            var listType     = typeof(List <>).MakeGenericType(genericType);
            var returnedList = (IList)Activator.CreateInstance(listType);

            foreach (var singleEntity in readValue.Split(new[] { _iniSettings.EnumerableEntitySeparator }, StringSplitOptions.RemoveEmptyEntries))
            {
                returnedList.Add(_underlyingTypeIniConverter.ParseReadValue(singleEntity, iniContext.TypeDetailsInformation.UnderlyingTypeInformation.Type, iniContext));
            }
            return(returnedList);
        }
Пример #3
0
        public object ParseReadValue(string readValue, Type destinationType, IniContext iniContext)
        {
            var ignoreAttribute = _memberInfoWrapper.GetAttribute <IniIgnoreAttribute>();

            return(ignoreAttribute == null?_iniConverter.ParseReadValue(readValue, destinationType, iniContext) : null);
        }