public void Dispatch(IDictionary values, Control parent, string collectionName) { string parentID = string.Empty; string page = string.Empty; if (parent != null) { parentID = parent.UniqueID; page = parent.Page.ToString(); } foreach (DictionaryEntry entry in values) { string id = (string)entry.Key; IControlItem item = Find(id); if (item != null) { ResourceDispatcher.DispatchGeneric(item, (IDictionary)entry.Value); } else // Invalid collection element { s_log.Debug( "'" + parentID + "' on page '" + page + "' does not contain an item with an ID of '" + id + "' inside the collection '" + collectionName + "'."); } } }
/// <summary> Dispatches the resources passed in <paramref name="values"/> to the control's properties. </summary> /// <param name="values"> An <c>IDictonary</c>: <string key, string value>. </param> protected virtual void Dispatch(IDictionary values) { HybridDictionary tabValues = new HybridDictionary(); HybridDictionary propertyValues = new HybridDictionary(); // Parse the values foreach (DictionaryEntry entry in values) { string key = (string)entry.Key; string[] keyParts = key.Split(new[] { ':' }, 3); // Is a property/value entry? if (keyParts.Length == 1) { string property = keyParts[0]; propertyValues.Add(property, entry.Value); } // Is collection entry? else if (keyParts.Length == 3) { // Compound key: "collectionID:elementID:property" string collectionID = keyParts[0]; string elementID = keyParts[1]; string property = keyParts[2]; IDictionary currentCollection = null; // Switch to the right collection switch (collectionID) { case c_resourceKeyTabs: { currentCollection = tabValues; break; } default: { // Invalid collection property s_log.Warn( "WebTabStrip '" + ID + "' in naming container '" + NamingContainer.GetType().FullName + "' on page '" + Page + "' does not contain a collection property named '" + collectionID + "'."); break; } } // Add the property/value pair to the collection if (currentCollection != null) { // Get the dictonary for the current element IDictionary elementValues = (IDictionary)currentCollection[elementID]; // If no dictonary exists, create it and insert it into the elements hashtable. if (elementValues == null) { elementValues = new HybridDictionary(); currentCollection[elementID] = elementValues; } // Insert the argument and resource's value into the dictonary for the specified element. elementValues.Add(property, entry.Value); } } else { // Not supported format or invalid property s_log.Warn( "WebTabStrip '" + ID + "' in naming container '" + NamingContainer.GetType().FullName + "' on page '" + Page + "' received a resource with an invalid or unknown key '" + key + "'. Required format: 'property' or 'collectionID:elementID:property'."); } } // Dispatch simple properties ResourceDispatcher.DispatchGeneric(this, propertyValues); // Dispatch to collections Tabs.Dispatch(tabValues, this, "Tabs"); }