示例#1
0
 protected ConfigBase Instantiate(ConfigBaseMetadata metadata, PluginRuntime pluginRuntime)
 {
   ServiceRegistration.Get<ILogger>().Debug("ConfigurationNode: Loading configuration item '{0}'", metadata.Location);
   ConfigBase result;
   if (metadata.GetType() == typeof(ConfigGroupMetadata))
     result = new ConfigGroup();
   else if (metadata.GetType() == typeof(ConfigSectionMetadata))
     result = new ConfigSection();
   else if (metadata.GetType() == typeof(ConfigSettingMetadata))
   {
     ConfigSettingMetadata csm = (ConfigSettingMetadata) metadata;
     try
     {
       ConfigSetting cs = (ConfigSetting) pluginRuntime.InstantiatePluginObject(csm.ClassName);
       if (cs == null)
         throw new ArgumentException(string.Format("Configuration class '{0}' not found", csm.ClassName));
       cs.Load();
       if (csm.ListenTo != null)
         foreach (string listenToLocation in csm.ListenTo)
         {
           IConfigurationNode node;
           if (FindNode(listenToLocation, out node))
             if (node.ConfigObj is ConfigSetting)
               cs.ListenTo((ConfigSetting) node.ConfigObj);
             else
               ServiceRegistration.Get<ILogger>().Warn("ConfigurationNode '{0}': Trying to listen to setting, but location '{1}' references a {2}",
                                                Location, listenToLocation, node.ConfigObj.GetType().Name);
         }
       result = cs;
     }
     catch (Exception ex)
     {
       ServiceRegistration.Get<ILogger>().Error("Error loading configuration class '{0}'", ex, csm.ClassName);
       return null;
     }
   }
   else
     throw new NotImplementedException(string.Format("Unknown child class '{0}' of '{1}'", metadata.GetType().FullName, typeof(ConfigBaseMetadata).FullName));
   result.SetMetadata(metadata);
   return result;
 }
示例#2
0
 public override void SetMetadata(ConfigBaseMetadata metadata)
 {
   base.SetMetadata(metadata);
   _metadata = metadata;
   _help = LocalizationHelper.CreateResourceString(SettingMetadata.HelpText);
 }
示例#3
0
 public virtual void SetMetadata(ConfigBaseMetadata metadata)
 {
     _metadata = metadata;
     _text     = LocalizationHelper.CreateResourceString(_metadata.Text);
 }
示例#4
0
 public override void SetMetadata(ConfigBaseMetadata metadata)
 {
     base.SetMetadata(metadata);
     _metadata = metadata;
     _help     = LocalizationHelper.CreateResourceString(SettingMetadata.HelpText);
 }
示例#5
0
 public virtual void SetMetadata(ConfigBaseMetadata metadata)
 {
   _metadata = metadata;
   _text = LocalizationHelper.CreateResourceString(_metadata.Text);
 }