/// <summary>
        ///     Creates a strongly typed resource class for a ResoureSet from the DbResourceManager.
        ///     Note: Uses the default ResourceProvider settings as set in the DbResourceConfiguration.Current
        ///     property for opening the database and otherwise setting values.
        /// </summary>
        /// <param name="ResourceSetName">The name of the resource set. Should be a GLOBAL resource</param>
        /// <param name="Namespace">The namespace for the generated class. Null or string.Empty to not generate a namespace</param>
        /// <param name="Classname">Name of the class to be generated</param>
        /// <param name="FileName">
        ///     Output filename for the CSharp class. If null no file is generated and only the class is
        ///     returned
        /// </param>
        /// <returns>string of the generated class</returns>
        public string CreateClassFromDatabaseResource(string ResourceSetName, string Namespace, string Classname,
                                                      string FileName)
        {
            // Use the custom ResourceManage to retrieve a ResourceSet
            var Man         = new DbResourceManager.DbResourceManager(configuration, ResourceSetName);
            var ResourceSet = Man.GetResourceSet(CultureInfo.InvariantCulture, false, false);

            return(CreateClassFromResourceSet(ResourceSet, Namespace, Classname, FileName));
        }
        /// <summary>
        ///     Creates a strongly typed resource from a ResourceSet object. The ResourceSet passed should always
        ///     be the invariant resourceset that contains all the ResourceIds.
        ///     Creates strongly typed keys for each of the keys/values.
        /// </summary>
        /// <param name="resourceSet"></param>
        /// <param name="Namespace">Namespace of the generated class. Pass Null or string.Empty to not generate a namespace</param>
        /// <param name="classname">Name of the class to generate. Pass null to use the ResourceSet name</param>
        /// <param name="fileName">
        ///     Output filename for the CSharp class. If null no file is generated and only the class is
        ///     returned
        /// </param>
        /// <returns></returns>
        public string CreateResxDesignerClassFromResourceSet(string resourceSetName, string nameSpace, string classname,
                                                             string fileName)
        {
            // Use the custom ResourceManage to retrieve a ResourceSet
            var man         = new DbResourceManager.DbResourceManager(configuration, resourceSetName);
            var resourceSet = man.GetResourceSet(CultureInfo.InvariantCulture, false, false);

            IsVb = IsFileVb(fileName);

            var sbClass = new StringBuilder();

            CreateResxDesignerClassHeader(classname, nameSpace, IsVb, sbClass);

            var indent = "\t\t";

            // Any resource set that contains a '.' is considered a Local Resource
            var IsGlobalResource = !classname.Contains(".");

            // We'll enumerate through the Recordset to get all the resources
            var Enumerator = resourceSet.GetEnumerator();

            // We have to turn into a concrete Dictionary
            while (Enumerator.MoveNext())
            {
                var item = (DictionaryEntry)Enumerator.Current;
                if (item.Value == null)
                {
                    item.Value = string.Empty;
                }

                var typeName = item.Value.GetType().FullName;
                var key      = item.Key as string;
                if (string.IsNullOrEmpty(key))
                {
                    continue;
                }

                var varName = SafeVarName(key);

                // It's a string
                if (!IsVb)
                {
                    sbClass.AppendLine(indent + "public static " + typeName + " " + varName + "\r\n" + indent + "{");
                    sbClass.AppendFormat(indent + "\tget\r\n" +
                                         indent + "\t{{\r\n" +
                                         indent + "\t\t" +
                                         (string.IsNullOrEmpty(typeName) || typeName == "System.String"
                                             ? "return ResourceManager.GetString(\"{0}\", resourceCulture);\r\n"
                                             : "return ({1})ResourceManager.GetObject(\"{0}\", resourceCulture);\r\n") +
                                         indent + "\t}}\r\n",
                                         key, typeName);
                    sbClass.AppendLine(indent + "}\r\n");
                }
                else
                {
                    sbClass.Append(indent + "Public Shared Property " + varName + "() as " + typeName + "\r\n");
                    sbClass.AppendFormat(
                        indent + "\tGet\r\n" + indent +
                        "\t\treturn CType( ResourceManager.GetObject(\"{1}\",resourceCulture)\r\n",
                        classname, key, typeName);
                    sbClass.Append(indent + "\tEnd Get\r\n");
                    sbClass.Append(indent + "End Property\r\n\r\n");
                }
            }

            if (!IsVb)
            {
                sbClass.Append("\t}\r\n\r\n");
            }
            else
            {
                sbClass.Append("End Class\r\n\r\n");
            }

            var Output = CreateNameSpaceWrapper(nameSpace, IsVb, sbClass.ToString());

            if (!string.IsNullOrEmpty(fileName))
            {
                File.WriteAllText(fileName, Output);
                return(Output);
            }

            return(sbClass.ToString());
        }