예제 #1
0
        /// <summary>
        /// Constructs the values.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns></returns>
        private NameValueCollection ConstructValues(IConfigContainer container)
        {
            var values = new NameValueCollection();
            var xNodes = container.Node.GetNodes(_sectionXPath);

            if (xNodes == null)
            {
                return(values);
            }

            foreach (XmlNode xNode in xNodes)
            {
                var xKey   = xNode.Attributes["key"];
                var xValue = xNode.Attributes["value"];
                if (xKey == null || xValue == null)
                {
                    continue;
                }

                var xSecure = xNode.Attributes["secure"];
                var secure  = EncryptionProvider != null && xSecure != null && xSecure.Value.ToLower() == "true";

                values[xKey.Value] = secure ? EncryptionProvider.DecryptString(xValue.Value, Encoding.UTF8) : xValue.Value;
            }

            return(values);
        }
예제 #2
0
        /// <summary>
        /// Adds the variables.
        /// </summary>
        /// <param name="configContainer">The configuration container.</param>
        /// <param name="bForceRefresh">if set to <c>true</c> [b force refresh].</param>
        public void AddVariables(IConfigContainer configContainer, bool bForceRefresh = true)
        {
            _variablesLock.EnterWriteLock();
            try
            {
                var container = FindContainer(configContainer);
                if (container == null)
                {
                    var variables = ConstructValues(configContainer);

                    container = new VariableContainer()
                    {
                        ReferenceCount = 0, Variables = variables
                    };
                    _variables.Add(configContainer, container);

                    configContainer.OnConfigChange += DoOnConfigContainerChange;
                }

                container.ReferenceCount++;

                if (bForceRefresh)
                {
                    ConfigManager.Refresh();
                }
            }
            finally
            {
                _variablesLock.ExitWriteLock();
            }
        }
예제 #3
0
 public FileLogWriter(IConfigContainer <IFileConfig> fileConfigContainer, IFileAnalyzer fileAnalyzer,
                      ILogMessageCreator logMessageCreator)
 {
     _fileConfigContainer = fileConfigContainer;
     _fileAnalyzer        = fileAnalyzer;
     _logMessageCreator   = logMessageCreator;
 }
예제 #4
0
 /// <summary>
 /// Does the on configuration container loaded.
 /// </summary>
 /// <param name="configContainer">The configuration container.</param>
 private static void DoOnConfigContainerLoaded(IConfigContainer configContainer)
 {
     if (OnConfigContainerLoaded != null)
     {
         OnConfigContainerLoaded(configContainer);
     }
 }
예제 #5
0
        /// <summary>
        /// Removes the variables.
        /// </summary>
        /// <param name="configContainer">The configuration container.</param>
        /// <param name="bForceRefresh">if set to <c>true</c> [b force refresh].</param>
        public void RemoveVariables(IConfigContainer configContainer, bool bForceRefresh = true)
        {
            _variablesLock.EnterWriteLock();
            try
            {
                var container = FindContainer(configContainer);
                if (container == null)
                {
                    return;
                }

                container.ReferenceCount--;
                if (container.ReferenceCount > 0)
                {
                    return;
                }

                configContainer.OnConfigChange -= DoOnConfigContainerChange;
                _variables.Remove(configContainer);
            }
            finally
            {
                _variablesLock.ExitWriteLock();
            }

            if (bForceRefresh)
            {
                ConfigManager.Refresh();
            }
        }
예제 #6
0
 /// <summary>
 /// Does the configuration file changed.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="changeType">Type of the change.</param>
 private static void DoConfigFileChanged(IConfigContainer configuration, OnChangeType changeType)
 {
     if (OnConfigChange != null)
     {
         OnConfigChange();
     }
 }
예제 #7
0
 /// <summary>
 /// Does the on configuration container change.
 /// </summary>
 /// <param name="configContainer">The configuration container.</param>
 /// <param name="cType">Type of the c.</param>
 private static void DoOnConfigContainerChange(IConfigContainer configContainer, OnChangeType cType)
 {
     if (OnConfigContainerChange != null)
     {
         OnConfigContainerChange(configContainer, cType);
     }
 }
예제 #8
0
        /// <summary>
        /// Removes the specified container.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="bDispose">if set to <c>true</c> [b dispose].</param>
        internal static void Remove(IConfigContainer container, bool bDispose)
        {
            lock (_congurations)
            {
                foreach (var node in _congurations.Values)
                {
                    if (ReferenceEquals(node.ConfigContainer, container))
                    {
                        node.ReferenceCount--;
                        if (node.ReferenceCount == 0)
                        {
                            DoOnConfigContainerUnloaded(container);

                            _congurations.Remove(node.FileKey);
                            container.OnConfigChange -= DoOnConfigContainerChange;

                            if (bDispose)
                            {
                                (container as IDisposable).Dispose();
                            }
                        }

                        break;
                    }
                }
            }
        }
예제 #9
0
 /// <summary>
 /// Prepare the user module for use. Attempt to
 /// pull in the login config.
 /// </summary>
 public override void OnStart()
 {
     if (Engine.Type == GameEngineType.Client)
     {
         IConfigContainer configContainer = GetModule <ConfigModule>();
         LoginConfig = configContainer.GetConfig <LoginConfig>();
     }
 }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProviderClassFactory"/> class.
        /// </summary>
        /// <param name="configContainer">The configuration container.</param>
        /// <param name="configSection">The configuration section.</param>
        /// <param name="attributeNodeName">Name of the attribute node.</param>
        public ProviderClassFactory(IConfigContainer configContainer, string configSection, string attributeNodeName = "provider")
        {
            Disposed           = false;
            _configContainer   = configContainer;
            _configSection     = configSection;
            _attributeNodeName = attributeNodeName;
            _configContainer.OnConfigChange += OnConfigChange;

            (this as IProviderClassFactoryExtension).RefreshAttributes();
        }
예제 #11
0
        /// <summary>
        /// When the module is first started see if
        /// we can find our menu container in the scene.
        /// </summary>
        public override void OnInit()
        {
            menuContainer   = GameObject.FindGameObjectWithTag(MenuContainerTag)?.transform;
            commandConsole  = GetModule <CommandConsoleModule>();
            configContainer = GetModule <ConfigModule>();

            if (menuContainer == null)
            {
                throw new FormatException("Scene is poorly formatted. No menu container found.");
            }
        }
예제 #12
0
        internal PluginConfigAccessor(INamedVersionedUniqueId idEdited, IConfigManagerExtended cfg, object contextObject)
        {
            Debug.Assert(cfg != null);

            _idEdited        = idEdited;
            _configContainer = cfg.Container;

            _system  = _configContainer.GetObjectPluginConfig(cfg.ConfigManager.SystemConfiguration, _idEdited);
            _user    = _configContainer.GetObjectPluginConfig(cfg.ConfigManager.UserConfiguration, _idEdited);
            _context = _configContainer.GetObjectPluginConfig(contextObject, _idEdited);
        }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionManager"/> class.
        /// </summary>
        /// <param name="configContainer">The configuration container.</param>
        /// <param name="configSection">The configuration section.</param>
        public ExceptionManager(IConfigContainer configContainer, string configSection)
        {
            Disposed                         = false;
            _unhandledExceptions             = new List <UnhandledExceptionInfo>();
            _publishers                      = new List <PublisherInfo>();
            _eventTracking                   = new TimeSpan();
            _configSection                   = configSection;
            _configContainer                 = configContainer;
            _configContainer.OnConfigChange += OnConfigChange;

            LoadPublishers();
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigMultiSettings"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="parentXPath">The parent x path.</param>
        public ConfigMultiSettings(IConfigContainer container, string parentXPath)
        {
            _emptySettings = new NameValueCollection();
            _settings      = new Dictionary <string, NameValueCollection>();

            NodeChildAttributes nca = ConfigHelper.GetNodeChildAttributes(container, parentXPath);

            foreach (var attributes in nca.ChildAttributes)
            {
                if (attributes.Attributes.Count > 0)
                {
                    string key = attributes.Attributes[0];
                    _settings[key] = attributes.Attributes;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SectionContentContainer"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="bDetectChange">if set to <c>true</c> [b detect change].</param>
        public SectionContentContainer(string path, bool bDetectChange = false)
        {
            Disposed      = false;
            _sections     = new Dictionary <string, Dictionary <string, string> >();
            _sectionsLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            _config = ConfigManager.GetConfiguration(path, "./configuration");

            if (bDetectChange)
            {
                _config.WatchAllowOnChangeAttribute(".", "reactOnConfigChange", "true");
                _config.OnConfigChange += OnConfigChange;
            }

            ReadSections();
        }
예제 #16
0
        /// <summary>
        /// Does the on configuration container change.
        /// </summary>
        /// <param name="configContainer">The configuration container.</param>
        /// <param name="cType">Type of the c.</param>
        private void DoOnConfigContainerChange(IConfigContainer configContainer, OnChangeType cType)
        {
            if (cType == OnChangeType.Refresh)
            {
                return;
            }

            _variablesLock.EnterReadLock();
            try
            {
                var container = _variables[configContainer];
                container.Variables = ConstructValues(configContainer);
            }
            finally
            {
                _variablesLock.ExitReadLock();
            }

            ConfigManager.Refresh();
        }
        protected virtual void Dispose(bool bDisposing)
        {
            lock (this)
            {
                if (!Disposed)
                {
                    Disposed = true;
                    GC.SuppressFinalize(this);

                    if (bDisposing)
                    {
                        if (_config != null)
                        {
                            _config.OnConfigChange -= OnConfigChange;
                            ConfigManager.Remove(_config);
                            _config = null;
                        }

                        _sectionsLock?.Dispose();
                    }
                }
            }
        }
예제 #18
0
        /// <summary>
        /// Constructs the values.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns></returns>
        private NameValueCollection ConstructValues(IConfigContainer container)
        {
            var values = new NameValueCollection();
            var xNodes = container.Node.GetNodes(_sectionXPath);

            if (xNodes == null)
            {
                return(values);
            }

            foreach (XmlNode xNode in xNodes)
            {
                var xKey   = xNode.Attributes["key"];
                var xValue = xNode.Attributes["value"];
                if (xKey == null || xValue == null)
                {
                    continue;
                }

                values[xKey.Value] = xValue.Value;
            }

            return(values);
        }
예제 #19
0
 /// <summary>
 /// Detaches from manager.
 /// </summary>
 /// <param name="container">The container.</param>
 public static void DetatchFromManager(this IConfigContainer container)
 {
     ConfigManager.Remove(container, false);
 }
예제 #20
0
 /// <summary>
 /// Create a new instance of the server menu presenter. This should
 /// only be called by the UI module itself.
 /// </summary>
 /// <param name="uIModule">The parent UI module.</param>
 /// <param name="commandConsole">The command console of the engine.</param>
 /// <param name="configContainer">The config container.</param>
 public ServerMenuPresenter(IMenuManager uIModule, ICommandConsole commandConsole, IConfigContainer configContainer) : base(uIModule, commandConsole, configContainer)
 {
 }
 /// <summary>
 /// Called when [configuration change].
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="cType">Type of the c.</param>
 private void OnConfigChange(IConfigContainer container, OnChangeType cType)
 {
     ReadSections();
 }
예제 #22
0
 /// <summary>
 /// Gets (creates it if needed) an easy to use <see cref="IObjectPluginConfig"/> that acts as a standard name-value dictionary.
 /// </summary>
 /// <param name="c">This <see cref="IConfigContainer"/> object.</param>
 /// <param name="o">Object that carries the properties.</param>
 /// <param name="p">Plugin identifier.</param>
 /// <returns>>An easy accessor for the object/plugin couple.</returns>
 public static IObjectPluginConfig GetObjectPluginConfig(this IConfigContainer c, object o, INamedVersionedUniqueId p)
 {
     return(c.GetObjectPluginConfig(o, p, true));
 }
예제 #23
0
 /// <summary>
 /// Called when [configuration change].
 /// </summary>
 /// <param name="configContainer">The configuration container.</param>
 /// <param name="cType">Type of the c.</param>
 private void OnConfigChange(IConfigContainer configContainer, OnChangeType cType)
 {
     (this as IProviderClassFactoryExtension).RefreshAttributes();
 }
예제 #24
0
 public AzureLogWriter(IAzureService azureService, IConfigContainer <IFileConfig> fileConfigContainer)
 {
     _azureService        = azureService;
     _fileConfigContainer = fileConfigContainer;
 }
예제 #25
0
 /// <summary>
 /// Removes the specified container.
 /// </summary>
 /// <param name="container">The container.</param>
 public static void Remove(IConfigContainer container)
 {
     Remove(container, true);
 }
예제 #26
0
 public AzureService(IConfigContainer <IAzureConfig> azureConfigContainer)
 {
     _azureConfigContainer = azureConfigContainer;
 }
예제 #27
0
 /// <summary>
 /// Gets the node child attributes.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="parentXPath">The parent x path.</param>
 /// <returns></returns>
 public static NodeChildAttributes GetNodeChildAttributes(IConfigContainer container, string parentXPath)
 {
     return(GetNodeChildAttributes(container.Node, parentXPath));
 }
예제 #28
0
 /// <summary>
 /// Called when [configuration change].
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="cType">Type of the c.</param>
 protected void OnConfigChange(IConfigContainer container, OnChangeType cType)
 {
     LoadPublishers();
 }
예제 #29
0
 /// <summary>
 /// Create a new instance of the main menu presenter. This should
 /// only be called by the UI Module itself.
 /// </summary>
 /// <param name="uiModule">The parent UI module.</param>
 /// <param name="commandConsole">The command console of the engine</param>
 /// <param name="configContainer">The config container.</param>
 public MainMenuPresenter(IMenuManager uiModule, ICommandConsole commandConsole, IConfigContainer configContainer) : base(uiModule, commandConsole, configContainer)
 {
 }
예제 #30
0
 /// <summary>
 /// Finds the container.
 /// </summary>
 /// <param name="configContainer">The configuration container.</param>
 /// <returns></returns>
 private VariableContainer FindContainer(IConfigContainer configContainer)
 {
     return(_variables.ContainsKey(configContainer) ? _variables[configContainer] : null);
 }