public CellFactoryInvokerClass (System.Type aType, CellFactoryProviderAttribute aAttr)
		{
			factoryType = aType;
			factoryProvider = aAttr;

			if (ShellMethod == null)
				ShellMethod = this.GetType().GetMethod ("Invoke");
			if (ShellMethodParameters == null)
				ShellMethodParameters = ShellMethod.GetParameters();
			
			MethodInfo[] methods = aType.GetMethods();
			foreach (MethodInfo method in methods) {
				if ((method.IsStatic == true) && (method.Name == aAttr.MethodName)) {
					ParameterInfo[] parms = method.GetParameters();
					if (method.ReturnType != ShellMethod.ReturnType)
						continue;
					if (ShellMethodParameters.Length == parms.Length) {
						for (int i=0; i<ShellMethodParameters.Length; i++)
							if (ShellMethodParameters[i].ParameterType != parms[i].ParameterType)
								continue;
					}
					factoryMethod = method;
				}
			}
			if (factoryMethod == null)
				throw new Exception ("Class doesn't support factory method");
		}
        public CellFactoryInvokerClass(System.Type aType, CellFactoryProviderAttribute aAttr)
        {
            factoryType     = aType;
            factoryProvider = aAttr;

            if (ShellMethod == null)
            {
                ShellMethod = this.GetType().GetMethod("Invoke");
            }
            if (ShellMethodParameters == null)
            {
                ShellMethodParameters = ShellMethod.GetParameters();
            }

            MethodInfo[] methods = aType.GetMethods();
            foreach (MethodInfo method in methods)
            {
                if ((method.IsStatic == true) && (method.Name == aAttr.MethodName))
                {
                    ParameterInfo[] parms = method.GetParameters();
                    if (method.ReturnType != ShellMethod.ReturnType)
                    {
                        continue;
                    }
                    if (ShellMethodParameters.Length == parms.Length)
                    {
                        for (int i = 0; i < ShellMethodParameters.Length; i++)
                        {
                            if (ShellMethodParameters[i].ParameterType != parms[i].ParameterType)
                            {
                                continue;
                            }
                        }
                    }
                    factoryMethod = method;
                }
            }
            if (factoryMethod == null)
            {
                throw new Exception("Class doesn't support factory method");
            }
        }
예제 #3
0
 /// <summary>
 /// Adds class to list of factory provider handlers
 /// </summary>
 /// <param name="aType">
 /// Factory type <see cref="System.Type"/>
 /// </param>
 /// <param name="aAttr">
 /// Attribute <see cref="WidgetFactoryProviderAttribute"/>
 /// </param>
 private static void AddClass(System.Type aType, CellFactoryProviderAttribute aAttr)
 {
     CellHandlers.Add(new CellFactoryInvokerClass(aType, aAttr));
 }
		/// <summary>
		/// Adds class to list of factory provider handlers
		/// </summary>
		/// <param name="aType">
		/// Factory type <see cref="System.Type"/>
		/// </param>
		/// <param name="aAttr">
		/// Attribute <see cref="WidgetFactoryProviderAttribute"/>
		/// </param>
		private static void AddClass (System.Type aType, CellFactoryProviderAttribute aAttr)
		{
			CellHandlers.Add (new CellFactoryInvokerClass (aType, aAttr));
		}