Exemplo n.º 1
0
 public ClassFactory(Type type)
 {
     _comClass = new ExcelComClassType 
     {
         Type = type,
         IsRtdServer = false
     };
 }
Exemplo n.º 2
0
 internal static void RegisterComClassType(ExcelComClassType comClassType)
 {
     // Just merge registrations into the overall list.
     registeredComClassTypes.Add(comClassType);
 }
Exemplo n.º 3
0
 internal static void RegisterComClassType(ExcelComClassType comClassType)
 {
     // Just merge registrations into the overall list.
     registeredComClassTypes.Add(comClassType);
 }
Exemplo n.º 4
0
 public ClassFactory(ExcelComClassType excelComClassType)
 {
     _comClass = excelComClassType;
 }
        // DOCUMENT: We register ComVisible types that
        //           (implement IRtdServer OR are in ExternalLibraries marked ComServer='true'
        public static void GetComClassTypes(ExportedAssembly assembly, Type type, object[] attributes, bool isRtdServer, List<ExcelComClassType> comClassTypes)
        {
            if (!Marshal.IsTypeVisibleFromCom(type))
            {
                return;
            }

            if (isRtdServer || assembly.ComServer)
            {
                string progId;
                Guid clsId;

                // Check for public default constructor
                if (type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) == null)
                {
                    // No use to us here - won't be able to construct.
                    return;
                }

                if (assembly.IsDynamic)
                {
                    // Check that we have an explicit Guid attribute
                    object[] attrs = type.GetCustomAttributes(typeof(GuidAttribute), false);
                    if (attrs.Length == 0)
                    {
                        // No Guid attribute - skip this type.
                        return;
                    }
                    else
                    {
                        GuidAttribute guidAtt = (GuidAttribute)attrs[0];
                        clsId = new Guid(guidAtt.Value);
                    }
                }
                else
                {
                    clsId = Marshal.GenerateGuidForType(type);
                }

                progId = Marshal.GenerateProgIdForType(type);

                ExcelComClassType comClassType = new ExcelComClassType
                {
                    Type = type,
                    ClsId = clsId,
                    ProgId = progId,
                    IsRtdServer = isRtdServer,
                    TypeLibPath = assembly.TypeLibPath
                };
                comClassTypes.Add(comClassType);
            }
        }