Ejemplo n.º 1
0
        // On startup, we register the class factories of the COM objects
        // that we serve. This requires the class facgtory name to be
        // equal to the served class name + "ClassFactory".
        private static bool RegisterClassFactories()
        {
            s_ClassFactories = new ArrayList();
            foreach (var type in s_ComObjectTypes)
            {
                var factory = new ClassFactory(type); // Use default context & flags
                s_ClassFactories.Add(factory);
                if (!factory.RegisterClassObject())
                {
                    MessageBox.Show(
                        "Failed to register class factory for " + type.Name,
                        "ASCOM LocalServer",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Stop);
                    return(false);
                }
            }

            ClassFactory.ResumeClassObjects(); // Served objects now go live
            return(true);
        }
Ejemplo n.º 2
0
        //
        // Register the class factories of the COM objects (drivers)
        // that we serve. This requires the class factory name to be
        // equal to the served class name + "ClassFactory".
        //
        private static IEnumerable <ClassFactory> RegisterClassFactories(DriverDiscovery drivers, ILog log)
        {
            var registeredFactories = new List <ClassFactory>();

            foreach (var type in drivers.DiscoveredTypes)
            {
                var factory = new ClassFactory(type); // Use default context & flags
                if (factory.RegisterClassObject())
                {
                    registeredFactories.Add(factory);
                }
                else
                {
                    // This will terminate the application
                    log.Fatal()
                    .Message("Failed to register class factory for {type}", type.Name)
                    .Write();
                }
            }
            ClassFactory.ResumeClassObjects(); // Served objects now go live
            return(registeredFactories);
        }