• Parameter Config


    public class ConfigInfo
        {
            public static ScriptsHelper Scripts
            {
                get { return new ScriptsHelper(); }
            }
            public static ParametersHelper Parameters
            {
                get { return new ParametersHelper(); }
            }
        }
    
        public class ScriptsHelper
        {
            string fileName = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, @"ConfigsScripts.xml");
            public PerScript this[string name]
            {
                get
                {
                    string value = Tools.ExecuteXPathInFile(fileName, string.Format(@"/Scripts/Script[@name='{0}']/text()", name.Trim()));
                    string connection = Tools.ExecuteXPathInFile(fileName, string.Format(@"/Scripts/Script[@name='{0}']/@connectionName", name.Trim()));
                    PerScript script = new PerScript(value, connection);
                    return script;
                }
            }
    
            public class PerScript
            {
                public PerScript(string value, string connection)
                {
                    m_Value = value;
                    m_Connection = connection;
                }
    
                string m_Value;
                public string Value { get { return m_Value; } }
    
                string m_Connection;
                public string Connection { get { return m_Connection; } }
            }
        }
    
        public class ParametersHelper
        {
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, JobConstValue.SERVICE_PARAMETER_FILE);
            public PerKeyValue this[string name]
            {
                get
                {
                    string keyValueStr = Tools.ExecuteXPathInFile(fileName, string.Format(@"/KeyValues/KeyValue[@name='{0}']", name.Trim()));
                    if (keyValueStr != null)
                    {
                        PerKeyValue returnObj = new PerKeyValue(name, keyValueStr);
                        return returnObj;
                    }
                    else
                    {
                        return null;
                    }
                }
            }
    
            public class PerKeyValue
            {
                public PerKeyValue(string name, string keyValueStr)
                {
                    m_KeyValueStr = keyValueStr;
                    m_Name = name;
                    m_Value = Tools.ExecuteXPathInString(keyValueStr, @"/KeyValue/text()");
                }
    
                string m_KeyValueStr;
    
                private string m_Name;
                public string Name { get { return m_Name; } }
    
                public PerKeyValueAttributes Attributes
                {
                    get
                    {
                        string[] temp = m_KeyValueStr.GetSubString(@"(?<=<KeyValues+).+.(?=/?>)");
                        if (temp != null && temp.Length > 0)
                            return new PerKeyValueAttributes(temp[0]);
                        else
                            return null;
                    }
                }
    
                string m_Value;
                public string Value { get { return m_Value; } }
    
                public List<PerKeyValue> KeyValus
                {
                    get
                    {
                        List<PerKeyValue> list = null;
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(m_KeyValueStr);
                        XmlNodeList nodes = doc.SelectNodes("/KeyValue/KeyValue");
                        if (nodes != null && nodes.Count > 0)
                        {
                            list = new List<PerKeyValue>();
                            foreach (XmlNode item in nodes)
                            {
                                list.Add(new PerKeyValue(item.Attributes["name"].InnerText, item.OuterXml));
                            }
                        }
                        return list;
                    }
                }
    
                public PerKeyValue this[string name]
                {
                    get
                    {
                        string keyValueStr = Tools.ExecuteXPathInString(m_KeyValueStr, string.Format(@"/KeyValue/KeyValue[@name='{0}']", name.Trim()));
                        if (keyValueStr != null)
                            return new PerKeyValue(name, keyValueStr);
                        else
                            return null;
                    }
                }
            }
    
            public class PerKeyValueAttributes
            {
                public PerKeyValueAttributes(string attributes)
                {
                    m_Attributes = attributes;
                }
    
                string m_Attributes = string.Empty;
    
                public string this[string name]
                {
                    get
                    {
                        string[] results = m_Attributes.GetSubString(string.Format(@"(?<={0}s*="").+", name));
                        if (results != null && results.Length > 0)
                        {
                            return results[0].ReplaceString(@""".*", string.Empty);
                        }
                        else
                            return null;
                    }
                }
            }
        }
  • 相关阅读:
    wtk2.1的问题
    扫雷大体完成了
    手机操作系统龟兔赛跑 Symbian深信将打败微软
    Practical UML™ A HandsOn Introduction for Developers
    有意思
    进展
    扫雷完成了:)
    Linux
    有关msn的api的两个网站
    csdn中讨论j2me之前途....
  • 原文地址:https://www.cnblogs.com/Wolfmanlq/p/4183412.html
Copyright © 2020-2023  润新知