/// <summary> /// Register all json providers (classes adornded with the JsonProxy attribute /// or having methods adorned with the JsonMethod attribute) defined in the /// specified assembly. /// </summary> /// <param name="type"></param> public static void RegisterProviders(Assembly assembly) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (CustomAttributeExtension.GetFirstMethodWithAttributeOfType <JsonMethod>(type) != null) { RegisterProvider(type); } } }
private static Control LoadControl(string virtualBoxPath, bool renderScripts, string requesterId, object injectionObject, bool postWindowLoad) { JavascriptPage controlLoader = new JavascriptPage(); Control control = controlLoader.LoadControl(virtualBoxPath); //if (control.Controls.Count == 0) // throw new UserControlIsNotBoxUserControlException(virtualBoxPath); BoxUserControl evolved = control as BoxUserControl;//control.Controls[0] as BoxUserControl; if (evolved == null) { throw new UserControlIsNotBoxUserControlException(virtualBoxPath); } Type controlType = control.GetType(); JavascriptServer.RegisterProvider(controlType);// makes any JsonMethod methods available to the client controlLoader.Controls.Add(control); if (injectionObject != null) { MethodInfo boxInject = CustomAttributeExtension.GetFirstMethodWithAttributeOfType <BoxInject>(controlType); if (boxInject != null) { ParameterInfo[] paramInfo = boxInject.GetParameters(); if (paramInfo.Length != 1 || paramInfo[0].ParameterType != injectionObject.GetType()) { throw ExceptionHelper.CreateException <JsonInvalidOperationException>("The BoxInject method of control type {0} has the wrong type or number of parameters.", control.GetType().Name); } boxInject.Invoke(control, new object[] { injectionObject }); } evolved.Inject(injectionObject); } MethodInfo boxInit = CustomAttributeExtension.GetFirstMethodWithAttributeOfType <BoxInit>(control.GetType()); if (boxInit != null) { boxInit.Invoke(control, null); } evolved.PostBoxLoad(renderScripts, requesterId, postWindowLoad); //loadedControls.Add(virtualBoxPath, control); return(control); }