Ejemplo n.º 1
0
        public Analyzer()
        {
            LoggingCommand.Initialize();

            _serviceProvider = new ServiceProvider();
            _consoleProvider = new ConsoleService();
            _commandService  = new CommandService();
            _symbolService   = new SymbolService(this);
            _contextService  = new ContextService(this);

            _serviceProvider.AddService <IHost>(this);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService <ICommandService>(_commandService);
            _serviceProvider.AddService <ISymbolService>(_symbolService);
            _serviceProvider.AddService <IContextService>(_contextService);
            _serviceProvider.AddServiceFactory <SOSLibrary>(() => SOSLibrary.Create(this));

            _contextService.ServiceProvider.AddServiceFactory <ClrMDHelper>(() => {
                ClrRuntime clrRuntime = _contextService.Services.GetService <ClrRuntime>();
                return(clrRuntime != null ? new ClrMDHelper(clrRuntime) : null);
            });

            _commandService.AddCommands(new Assembly[] { typeof(Analyzer).Assembly });
            _commandService.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly });
            _commandService.AddCommands(new Assembly[] { typeof(SOSHost).Assembly });
            _commandService.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandService, services));
            _commandService.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop));
        }
Ejemplo n.º 2
0
 internal BindingContext(InvocationContext invocationContext)
 {
     InvocationContext = invocationContext;
     ServiceProvider   = new ServiceProvider(this);
     ServiceProvider.AddService(_ => InvocationContext);
     ServiceProvider.AddService(_ => InvocationContext.GetCancellationToken());
 }
Ejemplo n.º 3
0
        private HostServices()
        {
            _serviceProvider  = new ServiceProvider();
            _symbolService    = new SymbolService(this);
            _commandProcessor = new CommandProcessor(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ">!ext" : null);
            _commandProcessor.AddCommands(new Assembly[] { typeof(HostServices).Assembly });
            _commandProcessor.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly });

            _serviceProvider.AddService <IHost>(this);
            _serviceProvider.AddService <ICommandService>(_commandProcessor);
            _serviceProvider.AddService <ISymbolService>(_symbolService);

            _hostWrapper = new HostWrapper(this);
            _hostWrapper.AddServiceWrapper(IID_IHostServices, this);
            _hostWrapper.AddServiceWrapper(SymbolServiceWrapper.IID_ISymbolService, () => new SymbolServiceWrapper(this));

            VTableBuilder builder = AddInterface(IID_IHostServices, validate: false);

            builder.AddMethod(new GetHostDelegate(GetHost));
            builder.AddMethod(new RegisterDebuggerServicesDelegate(RegisterDebuggerServices));
            builder.AddMethod(new CreateTargetDelegate(CreateTarget));
            builder.AddMethod(new UpdateTargetDelegate(UpdateTarget));
            builder.AddMethod(new FlushTargetDelegate(FlushTarget));
            builder.AddMethod(new DestroyTargetDelegate(DestroyTarget));
            builder.AddMethod(new DispatchCommandDelegate(DispatchCommand));
            builder.AddMethod(new DispatchCommandDelegate(DisplayHelp));
            builder.AddMethod(new UninitializeDelegate(Uninitialize));
            IHostServices = builder.Complete();

            AddRef();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add all the services needed by commands
        /// </summary>
        private void AddServices(DataTarget target)
        {
            _serviceProvider.AddService(target);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService(_commandProcessor);
            _serviceProvider.AddServiceFactory(typeof(IHelpBuilder), _commandProcessor.CreateHelpBuilder);

            // Create common analyze context for commands
            var analyzeContext = new AnalyzeContext()
            {
                CurrentThreadId = unchecked ((int)target.DataReader.EnumerateAllThreads().FirstOrDefault())
            };

            _serviceProvider.AddService(analyzeContext);

            // Add the register, SOSHost and ClrRuntime services
            var registerService = new RegisterService(target);

            _serviceProvider.AddService(registerService);

            _serviceProvider.AddServiceFactory(typeof(ClrRuntime), () => CreateRuntime(target));

            _serviceProvider.AddServiceFactory(typeof(SOSHost), () => {
                var sosHost = new SOSHost(_serviceProvider);
                sosHost.InitializeSOSHost(s_tempDirectory, _dacFilePath, dbiFilePath: null);
                return(sosHost);
            });
        }
Ejemplo n.º 5
0
        private void ExecutePostBuildAdaptations(ILogger logger, List <AdaptationUsage> usages)
        {
            if (usages.All(u => u.PostBuildMethod == null))
            {
                logger.Info("There is no discovered adaptations with post build instructions");
                return;
            }

            logger.Info("Executing discovered adaptations with post build instructions");

            foreach (var usage in Sort(usages))
            {
                var method = usage.PostBuildMethod;
                if (method == null)
                {
                    logger.Debug("Adaptation does not contain void PostBuild(IServiceProvider provider) method. Skipping...");
                    continue;
                }

                var attribute = usage.Attribute;
                if (attribute == null)
                {
                    try
                    {
                        attribute = usage.AttributeData.CreateAttribute();
                    }
                    catch (Exception e)
                    {
                        logger.Warn($"Could not create adaptation attribute. Details: {e.GetBaseException().Message}.");
                        continue;
                    }
                }

                try
                {
                    logger.Info("------------");
                    logger.Info($"Adaptation: {usage.AttributeData}");

                    var serviceProvider = new ServiceProvider();
                    serviceProvider.AddService(typeof(CSharpCompilation), _compilation);
                    serviceProvider.AddService(typeof(SyntaxNode), usage.AssociatedSyntaxNode);
                    serviceProvider.AddService(typeof(SyntaxTree), usage.SyntaxTree);
                    serviceProvider.AddService(typeof(SemanticModel), usage.SemanticModel);
                    serviceProvider.AddService(typeof(ILogger), new ScopeLogger(logger));
                    serviceProvider.AddService(typeof(IExplorer), _explorer);
                    serviceProvider.AddService(typeof(INugetExplorer), _nugetExplorer);
                    serviceProvider.AddService(typeof(IDynamicVault), _dynamicVault);
                    serviceProvider.AddService(typeof(IMacroResolver), _macroResolver);

                    method.Invoke(attribute, new object[] { serviceProvider });
                }
                catch (Exception e)
                {
                    logger.Error($"Adaptation failed. Details: {e.GetBaseException().Message}.");
                }
            }
        }
Ejemplo n.º 6
0
        public TestDump(TestConfiguration config)
            : base(config)
        {
            _serviceProvider = new ServiceProvider();
            _contextService  = new ContextService(this);
            _symbolService   = new SymbolService(this);
            _serviceProvider.AddService <IContextService>(_contextService);
            _serviceProvider.AddService <ISymbolService>(_symbolService);

            // Automatically enable symbol server support
            _symbolService.AddSymbolServer(msdl: true, symweb: false, timeoutInMinutes: 6, retryCount: 5);
            _symbolService.AddCachePath(_symbolService.DefaultSymbolCache);
        }
Ejemplo n.º 7
0
        public DatabaseTool(
            [CanBeNull] IServiceProvider serviceProvider,
            [NotNull] ILoggerProvider loggerProvider)
        {
            Check.NotNull(loggerProvider, nameof(loggerProvider));

            _serviceProvider = new ServiceProvider(serviceProvider);
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddProvider(loggerProvider);
            _logger = new LazyRef <ILogger>(() => loggerFactory.CreateLogger <DatabaseTool>());
            _serviceProvider.AddService(typeof(ILogger), _logger.Value);
            _serviceProvider.AddService(typeof(CSharpCodeGeneratorHelper), new CSharpCodeGeneratorHelper());
            _serviceProvider.AddService(typeof(ModelUtilities), new ModelUtilities());
        }
Ejemplo n.º 8
0
 private void RegisterServices()
 {
     ServiceProvider.AddService <ITokenStorage>(new InternalTokenStorage(ApplicationInfo.DataDir));
     ServiceProvider.AddService(new AuthorizationViewModel());
     ServiceProvider.AddService(new ScoreBoardViewModel());
     ServiceProvider.AddService(new OmlViewModel());
 }
Ejemplo n.º 9
0
        public Analyzer()
        {
            _serviceProvider  = new ServiceProvider();
            _consoleProvider  = new ConsoleProvider();
            _commandProcessor = new CommandProcessor();
            _symbolService    = new SymbolService(this);

            _serviceProvider.AddService <IHost>(this);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService <ICommandService>(_commandProcessor);
            _serviceProvider.AddService <ISymbolService>(_symbolService);

            _commandProcessor.AddCommands(new Assembly[] { typeof(Analyzer).Assembly });
            _commandProcessor.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandProcessor, services));
            _commandProcessor.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop));
        }
Ejemplo n.º 10
0
        private ServiceProvider SetupServiceProvider()
        {
#if DNX451 || DNXCORE50
            // provides ILibraryManager etc services
            var serviceProvider = new ServiceProvider(
                CallContextServiceLocator.Locator.ServiceProvider);
#else
            var serviceProvider = new ServiceProvider(null);
#endif
            serviceProvider.AddService(typeof(CSharpCodeGeneratorHelper), new CSharpCodeGeneratorHelper());
            serviceProvider.AddService(typeof(ModelUtilities), new ModelUtilities());
            var metadataReferencesProvider = new MetadataReferencesProvider(serviceProvider);
            serviceProvider.AddService(typeof(MetadataReferencesProvider), metadataReferencesProvider);
            var compilationService = new RoslynCompilationService();
            serviceProvider.AddService(typeof(ITemplating), new RazorTemplating(compilationService, metadataReferencesProvider));

            return(serviceProvider);
        }
Ejemplo n.º 11
0
        public CrosslightAppAppService(IApplicationContext context)
            : base(context)
        {
            Container.Current.Register <IItemRepository>((c) => new ItemRepository()).WithLifetimeManager(new ContainerLifetime());
            Container.Current.Register <ICategoryRepository>((c) => new CategoryRepository()).WithLifetimeManager(new ContainerLifetime());

            ServiceProvider.AddService <IResourceLoaderService, ResourceLoaderService>();
            ServiceProvider.AddService <IResourceCacheService, ResourceCacheService>();
            ServiceProvider.AddService <IImageLoaderService, ImageLoaderService>();
        }
Ejemplo n.º 12
0
 void InitializeDefaults()
 {
     if (StartWorkflowOnObjectChangeService != null)
     {
         ServiceProvider.AddService(StartWorkflowOnObjectChangeService);
     }
     if (ScheduledWorkflowStartService != null)
     {
         ServiceProvider.AddService(ScheduledWorkflowStartService);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Add all the services needed by commands
        /// </summary>
        private void AddServices(DataTarget target)
        {
            _serviceProvider.AddService(target);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService(_commandProcessor);
            _serviceProvider.AddServiceFactory(typeof(IHelpBuilder), _commandProcessor.CreateHelpBuilder);

            // Create common analyze context for commands
            var analyzeContext = new AnalyzeContext()
            {
                CurrentThreadId = target.DataReader.EnumerateAllThreads().FirstOrDefault()
            };

            _serviceProvider.AddService(analyzeContext);

            // Add the thread, memory, SOSHost and ClrRuntime services
            var threadService = new ThreadService(target.DataReader);

            _serviceProvider.AddService <IThreadService>(threadService);

            var memoryService = new MemoryService(target.DataReader);

            _serviceProvider.AddService(memoryService);

            _serviceProvider.AddServiceFactory(typeof(ClrRuntime), () => CreateRuntime(target));

            _serviceProvider.AddServiceFactory(typeof(SOSHost), () => {
                var sosHost = new SOSHost(_serviceProvider);
                sosHost.InitializeSOSHost(SymbolReader.TempDirectory, _isDesktop, _dacFilePath, dbiFilePath: null);
                return(sosHost);
            });
        }
Ejemplo n.º 14
0
        public WarpSceneRenderer(Scene scene, int width, int height)
        {
            _scene       = scene;
            _width       = width;
            _height      = height;
            _aspectRatio = width / (float)height;

            _device = GraphicsDevice.New(DriverType.Warp, DeviceCreationFlags.None, FeatureLevel.Level_10_1);

            var serviceProvider = new ServiceProvider();

            serviceProvider.AddService <IGraphicsDeviceService>(new GraphicsDeviceService(_device));

            _contentManager = new ContentManager(serviceProvider);
            _contentManager.Resolvers.Add(new ContentResolver());

            var viewport = new Viewport(0, 0, _width, _height);

            _device.SetViewports(viewport);

            const MSAALevel msaaLevel = MSAALevel.None;

            _depthStencilTexture = DepthStencilBuffer.New(_device, _width, _height, msaaLevel, DepthFormat.Depth24Stencil8);
            _renderTexture       = RenderTarget2D.New(_device, _width, _height, msaaLevel, PixelFormat.R8G8B8A8.UNorm);

            Options = new RenderOptions();

            _effect = new BasicEffect(_device);
            _effect.EnableDefaultLighting();

            _inputLayout = VertexInputLayout.New(0, typeof(VertexPositionNormalTexture));
            _device.SetVertexInputLayout(_inputLayout);

            _meshes = new List <WarpMesh>();
            foreach (Mesh mesh in _scene.Meshes)
            {
                if (!mesh.Positions.Any())
                {
                    continue;
                }

                var warpMesh = new WarpMesh(_device, mesh);
                _meshes.Add(warpMesh);

                warpMesh.Initialize(_contentManager);
            }
        }
Ejemplo n.º 15
0
        public static Manifest FromManifestFile(string pathToManifestFile)
        {
            var services = new ServiceProvider();

            services.AddService(FileSystem.Default); // Add as extended for our code
            var catalog    = Catalog.Parse(services, pathToManifestFile);
            var dictionary = new Dictionary <string, IPackage>();

            foreach (var package in catalog.Packages)
            {
                if (!dictionary.ContainsKey(package.Id.ToLower()))
                {
                    dictionary.Add(package.Id.ToLower(), package);
                }
            }

            return(new Manifest(dictionary));
        }
Ejemplo n.º 16
0
		public WarpSceneRenderer(Scene scene, int width, int height)
		{
			_scene = scene;
			_width = width;
			_height = height;
			_aspectRatio = width / (float)height;

			_device = GraphicsDevice.New(DriverType.Warp, DeviceCreationFlags.None, FeatureLevel.Level_10_1);

			var serviceProvider = new ServiceProvider();
			serviceProvider.AddService<IGraphicsDeviceService>(new GraphicsDeviceService(_device));

			_contentManager = new ContentManager(serviceProvider);
			_contentManager.Resolvers.Add(new ContentResolver());

			var viewport = new Viewport(0, 0, _width, _height);
			_device.SetViewports(viewport);

			const MSAALevel msaaLevel = MSAALevel.None;
			_depthStencilTexture = DepthStencilBuffer.New(_device, _width, _height, msaaLevel, DepthFormat.Depth24Stencil8);
			_renderTexture = RenderTarget2D.New(_device, _width, _height, msaaLevel, PixelFormat.R8G8B8A8.UNorm);

			Options = new RenderOptions();

			_effect = new BasicEffect(_device);
			_effect.EnableDefaultLighting();

			_inputLayout = VertexInputLayout.New(0, typeof(VertexPositionNormalTexture));
			_device.SetVertexInputLayout(_inputLayout);

			_meshes = new List<WarpMesh>();
			foreach (Mesh mesh in _scene.Meshes)
			{
				if (!mesh.Positions.Any())
					continue;

				var warpMesh = new WarpMesh(_device, mesh);
				_meshes.Add(warpMesh);

				warpMesh.Initialize(_contentManager);
			}
		}
            public ModuleFromDebuggerServices(
                ModuleServiceFromDebuggerServices moduleService,
                int moduleIndex,
                string imageName,
                ulong imageBase,
                ulong imageSize,
                uint indexFileSize,
                uint indexTimeStamp)
                : base(moduleService.Target)
            {
                _moduleService = moduleService;
                ModuleIndex    = moduleIndex;
                FileName       = imageName;
                ImageBase      = imageBase;
                ImageSize      = imageSize;
                IndexFileSize  = indexTimeStamp == InvalidTimeStamp ? null : indexFileSize;
                IndexTimeStamp = indexTimeStamp == InvalidTimeStamp ? null : indexTimeStamp;

                ServiceProvider.AddService <IModuleSymbols>(this);
            }
Ejemplo n.º 18
0
        /// <summary>
        /// Add all the services needed by commands
        /// </summary>
        private void AddServices(DataTarget target)
        {
            _serviceProvider.AddService(target);
            _serviceProvider.AddService(target.DataReader);
            _serviceProvider.AddService <IConsoleService>(_consoleProvider);
            _serviceProvider.AddService(_commandProcessor);
            _serviceProvider.AddServiceFactory(typeof(IHelpBuilder), _commandProcessor.CreateHelpBuilder);

            if (!(target.DataReader is IThreadReader threadReader))
            {
                throw new InvalidOperationException("IThreadReader not implemented");
            }

            // Create common analyze context for commands
            var analyzeContext = new AnalyzeContext()
            {
                CurrentThreadId = threadReader.EnumerateOSThreadIds().FirstOrDefault()
            };

            _serviceProvider.AddService(analyzeContext);

            // Add the thread, memory, SOSHost and ClrRuntime services
            var threadService = new ThreadService(target.DataReader);

            _serviceProvider.AddService <IThreadService>(threadService);

            var memoryService = new MemoryService(target.DataReader);

            _serviceProvider.AddService(memoryService);

            _serviceProvider.AddServiceFactory(typeof(ClrRuntime), () => CreateRuntime(target));

            _serviceProvider.AddServiceFactory(typeof(SOSHost), () => {
                var sosHost = new SOSHost(_serviceProvider);
                sosHost.InitializeSOSHost(SymbolReader.TempDirectory, _isDesktop, _dacFilePath, dbiFilePath: null);
                return(sosHost);
            });

            // ClrMD helper for extended commands
            _serviceProvider.AddServiceFactory(typeof(ClrMDHelper), () =>
                                               new ClrMDHelper(_serviceProvider)
                                               );
        }
Ejemplo n.º 19
0
        public CrosslightAppAppService(IApplicationContext context)
            : base(context)
        {
            // To learn more about social network integrations,
            // please refer to http://developer.intersoftpt.com/display/crosslight/Integration+with+Social+Networks

            // configure app settings
            AppSettings appSettings = new AppSettings();

            appSettings.SingleSignOnAppId          = "PropertyCross_Intersoft";
            appSettings.WebServerUrl               = "http://192.168.10.85:57315";
            appSettings.BaseAppUrl                 = appSettings.WebServerUrl;
            appSettings.BaseImageUrl               = appSettings.BaseAppUrl + "/images/";
            appSettings.RestServiceUrl             = appSettings.BaseAppUrl + "/data/Inventory";
            appSettings.RequiresInternetConnection = true;
            appSettings.LocalDatabaseName          = "PropertyCross.db3";
            appSettings.LocalDatabaseLocation      = LocalFolderKind.Data;

            // shared services registration
            this.GetService <ITypeResolverService>().Register(typeof(CrosslightAppAppService).Assembly);

            // components specific registration
            this.GetService <IActivatorService>().Register <IRestClient>(c => new RestClient(appSettings.RestServiceUrl));

            // application-specific containers registration
            // such as data repositories and account services
            Container.Current.RegisterInstance(appSettings);
            Container.Current.Register <IEntityContainer>("Default", c => new EntityContainer()).WithLifetimeManager(new ContainerLifetime());

            // for best practices, data repositories shouldn't use life-time container
            Container.Current.Register <IPropertyRepository>(c => new PropertyRepository());

            // add new services (extensions)
            ServiceProvider.AddService <IResourceLoaderService, ResourceLoaderService>();
            ServiceProvider.AddService <IResourceCacheService, ResourceCacheService>();
            ServiceProvider.AddService <IImageLoaderService, ImageLoaderService>();
            ServiceProvider.AddService <ISQLiteService, SQLiteService>();
        }
Ejemplo n.º 20
0
        public DatabaseTool(
            [CanBeNull] IServiceProvider serviceProvider,
            [NotNull] ILoggerProvider loggerProvider)
        {
            Check.NotNull(loggerProvider, nameof(loggerProvider));

            _serviceProvider = new ServiceProvider(serviceProvider);
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddProvider(loggerProvider);
            _logger = new LazyRef <ILogger>(() => loggerFactory.CreateLogger <DatabaseTool>());
            _serviceProvider.AddService(typeof(ILogger), _logger.Value);
            _serviceProvider.AddService(typeof(IFileService), new FileSystemFileService());
            _serviceProvider.AddService(typeof(CSharpCodeGeneratorHelper), new CSharpCodeGeneratorHelper());
            _serviceProvider.AddService(typeof(ModelUtilities), new ModelUtilities());
            var metadataReferencesProvider = new MetadataReferencesProvider(_serviceProvider);

            _serviceProvider.AddService(typeof(MetadataReferencesProvider), metadataReferencesProvider);
            var compilationService = new RoslynCompilationService();

            _serviceProvider.AddService(typeof(ITemplating), new RazorTemplating(compilationService, metadataReferencesProvider));
        }
Ejemplo n.º 21
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load Assets
            Assets.LoadContent(Content);

            // A style for buttons to use.
            ControlStyle buttonStyle = new ControlStyle(
                Assets.Button,
                Assets.ButtonHover,
                Assets.ButtonPressed,
                null,
                Rectangle.Empty
                );

            buttonStyle.FontStyle = new FontStyle(Assets.Font_MineCraftia11, Color.White);


            // Control Manager - updates / draws all controls
            WindowContentManager = new ContentManager(
                GraphicsDevice,
                new AnchoredRectangle(
                    0, 0,
                    Graphics.PreferredBackBufferWidth,
                    Graphics.PreferredBackBufferHeight
                    )
                );


            // Panel:
            ControlStyle panelStyle = new ControlStyle(Assets.Panel_Bg);

            panelStyle.FontStyle     = buttonStyle.FontStyle;
            panelStyle.ScrollerStyle = Assets.ScrollerStyle;


            myPanel = new Panel("Test Window", panelStyle, true, true);
            // HACKY HACK HACK - hard coding for simplicity right now
            myPanel.MoveTo(new Vector2(200, 350));
            myPanel.DragAreaOffset = new Rectangle(5, 1, 488, 25);
            myPanel.SetContentArea(40, 37, 417, 445);


            // Button:
            Button btn = new Button("Click Me", buttonStyle);

            btn.OnClicked += btn_click;
            btn.AnchorTo(myPanel, PositionType.Inside_Top_Left, 40, 75, AnchorType.Bounds);

            // Label:  will re-use the same FontStyle as buttons
            Label myLabel1 =
                new Label("Scroll Down?", buttonStyle.FontStyle);

            myLabel1.AnchorTo(btn, PositionType.Below_Left, 0, 50, AnchorType.Bounds);

            Label myLabel2 =
                new Label("-- That's All Folks! --", buttonStyle.FontStyle);

            myLabel2.AnchorTo(myLabel1, PositionType.Below_Left, 0, 150, AnchorType.Bounds);

            myPanel.ContentManager.Add(btn);
            myPanel.ContentManager.Add(myLabel1);
            myPanel.ContentManager.Add(myLabel2);

            WindowContentManager.Add(myPanel);      // Important :)


            // FPS Counter:
            // ServiceProvider.AddService(new FramesPerSecondCounter(100));

            // Dev Console
            ControlStyle styleDevConsole = new ControlStyle(Assets.DevConsole_Bg);

            styleDevConsole.FontStyle = buttonStyle.FontStyle;

            var console = new DevConsole(GraphicsDevice, Keys.OemTilde, new Panel("DevConsole", styleDevConsole));

            console.TextStartPosition = new Vector2(15, 20);

            ServiceProvider.AddService(console);

            // Cursor - note this needs to be added last
            ServiceProvider.AddService(new Cursor(this));
            ServiceProvider.GetService <Cursor>().SetCursor(Assets.Cursor);
        }
Ejemplo n.º 22
0
        private HResult RegisterDebuggerServices(
            IntPtr self,
            IntPtr iunk)
        {
            if (iunk == IntPtr.Zero || DebuggerServices != null)
            {
                return(HResult.E_FAIL);
            }
            // Create the wrapper for the host debugger services
            try
            {
                DebuggerServices = new DebuggerServices(iunk, HostType);
            }
            catch (InvalidCastException ex)
            {
                Trace.TraceError(ex.Message);
                return(HResult.E_NOINTERFACE);
            }
            try
            {
                var remoteMemoryService = new RemoteMemoryService(iunk);
                _serviceProvider.AddService <IRemoteMemoryService>(remoteMemoryService);
            }
            catch (InvalidCastException)
            {
            }
            HResult hr;

            try
            {
                var consoleService = new ConsoleServiceFromDebuggerServices(DebuggerServices);
                _serviceProvider.AddService <IConsoleService>(consoleService);
                _serviceProvider.AddServiceFactory <IThreadUnwindService>(() => new ThreadUnwindServiceFromDebuggerServices(DebuggerServices));
                Trace.TraceInformation("HostServices.RegisterDebuggerServices");

                // Add each extension command to the native debugger
                foreach ((string name, string help, IEnumerable <string> aliases) in _commandProcessor.Commands)
                {
                    hr = DebuggerServices.AddCommand(name, help, aliases);
                    if (hr != HResult.S_OK)
                    {
                        Trace.TraceWarning($"Cannot add extension command {hr:X8} {name} - {help}");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                return(HResult.E_FAIL);
            }
            hr = DebuggerServices.GetSymbolPath(out string symbolPath);
            if (hr == HResult.S_OK)
            {
                if (!_symbolService.ParseSymbolPath(symbolPath))
                {
                    Trace.TraceError("ParseSymbolPath FAILED: {0}", symbolPath);
                }
            }
            else
            {
                Trace.TraceError("DebuggerServices.GetSymbolPath FAILED: {0:X8}", hr);
            }
            return(HResult.S_OK);
        }
Ejemplo n.º 23
0
 private void RegisterServices()
 {
     ServiceProvider.AddService <ITokenStorage>(new InternalTokenStorage(ApplicationContext.DataDir.AbsolutePath));
     ServiceProvider.AddService(new AuthorizationViewModel());
 }
Ejemplo n.º 24
0
 public void InitializeServices(IApplicationHost appHost)
 {
     ServiceProvider.AddService <IApplicationStateService, ApplicationStateService>();
 }
Ejemplo n.º 25
0
        private SerializableArtifact[] ExecutePreBuildAdaptationsInternal(ILogger logger)
        {
            var result = new List <SerializableArtifact>();

            var adaptationTypes = SearchCompiledAdaptations(logger);

            if (!adaptationTypes.Any())
            {
                logger.Info("Assembly references do not contains adaptation attributes.");
                return(result.ToArray());
            }

            var syntaxTrees = CreateSyntaxTrees();

            var suspiciousAttributeSyntaxes = AnalyzeSyntaxForAdaptationUsages(adaptationTypes, syntaxTrees, logger);

            if (!suspiciousAttributeSyntaxes.Any())
            {
                logger.Info("Assembly does not use any defined adaptation attribute.");
                return(result.ToArray());
            }

            _compilation = CreateCompilation(syntaxTrees.Select(t => t.Item2), logger);
            if (_compilation == null)
            {
                throw new Exception("Can not create compilation");
            }

            _usages = AnalyzeSemanticForAdaptationUsages(suspiciousAttributeSyntaxes, _compilation, logger);

            if (!_usages.Any())
            {
                logger.Info("Assembly does not use any defined adaptation attribute.");
                return(result.ToArray());
            }

            var setupMethods = new List <MethodInfo>();

            foreach (var usage in Sort(_usages))
            {
                setupMethods.AddRange(usage.SetupMethods);
            }

            if (setupMethods.Any())
            {
                logger.Info("Setup adaptations");
                var calledMethods = new List <MethodInfo>();
                foreach (var method in setupMethods)
                {
                    if (calledMethods.Contains(method))
                    {
                        continue;
                    }
                    calledMethods.Add(method);

                    logger.Info("------------");
                    logger.Info($"Setup: {method.DeclaringType?.Name} type");

                    var serviceProvider = new ServiceProvider();
                    serviceProvider.AddService(typeof(ILogger), new ScopeLogger(logger));
                    serviceProvider.AddService(typeof(IExplorer), _explorer);
                    serviceProvider.AddService(typeof(INugetExplorer), _nugetExplorer);
                    serviceProvider.AddService(typeof(IDynamicVault), _dynamicVault);
                    serviceProvider.AddService(typeof(IMacroResolver), _macroResolver);
                    method.Invoke(null, new object[] { serviceProvider });
                }
            }

            var artifacts = new List <Artifact>();

            artifacts.AddRange(ExecutePreBuildAdaptations(_usages, logger));

            using (var cacheManager = new CacheManager <ArtifactCache>(_explorer.Directories[BuildDirectory.Intermediate], logger))
            {
                HandleArtifactsContent(artifacts, cacheManager, logger);
                artifacts.Add(new Artifact(cacheManager.GetCachePath(), BuildItem.Internal));
            }

            result.AddRange(artifacts.Select(a => a.Serialize()));

            return(result.ToArray());
        }
 public void InitializeServices(IApplicationHost appHost)
 {
     ServiceProvider.AddService <IApplicationStateService, ApplicationStateService>();
     ServiceProvider.GetService <IPresenterService>().Register <ICustomPresenter, WindowsCustomPresenter>();
 }
        private void LoadTextures()
        {
            bool exportTexturesToFiles = false;
            Form graphicsDeviceForm = new Form();
            graphicsDeviceForm.Size = new Size(256, 256);

            PresentationParameters presentationParameters = new PresentationParameters();
            presentationParameters.IsFullScreen = false;
            presentationParameters.DeviceWindowHandle = graphicsDeviceForm.Handle;

            // We don't need an advanced adaptor. One that can support DirectX 9
            // is prefectly fine for exporting the textures.
            var adaptorQuery =
                from adaptor in GraphicsAdapter.Adapters
                where adaptor.IsProfileSupported(GraphicsProfile.Reach)
                select adaptor;

            GraphicsAdapter adapter = adaptorQuery.FirstOrDefault();

            // Fallback to the default.
            if (adapter == null) {
                adapter = GraphicsAdapter.DefaultAdapter;
            }

            GraphicsDevice graphicsDevice = new GraphicsDevice(adapter, GraphicsProfile.Reach, presentationParameters);

            ServiceProvider serviceProvider = new ServiceProvider();
            serviceProvider.AddService(typeof(IGraphicsDeviceService), new GraphicsDeviceService(graphicsDevice));

            ContentManager content = new ContentManager(serviceProvider, Path.Combine(options.TerrariaDirectory, "Content"));

            for (int i = 0; i < World.NumTiles; i++) {
                textures.tileTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\tiles_" + i));

                if (exportTexturesToFiles) {
                    textures.tileTexture[i].Save("Tile" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 1; i < 14; i++) {
                textures.wallTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Wall_" + i));

                if (exportTexturesToFiles) {
                    textures.wallTexture[i].Save("Wall" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 7; i++) {
                textures.backgroundTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Background_" + i));

                if (exportTexturesToFiles) {
                    textures.backgroundTexture[i].Save("Background" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 44; i++) {
                textures.npcTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\NPC_" + i));

                if (exportTexturesToFiles) {
                    textures.npcTexture[i].Save("Npc" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 4; i++) {
                textures.cloudTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Cloud_" + i));

                if (exportTexturesToFiles) {
                    textures.cloudTexture[i].Save("Cloud" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 2; i++) {
                textures.liquidTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Liquid_" + i));

                if (exportTexturesToFiles) {
                    textures.liquidTexture[i].Save("Liquid" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 3; i++) {
                textures.treeTopTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Tree_Tops_" + i));

                if (exportTexturesToFiles) {
                    textures.treeTopTexture[i].Save("TreeTop" + i + ".png", ImageFormat.Png);
                }
            }

            for (int i = 0; i < 3; i++) {
                textures.treeBranchTexture[i] = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Tree_Branches_" + i));

                if (exportTexturesToFiles) {
                    textures.treeBranchTexture[i].Save("TreeBranch" + i + ".png", ImageFormat.Png);
                }
            }

            textures.sunTexture = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Sun"));

            if (exportTexturesToFiles) {
                textures.sunTexture.Save("SunTexture.png", ImageFormat.Png);
            }

            textures.moonTexture = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Moon"));

            if (exportTexturesToFiles) {
                textures.moonTexture.Save("MoonTexture.png", ImageFormat.Png);
            }

            textures.shroomCapTexture = ConvertTextureToImage(content.Load<Texture2D>(@"Images\Shroom_Tops"));

            if (exportTexturesToFiles) {
                textures.shroomCapTexture.Save("ShroomCapTexture.png", ImageFormat.Png);
            }
        }