Exemplo n.º 1
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            obj.Name = comboBoxName.SelectedItem + "";
            ISeparatedAssemblyEditedObject s = obj.GetObject <ISeparatedAssemblyEditedObject>();

            if (s != null)
            {
                s.FirstLoad();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates object the corresponds to button
 /// </summary>
 /// <param name="button">The button</param>
 /// <returns>Created object</returns>
 public virtual ICategoryObject CreateObject(IPaletteButton button)
 {
     foreach (IUIFactory f in factories)
     {
         ICategoryObject o = f.CreateObject(button);
         if (o != null)
         {
             return(o);
         }
     }
     if (defaultValue)
     {
         Type   t    = button.ReflectionType;
         string kind = button.Kind;
         if (t != null)
         {
             if (kind.Length > 0) // Kind or additional parameter
             {
                 // Searches constructor from string
                 ConstructorInfo ci = t.GetConstructor(new System.Type[] { typeof(string) });
                 if (ci != null)
                 {
                     // Creates an object
                     ICategoryObject ob = ci.Invoke(new object[] { kind }) as ICategoryObject;
                     if (ob is ISeparatedAssemblyEditedObject)
                     {
                         ISeparatedAssemblyEditedObject sa = ob as ISeparatedAssemblyEditedObject;
                         if (sa.AssemblyBytes == null)
                         {
                             sa.FirstLoad();
                         }
                     }
                     return(ob); // returns the object
                 }
             }
             if (t.Equals(typeof(ObjectsCollection)))
             {
                 string s  = button.Kind;
                 Type   to = Type.GetType(s, true, false);
                 return(new ObjectsCollection(to));
             }
             if (t.GetInterface(typeof(IObjectFactory).ToString()) != null)
             {
                 IObjectFactory of = null;
                 FieldInfo      fi = t.GetField("Object");
                 if (fi != null)
                 {
                     of = fi.GetValue("Object") as IObjectFactory;
                 }
                 else
                 {
                     of = t.GetConstructor(new Type[] { }).Invoke(new object[] { }) as IObjectFactory;
                 }
                 return(of[kind]);
             }
             ConstructorInfo cons = t.GetConstructor(new System.Type[0]);
             if (cons != null)
             {
                 ICategoryObject ob = cons.Invoke(null) as ICategoryObject;
                 if (ob is ISeparatedAssemblyEditedObject)
                 {
                     ISeparatedAssemblyEditedObject sa = ob as ISeparatedAssemblyEditedObject;
                     if (sa.AssemblyBytes == null)
                     {
                         sa.FirstLoad();
                     }
                 }
                 return(ob);
             }
         }
     }
     return(null);
 }