// Called directly from AutoOpen.
        public static void Register()
        {
            if (IsDisabled())
            {
                return;
            }

            RegisterControlFunction();
            PublishRegistration();

            bool shouldActivate = false;
            var  activeInfo     = GetActiveRegistrationInfo();

            if (activeInfo == null)
            {
                shouldActivate = true;
            }
            else if (RegistrationInfo.CompareVersions(ServerVersion, activeInfo.Version) > 0)
            {
                // Check version
                // We're newer - deactivate the active server and activate ourselves.
                shouldActivate = true;
            }
            // Else we're not activating - there is an active server and it is the same version or newer
            // TODO: Tell it to load our UDFs somehow - maybe call a hidden macro?

            if (shouldActivate)
            {
                var activated = Activate();
            }

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
        }
Пример #2
0
        // Called directly from AutoOpen.
        public static void Register()
        {
            TraceLogger.Initialize();

            Logger.Initialization.Info($"IntelliSenseServer.Register Begin: Version {ServerVersion} in {AppDomain.CurrentDomain.FriendlyName}");
            if (IsDisabled())
            {
                return;
            }

            RegisterControlMacro();
            PublishRegistration();

            bool shouldActivate = false;
            var  activeInfo     = GetActiveRegistrationInfo();

            if (activeInfo == null)
            {
                shouldActivate = true;
            }
            else if (RegistrationInfo.CompareVersions(ServerVersion, activeInfo.Version) > 0)
            {
                // Check version
                // We're newer - deactivate the active server and activate ourselves.
                shouldActivate = true;
            }
            else
            {
                Logger.Initialization.Info($"IntelliSenseServer not being activated now. Active Version: {activeInfo.Version}");
            }
            // Else we're not activating - there is an active server and it is the same version or newer

            if (shouldActivate &&
                (activeInfo == null || DeactivateServer(activeInfo)))
            {
                Activate();
            }

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
            AppDomain.CurrentDomain.ProcessExit  += CurrentDomain_ProcessExit;
            Logger.Initialization.Info("IntelliSenseServer.Register End");
        }