Ejemplo n.º 1
0
        public FactoryInvokerClass(System.Type aType, WidgetFactoryProviderAttribute 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");
            }
        }
Ejemplo n.º 2
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, WidgetFactoryProviderAttribute aAttr)
 {
     WidgetHandlers.Add(new FactoryInvokerClass(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, WidgetFactoryProviderAttribute aAttr)
		{
			WidgetHandlers.Add (new FactoryInvokerClass (aType, aAttr));
		}