コード例 #1
0
        private static LangProperties GetLangProperties(string path, LangType lang)
        {
            LangProperties properties = null;
            int            length     = path.LastIndexOf('.');

            if (length != -1)
            {
                Dictionary <string, Dictionary <string, LangProperties> > dictionary;
                Dictionary <string, LangProperties> dictionary2;
                string moduleName = path.Substring(0, length);
                string key        = path.Remove(0, length + 1);
                string str3       = ResourceInfo(moduleName, Thread.CurrentThread.CurrentCulture.Name);
                LoadResources();
                if ((m_Resources.TryGetValue(str3, out dictionary) && dictionary.TryGetValue(lang.ToString(), out dictionary2)) && !dictionary2.TryGetValue(key, out properties))
                {
                    LangProperties properties2 = null;
                    if (dictionary2.TryGetValue(m_inheritName, out properties2))
                    {
                        key = properties2.GetItem(PropertyType.Inherit, key);
                        if (key.Length != 0)
                        {
                            dictionary2.TryGetValue(key, out properties);
                        }
                    }
                }
            }
            return(properties);
        }
コード例 #2
0
 private static void AddProperties(string resInfo, LangType lang, PropertyType[] attribs, XmlNodeList xNodes)
 {
     foreach (XmlNode node in xNodes)
     {
         string name = node.Attributes["name"].Value;
         if (name.Length != 0)
         {
             LangProperties lp = null;
             if (!FindResource(resInfo, lang, name, ref lp))
             {
                 lp = new LangProperties();
             }
             AddInheritances(resInfo, lang, name, node);
             foreach (XmlNode node2 in node.SelectNodes("Property"))
             {
                 string str2 = node2.Attributes["name"].Value;
                 if (str2.Length != 0)
                 {
                     foreach (PropertyType type in attribs)
                     {
                         XmlNode namedItem = node2.Attributes.GetNamedItem(type.ToString().ToLower());
                         if (namedItem != null)
                         {
                             lp.AddItem(type, str2, namedItem.Value);
                         }
                     }
                 }
             }
             AddResource(resInfo, lang, name, lp);
         }
     }
 }
コード例 #3
0
        private static bool FindResource(string resInfo, LangType lang, string name, ref LangProperties lp)
        {
            Dictionary <string, Dictionary <string, LangProperties> > dictionary;
            Dictionary <string, LangProperties> dictionary2;

            return((m_Resources.TryGetValue(resInfo, out dictionary) && dictionary.TryGetValue(lang.ToString(), out dictionary2)) && dictionary2.TryGetValue(name, out lp));
        }
コード例 #4
0
        private static void AddResource(string resInfo, LangType lang, string name, LangProperties lp)
        {
            Dictionary <string, Dictionary <string, LangProperties> > dictionary;
            Dictionary <string, LangProperties> dictionary2;
            LangProperties properties = null;

            if (m_Resources.TryGetValue(resInfo, out dictionary))
            {
                if (dictionary.TryGetValue(lang.ToString(), out dictionary2))
                {
                    if (dictionary2.TryGetValue(name, out properties))
                    {
                        dictionary2[name] = lp;
                    }
                    else
                    {
                        dictionary2.Add(name, lp);
                    }
                }
                else
                {
                    dictionary2 = new Dictionary <string, LangProperties>();
                    dictionary2.Add(name, lp);
                    dictionary.Add(lang.ToString(), dictionary2);
                }
            }
            else
            {
                dictionary2 = new Dictionary <string, LangProperties>();
                dictionary2.Add(name, lp);
                dictionary = new Dictionary <string, Dictionary <string, LangProperties> >();
                dictionary.Add(lang.ToString(), dictionary2);
                m_Resources.Add(resInfo, dictionary);
            }
        }
コード例 #5
0
        public static string GetText(string path, string name)
        {
            LangProperties langProperties = GetLangProperties(path, LangType.Class);

            if (langProperties == null)
            {
                return(string.Empty);
            }
            return(langProperties.GetItem(PropertyType.Caption, name));
        }
コード例 #6
0
        public static Dictionary <string, string> GetEnumList(string path)
        {
            LangProperties langProperties = GetLangProperties(path, LangType.Enum);

            if (langProperties == null)
            {
                return(null);
            }
            return(langProperties.GetItems(PropertyType.Caption));
        }
コード例 #7
0
        public static string GetActionDescription(string path, string name)
        {
            LangProperties langProperties = GetLangProperties(path, LangType.Action);

            if (langProperties == null)
            {
                return(string.Empty);
            }
            return(langProperties.GetItem(PropertyType.Description, name));
        }
コード例 #8
0
        public static string GetText(PropertyDescriptor pd)
        {
            string className = string.Empty;
            string propName  = string.Empty;

            if (!TryFindResourcePath(pd, ref className, ref propName))
            {
                return(string.Empty);
            }
            LangProperties langProperties = GetLangProperties(className, LangType.Class);

            if (langProperties == null)
            {
                return(string.Empty);
            }
            return(langProperties.GetItem(PropertyType.Caption, propName));
        }
コード例 #9
0
        public static Dictionary <string, string> GetEnumList(PropertyDescriptor pd)
        {
            string className = string.Empty;
            string propName  = string.Empty;

            if (!TryFindResourcePath(pd, ref className, ref propName))
            {
                return(null);
            }
            LangProperties langProperties = GetLangProperties(className, LangType.Enum);

            if (langProperties == null)
            {
                return(null);
            }
            return(langProperties.GetItems(PropertyType.Caption));
        }
コード例 #10
0
        public static void AddClassCaption(string path, string name, string lang, string value)
        {
            int length = path.LastIndexOf('.');

            if (length != -1)
            {
                string         moduleName = path.Substring(0, length);
                string         str2       = path.Remove(0, length + 1);
                string         resInfo    = ResourceInfo(moduleName, lang);
                LangProperties lp         = null;
                if (!FindResource(resInfo, LangType.Class, str2, ref lp))
                {
                    lp = new LangProperties();
                }
                lp.AddItem(PropertyType.Caption, name, value);
                AddResource(resInfo, LangType.Class, str2, lp);
            }
        }
コード例 #11
0
        public static string GetEnumText(FieldInfo fi)
        {
            string enumName  = string.Empty;
            string valueName = string.Empty;

            if (!IsActive)
            {
                return(valueName);
            }
            if (!TryFindResourcePath(fi, ref enumName, ref valueName))
            {
                return(string.Empty);
            }
            LangProperties langProperties = GetLangProperties(enumName, LangType.Enum);

            if (langProperties == null)
            {
                return(string.Empty);
            }
            return(langProperties.GetItem(PropertyType.Caption, valueName));
        }
コード例 #12
0
        private static void AddInheritances(string resInfo, LangType lang, string name, XmlNode xNodeParent)
        {
            XmlNode node = xNodeParent.SelectSingleNode("Inheritances");

            if ((node != null) && (node.ChildNodes.Count != 0))
            {
                LangProperties lp = null;
                if (!FindResource(resInfo, lang, m_inheritName, ref lp))
                {
                    lp = new LangProperties();
                }
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    string str = node2.Attributes["name"].Value;
                    if (str.Length != 0)
                    {
                        lp.AddItem(PropertyType.Inherit, str, name);
                    }
                }
                AddResource(resInfo, lang, m_inheritName, lp);
            }
        }
コード例 #13
0
        // Methods
        public static void AddClassCaption(PropertyDescriptor pd, string lang, string value)
        {
            string className = string.Empty;
            string propName  = string.Empty;

            if (TryFindResourcePath(pd, ref className, ref propName))
            {
                int length = className.LastIndexOf('.');
                if (length != -1)
                {
                    string         moduleName = className.Substring(0, length);
                    string         name       = className.Remove(0, length + 1);
                    string         resInfo    = ResourceInfo(moduleName, lang);
                    LangProperties lp         = null;
                    if (!FindResource(resInfo, LangType.Class, name, ref lp))
                    {
                        lp = new LangProperties();
                    }
                    lp.AddItem(PropertyType.Caption, propName, value);
                    AddResource(resInfo, LangType.Class, name, lp);
                }
            }
        }