Пример #1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            SrcMLFileLogger.DefaultLogger.Info("Initializing SrcML.NET Service ...");

            base.Initialize();

            ExtensionDirectory = GetExtensionDirectory();

            SetUpLogger();

            //SetUpCommand(); // SrcML.NET does not need any command so far.

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            //// setup cursor monitoring service
            //cursorMonitor = GetService(typeof(SCursorMonitorService)) as ICursorMonitorService;

            // setup srcML service
            srcMLService = GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService;

            // setup working set registrar
            _workingSetRegistrar = GetService(typeof(SWorkingSetRegistrarService)) as IWorkingSetRegistrarService;
            _workingSetRegistrar.RegisterWorkingSetFactory(new DefaultWorkingSetFactory <CompleteWorkingSet>());

            SetUpDTEEvents();

            SrcMLFileLogger.DefaultLogger.Info("Initialization completed.");
        }
Пример #2
0
        /// <summary>
        /// Creates a new data service
        /// </summary>
        /// <param name="serviceProvider">The container where this service is sited</param>
        /// <param name="taskManagerService">The task manager</param>
        /// <param name="srcMLService">The srcML service</param>
        /// <param name="workingSetService">The working set factory service</param>
        public VsDataService(SrcMLServicePackage serviceProvider, ITaskManagerService taskManagerService, ISrcMLGlobalService srcMLService, IWorkingSetRegistrarService workingSetService)
            : base(serviceProvider, taskManagerService) {
            _srcMLService = srcMLService;
            _workingSetFactories = workingSetService;

            if(_srcMLService.IsMonitoring) {
                _srcMLService_MonitoringStarted(this, new EventArgs());
            }
            Subscribe();
        }
Пример #3
0
        /// <summary>
        /// Step 3: Implement the callback method.
        /// This is the function that will create a new instance of the services the first time a client
        /// will ask for a specific service type. It is called by the base class's implementation of
        /// IServiceProvider.
        /// </summary>
        /// <param name="container">The IServiceContainer that needs a new instance of the service.
        ///                         This must be this package.</param>
        /// <param name="serviceType">The type of service to create.</param>
        /// <returns>The instance of the service.</returns>
        private object CreateService(IServiceContainer container, Type serviceType)
        {
            SrcMLFileLogger.DefaultLogger.Info("    SrcMLServicePackage.CreateService()");

            // Check if the IServiceContainer is this package.
            if (container != this)
            {
                Trace.WriteLine("ServicesPackage.CreateService called from an unexpected service container.");
                return(null);
            }

            // Find the type of the requested service and create it.

            if (typeof(SCursorMonitorService) == serviceType)
            {
                return(new CursorMonitor(this));
            }

            if (typeof(SMethodTrackService) == serviceType)
            {
                return(new MethodTrack(this));
            }

            if (typeof(SSrcMLGlobalService) == serviceType)
            {
                // Build the global service using this package as its service provider.
                ITaskManagerService taskManager = GetService(typeof(STaskManagerService)) as ITaskManagerService;
                return(new VsMonitoringService(this, taskManager));
            }

            if (typeof(SSrcMLDataService) == serviceType)
            {
                ITaskManagerService         taskManager       = GetService(typeof(STaskManagerService)) as ITaskManagerService;
                ISrcMLGlobalService         srcMLService      = GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService;
                IWorkingSetRegistrarService workingSetService = GetService(typeof(SWorkingSetRegistrarService)) as IWorkingSetRegistrarService;

                return(new VsDataService(this, taskManager, srcMLService, workingSetService));
            }

            if (typeof(STaskManagerService) == serviceType)
            {
                return(new TaskManagerService(this, new ConservativeAbbCoreStrategy()));
            }

            if (typeof(SWorkingSetRegistrarService) == serviceType)
            {
                return(new WorkingSetRegistrarService(this));
            }

            // If we are here the service type is unknown, so write a message on the debug output
            // and return null.
            Trace.WriteLine("ServicesPackage.CreateService called for an unknown service type.");
            return(null);
        }
Пример #4
0
        /// <summary>
        /// Creates a new data service
        /// </summary>
        /// <param name="serviceProvider">The container where this service is sited</param>
        /// <param name="taskManagerService">The task manager</param>
        /// <param name="srcMLService">The srcML service</param>
        /// <param name="workingSetService">The working set factory service</param>
        public VsDataService(SrcMLServicePackage serviceProvider, ITaskManagerService taskManagerService, ISrcMLGlobalService srcMLService, IWorkingSetRegistrarService workingSetService)
            : base(serviceProvider, taskManagerService)
        {
            _srcMLService        = srcMLService;
            _workingSetFactories = workingSetService;

            if (_srcMLService.IsMonitoring)
            {
                _srcMLService_MonitoringStarted(this, new EventArgs());
            }
            Subscribe();
        }
Пример #5
0
        /// <summary>
        /// Creates a new data service object
        /// </summary>
        /// <param name="serviceProvider">The service provider where this service is sited</param>
        public SrcMLDataService(IServiceProvider serviceProvider)
        {
            _isMonitoring    = false;
            _isUpdating      = false;
            _serviceProvider = serviceProvider;

            _workingSetFactories = serviceProvider.GetService(typeof(SWorkingSetRegistrarService)) as IWorkingSetRegistrarService;
            _taskManager         = _serviceProvider.GetService(typeof(STaskManagerService)) as ITaskManagerService;
            _srcMLService        = _serviceProvider.GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService;

            if (_srcMLService != null)
            {
                if (_srcMLService.IsMonitoring)
                {
                    RespondToMonitoringStarted(this, new EventArgs());
                }
                SubscribeToEvents();
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a new data service object
        /// </summary>
        /// <param name="serviceProvider">The service provider where this service is sited</param>
        public SrcMLDataService(IServiceProvider serviceProvider) {
            _isMonitoring = false;
            _isUpdating = false;
            _serviceProvider = serviceProvider;

            _workingSetFactories = serviceProvider.GetService(typeof(SWorkingSetRegistrarService)) as IWorkingSetRegistrarService;
            _taskManager = _serviceProvider.GetService(typeof(STaskManagerService)) as ITaskManagerService;
            _srcMLService = _serviceProvider.GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService;
            
            if(_srcMLService != null) {
                if(_srcMLService.IsMonitoring) {
                    RespondToMonitoringStarted(this, new EventArgs());
                }
                SubscribeToEvents();
            }
        }
Пример #7
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize() {
            SrcMLFileLogger.DefaultLogger.Info("Initializing SrcML.NET Service ...");

            base.Initialize();

            ExtensionDirectory = GetExtensionDirectory();

            SetUpLogger();

            //SetUpCommand(); // SrcML.NET does not need any command so far.

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            //// setup cursor monitoring service
            //cursorMonitor = GetService(typeof(SCursorMonitorService)) as ICursorMonitorService;
            
            // setup srcML service
            srcMLService = GetService(typeof(SSrcMLGlobalService)) as ISrcMLGlobalService;

            // setup working set registrar
            _workingSetRegistrar = GetService(typeof(SWorkingSetRegistrarService)) as IWorkingSetRegistrarService;
            _workingSetRegistrar.RegisterWorkingSetFactory(new DefaultWorkingSetFactory<CompleteWorkingSet>());

            SetUpDTEEvents();

            SrcMLFileLogger.DefaultLogger.Info("Initialization completed.");
        }