Ejemplo n.º 1
0
 static public void GetExcelAddIns(ExportedAssembly assembly, Type t, bool loadRibbons, List <ExcelAddInInfo> addIns)
 {
     // NOTE: We probably should have restricted this to public types, but didn't. Now it's too late.
     //       So internal classes that implement IExcelAddIn are also loaded.
     try
     {
         Type addInType = t.GetInterface("ExcelDna.Integration.IExcelAddIn");
         bool isRibbon  = IsRibbonType(t);
         if (addInType != null || (isRibbon && loadRibbons))
         {
             ExcelAddInInfo info = new ExcelAddInInfo();
             if (addInType != null)
             {
                 info.AutoOpenMethod  = addInType.GetMethod("AutoOpen");
                 info.AutoCloseMethod = addInType.GetMethod("AutoClose");
             }
             info.IsCustomUI = isRibbon;
             // TODO: Consider how to handle exception from constructors here.
             info.Instance         = Activator.CreateInstance(t);
             info.ParentDnaLibrary = assembly.ParentDnaLibrary;
             addIns.Add(info);
             Logger.Registration.Verbose("GetExcelAddIns - Created add-in object of type: {0}", t.FullName);
         }
     }
     catch (Exception e) // I think only CreateInstance can throw an exception here...
     {
         Logger.Initialization.Warn("GetExcelAddIns CreateInstance problem for type: {0} - exception: {1}", t.FullName, e);
     }
 }
Ejemplo n.º 2
0
 static public void GetExcelAddIns(ExportedAssembly assembly, Type t, bool loadRibbons, List <ExcelAddInInfo> addIns)
 {
     try
     {
         Type addInType = t.GetInterface("ExcelDna.Integration.IExcelAddIn");
         bool isRibbon  = IsRibbonType(t);
         if (addInType != null || (isRibbon && loadRibbons))
         {
             ExcelAddInInfo info = new ExcelAddInInfo();
             if (addInType != null)
             {
                 info.AutoOpenMethod  = addInType.GetMethod("AutoOpen");
                 info.AutoCloseMethod = addInType.GetMethod("AutoClose");
             }
             info.IsCustomUI = isRibbon;
             // TODO: Consider how to handle exception from constructors here.
             info.Instance         = Activator.CreateInstance(t);
             info.ParentDnaLibrary = assembly.ParentDnaLibrary;
             addIns.Add(info);
         }
     }
     catch (Exception e) // I think only CreateInstance can throw an exception here...
     {
         Debug.Print("GetExcelAddIns CreateInstance problem for type: {0} - exception: {1}", t.FullName, e);
     }
 }
Ejemplo n.º 3
0
        static public List <ExcelAddInInfo> GetExcelAddIns(Assembly assembly)
        {
            List <ExcelAddInInfo> addIns = new List <ExcelAddInInfo>();

            Type[] types = assembly.GetTypes();
            foreach (Type t in types)
            {
                Type addInType = t.GetInterface("ExcelDna.Integration.IExcelAddIn");
                if (addInType != null)
                {
                    ExcelAddInInfo info = new ExcelAddInInfo();
                    info.AutoOpenMethod  = addInType.GetMethod("AutoOpen");
                    info.AutoCloseMethod = addInType.GetMethod("AutoClose");

                    info.Instance = Activator.CreateInstance(t);
                    addIns.Add(info);
                }
            }
            return(addIns);
        }
Ejemplo n.º 4
0
 public static void GetExcelAddIns(ExportedAssembly assembly, Type t, bool loadRibbons, List<ExcelAddInInfo> addIns)
 {
     try
     {
         Type addInType = t.GetInterface("ExcelDna.Integration.IExcelAddIn");
         bool isRibbon = IsRibbonType(t);
         if (addInType != null || (isRibbon && loadRibbons) )
         {
             ExcelAddInInfo info = new ExcelAddInInfo();
             if (addInType != null)
             {
                 info.AutoOpenMethod = addInType.GetMethod("AutoOpen");
                 info.AutoCloseMethod = addInType.GetMethod("AutoClose");
             }
             info.IsCustomUI = isRibbon;
             // TODO: Consider how to handle exception from constructors here.
             info.Instance = Activator.CreateInstance(t);
             info.ParentDnaLibrary = assembly.ParentDnaLibrary;
             addIns.Add(info);
         }
     }
     catch (Exception e) // I think only CreateInstance can throw an exception here...
     {
         Debug.Print("GetExcelAddIns CreateInstance problem for type: {0} - exception: {1}", t.FullName, e);
     }
 }
Ejemplo n.º 5
0
 public static void GetExcelAddIns(ExportedAssembly assembly, Type t, bool loadRibbons, List<ExcelAddInInfo> addIns)
 {
     // NOTE: We probably should have restricted this to public types, but didn't. Now it's too late.
     //       So internal classes that implement IExcelAddIn are also loaded.
     try
     {
         Type addInType = t.GetInterface("ExcelDna.Integration.IExcelAddIn");
         bool isRibbon = IsRibbonType(t);
         if (addInType != null || (isRibbon && loadRibbons) )
         {
             ExcelAddInInfo info = new ExcelAddInInfo();
             if (addInType != null)
             {
                 info.AutoOpenMethod = addInType.GetMethod("AutoOpen");
                 info.AutoCloseMethod = addInType.GetMethod("AutoClose");
             }
             info.IsCustomUI = isRibbon;
             // TODO: Consider how to handle exception from constructors here.
             info.Instance = Activator.CreateInstance(t);
             info.ParentDnaLibrary = assembly.ParentDnaLibrary;
             addIns.Add(info);
             Logger.Registration.Verbose("GetExcelAddIns - Created add-in object of type: {0}", t.FullName);
         }
     }
     catch (Exception e) // I think only CreateInstance can throw an exception here...
     {
         Logger.Initialization.Warn("GetExcelAddIns CreateInstance problem for type: {0} - exception: {1}", t.FullName, e);
     }
 }