Exemple #1
0
        public static T GetAny <T>()
            where T : IConfigApplication
        {
            T    result  = default(T);
            Type typeOfT = typeof(T);

            try
            {
                result = Get <T>();
                if (result == null)
                {
                    foreach (var instance in _instances)
                    {
                        IConfigApplication value = instance.Value;
                        if (value != null)
                        {
                            var found = (from i in value.GetType().GetInterfaces()
                                         where i.FullName.IgnoreCaseCompare(typeOfT.FullName)
                                         select i).FirstOrDefault();
                            if (found != null)
                            {
                                result = (T)value;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogExceptionAdapter.WriteException(ex);
            }

            return(result);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args == null || args.Length < 1)
            {
                Console.WriteLine("Invalid arguments passed.");
                return;
            }
            string getEnv = string.Empty;

            getEnv = Environment.GetEnvironmentVariable("BMCConfigPath", EnvironmentVariableTarget.Machine);
            Console.WriteLine("getEnv :" + getEnv);

            if (string.IsNullOrWhiteSpace(getEnv))
            {
                getEnv = Path.GetFullPath(Path.Combine(Extensions.GetStartupDirectory(), ".."));
                Environment.SetEnvironmentVariable("BMCConfigPath", getEnv, EnvironmentVariableTarget.Machine);
            }

            IConfigApplication app = null;

            switch (args[0].ToLower())
            {
            case "exchangeserver":
                app = ConfigApplicationFactory.Get <IConfig_ExchangeServer>();
                break;

            case "exchangeclient":
                app = ConfigApplicationFactory.Get <IConfig_ExchangeClient>();
                break;

            case "enterpriseserver":
                app = ConfigApplicationFactory.Get <IConfig_EnterpriseServer>();
                break;

            case "enterpriseclient":
                app = ConfigApplicationFactory.Get <IConfig_EnterpriseClient>();
                break;

            default:
                break;
            }

            if (app == null)
            {
                Console.WriteLine("Invalid arguments passed.");
                return;
            }

            if (args.Length > 1 && args[1].ToLower() == "u")
            {
                app.RemoveValues();
            }
            else
            {
                app.InitializeToDefaultValues();
            }
            app.Save();
            Console.WriteLine("Configuration saved successfully.");
        }
Exemple #3
0
        public static IConfigApplication Get(string typeOfT)
        {
            IConfigApplication result = null;

            lock (_lock)
            {
                if (_instances.ContainsKey(typeOfT))
                {
                    result = _instances[typeOfT];
                }
                else if (_instanceFuncs.ContainsKey(typeOfT))
                {
                    result = _instanceFuncs[typeOfT](_configProvider, true);
                    _instances.Add(typeOfT, result);
                }
            }

            return(result);
        }
        private void cboInstallationTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            ModuleProc PROC = new ModuleProc("", "cboInstallationTypes_SelectedIndexChanged");

            try
            {
                ComboBoxItem<string> cbItem = cboInstallationTypes.SelectedItem as ComboBoxItem<string>;
                _config = ConfigApplicationFactory.Get(cbItem.Value);
                ConfigKeyValuePairTopDictionary keyValues = _config.KeyValues;
                _classRoot = null;
                _selectedClass = null;
                tvwSections.Nodes.Clear();

                // find the class hierarchy
                char[] dirChars = new char[] { '\\' };
                RegClassNames classNames = new RegClassNames();
                RegClassName classParent = null;
                foreach (var pair1 in keyValues)
                {
                    string[] values = pair1.Key.Split(dirChars);
                    foreach (string value in values)
                    {
                        if (!classNames.ContainsKey(value))
                        {
                            RegClassName child = new RegClassName(value);
                            child.RefKeyName = pair1.Key;

                            TreeNode node = new TreeNode(child.ClassName, 2, 2);
                            child.Node = node;
                            node.Tag = child;

                            if (classParent != null)
                            {
                                classParent.Children.Add(child);
                            }
                            classNames.Add(value, child);

                            if (classParent == null)
                            {
                                _classRoot = child;
                                tvwSections.Nodes.Add(node);
                            }
                            else
                            {
                                classParent.Node.Nodes.Add(node);
                                classParent = child;
                            }
                        }
                        else
                        {
                            classParent = classNames[value];
                        }
                    }
                }

                if (tvwSections.Nodes.Count > 0)
                {
                    tvwSections.Nodes[0].ExpandAll();
                    tvwSections.SelectedNode = tvwSections.Nodes[0];
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }
Exemple #5
0
        private void cboInstallationTypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            ModuleProc PROC = new ModuleProc("", "cboInstallationTypes_SelectedIndexChanged");

            try
            {
                ComboBoxItem <string> cbItem = cboInstallationTypes.SelectedItem as ComboBoxItem <string>;
                _config = ConfigApplicationFactory.Get(cbItem.Value);
                ConfigKeyValuePairTopDictionary keyValues = _config.KeyValues;
                _classRoot     = null;
                _selectedClass = null;
                tvwSections.Nodes.Clear();

                // find the class hierarchy
                char[]        dirChars    = new char[] { '\\' };
                RegClassNames classNames  = new RegClassNames();
                RegClassName  classParent = null;
                foreach (var pair1 in keyValues)
                {
                    string[] values = pair1.Key.Split(dirChars);
                    foreach (string value in values)
                    {
                        if (!classNames.ContainsKey(value))
                        {
                            RegClassName child = new RegClassName(value);
                            child.RefKeyName = pair1.Key;

                            TreeNode node = new TreeNode(child.ClassName, 2, 2);
                            child.Node = node;
                            node.Tag   = child;

                            if (classParent != null)
                            {
                                classParent.Children.Add(child);
                            }
                            classNames.Add(value, child);

                            if (classParent == null)
                            {
                                _classRoot = child;
                                tvwSections.Nodes.Add(node);
                            }
                            else
                            {
                                classParent.Node.Nodes.Add(node);
                                classParent = child;
                            }
                        }
                        else
                        {
                            classParent = classNames[value];
                        }
                    }
                }

                if (tvwSections.Nodes.Count > 0)
                {
                    tvwSections.Nodes[0].ExpandAll();
                    tvwSections.SelectedNode = tvwSections.Nodes[0];
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
        }