예제 #1
0
        protected override void Initialize()
        {
            var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager));

            OLECRINFO[] crinfo = new OLECRINFO[1];
            crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
            crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime;
            crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
            crinfo[0].uIdleTimeInterval = 0;
            ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID));

            _activityLog = GetService(typeof(SVsActivityLog)) as IVsActivityLog;

            base.Initialize();
            Instance = this;

            _packageDTEEvents = ApplicationObject.Events.DTEEvents;
            _packageDTEEvents.OnBeginShutdown += OnBeginShutdown;
        }
예제 #2
0
        protected override void Initialize()
        {
            // determine whether we're running the experimental instance.
            _isExperimental = false;
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length >= 3 && args[2].Equals("exp", StringComparison.OrdinalIgnoreCase))
            {
                _isExperimental = true;
            }

            // get the product version
            IVsExtensionManager manager     = GetService(typeof(SVsExtensionManager)) as IVsExtensionManager;
            IInstalledExtension myExtension = manager.GetInstalledExtension(PackageId);

            if (myExtension != null)
            {
                ProductVersion = myExtension.Header.Version;
            }

            // Initialize NLog
            if (LogManager.Configuration == null)
            {
                string path = Path.Combine(SettingsDirectory, string.Format("{0}_NLog.config", PackageName));
                if (!File.Exists(path))
                {
                    // Get the template from resources and write it to the directory.
                    if (!Directory.Exists(SettingsDirectory))
                    {
                        Directory.CreateDirectory(SettingsDirectory);
                    }
                    File.WriteAllText(path, GetDefaultNLogConfigFileContents());
                }
                if (File.Exists(path))
                {
                    LogManager.Configuration = new XmlLoggingConfiguration(path);
                    // Register for changes to the config file
                    LogManager.ConfigurationChanged += LogManager_ConfigurationChanged;
                }
            }

            // Get the current logger now, since we have the configuration
            _logger = LogManager.GetCurrentClassLogger();
            _logger.Trace("VS arguments: [{0}]", string.Join(",", args));

            var componentManager = _compMgr = (IOleComponentManager)GetService(typeof(SOleComponentManager));

            OLECRINFO[] crinfo = new OLECRINFO[1];
            crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
            crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime;
            crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
            crinfo[0].uIdleTimeInterval = 0;
            ErrorHandler.ThrowOnFailure(componentManager.FRegisterComponent(this, crinfo, out _componentID));

            _activityLog = GetService(typeof(SVsActivityLog)) as IVsActivityLog;

            base.Initialize();
            Instance = this;

            _packageDTEEvents = ApplicationObject.Events.DTEEvents;
            _packageDTEEvents.OnBeginShutdown += OnBeginShutdown;
        }