Example #1
0
 public void LoadTheoremServer(ITheoremServer theoremServer)
 {
     if (theoremServer == null)
     {
         throw new ArgumentNullException("theoremServer");
     }
     theoremServer.AppendTheorems(theoremTable);
 }
Example #2
0
        /// <summary>
        /// Looks for package manager or servers to load and analyze the assembly.
        /// If none is available, a manual analysis is tried instead.
        /// </summary>
        public void LoadAssembly(Assembly assembly)
        {
            Type packageManagerType     = typeof(PackageManagerAttribute);
            Type architectureServerType = typeof(ArchitectureServerAttribute);
            Type entityServerType       = typeof(EntityServerAttribute);
            Type theoremServerType      = typeof(TheoremServerAttribute);
            Type structreServerType     = typeof(StructureServerAttribute);

            bool foundPackageManager     = false;
            bool foundArchitectureServer = false;
            bool foundEntityServer       = false;
            bool foundTheoremServer      = false;
            bool foundStructureServer    = false;

            foreach (Type t in assembly.GetTypes())
            {
                object instance = null;

                object[] pmas = t.GetCustomAttributes(packageManagerType, false);
                if (pmas.Length > 0)
                {
                    foundPackageManager = true;
                    if (instance == null)
                    {
                        instance = Activator.CreateInstance(t, new object[] { context });
                    }
                    IPackageManager packageManager = instance as IPackageManager;
                    if (packageManager != null)
                    {
                        LoadPackageManager(packageManager);
                    }
                }

                object[] asas = t.GetCustomAttributes(architectureServerType, false);
                if (asas.Length > 0)
                {
                    foundArchitectureServer = true;
                    if (instance == null)
                    {
                        instance = Activator.CreateInstance(t, new object[] { context });
                    }
                    IArchitectureServer architectureServer = instance as IArchitectureServer;
                    if (architectureServer != null)
                    {
                        LoadArchitectureServer(architectureServer);
                    }
                }

                object[] esas = t.GetCustomAttributes(entityServerType, false);
                if (esas.Length > 0)
                {
                    foundEntityServer = true;
                    if (instance == null)
                    {
                        instance = Activator.CreateInstance(t, new object[] { context });
                    }
                    IEntityServer entityServer = instance as IEntityServer;
                    if (entityServer != null)
                    {
                        LoadEntityServer(entityServer);
                    }
                }

                object[] tsas = t.GetCustomAttributes(theoremServerType, false);
                if (tsas.Length > 0)
                {
                    foundTheoremServer = true;
                    if (instance == null)
                    {
                        instance = Activator.CreateInstance(t, new object[] { context });
                    }
                    ITheoremServer theoremServer = instance as ITheoremServer;
                    if (theoremServer != null)
                    {
                        LoadTheoremServer(theoremServer);
                    }
                }

                object[] ssas = t.GetCustomAttributes(structreServerType, false);
                if (ssas.Length > 0)
                {
                    foundStructureServer = true;
                    if (instance == null)
                    {
                        instance = Activator.CreateInstance(t, new object[] { context });
                    }
                    IStructureServer structureServer = instance as IStructureServer;
                    if (structureServer != null)
                    {
                        LoadStructureServer(structureServer);
                    }
                }
            }

            if (!foundPackageManager && !foundArchitectureServer && !foundEntityServer && !foundTheoremServer && !foundStructureServer)
            {
                LoadAssemblyManual(assembly);
            }
        }