Esempio n. 1
0
        private void FormatAllSQLQueries(Column availableAttributes)
        {
            try
            {
                Assembly assembly     = this.GetType().Assembly;
                string   resourceName = (from n in assembly.GetManifestResourceNames()
                                         where n.Contains("SQLQueries")
                                         select n).SingleOrDefault();
                if (string.IsNullOrEmpty(resourceName))
                {
                    return;
                }

                resourceName = resourceName.Substring(0, resourceName.LastIndexOf('.'));
                ResourceManager       resourceManager = new ResourceManager(resourceName, assembly);
                ResourceSet           resources       = resourceManager.GetResourceSet(EyediaCoreConfigurationSection.CurrentConfig.CurrentCulture, true, true);
                IDictionaryEnumerator enumerator      = resources.GetEnumerator();

                Information.SQLQueries = new Dictionary <string, string>();
                string errorMessage = string.Empty;
                while (enumerator.MoveNext())
                {
                    string name  = (string)enumerator.Key;
                    string query = FormatSQLParameters((string)enumerator.Value, string.Empty, availableAttributes, ref errorMessage);
                    Information.SQLQueries.Add(name, query);
                }
            }
            catch { }
        }
Esempio n. 2
0
        private static List <T> MakeApparels()
        {
            Trace.WriteLine("In makeapparels");
            List <T>    apparels       = new List <T>();
            ResourceSet apparelStrings = ApparelNames.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, false);
            ResourceSet stuffStrings   = StuffNames.ResourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, false);

            Trace.WriteLine("Load resources");
            IDictionaryEnumerator apparelEnumerator = apparelStrings.GetEnumerator();

            foreach (DictionaryEntry app in apparelStrings)
            {
                Trace.WriteLine(app.Value as string);
                foreach (DictionaryEntry s in stuffStrings)
                {
                    Trace.WriteLine(s.Value as string);
                    foreach (QualityCategory qc in Enum.GetValues(typeof(QualityCategory)))
                    {
                        Apparel apparel = new Apparel()
                        {
                            def = MakeDef(app.Value as string)
                        };
                        apparel.SetStuffDirect(MakeDef(s.Value as string));
                        Traverse.Create(apparel).Field("comps").SetValue(new List <ThingComp>()).Method("Add", new CompQuality()).GetValue();
                        apparel.TryGetComp <CompQuality>().SetQuality(qc, ArtGenerationContext.Outsider);
                        apparels.Add(apparel as T);
                    }
                }
            }
            return(apparels);
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            ResourceManager rm = new ResourceManager(ConfigurationManager.AppSettings["JSResourcesAssemblyType"].ToString(),
                                                     Assembly.LoadFile(ConfigurationManager.AppSettings["JSResourcesAssemblyPath"].ToString()));

            if (context.Request.QueryString["CultureCode"] == null)
            {
                return;
            }
            var         culture   = context.Request.QueryString["CultureCode"].ToString();
            ResourceSet rs        = rm.GetResourceSet(new CultureInfo(culture), true, true);
            var         sbInitial = "var rm = {";
            var         sb        = new StringBuilder(sbInitial);
            var         resEnum   = rs.GetEnumerator();

            while (resEnum.MoveNext())
            {
                if (sb.ToString() != sbInitial)
                {
                    sb.Append(",");
                }
                sb.Append("\"" + resEnum.Key + "\":\"" +
                          resEnum.Value.ToString().Replace("\r\n", "").Replace("\"", "\\\"") + "\"");
            }

            sb.Append("}");
            sb.ToString();

            context.Response.ContentType = "text/javascript";
            context.Response.Write(sb.ToString());
        }
        /// <summary>
        /// Populates the needed enumeration Dictionaries for translating en-US strings by
        /// transversing the en-US resource file and finding the appropriate EnumSets.
        /// </summary>
        /// <remarks>
        /// This method should be faster than using the enumSets/{id}/members api endpoint.
        /// This method has a potential for value mismatch if the local enumeration values differ
        /// from the server. This will cause the translation functionality to fail since no matching
        /// enumeration key will be found in dictionaries.
        /// </remarks>
        private static void SetEnumerationDictionaries()
        {
            // First time setup, there are about 349 values in the command set, 800 in the objectType set
            CommandEnumerations    = new Dictionary <string, string>();
            ObjectTypeEnumerations = new List <Dictionary <string, string> >();
            var                   ObjectTypeEnumerations1 = new Dictionary <string, string>();
            var                   ObjectTypeEnumerations2 = new Dictionary <string, string>();
            ResourceSet           ResourcesEnUS           = Resource.GetResourceSet(CultureEnUS, true, true);
            IDictionaryEnumerator ide = ResourcesEnUS.GetEnumerator();

            while (ide.MoveNext())
            {
                if (ide.Key.ToString().Contains("commandIdEnumSet."))
                {
                    CommandEnumerations.Add(ide.Value.ToString(), ide.Key.ToString());
                }
                else if (ide.Key.ToString().Contains("objectTypeEnumSet."))
                {
                    try
                    {
                        ObjectTypeEnumerations1.Add(ide.Value.ToString(), ide.Key.ToString());
                    }
                    catch
                    {
                        ObjectTypeEnumerations2.Add(ide.Value.ToString(), ide.Key.ToString());
                    }
                }
            }
            ObjectTypeEnumerations.Add(ObjectTypeEnumerations1);
            ObjectTypeEnumerations.Add(ObjectTypeEnumerations2);
        }
        /// <summary>
        /// Look for a file with a .FormMapping extension in the XAP file. If one isn't found,
        /// return FormMapping.xml just for backwards compatibility reasons.
        /// </summary>
        /// <returns></returns>
        private string FindFormMappingFileName()
        {
            string fileName = "FormMapping.xml"; // Just in case the old style name has been used, for backwards compatibility

            Assembly assembly = Application.Current.GetType().Assembly;

            string[] embeddedResourceNames = assembly.GetManifestResourceNames();

            foreach (var resource in embeddedResourceNames)
            {
                ResourceManager rm = new ResourceManager(resource.Replace(".resources", ""), assembly); // All resources have “.resources” in the name – so we need to get rid of it

                Stream dummy = rm.GetStream("app.xaml");                                                // Seems like some issue here, but without getting any real stream next statement doesn't work....

                ResourceSet rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, false, true);

                IDictionaryEnumerator enumerator = rs.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    string resourceName = (string)enumerator.Key;

                    if (resourceName.EndsWith(".FormMapping", System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        fileName = resourceName;
                        break;
                    }
                }
            }

            return(fileName);
        }
Esempio n. 6
0
        /// THIS METHOD IS JUST FOR MAINTAINENCE PURPOSES
        /// <summary>
        /// Cleans the resources.
        /// </summary>
        public static void CleanResources()
        {
            ResourceSet           resourceSet = controlsResourceManager.GetResourceSet(new CultureInfo("en-US"), true, true);
            IDictionaryEnumerator enumerator  = resourceSet.GetEnumerator();

            NameValueCollection list     = new NameValueCollection();
            ArrayList           keysList = new ArrayList();


            while (enumerator.MoveNext())
            {
                string key = (string)enumerator.Key;
                key = key.Replace(' ', '_').ToLower();
                list.Add(key, (string)enumerator.Value);
                keysList.Add(key);
            }

            string[] array = new string[keysList.Count];
            for (int i = 0; i < keysList.Count; i++)
            {
                array[i] = (string)keysList[i];
            }

            Array.Sort(array);

            StreamWriter writer = File.CreateText("c:\\controls.txt");

            foreach (string s in array)
            {
                writer.WriteLine(s + "=" + list[s]);
            }

            writer.Close();
        }
        /// <summary>
        /// Translates alle the Strings!
        /// </summary>
        public virtual void Translate()
        {
            // Check current UI Culture and see if we already translated this language!
            CultureInfo lCurrentCulture = Thread.CurrentThread.CurrentUICulture;

            if (lCurrentCulture.TwoLetterISOLanguageName == mTranslatedLanguage)
            {
                return; // already translated
            }

            // Reset to original Strings handled by the Factory Method overriden in specialized Classes
            mCustomizer.ResetAllCustomizedStrings();

            // Iterate through all keys and set the translated Text
            ResourceSet rs = this.rm.GetResourceSet(lCurrentCulture, true, true);

            if (rs != null)
            {
                IDictionaryEnumerator dictEnum = rs.GetEnumerator();
                while (dictEnum.MoveNext())
                {
                    string lKey = dictEnum.Key.ToString();
                    if (dictEnum.Value is string)
                    {
                        string lVal = dictEnum.Value.ToString();
                        mCustomizer.SetCustomizedString(lKey, lVal);
                    }

                    // Leave the others untouched
                }
            }
            // Store the current Language as translated
            mTranslatedLanguage = lCurrentCulture.TwoLetterISOLanguageName;
        }
Esempio n. 8
0
        private void CheckCoverage(HashSet <string> obtainedMembers)
        {
            var                   rm         = (ResourceManager)Reflector.GetField(typeof(Res), "resourceManager");
            ResourceSet           rs         = rm.GetResourceSet(CultureInfo.InvariantCulture, true, false);
            IDictionaryEnumerator enumerator = rs.GetEnumerator();
            var                   uncovered  = new List <string>();

            while (enumerator.MoveNext())
            {
                // ReSharper disable once PossibleNullReferenceException
                string key = ((string)enumerator.Key).Replace("_", String.Empty);
                if (key.StartsWith("General", StringComparison.Ordinal))
                {
                    key = key.Substring("General".Length);
                }
                if (obtainedMembers.Contains(key) || !key.EndsWith("Format", StringComparison.Ordinal))
                {
                    continue;
                }
                key = key.Substring(0, key.Length - "Format".Length);
                if (!obtainedMembers.Contains(key))
                {
                    uncovered.Add((string)enumerator.Key);
                }
            }

            Assert.IsTrue(uncovered.Count == 0, $"{uncovered.Count} orphan compiled resources detected:{Environment.NewLine}{String.Join(Environment.NewLine, uncovered.ToArray())}");
        }
Esempio n. 9
0
        public static string TranslateTaggedString(string taggedString)
        {
            string retVal = taggedString;

            if (translate && !string.IsNullOrEmpty(taggedString))
            {
                retVal = taggedString;

                foreach (ResourceManager rm in _resManagers)
                {
                    ResourceSet rs = rm.GetResourceSet(Thread.CurrentThread.CurrentUICulture, true, true);
                    if (rs != null)
                    {
                        IDictionaryEnumerator enu = rs.GetEnumerator();

                        while (enu.MoveNext())
                        {
                            retVal = retVal.Replace(enu.Key as string, enu.Value as string);
                        }
                    }
                }
            }

            return(retVal);
        }
Esempio n. 10
0
        internal static void smethod_0(ResourceManager resourceManager_0)
        {
            ResourceSet set = null;

            try
            {
                set = resourceManager_0.GetResourceSet(CultureInfo.CurrentCulture, true, true);
                IDictionaryEnumerator enumerator = set.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    dictionary_0[enumerator.Key.ToString()] = enumerator.Value;
                }
            }
            catch (Exception exception)
            {
                ilog_0.Error("加载资源文件异常:" + resourceManager_0.BaseName, exception);
            }
            finally
            {
                if (resourceManager_0 != null)
                {
                    resourceManager_0.ReleaseAllResources();
                }
                if (set != null)
                {
                    set.Dispose();
                }
            }
        }
Esempio n. 11
0
        public Dictionary <string, string> GetResourcesByLanguage(CultureInfo cultureInfo,
                                                                  bool includeMissing = false)
        {
            if (cultureInfo == CultureInfo.InvariantCulture)
            {
                throw new ArgumentOutOfRangeException("cultureInfo", "Can not be InvariantCulture");
            }

            if (includeMissing)
            {
                return(GetAllResourcesByLanguage(cultureInfo));
            }

            Dictionary <string, string> resources = new Dictionary <string, string>();
            ResourceSet resourceSet = _resourceManager.GetResourceSet(cultureInfo, true, false);

            IDictionaryEnumerator enumerator = resourceSet.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Entry.Value is string)
                {
                    resources.Add(enumerator.Entry.Key.ToString(), enumerator.Entry.Value.ToString());
                }
            }

            return(resources);
        }
Esempio n. 12
0
        public static void LoadResources(string strCulture)
        {
            try
            {
                System.Reflection.Assembly targetAsmbly = System.Reflection.Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "PACT.Globalization.dll");
                System.Reflection.Assembly satAsmbly    = targetAsmbly.GetSatelliteAssembly(new CultureInfo(strCulture));
                string[] resources = satAsmbly.GetManifestResourceNames();
                string   strName   = "";
                string   strValue  = "";
                UIResources.Clear();
                foreach (string resource in resources)
                {
                    string                baseName        = resource.Substring(0, resource.LastIndexOf('.'));
                    ResourceManager       resourceManager = new ResourceManager(baseName, satAsmbly);
                    ResourceSet           resourceSet     = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
                    IDictionaryEnumerator enumerator      = resourceSet.GetEnumerator();

                    while (enumerator.MoveNext())
                    {
                        strName  = enumerator.Key.ToString();
                        strValue = enumerator.Value.ToString();
                        UIResources.Add(strName, strValue);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 13
0
        public virtual void ApplyResources
            (Object value, String objectName, CultureInfo culture)
        {
            // Validate the parameters.
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (objectName == null)
            {
                throw new ArgumentNullException("objectName");
            }

            // Get the default UI culture if necessary.
            if (culture == null)
            {
                culture = CultureInfo.CurrentUICulture;
            }

            // Read the resources for the specified culture.
            ResourceSet set = GetResourceSet(culture, true, true);

            if (set == null)
            {
                return;
            }

            // Get the properties for the object.
            PropertyDescriptorCollection props;

            props = TypeDescriptor.GetProperties(value);

            // Set the resources for the value.
            IDictionaryEnumerator e = set.GetEnumerator();

            while (e.MoveNext())
            {
                // Check that this key is appropriate to the object.
                String key = (String)(e.Key);
                if (objectName == null || key.StartsWith(objectName))
                {
                    // Remove the object name prefix from the key.
                    if (objectName != null)
                    {
                        key = key.Substring(objectName.Length);
                    }

                    // Find the specified property and set it.
                    PropertyDescriptor prop;
                    prop = props[key];
                    if (prop != null && !prop.IsReadOnly)
                    {
                        prop.SetValue(value, e.Value);
                    }
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Retourne toutes les clés du fichier
        /// </summary>
        /// <returns>toutes les clés du fichier</returns>
        public IEnumerable <string> GetAllKeys()
        {
            var enumerator = _resourceSet.GetEnumerator();

            while (enumerator.MoveNext())
            {
                yield return((string)enumerator.Key);
            }
        }
Esempio n. 15
0
        private IEnumerable <DictionaryEntry> AsEnumerable(ResourceSet rs)
        {
            var dic = rs.GetEnumerator();

            while (dic.MoveNext())
            {
                yield return(dic.Entry);
            }
            yield break;
        }
Esempio n. 16
0
        private static void RegisterDefaultTokens()
        {
            ResourceManager       manager    = new ResourceManager(typeof(StrixIT.Platform.Modules.Cms.Resources.DefaultTokens));
            ResourceSet           resources  = manager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
            IDictionaryEnumerator enumerator = resources.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Tokenizer.RegisterToken(string.Format("[[{0}]]", enumerator.Key.ToString().ToUpper()), (string)enumerator.Value);
            }
        }
Esempio n. 17
0
        public IEnumerator <KeyValuePair <string, string> > GetEnumerator()
        {
            var                   manager    = new ResourceManager(typeof(AppResources));
            ResourceSet           resources  = manager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            IDictionaryEnumerator enumerator = resources.GetEnumerator();

            while (enumerator.MoveNext())
            {
                yield return(new KeyValuePair <string, string>((string)enumerator.Key, (string)enumerator.Value));
            }
        }
Esempio n. 18
0
 private void Form1_Load(object sender, EventArgs e)
 {
     resourceSet = Properties.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
     iDict       = resourceSet.GetEnumerator();
     foreach (DictionaryEntry entry in resourceSet)
     {
         imgDict.Add(currentIndex, (Bitmap)entry.Value);
         currentIndex++;
     }
     currentIndex      = 0;
     pictureBox1.Image = imgDict[currentIndex];
 }
Esempio n. 19
0
        public static void Main(string[] args)
        {
            CultureInfo culture = CultureInfo.InvariantCulture;

            foreach (string arg in args)
            {
                string basename = Path.GetFileNameWithoutExtension(arg);

                string basedir = Path.GetDirectoryName(arg);

                Console.WriteLine("");

                Console.WriteLine("[*] ------ Processing " + basename + " ------");

                ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(basename, basedir, null);

                ResourceSet rs = rm.GetResourceSet(culture, true, true);

                if (rs != null)
                {
                    IDictionaryEnumerator dict = rs.GetEnumerator();

                    while (dict.MoveNext())
                    {
                        string key = (string)dict.Key;

                        if (dict.Value is byte[])
                        {
                            Console.WriteLine("[i] Extracting resource '{0}' as bytes", key);

                            storeContent(basedir, basename, key, "bin", (byte [])rs.GetObject(key));
                        }

                        else if (dict.Value is System.Drawing.Bitmap)
                        {
                            Console.WriteLine("[i] Extracting resource '{0}' as image data", key);

                            System.Drawing.Bitmap img = (Bitmap)rs.GetObject(key);

                            ImageConverter converter = new ImageConverter();

                            storeContent(basedir, basename, key, "img", (byte [])converter.ConvertTo(img, typeof(byte [])));
                        }

                        else
                        {
                            Console.WriteLine("[!] Unhandled resource type for '{0}': {1}", key, dict.Value);
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        private void frmConfig_Load(object sender, EventArgs e)
        {
            try
            {
                txt_aion_path.Text = Config.get_game_path();

                for (int i = 0; i < combobox_language.Items.Count; i++)
                {
                    if (Config.get_language().ToLower() == ((string)combobox_language.Items[i]).ToLower())
                    {
                        combobox_language.SelectedIndex = i;
                        break;
                    }
                }

                chk_scan_previos_session.Checked = Config.get_scan_previos_session_on_startup();
                chkWindowOnTop.Checked           = Config.get_window_on_top();

                lbl_font.Font       = Config.get_font();
                lbl_font.Text       = lbl_font.Font.Name + " " + lbl_font.Font.Size;
                lbl_color.ForeColor = Config.get_color();

                this.numericUpDown_windowopacity.Value = (decimal)(Config.get_window_opacity() * 100);

                // Iterate through embbeded textures
                combobox_textures.ImageList            = new ImageList();
                combobox_textures.ImageList.ColorDepth = ColorDepth.Depth32Bit;
                combobox_textures.ImageList.ImageSize  = new Size(256, 32);
                ResourceManager rm = new ResourceManager(typeof(Textures));
                using (ResourceSet rs = rm.GetResourceSet(System.Threading.Thread.CurrentThread.CurrentUICulture, true, true))
                {
                    IDictionaryEnumerator resourceEnumerator = rs.GetEnumerator();
                    while (resourceEnumerator.MoveNext())
                    {
                        if (resourceEnumerator.Value is Image)
                        {
                            Image img = (Image)resourceEnumerator.Value;
                            combobox_textures.ImageList.Images.Add(img);
                            combobox_textures.Items.Add(new ComboBoxExItem(combobox_textures.ImageList.Images.Count - 1, resourceEnumerator.Key.ToString()));
                            if (Config.get_bar_texture_name() == resourceEnumerator.Key.ToString())
                            {
                                combobox_textures.SelectedIndex = combobox_textures.Items.Count - 1;
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            { }
        }
Esempio n. 21
0
        //currently does not work if called before Initialize, this will change when Board is implemented
        public bool CreateFile(Board map, string timeStamp)
        {
            if (map == null)
            {
                return(false);
            }
            string newMap = "";

            newMap += String.Format("{0}X{1}\n", map.numRows, map.numColumns);
            for (int i = 0; i < map.numRows; i++)
            {
                for (int j = 0; j < map.numColumns; j++)
                {
                    int             row         = i;
                    int             column      = j;
                    Tile            currentTile = map.spaces[row, column];
                    TileEnumeration terrain     = currentTile.m_terrainType;
                    Unit            unit        = currentTile.m_unit;
                    if (i == map.numRows - 1 && j == map.numColumns - 1)
                    {
                        newMap += String.Format("{0}{1} {2}{3}", (char)(row + 'A'), column + 1, (int)terrain, (unit == null) ? "" : " " + ConvertUnitToRegexFormat(unit));
                    }
                    else
                    {
                        newMap += String.Format("{0}{1} {2}{3}\n", (char)(row + 'A'), column + 1, (int)terrain, (unit == null) ? "" : " " + ConvertUnitToRegexFormat(unit));
                    }
                }
            }
            ResourceSet                 reader   = new ResourceSet("MapFiles.resources");
            IDictionaryEnumerator       saves    = reader.GetEnumerator();
            Dictionary <object, object> saveInfo = new Dictionary <object, object>();

            foreach (DictionaryEntry entry in reader)
            {
                saveInfo.Add(entry.Key, entry.Value);
            }
            reader.Close();
            ResourceWriter resWriter = new ResourceWriter("MapFiles.resources");

            foreach (KeyValuePair <object, object> entry in saveInfo)
            {
                string key   = entry.Key.ToString();
                string value = entry.Value.ToString();
                resWriter.AddResource(key, value);
            }
            resWriter.AddResource(String.Format("{0}_{1}", map.name, timeStamp), newMap);
            resWriter.Close();
            return(true);
        }
        public bool ContainsResource(string name, bool ignoreCase)
        {
            ResXResourceSet resx     = resxResourceSet;
            ResourceSet     compiled = compiledResourceSet;

            if (resx == null || compiled == null)
            {
                Throw.ObjectDisposedException();
            }

            if (resx.ContainsResource(name, ignoreCase))
            {
                return(true);
            }

            HashSet <string> binKeys = compiledKeys;

            if (binKeys == null)
            {
                // no foreach because that would evaluate (deserialize) the values, too
                binKeys = new HashSet <string>();
                IDictionaryEnumerator compiledEnumerator = compiled.GetEnumerator();
                while (compiledEnumerator.MoveNext())
                {
                    binKeys.Add(compiledEnumerator.Key.ToString());
                }

                compiledKeys = binKeys;
            }

            if (binKeys.Contains(name))
            {
                return(true);
            }

            if (!ignoreCase)
            {
                return(false);
            }

            HashSet <string> binKeysIgnoreCase = compiledKeysCaseInsensitive;

            if (binKeysIgnoreCase == null)
            {
                compiledKeysCaseInsensitive = binKeysIgnoreCase = new HashSet <string>(binKeys, StringComparer.OrdinalIgnoreCase);
            }

            return(binKeysIgnoreCase.Contains(name));
        }
Esempio n. 23
0
        /// <summary>
        /// Creates localization dictionary by resourse manager
        /// </summary>
        /// <param name="man">The manager</param>
        /// <returns>Localization dictionary</returns>
        public static Dictionary <string, object> CreateLocalizationDictionary(ResourceManager man)
        {
            Dictionary <string, object> d = new Dictionary <string, object>();
            ResourceSet           rs      = man.GetResourceSet(System.Globalization.CultureInfo.InvariantCulture, true, false);
            IDictionaryEnumerator rEnu    = rs.GetEnumerator();

            while (rEnu.MoveNext())
            {
                string k = rEnu.Key + "";
                k = ReverseTransform(k);
                object v = rEnu.Value;
                d[k] = v;
            }
            return(d);
        }
Esempio n. 24
0
        /// <summary>
        /// Localization by resourse manager
        /// </summary>
        /// <param name="man">The manager</param>
        public static void Localize(ResourceManager man)
        {
            Dictionary <string, string> d = new Dictionary <string, string>();
            ResourceSet           rs      = man.GetResourceSet(System.Globalization.CultureInfo.InvariantCulture, true, false);
            IDictionaryEnumerator rEnu    = rs.GetEnumerator();

            while (rEnu.MoveNext())
            {
                string k = rEnu.Key + "";
                k = ReverseTransform(k);
                object v = rEnu.Value;
                ControlResources[k] = v;
                CommonResources[k]  = v;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Loads resources from file
        /// </summary>
        /// <param name="filename">Filename</param>
        public static void LoadResources(string filename)
        {
            Stream                stream = File.OpenRead(filename);
            ResourceReader        r      = new ResourceReader(stream);
            ResourceSet           s      = new ResourceSet(r);
            IDictionaryEnumerator d      = s.GetEnumerator();

            while (d.MoveNext())
            {
                object k = d.Key;
                object v = d.Value;
                resources[k + ""] = v;
            }
            stream.Close();
        }
Esempio n. 26
0
        /// <summary>
        /// Loads resources of controls
        /// </summary>
        /// <param name="filename">File name</param>
        public static void LoadErrorResources(string filename)
        {
            Stream                stream = File.OpenRead(filename);
            ResourceReader        rr     = new ResourceReader(stream);
            ResourceSet           rs     = new ResourceSet(rr);
            IDictionaryEnumerator de     = rs.GetEnumerator();

            while (de.MoveNext())
            {
                object k = de.Key;
                object v = de.Value;
                errorResources[k + ""] = v + "";
            }
            stream.Close();
        }
Esempio n. 27
0
        public Dictionary <string, string> BuildResourceDictionary(ResourceManager manager)
        {
            Dictionary <string, string> resourceDict = new Dictionary <string, string>();

            ResourceSet resourceSet = manager.GetResourceSet(System.Globalization.CultureInfo.CurrentUICulture, true, true);

            System.Collections.IDictionaryEnumerator enumerator = resourceSet.GetEnumerator();

            while (enumerator.MoveNext())
            {
                resourceDict.Add((string)enumerator.Key, (string)enumerator.Value);
            }

            return(resourceDict);
        }
Esempio n. 28
0
        public static Dictionary <string, string> ConvertActorLabelType()
        {
            Dictionary <string, string> labelTypes = new Dictionary <string, string>();

            System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(typeof(Resources.ActorLabelType));
            ResourceSet           resourceSet = resourceManager.GetResourceSet(CultureInfo.CurrentCulture, true, true);
            IDictionaryEnumerator id          = resourceSet.GetEnumerator();

            while (id.MoveNext())
            {
                labelTypes.Add(id.Key.ToString(), id.Value.ToString());
            }
            resourceSet.Close();
            return(labelTypes);
        }
        /// <summary>
        /// Generates a strongly typed assembly from the resources
        ///
        /// UNDER CONSTRUCTION.
        /// Doesn't work correctly for Web forms due to hard coded resource managers.
        /// </summary>
        /// <param name="ResourceSetName"></param>
        /// <param name="Namespace"></param>
        /// <param name="Classname"></param>
        /// <param name="FileName"></param>
        /// <returns></returns>
        public bool CreateStronglyTypedResource(string ResourceSetName, string Namespace, string Classname, string FileName)
        {
            try
            {
                //wwDbResourceDataManager Data = new wwDbResourceDataManager();
                //IDictionary ResourceSet = Data.GetResourceSet("", ResourceSetName);

                // *** Use the custom ResourceManage to retrieve a ResourceSet
                wwDbResourceManager   Man        = new wwDbResourceManager(ResourceSetName);
                ResourceSet           rs         = Man.GetResourceSet(CultureInfo.InvariantCulture, false, false);
                IDictionaryEnumerator Enumerator = rs.GetEnumerator();

                // *** We have to turn into a concret Dictionary
                Dictionary <string, object> Resources = new Dictionary <string, object>();
                while (Enumerator.MoveNext())
                {
                    DictionaryEntry Item = (DictionaryEntry)Enumerator.Current;
                    Resources.Add(Item.Key as string, Item.Value);
                }

                string[]        UnmatchedElements;
                CodeDomProvider CodeProvider = null;

                string FileExtension = Path.GetExtension(FileName).TrimStart('.').ToLower();
                if (FileExtension == "cs")
                {
                    CodeProvider = new Microsoft.CSharp.CSharpCodeProvider();
                }
                else if (FileExtension == "vb")
                {
                    CodeProvider = new Microsoft.VisualBasic.VBCodeProvider();
                }

                CodeCompileUnit Code = StronglyTypedResourceBuilder.Create(Resources,
                                                                           ResourceSetName, Namespace, CodeProvider, false, out UnmatchedElements);

                StreamWriter writer = new StreamWriter(FileName);
                CodeProvider.GenerateCodeFromCompileUnit(Code, writer, new CodeGeneratorOptions());
                writer.Close();
            }
            catch (Exception ex)
            {
                this.ErrorMessage = ex.Message;
                return(false);
            }

            return(true);
        }
Esempio n. 30
0
        public string ShowAssemblyResourceInfo(Assembly assembly)
        {
            var result = new StringBuilder();
            var manifestResourceNames = assembly.GetManifestResourceNames();

            foreach (var manifestResourceName in manifestResourceNames)
            {
                var set = new ResourceSet(assembly.GetManifestResourceStream(manifestResourceName));
                var id  = set.GetEnumerator();
                while (id.MoveNext())
                {
                    result.AppendLine($"{manifestResourceName} - {id.Key} = {id.Value}");
                }
            }
            return(result.ToString());
        }