ICSharpCode.Core.ResourceService.GetString C# (CSharp) Method

GetString() public static method

Returns a string from the resource database, it handles localization transparent for the user.
/// Is thrown when the GlobalResource manager can't find a requested resource. ///
public static GetString ( string name ) : string
name string /// The name of the requested resource. ///
return string
        public static string GetString(string name)
        {
            if (localStrings != null && localStrings[name] != null) {
                return localStrings[name].ToString();
            }

            string s = null;
            foreach (ResourceManager resourceManger in localStringsResMgrs) {
                try {
                    s = resourceManger.GetString(name);
                }
                catch (Exception) { }

                if (s != null) {
                    break;
                }
            }

            if (s == null) {
                foreach (ResourceManager resourceManger in strings) {
                    try {
                        s = resourceManger.GetString(name);
                    }
                    catch (Exception) { }

                    if (s != null) {
                        break;
                    }
                }
            }
            if (s == null) {
                throw new ResourceNotFoundException("string >" + name + "<");
            }

            return s;
        }

Usage Example

Exemplo n.º 1
0
        public override void Run()
        {
            string dir = FileService.GetDirectory(Res.GetString("TITLE_CONNECT_SHP_DIR"));

            if (FileService.DirectoryExists(dir))
            {
                FdoConnection        conn  = new FdoConnection("OSGeo.SHP", "DefaultFileLocation=" + dir);
                FdoConnectionManager mgr   = ServiceManager.Instance.GetService <FdoConnectionManager>();
                NamingService        namer = ServiceManager.Instance.GetService <NamingService>();

                string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SHP"));
                if (name == null)
                {
                    return;
                }

                while (string.IsNullOrEmpty(name) || mgr.NameExists(name))
                {
                    Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS"));
                    name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name);

                    if (name == null)
                    {
                        return;
                    }
                }
                mgr.AddConnection(name, conn);
            }
        }
All Usage Examples Of ICSharpCode.Core.ResourceService::GetString