/// <summary> /// Dispatches resources. /// </summary> /// <include file='..\..\doc\include\ResourceDispatcher.xml' path='/ResourceDispatcher/Dispatch/remarks' /> /// <param name="control"> /// The control for which resources are to be dispatched. Must not be <see langname="null"/>. /// </param> /// <param name="resourceManager"> /// The resource manager to be used. Must not be <see langname="null"/>. /// </param> public static void Dispatch(Control control, IResourceManager resourceManager) { ArgumentUtility.CheckNotNull("control", control); ArgumentUtility.CheckNotNull("resourceManager", resourceManager); const string prefix = "auto:"; if (ControlHelper.IsDesignModeForControl(control)) { return; } IDictionary autoElements = ResourceDispatcher.GetResources(resourceManager, prefix); ResourceDispatcher.Dispatch(control, autoElements, resourceManager.Name); }
/// <summary> /// Dispatches an IDictonary of elementID/IDictonary pairs to the specified control. /// </summary> /// <include file='..\..\doc\include\ResourceDispatcher.xml' path='/ResourceDispatcher/DispatchMain/*' /> public static void Dispatch(Control control, IDictionary elements, string resourceSource) { ArgumentUtility.CheckNotNull("control", control); ArgumentUtility.CheckNotNull("elements", elements); if (ControlHelper.IsDesignModeForControl(control)) { return; } // Dispatch the resources to the controls foreach (DictionaryEntry elementsEntry in elements) { string elementID = (string)elementsEntry.Key; Control targetControl; if (elementID == c_thisElementID) { targetControl = (Control)control; } else { targetControl = control.FindControl(elementID); } if (targetControl == null) { s_log.Warn("Control '" + control.ToString() + "': No child-control with ID '" + elementID + "' found. ID was read from \"" + resourceSource + "\"."); } else { // Pass the value to the control IDictionary values = (IDictionary)elementsEntry.Value; IResourceDispatchTarget resourceDispatchTarget = targetControl as IResourceDispatchTarget; if (resourceDispatchTarget != null) // Control knows how to dispatch { resourceDispatchTarget.Dispatch(values); } else { ResourceDispatcher.DispatchGeneric(targetControl, values); } } } }