Exemplo n.º 1
0
        /// <summary>
        /// Generates the Database resources for a given form
        /// </summary>
        /// <param name="ParentControl"></param>
        /// <param name="ResourcePrefix"></param>
        public void AddResourceToResourceFile(Control ParentControl, string ResourcePrefix, string ResourceSet)
        {
            if (ResourcePrefix == null)
            {
                ResourcePrefix = "Resource1";
            }

            if (ResourceSet == null)
            {
                ResourceSet = this.Context.Request.ApplicationPath + this.Parent.TemplateControl.AppRelativeVirtualPath.Replace("~", "");
            }


            wwDbResourceDataManager Data = new wwDbResourceDataManager();

            List <LocalizableProperty> ResourceList = this.GetAllLocalizableControls(ParentControl);

            foreach (LocalizableProperty Resource in ResourceList)
            {
                string ResourceKey = Resource.ControlId + ResourcePrefix + "." + Resource.Property;

                if (!Data.ResourceExists(ResourceKey, "", ResourceSet))
                {
                    Data.AddResource(ResourceKey, Resource.Value, "", ResourceSet);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The main method to retrieve a specific resource key. The provider
        /// internally handles resource fallback based on the ResourceSet implementation.
        /// </summary>
        /// <param name="ResourceKey"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        object IResourceProvider.GetObject(string ResourceKey, CultureInfo culture)
        {
            object value = this.ResourceManager.GetObject(ResourceKey, culture);

            // *** If the value is still null and we're at the invariant culture
            // *** let's add a marker that the value is missing
            // *** this also allows the pre-compiler to work and never return null
            if (value == null && (culture == null || culture == CultureInfo.InvariantCulture))
            {
                // *** No entry there
                value = "";

                if (wwDbResourceConfiguration.Current.AddMissingResources)
                {
                    // *** Add invariant resource
                    wwDbResourceDataManager Data = new wwDbResourceDataManager();
                    if (!Data.ResourceExists(ResourceKey, "", this._className))
                    {
                        Data.UpdateOrAdd(ResourceKey, "*** Missing", "", this._className);
                    }
                }
            }

            return(value);
        }