示例#1
0
 public void ReadParameter ( ISettingsParameter parameter )
 {
     var item = this[parameter.Id];
     if ( item != null )
     {
         if ( ( parameter is ISettingsParameterGroup ) && ( item.Childs != null ) )
         {
             SettingsScope innerScope = new SettingsScope( item.Childs.ConvertToDictionary() );
             ( (ISettingsParameterGroup)parameter ).ReadParameter( innerScope );
         }
         else if ( ( parameter.ObjectValue is ISettingsParameterGroup ) && ( item.Childs != null ) )
         {
             SettingsScope innerScope = new SettingsScope( item.Childs.ConvertToDictionary() );
             ( (ISettingsParameterGroup)parameter.ObjectValue ).ReadParameter( innerScope );
         }
         else
         {
             parameter.ObjectValue = TypeConverter.ConvertTo( item.Value, parameter.ObjectType );
         }
     }
 }
示例#2
0
        public void WriteParameter ( ISettingsParameter parameter )
        {
            var rootItem = new Parameter( parameter.Id, parameter.ObjectType );

            if ( parameter is ISettingsParameterGroup )
            {
                SettingsScope innerScope = new SettingsScope();
                ( (ISettingsParameterGroup)parameter ).WriteParameter( innerScope );
                rootItem.Childs = innerScope.ConvertToList();
            }
            else if ( parameter.ObjectValue is ISettingsParameterGroup )
            {
                SettingsScope innerScope = new SettingsScope();
                ( (ISettingsParameterGroup)parameter.ObjectValue ).WriteParameter( innerScope );
                rootItem.Childs = innerScope.ConvertToList();
            }
            else
            {
                rootItem.Value = (string)TypeConverter.ConvertTo( parameter.ObjectValue, typeof( string ) );
            }

            _settings[parameter.Id] = rootItem;
        }