Ejemplo n.º 1
0
 void ValueSet (Value value)
 {
     if (MessageCreated != null)
         MessageCreated (new ConfigFileValueSetMessage (value));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the override for the configuration.
 /// </summary>
 /// <param name="section">Section.</param>
 /// <param name="valueName">Value name.</param>
 /// <param name="value">Value.</param>
 public void AddOverride (string section, string valueName, Value value)
 {
     Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Adding new override for '{0}:{1}' in {2}.conf",
         section, valueName, Name);
     Section s;
     if (!Overrides.TryGetValue (section, out s))
     {
         s = new Section ();
         Overrides.Add (section, s);
     }
     s.Add (valueName, value);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the value.
        /// </summary>
        /// <returns><c>true</c>, if value was set, <c>false</c> otherwise.</returns>
        /// <param name="section">Section.</param>
        /// <param name="valueName">Value name.</param>
        /// <param name="value">Value.</param>
        public bool SetValue (string section, string valueName, Value value)
        {
            Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Setting value '{0}:{1}' from {2}.conf ...",
                section, valueName, Name);

            Section s;
            if (!Defaults.TryGetValue (section, out s))
            {
                Logger.Log.AddLogEntry (LogLevel.Error, ClassName, Status.BadArgument,
                    "Section '{0}' is not registered!", section);
                return false;
            }

            Value defValue;
            if (!s.TryGetValue (valueName, out defValue))
            {
                Logger.Log.AddLogEntry (LogLevel.Error, ClassName, Status.BadArgument,
                    "'{0}' is not registered!", valueName);
                return false;
            }

            if (value.Type != defValue.Type)
            {
                Logger.Log.AddLogEntry (LogLevel.Error, ClassName, Status.BadArgument,
                    "The given value type '{0}' is not equal with the default value type!", value.Type.ToString ());
                return false;
            }

            switch (value.Type)
            {
            case ValueType.Boolean:
                IniConfig.SetValue (section, valueName, value.Boolean);
                ValueSet (value);
                return true;
            case ValueType.Integer:
                IniConfig.SetValue (section, valueName, value.Integer);
                ValueSet (value);
                return true;
            case ValueType.Double:
                IniConfig.SetValue (section, valueName, value.Double);
                ValueSet (value);
                return true;
            case ValueType.String:
                IniConfig.SetValue (section, valueName, value.String);
                ValueSet (value);
                return true;
            case ValueType.Bytes:
                IniConfig.SetValue (section, valueName, value.Bytes);
                ValueSet (value);
                return true;
            default:
                Logger.Log.AddLogEntry (LogLevel.Severe, ClassName, Status.UnexpectedData,
                    "The type '{0}' of the given value is not supported! This type shouldn't even exist!",
                    value.Type.ToString ());
                return false;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.ConfigFileValueSetMessage"/> class.
 /// </summary>
 /// <param name="value">Value.</param>
 public ConfigFileValueSetMessage (Value value)
 {
     Value = value;
 }