internal void EnsureGetPageResources()
 {
     if (!this._attemptedGetPageResources)
     {
         this._attemptedGetPageResources = true;
         IResourceReader resourceReader = this._resourceProvider.ResourceReader;
         if (resourceReader != null)
         {
             this._implicitResources = new Hashtable(StringComparer.OrdinalIgnoreCase);
             foreach (DictionaryEntry entry in resourceReader)
             {
                 ImplicitResourceKey key = ParseFullKey((string)entry.Key);
                 if (key != null)
                 {
                     ArrayList list = (ArrayList)this._implicitResources[key.KeyPrefix];
                     if (list == null)
                     {
                         list = new ArrayList();
                         this._implicitResources[key.KeyPrefix] = list;
                     }
                     list.Add(key);
                 }
             }
         }
     }
 }
        public virtual object GetObject(ImplicitResourceKey entry, CultureInfo culture)
        {
            // Put together the full resource key based on the ImplicitResourceKey
            string fullResourceKey = ConstructFullKey(entry);

            // Look it up in the resource provider
            return(_resourceProvider.GetObject(fullResourceKey, culture));
        }
 private static string ConstructFullKey(ImplicitResourceKey entry)
 {
     string str = entry.KeyPrefix + "." + entry.Property;
     if (entry.Filter.Length > 0)
     {
         str = entry.Filter + ":" + str;
     }
     return str;
 }
        private static string ConstructFullKey(ImplicitResourceKey entry)
        {
            string str = entry.KeyPrefix + "." + entry.Property;

            if (entry.Filter.Length > 0)
            {
                str = entry.Filter + ":" + str;
            }
            return(str);
        }
        /*
         * Create a dictionary, in which the key is a resource key (as found on meta:resourcekey
         * attributes), and the value is an ArrayList containing all the resources for that
         * resource key.  Each element of the ArrayList is an ImplicitResourceKey
         */
        internal void EnsureGetPageResources()
        {
            // If we already attempted to get them, don't do it again
            if (_attemptedGetPageResources)
            {
                return;
            }

            _attemptedGetPageResources = true;

            IResourceReader resourceReader = _resourceProvider.ResourceReader;

            if (resourceReader == null)
            {
                return;
            }

            _implicitResources = new Hashtable(StringComparer.OrdinalIgnoreCase);

            // Enumerate through all the page resources
            foreach (DictionaryEntry entry in resourceReader)
            {
                // Attempt to parse the key into a ImplicitResourceKey
                ImplicitResourceKey implicitResKey = ParseFullKey((string)entry.Key);

                // If we couldn't parse it as such, skip it
                if (implicitResKey == null)
                {
                    continue;
                }

                // Check if we already have an entry for this resource key prefix
                ArrayList controlResources = (ArrayList)_implicitResources[implicitResKey.KeyPrefix];

                // If not, create one
                if (controlResources == null)
                {
                    controlResources = new ArrayList();
                    _implicitResources[implicitResKey.KeyPrefix] = controlResources;
                }

                // Add an entry in the ArrayList for this property
                controlResources.Add(implicitResKey);
            }
        }
        /*
         * Parse a complete page resource key into a ImplicitResourceKey.
         * Return null if the key does not appear to be meant for implict resources.
         */
        private static ImplicitResourceKey ParseFullKey(string key)
        {
            string filter = String.Empty;

            // A page resource key looks like [myfilter:]MyResKey.MyProp[.MySubProp]

            // Check if there is a filter
            if (key.IndexOf(':') > 0)
            {
                string[] parts = key.Split(':');

                // Shouldn't be multiple ':'.  If there is, ignore it
                if (parts.Length > 2)
                {
                    return(null);
                }

                filter = parts[0];
                key    = parts[1];
            }

            int periodIndex = key.IndexOf('.');

            // There should be at least one period, for the meta:resourcekey part. If not, ignore.
            if (periodIndex <= 0)
            {
                return(null);
            }

            string keyPrefix = key.Substring(0, periodIndex);

            // The rest of the string is the property (e.g. MyProp.MySubProp)
            string property = key.Substring(periodIndex + 1);

            // Create a ImplicitResourceKey with the parsed data
            ImplicitResourceKey implicitResKey = new ImplicitResourceKey();

            implicitResKey.Filter    = filter;
            implicitResKey.KeyPrefix = keyPrefix;
            implicitResKey.Property  = property;

            return(implicitResKey);
        }
        /// <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);
        }
        // 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;
        }
        /// <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;
        }  
 /// <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);
 }
 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;
 }
        public virtual object GetObject(ImplicitResourceKey entry, CultureInfo culture) {

            // Put together the full resource key based on the ImplicitResourceKey
            string fullResourceKey = ConstructFullKey(entry);

            // Look it up in the resource provider
            return _resourceProvider.GetObject(fullResourceKey, culture);
        }
 public virtual object GetObject(ImplicitResourceKey entry, CultureInfo culture)
 {
     string resourceKey = ConstructFullKey(entry);
     return this._resourceProvider.GetObject(resourceKey, culture);
 }
        public virtual object GetObject(ImplicitResourceKey entry, CultureInfo culture)
        {
            string resourceKey = ConstructFullKey(entry);

            return(this._resourceProvider.GetObject(resourceKey, culture));
        }
        /// <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;
        }
 /// <summary>
 /// Gets an object representing the value of the specified resource key.
 /// </summary>
 /// <param name="key">The resource key containing the prefix, filter, and property.</param>
 /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> that
 /// represents the culture for which the resource is localized.</param>
 /// <returns>
 /// An <see cref="T:System.Object" /> representing the localized value of
 /// an implicit resource key.
 /// </returns>
 public object GetObject(ImplicitResourceKey key, CultureInfo culture)
 {
     throw new NotImplementedException();
 }
        /*
         * Parse a complete page resource key into a ImplicitResourceKey.
         * Return null if the key does not appear to be meant for implict resources.
         */
        private static ImplicitResourceKey ParseFullKey(string key) {

            string filter = String.Empty;

            // A page resource key looks like [myfilter:]MyResKey.MyProp[.MySubProp]

            // Check if there is a filter
            if (key.IndexOf(':') > 0) {
                string[] parts = key.Split(':');

                // Shouldn't be multiple ':'.  If there is, ignore it
                if (parts.Length > 2)
                    return null;

                filter = parts[0];
                key = parts[1];
            }

            int periodIndex = key.IndexOf('.');

            // There should be at least one period, for the meta:resourcekey part. If not, ignore.
            if (periodIndex <= 0)
                return null;

            string keyPrefix = key.Substring(0, periodIndex);

            // The rest of the string is the property (e.g. MyProp.MySubProp)
            string property = key.Substring(periodIndex+1);

            // Create a ImplicitResourceKey with the parsed data
            ImplicitResourceKey implicitResKey = new ImplicitResourceKey();
            implicitResKey.Filter = filter;
            implicitResKey.KeyPrefix = keyPrefix;
            implicitResKey.Property = property;

            return implicitResKey;
        }