Ejemplo n.º 1
0
        public static RunTimeConfig ReadRunTimeConfig(string runTimePath, string publicKey)
        {
            RunTimeConfig rtc = new RunTimeConfig();

            try
            {
                var          fi      = new FileInfo(runTimePath);
                StreamReader sr      = fi.OpenText();
                string       content = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(publicKey))
                {
                    content = EncrypterHelper.DecryptRASString(content, publicKey);
                }
                string[] temps = content.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                sr.Close();
                string group = "";
                foreach (string str in temps)
                {
                    if (str.Contains("[") && str.Contains("]"))
                    {
                        group = str.Replace("[", "").Replace("]", "");
                        continue;
                    }
                    int index = str.IndexOf('=');
                    if (index >= 1)
                    {
                        try
                        {
                            string key   = str.Substring(0, index);
                            string value = str.Substring(index + 1, str.Length - index - 1).Trim();
                            if (group.ToLower().Equals(group.ToLower()))
                            {
                                switch (key.ToLower())
                                {
                                case FramePluginKey:
                                    rtc.FramePluginKey = value;
                                    break;

                                case FunctionPluginKey:
                                    rtc.FunctionPluginKey = value;
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Error(ex);
                            Environment.Exit(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(rtc);
        }
Ejemplo n.º 2
0
        public void Init()
        {
            rtc = IniConfigHelper.ReadRunTimeConfig(RunTimeConfigPath, PublicKey);
            DataTable dt = new DataTable();

            if (File.Exists(pluginsPath))
            {
                dt.ReadXml(pluginsPath);
            }
            LoadDefault(_pluginSign);
            foreach (DataRow dr in dt.Rows)
            {
                int  pluginKey = (int)dr["PluginKey"];
                bool enable    = (bool)dr["Enabled"];
                var  p         = GetPlugin(pluginKey);
                if (p != null)
                {
                    p.Enabled = enable;
                }
            }
        }