예제 #1
0
        /// <summary>
        /// Creates strongly typed classes from all global resources in the current application
        /// from the active DbResourceManager. One class is created which contains each of the
        /// resource classes. Classnames are not necessarily named with
        ///
        /// Uses the default DbResourceConfiguration.Current settings for connecting
        /// to the database.
        /// </summary>
        /// <param name="Namespace">Optional namespace for the generated file</param>
        /// <param name="FileName">Output class file. .cs or .vb determines code language</param>
        /// <returns>Generated class as a string</returns>
        public string CreateClassFromAllDatabaseResources(string Namespace, string FileName)
        {
            bool IsVb = IsFileVb(FileName);

            DbResourceDataManager man       = new DbResourceDataManager();
            DataTable             Resources = man.GetAllResourceSets(ResourceListingTypes.GlobalResourcesOnly);

            StringBuilder sbClasses = new StringBuilder();

            foreach (DataRow row in Resources.Rows)
            {
                string ResourceSet = row["resourceset"] as string;
                string Class       = CreateClassFromDatabaseResource(ResourceSet, null, ResourceSet, null);
                sbClasses.Append(Class);
            }

            string Output = CreateNameSpaceWrapper(Namespace, IsVb, sbClasses.ToString());

            File.WriteAllText(FileName, Output);

            return(Output);
        }
 public IEnumerable <string> GetResourceSets()
 {
     return(Manager.GetAllResourceSets(ResourceListingTypes.AllResources));
 }
 public JsonResult GetResourceSets()
 //public IEnumerable<string> GetResourceSets()
 {
     return(Json(Manager.GetAllResourceSets(ResourceListingTypes.AllResources), jsonSettings));
 }
예제 #4
0
        private void GetResourceSet()
        {
            ResourceSet = Request.Form[lstResourceSet.UniqueID];
            if (ResourceSet == null)
            {
                ResourceSet = Request.QueryString["ResourceSet"];
            }
            if (ResourceSet == null)
            {
                ResourceSet = ViewState["ResourceSet"] as string;
            }

            if (ResourceSet == null)
            {
                ResourceSet = "";
            }

            ResourceSet = ResourceSet.ToLower();

            if (!string.IsNullOrEmpty(ResourceSet))
            {
                ViewState["ResourceSet"] = ResourceSet;
            }

            // *** Clear selections
            //lstResourceIds.Items.Clear();
            lstResourceIds.ClearSelection();
            lstResourceSet.Items.Clear();
            lstResourceSet.ClearSelection();

            DataTable dt = Manager.GetAllResourceSets(ResourceListingTypes.AllResources);

            lstResourceSet.DataSource     = dt;
            lstResourceSet.DataValueField = "ResourceSet";

            try
            {
                lstResourceSet.DataBind();
            }
            catch
            {
                // this fails for some unknown reason on rebinds (off a btn submission)
                // which in effect rebinds an already bound list.
                //
                // First pass through always works fine - only rebind fails.
                //
                // complains about SelectedValue being set to a value
                // that doesn't exist even though selection is already
                // cleared AND the value that it actually is set after
                // DataBind() DOES exist in the data.
            }

            if (!string.IsNullOrEmpty(ResourceSet))
            {
                // find item to select w/o case
                foreach (ListItem itm in lstResourceSet.Items)
                {
                    if (itm.Value.ToLower() == ResourceSet)
                    {
                        itm.Selected = true;
                        break;
                    }
                }
            }
            else
            {
                if (lstResourceSet.Items.Count > 0)
                {
                    ResourceSet = lstResourceSet.Items[0].Value;
                    lstResourceSet.SelectedValue = ResourceSet;
                }
            }
        }