public object GetObject(ImplicitResourceKey key, CultureInfo culture)
        {
            string format      = String.IsNullOrWhiteSpace(key.Filter) ? "{0}.{1}" : "{2}:{0}.{1}";
            string resourceKey = String.Format(format, key.KeyPrefix, key.Property, key.Filter);

            return(resourceManager.Value.GetObject(resourceKey, culture));
        }
示例#2
0
        // IImplict Resource Provider implementation is purely optional
        //     If not provided ASP.NET uses a default implementation.
#if false
        #region IImplicitResourceProvider Members

        /// <summary>
        /// Called when an ASP.NET Page is compiled asking for a collection
        /// of keys that match a given control name (keyPrefix). This
        /// routine for example returns control.Text,control.ToolTip from the
        /// Resource collection if they exist when a request for "control"
        /// is made as the key prefix.
        /// </summary>
        /// <param name="keyPrefix"></param>
        /// <returns></returns>
        public ICollection GetImplicitResourceKeys(string keyPrefix)
        {
            List <ImplicitResourceKey> keys = new List <ImplicitResourceKey>();

            IDictionaryEnumerator Enumerator = this.ResourceReader.GetEnumerator();

            if (Enumerator == null)
            {
                return(keys); // Cannot return null!
            }
            foreach (DictionaryEntry dictentry in this.ResourceReader)
            {
                string key = (string)dictentry.Key;

                if (key.StartsWith(keyPrefix + ".", StringComparison.InvariantCultureIgnoreCase) == true)
                {
                    string keyproperty = String.Empty;
                    if (key.Length > (keyPrefix.Length + 1))
                    {
                        int pos = key.IndexOf('.');
                        if ((pos > 0) && (pos == keyPrefix.Length))
                        {
                            keyproperty = key.Substring(pos + 1);
                            if (String.IsNullOrEmpty(keyproperty) == false)
                            {
                                //Debug.WriteLine("Adding Implicit Key: " + keyPrefix + " - " + keyproperty);
                                ImplicitResourceKey implicitkey = new ImplicitResourceKey(String.Empty, keyPrefix, keyproperty);
                                keys.Add(implicitkey);
                            }
                        }
                    }
                }
            }
            return(keys);
        }
示例#3
0
        /// <summary>
        /// Retrieves all keys for from the resource store that match the given key prefix.
        /// The value here is generally a property name (or resourceId) and this routine
        /// retrieves all matching property values.
        ///
        /// So, lnkSubmit as the prefix finds lnkSubmit.Text, lnkSubmit.ToolTip and
        /// returns both of those keys.
        /// </summary>
        /// <param name="keyPrefix"></param>
        /// <returns></returns>
        ICollection IImplicitResourceProvider.GetImplicitResourceKeys(string keyPrefix)
        {
            List <ImplicitResourceKey> keys = new List <ImplicitResourceKey>();

            foreach (DictionaryEntry dictentry in this.ResourceReader)
            {
                string key = (string)dictentry.Key;

                if (key.StartsWith(keyPrefix + ".", StringComparison.InvariantCultureIgnoreCase) == true)
                {
                    string keyproperty = String.Empty;
                    if (key.Length > (keyPrefix.Length + 1))
                    {
                        int pos = key.IndexOf('.');
                        if ((pos > 0) && (pos == keyPrefix.Length))
                        {
                            keyproperty = key.Substring(pos + 1);
                            if (String.IsNullOrEmpty(keyproperty) == false)
                            {
                                ImplicitResourceKey implicitkey = new ImplicitResourceKey(String.Empty, keyPrefix, keyproperty);
                                keys.Add(implicitkey);
                            }
                        }
                    }
                }
            }
            return(keys);
        }
示例#4
0
        /// <summary>
        /// Routine that generates a full resource key string from
        /// an Implicit Resource Key value
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        private static string ConstructFullKey(ImplicitResourceKey entry)
        {
            string text = entry.KeyPrefix + "." + entry.Property;

            if (entry.Filter.Length > 0)
            {
                text = entry.Filter + ":" + text;
            }
            return(text);
        }
示例#5
0
        /// <summary>
        /// Returns an Implicit key value from the ResourceSet.
        /// Note this method is called only if a ResourceKey was found in the
        /// ResourceSet at load time. If a resource cannot be located this
        /// method is never called to retrieve it. IOW, GetImplicitResourceKeys
        /// determines which keys are actually retrievable.
        ///
        /// This method simply parses the Implicit key and then retrieves
        /// the value using standard GetObject logic for the ResourceID.
        /// </summary>
        /// <param name="implicitKey"></param>
        /// <param name="culture"></param>
        /// <returns></returns>

        public object GetObject(ImplicitResourceKey implicitKey, CultureInfo culture)
        {
            string ResourceKey = ConstructFullKey(implicitKey);


            if (culture == null)
            {
                culture = CultureInfo.CurrentUICulture;
            }

            return(this.getObjectInternal(ResourceKey, culture));
        }
示例#6
0
        /// <summary>
        /// Returns an Implicit key value from the ResourceSet.
        /// Note this method is called only if a ResourceKey was found in the
        /// ResourceSet at load time. If a resource cannot be located this
        /// method is never called to retrieve it. IOW, GetImplicitResourceKeys
        /// determines which keys are actually retrievable.
        ///
        /// This method simply parses the Implicit key and then retrieves
        /// the value using standard GetObject logic for the ResourceID.
        /// </summary>
        /// <param name="implicitKey"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object GetObject(ImplicitResourceKey implicitKey, CultureInfo culture)
        {
            string ResourceKey = ConstructFullKey(implicitKey);

            string CultureName = null;

            if (culture != null)
            {
                CultureName = culture.Name;
            }
            else
            {
                CultureName = CultureInfo.CurrentUICulture.Name;
            }

            return(this.GetObjectInternal(ResourceKey, CultureName));
        }
示例#7
0
        /// <summary>
        /// Gets a collection of implicit resource keys as specified by the prefix.
        /// </summary>
        /// <param name="keyPrefix">The prefix of the implicit resource keys to be collected.</param>
        /// <returns>
        /// An <see cref="T:System.Collections.ICollection" /> of implicit resource
        /// keys.
        /// </returns>
        public ICollection GetImplicitResourceKeys(string keyPrefix)
        {
            if (string.IsNullOrEmpty(keyPrefix))
            {
                throw new ArgumentNullException("keyPrefix");
            }

            List <ImplicitResourceKey> keys = new List <ImplicitResourceKey>();

            foreach (var locEntry in this.Cache)
            {
                if (!this.IsImplicitKey(locEntry.Key))
                {
                    continue;
                }

                var implicitKeyPrefix = this.GetImplicitKeyPrefix(locEntry.Key);
                if (!implicitKeyPrefix.Equals(keyPrefix, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                var key = new ImplicitResourceKey();
                key.KeyPrefix = keyPrefix;
                key.Property  = this.GetImplicitKeyProperty(locEntry.Key);

                if (!string.IsNullOrEmpty(locEntry.Culture))
                {
                    key.Filter = locEntry.Culture;
                }
                else
                {
                    key.Filter = "";
                }

                keys.Add(key);
            }

            return(keys);
        }
示例#8
0
 public object GetObject(ImplicitResourceKey key, CultureInfo culture)
 {
     throw new NotImplementedException();
 }
 object IImplicitResourceProvider.GetObject(ImplicitResourceKey key, CultureInfo culture)
 {
     throw new NotSupportedException();
 }
            private IDictionary GetPageResources()
            {
                if (this._owner.Component == null)
                {
                    return(null);
                }
                IServiceProvider site = this._owner.Component.Site;

                if (site == null)
                {
                    return(null);
                }
                DesignTimeResourceProviderFactory designTimeResourceProviderFactory = ControlDesigner.GetDesignTimeResourceProviderFactory(site);

                if (designTimeResourceProviderFactory == null)
                {
                    return(null);
                }
                IResourceProvider provider2 = designTimeResourceProviderFactory.CreateDesignTimeLocalResourceProvider(site);

                if (provider2 == null)
                {
                    return(null);
                }
                IResourceReader resourceReader = provider2.ResourceReader;

                if (resourceReader == null)
                {
                    return(null);
                }
                IDictionary dictionary = new HybridDictionary(true);

                if (resourceReader != null)
                {
                    foreach (DictionaryEntry entry in resourceReader)
                    {
                        string str  = (string)entry.Key;
                        string str2 = string.Empty;
                        if (str.IndexOf(':') > 0)
                        {
                            string[] strArray = str.Split(new char[] { ':' });
                            if (strArray.Length > 2)
                            {
                                continue;
                            }
                            str2 = strArray[0];
                            str  = strArray[1];
                        }
                        int index = str.IndexOf('.');
                        if (index > 0)
                        {
                            string    str3 = str.Substring(0, index);
                            string    str4 = str.Substring(index + 1);
                            ArrayList list = (ArrayList)dictionary[str3];
                            if (list == null)
                            {
                                list             = new ArrayList();
                                dictionary[str3] = list;
                            }
                            ImplicitResourceKey key = new ImplicitResourceKey {
                                Filter    = str2,
                                Property  = str4,
                                KeyPrefix = str3
                            };
                            list.Add(key);
                        }
                    }
                }
                return(dictionary);
            }
示例#11
0
 /// <summary>
 /// Implicit ResourceKey GetMethod that is called off meta:Resource key values.
 /// Note that if a value is missing at compile time this method is never called
 /// at runtime as the key isn't added to the Implicit key dictionary
 /// </summary>
 /// <param name="implicitKey"></param>
 /// <param name="culture"></param>
 /// <returns></returns>
 object IImplicitResourceProvider.GetObject(ImplicitResourceKey implicitKey, CultureInfo culture)
 {
     return(this.ResourceManager.GetObject(ConstructFullKey(implicitKey), culture));
 }