예제 #1
0
 /// <summary>
 /// Adds a defined value to the list of defined values
 /// </summary>
 /// <param name="value">The value to add</param>
 public void AddDefinedProtocolSettingValue(DefinedProtocolSettingValue value)
 {
     if (_definedValues == null)
     {
         _definedValues = new List <DefinedProtocolSettingValue>();
     }
     _definedValues.Add(value);
 }
예제 #2
0
        /// <summary>
        /// Initiate Protocol settings with default values
        /// </summary>
        private void InitiateProtocolSettings()
        {
            _protocolSettings = new SortedList <string, ProtocolSetting>();
            FileInfo _propertyMappingsIniFile = new FileInfo(this.Config.GetDirectory() + "\\mapping.ini");

            if (!_propertyMappingsIniFile.Exists)
            {
                throw new ProtocolConfigurationException(beRemoteExInfoPackage.SignificantInformationPackage, "Could not find mappings file for protocol setting mappings. (FileNotFound: " + _propertyMappingsIniFile.FullName + ")");
            }

            _propertyMappings = new IniFile(_propertyMappingsIniFile);

            foreach (String key in Config.GetSection(IniSection.SETTINGS_CUSTOM).Keys)
            {
                String dataTypeString = _propertyMappings.GetValue(IniSection.SETTINGS_MAPPING_DATATYPES, key);
                bool   multiple       = false;
                if (dataTypeString.ToLower().Contains("multiple"))
                {
                    dataTypeString = dataTypeString.Split(new String[] { ";" }, StringSplitOptions.None)[1];
                    multiple       = true;
                }
                Type dataType;

                if (Type.GetType(dataTypeString) != null)
                {
                    dataType = Type.GetType(dataTypeString, false, true);
                }
                else if (Type.GetType("System." + dataTypeString, false, true) != null)
                {
                    dataType = Type.GetType("System." + dataTypeString, false, true);
                }
                else if (dataTypeString.Contains("credential"))
                {
                    dataType = typeof(UserCredential);
                }
                else
                {
                    throw new TypeAccessException("This System.Type is not known (" + dataTypeString + ")");
                }

                ProtocolSetting ps = new ProtocolSetting(key, _propertyMappings.GetValue(IniSection.SETTINGS_MAPPING_DISPLAYTEXT, key), "description", dataType);
                ps.SetDefaultValue(new DefinedProtocolSettingValue(Config.GetValue(IniSection.SETTINGS_CUSTOM, key) + GetDefinedValueTitle(key), Config.GetValue(IniSection.SETTINGS_CUSTOM, key)));
                if (multiple)
                {
                    String[] definedValues = _propertyMappings.GetValue(IniSection.SETTINGS_MAPPING_DEFINEDVALUES, key).Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (String value in definedValues)
                    {
                        DefinedProtocolSettingValue dv = new DefinedProtocolSettingValue(value + GetDefinedValueTitle(key), value);
                        ps.AddDefinedProtocolSettingValue(dv);
                    }
                }

                _protocolSettings.Add(key, ps);
            }
        }
예제 #3
0
 /// <summary>
 /// Sets the default value for this ProtocolSetting
 /// </summary>
 /// <param name="value">The value to set</param>
 public void SetDefaultValue(DefinedProtocolSettingValue value)
 {
     _value = value;
 }