public AddService ( |
||
serviceType | ||
callback | ServiceCreatorCallback | |
리턴 | void |
private void BuildTest(Address addrBase, IPlatform platform , Action<X86Assembler> asmProg) { var sc = new ServiceContainer(); sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener()); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); var entryPoints = new List<EntryPoint>(); var asm = new X86Assembler(sc, platform, addrBase, entryPoints); asmProg(asm); var lr = asm.GetImage(); program = new Program( lr.Image, lr.ImageMap, arch, platform); var project = new Project { Programs = { program } }; scanner = new Scanner( program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), sc); scanner.EnqueueEntryPoint(new EntryPoint(addrBase, arch.CreateProcessorState())); scanner.ScanImage(); }
public void Setup() { mr = new MockRepository(); mockFactory = new MockFactory(mr); var platform = mockFactory.CreatePlatform(); var imageMap = new SegmentMap(Address32.Ptr32(0x05)); program = new Program(imageMap, platform.Architecture, platform); interactor = new CombinedCodeViewInteractor(); var uiPreferencesSvc = mr.Stub<IUiPreferencesService>(); var uiSvc = mr.Stub<IDecompilerShellUiService>(); var styles = new Dictionary<string, UiStyle>() { { UiStyles.CodeWindow, new UiStyle { Background = new SolidBrush(Color.White), } } }; uiPreferencesSvc.Stub(u => u.Styles).Return(styles); var sc = new ServiceContainer(); sc.AddService<IUiPreferencesService>(uiPreferencesSvc); sc.AddService<IDecompilerShellUiService>(uiSvc); interactor.SetSite(sc); }
protected Program RewriteFile(string relativePath, Address addrBase) { var sc = new ServiceContainer(); var config = new FakeDecompilerConfiguration(); sc.AddService<IConfigurationService>(config); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener()); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); ILoader ldr = new Loader(sc); var program = ldr.AssembleExecutable( FileUnitTester.MapTestPath(relativePath), new X86TextAssembler(sc, new IntelArchitecture(ProcessorMode.Real)), addrBase); program.Platform = new DefaultPlatform(sc, program.Architecture); var ep = new EntryPoint(program.Image.BaseAddress, program.Architecture.CreateProcessorState()); var project = new Project { Programs = { program } }; var scan = new Scanner( program, new Dictionary<Address, ProcedureSignature>(), new ImportResolver(project), sc); scan.EnqueueEntryPoint(ep); scan.ScanImage(); var dfa = new DataFlowAnalysis(program, new FakeDecompilerEventListener()); dfa.AnalyzeProgram(); return program; }
public void Sgrom_LoadImage() { var sc = new ServiceContainer(); var cfgSvc = mr.Stub<IConfigurationService>(); var openv = mr.Stub<OperatingEnvironment>(); var diagSvc = mr.StrictMock<IDiagnosticsService>(); var arch = new M68kArchitecture(); var platform = new SegaGenesisPlatform(sc, arch); cfgSvc.Expect(c => c.GetArchitecture("m68k")).Return(arch); cfgSvc.Expect(c => c.GetEnvironment("sega-genesis")).Return(openv); openv.Expect(o => o.Load(sc, arch)).Return(platform); sc.AddService<IConfigurationService>(cfgSvc); sc.AddService<IDiagnosticsService>(diagSvc); Given_AbsoluteMemoryMap(platform); mr.ReplayAll(); var rawBytes = new byte[0x300]; var sgrom = new RomLoader(sc, "foo.bin", rawBytes); var program = sgrom.Load(Address.Ptr32(0)); var romSegment = program.SegmentMap.Segments.Values.First(); Assert.IsNotNull(romSegment.MemoryArea, "ROM image should have been loaded into first segment"); Assert.AreSame(rawBytes, romSegment.MemoryArea.Bytes, "ROM image should have been loaded into first segment"); Assert.AreEqual(rawBytes.Length, romSegment.ContentSize); var ramSegment = program.SegmentMap.Segments.Values.First(s => s.Name == ".data"); Assert.IsNotNull(ramSegment.MemoryArea, "RAM segment should have a MemoryArea"); }
public void SysV_TerminatingFunction() { var mr = new MockRepository(); var sc = new ServiceContainer(); var arch = mr.Stub<IProcessorArchitecture>(); var tlSvc = mr.Stub<ITypeLibraryLoaderService>(); var cfgSvc = mr.Stub<IConfigurationService>(); sc.AddService<IConfigurationService>(cfgSvc); sc.AddService<ITypeLibraryLoaderService>(tlSvc); cfgSvc.Stub(c => c.GetEnvironment(null)) .IgnoreArguments() .Return(new OperatingEnvironmentElement { TypeLibraries = { new TypeLibraryElement { Name="libc.xml" } }, CharacteristicsLibraries = { new TypeLibraryElement { Name="libcharacteristics.xml", } } }); tlSvc.Stub(t => t.LoadCharacteristics(null)) .IgnoreArguments() .Return(new CharacteristicsLibrary { Entries = { { "exit", new ProcedureCharacteristics { Terminates = true } } } }); tlSvc.Stub(t => t.LoadLibrary(null, null)) .IgnoreArguments() .Return(new TypeLibrary { Signatures = { { "exit", new ProcedureSignature(null) } } }); mr.ReplayAll(); var sysv = new SysVPlatform(sc, arch); var proc = sysv.LookupProcedureByName(null, "exit"); Assert.IsTrue(proc.Characteristics.Terminates, "exit should have been marked as terminating."); }
protected Program RewriteFile(string relativePath, Address addrBase) { sc = new ServiceContainer(); var config = new FakeDecompilerConfiguration(); var eventListener = new FakeDecompilerEventListener(); sc.AddService<IConfigurationService>(config); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); sc.AddService<DecompilerEventListener>(eventListener); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); ILoader ldr = new Loader(sc); var program = ldr.AssembleExecutable( FileUnitTester.MapTestPath(relativePath), new X86TextAssembler(sc, new X86ArchitectureReal()), addrBase); program.Platform = new DefaultPlatform(sc, program.Architecture); var ep = new ImageSymbol(program.SegmentMap.BaseAddress); var project = new Project { Programs = { program } }; var scan = new Scanner( program, new ImportResolver(project, program, eventListener), sc); scan.EnqueueImageSymbol(ep, true); scan.ScanImage(); var importResolver = new ImportResolver(project, program, eventListener); var dfa = new DataFlowAnalysis(program, importResolver, eventListener); dfa.AnalyzeProgram(); return program; }
public static void InitializeServices(Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleProvider) { if (oleProvider == null) { throw new ArgumentNullException("oleProvider"); } if (!servicesInitialized) { try { serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(oleProvider); container = new System.ComponentModel.Design.ServiceContainer(serviceProvider); componentHost = new VsShellComponentModelHost(oleProvider); catalogProvider = new VsCatalogProvider(componentHost); globalCatalog = catalogProvider.GetCatalog("Microsoft.VisualStudio.Default"); if (globalCatalog == null) { throw new InvalidOperationException("T4 Composition services initialization error: Failed to get default composition catalog."); } composition = VsCompositionContainer.Create(globalCatalog); composition.ComposeExportedValue <SVsServiceProvider>(new VsServiceProviderWrapper(container)); localComponentModel = new LocalComponentModel(catalogProvider, composition); container.AddService(typeof(SComponentModel), localComponentModel); container.AddService(typeof(IComponentModel), localComponentModel); AppDomain.CurrentDomain.ProcessExit += new EventHandler(Microsoft.VisualStudio.TextTemplating.VSHost.CompositionServices.CurrentDomain_Cleanup); AppDomain.CurrentDomain.DomainUnload += new EventHandler(Microsoft.VisualStudio.TextTemplating.VSHost.CompositionServices.CurrentDomain_Cleanup); servicesInitialized = true; } catch (Exception) { CleanupFields(); throw; } } }
public void Setup() { mr = new MockRepository(); sc = new ServiceContainer(); svc = new DecompilerService(); sc.AddService(typeof(IDecompilerService), svc); sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener()); }
public void Setup() { mr = new MockRepository(); sc = new ServiceContainer(); listener = mr.Stub<DecompilerEventListener>(); sc.AddService<DecompilerEventListener>(listener); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); }
public void Setup() { this.mr = new MockRepository(); this.mockFactory = new MockFactory(mr); this.cfgSvc = mr.Stub<IConfigurationService>(); this.sc = new ServiceContainer(); sc.AddService<IFileSystemService>(new FileSystemServiceImpl('/')); sc.AddService<IConfigurationService>(cfgSvc); }
public static void Main(string[] args) { var services = new ServiceContainer(); services.AddService(typeof(IServiceFactory), new ServiceFactory(services)); services.AddService(typeof(IDialogFactory), new WindowsFormsDialogFactory(services)); services.AddService(typeof(IRegistryService), new WindowsFormsRegistryService()); services.AddService(typeof(ISettingsService), new WindowsFormsSettingsService(services)); var interactor = new MainFormInteractor(services); interactor.Run(); }
public void Setup() { mr = new MockRepository(); sc = new ServiceContainer(); cfgSvc = mr.Stub<IConfigurationService>(); fsSvc = mr.Stub<IFileSystemService>(); diagSvc = mr.Stub<IDiagnosticsService>(); sc.AddService<IFileSystemService>(fsSvc); sc.AddService<IDiagnosticsService>(diagSvc); }
public virtual void InstantiateIn(Control container) { IServiceProvider serviceProvider = null; if (this._designerHost != null) { serviceProvider = this._designerHost; } else if (!base.IsNoCompile) { ServiceContainer container2 = new ServiceContainer(); if (container is IThemeResolutionService) { container2.AddService(typeof(IThemeResolutionService), (IThemeResolutionService) container); } if (container is IFilterResolutionService) { container2.AddService(typeof(IFilterResolutionService), (IFilterResolutionService) container); } serviceProvider = container2; } HttpContext current = null; TemplateControl templateControl = null; TemplateControl control2 = container as TemplateControl; if (control2 != null) { current = HttpContext.Current; if (current != null) { templateControl = current.TemplateControl; } } try { if (!base.IsNoCompile) { base.SetServiceProvider(serviceProvider); } if (current != null) { current.TemplateControl = control2; } this.BuildChildren(container); } finally { if (!base.IsNoCompile) { base.SetServiceProvider(null); } if (current != null) { current.TemplateControl = templateControl; } } }
public EditorHost (MonoDevelopProxy proxy) { this.proxy = proxy; //set up the services services = new ServiceContainer (); services.AddService (typeof(INameCreationService), new NameCreationService ()); services.AddService (typeof(ISelectionService), new SelectionService ()); services.AddService (typeof(ITypeResolutionService), new TypeResolutionService ()); services.AddService ( typeof(IEventBindingService), new AspNetEdit.Editor.ComponentModel.EventBindingService (proxy) ); ExtenderListService extListServ = new ExtenderListService (); services.AddService (typeof(IExtenderListService), extListServ); services.AddService (typeof(IExtenderProviderService), extListServ); services.AddService (typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService ()); services.AddService (typeof (IMenuCommandService), new AspNetEdit.Editor.ComponentModel.MenuCommandService ()); //services.AddService (typeof (IToolboxService), toolboxService); var project = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.Project as AspNetAppProject; var aspParsedDoc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as AspNetParsedDocument; if (project != null && aspParsedDoc != null) { WebFormReferenceManager refMan = new WebFormReferenceManager (project); refMan.Doc = aspParsedDoc; services.AddService (typeof(WebFormReferenceManager), refMan); } System.Diagnostics.Trace.WriteLine ("Creating DesignerHost"); designerHost = new DesignerHost (services, this); System.Diagnostics.Trace.WriteLine ("Created DesignerHost"); designerHost.DocumentChanged += new DesignerHost.DocumentChangedEventHandler (OnDocumentChanged); }
public void Setup() { mr = new MockRepository(); form = new MainForm(); sc = new ServiceContainer(); loader = mr.StrictMock<ILoader>(); dec = mr.StrictMock<IDecompiler>(); sc = new ServiceContainer(); uiSvc = new FakeShellUiService(); host = mr.StrictMock<DecompilerHost>(); memSvc = mr.StrictMock<ILowLevelViewService>(); var image = new LoadedImage(Address.Ptr32(0x10000), new byte[1000]); var imageMap = image.CreateImageMap(); var arch = mr.StrictMock<IProcessorArchitecture>(); var platform = mr.StrictMock<IPlatform>(); program = new Program(image, imageMap, arch, platform); project = new Project { Programs = { program } }; browserSvc = mr.StrictMock<IProjectBrowserService>(); sc.AddService<IDecompilerUIService>(uiSvc); sc.AddService(typeof(IDecompilerShellUiService), uiSvc); sc.AddService(typeof(IDecompilerService), new DecompilerService()); sc.AddService(typeof(IWorkerDialogService), new FakeWorkerDialogService()); sc.AddService(typeof(DecompilerEventListener), new FakeDecompilerEventListener()); sc.AddService(typeof(IProjectBrowserService), browserSvc); sc.AddService(typeof(ILowLevelViewService), memSvc); sc.AddService<ILoader>(loader); sc.AddService<DecompilerHost>(host); i = new TestInitialPageInteractor(sc, dec); }
public DesignerHost (ServiceContainer parentServices) { this.parentServices = parentServices; container = new DesignContainer (this); referenceManager = new WebFormReferenceManager (this); //register services parentServices.AddService (typeof (IDesignerHost), this); parentServices.AddService (typeof (IComponentChangeService), container); parentServices.AddService (typeof (IWebFormReferenceManager), referenceManager); }
public void GeneralTest2 () { ServiceContainer sc = new ServiceContainer (); sc.AddService (typeof (Svc), new Svc()); Svc service1 = sc.GetService (typeof (Svc)) as Svc; AssertNotNull ("GT1#01", service1); AssertEquals ("GT1#02", service1, sc.GetService (typeof (Svc))); sc.AddService (typeof (Svc), new Svc()); }
public DesignerMain(PropertyGrid props, ToolBoxPane t, Panel p) { propertyGrid = props; toolbox = t; panelMain = p; hostingServiceContainer = new ServiceContainer(); generatedCode = new CodeStrings(); hostingServiceContainer.AddService(typeof(CodeStrings), generatedCode); hostingServiceContainer.AddService(typeof(PropertyGrid), propertyGrid); hostingServiceContainer.AddService(typeof(ToolBoxPane), toolbox); }
/// <summary> /// Engine constructor. Initialize any objects required by the Engine. /// </summary> /// <param name="graphics">The GraphicsDeviceManage service to add.</param> public Engine(GraphicsDeviceManager graphics) { Services = new ServiceContainer(); Services.AddService(typeof(IGraphicsDeviceManager), graphics); Services.AddService(typeof(IGraphicsDeviceService), graphics); GraphicsDevice = graphics.GraphicsDevice; Content = new CEContentManager(Services); SpriteBatch = new SpriteBatch(GraphicsDevice); }
public void Setup() { this.mr = new MockRepository(); this.sc = new ServiceContainer(); this.arch = mr.Stub<IProcessorArchitecture>(); this.tlSvc = mr.Stub<ITypeLibraryLoaderService>(); this.cfgSvc = mr.Stub<IConfigurationService>(); sc.AddService<IConfigurationService>(cfgSvc); sc.AddService<ITypeLibraryLoaderService>(tlSvc); }
public DesignerHost (ServiceContainer parentServices, EditorHost host) { this.parentServices = parentServices; container = new DesignContainer (this); //register services parentServices.AddService (typeof (IDesignerHost), this); parentServices.AddService (typeof (IComponentChangeService), container); editorHost = host; }
public static void Main(string[] args) { var services = new ServiceContainer(); var listener = new CmdLineListener(); var config = new DecompilerConfiguration(); var diagnosticSvc = new CmdLineDiagnosticsService(Console.Out); services.AddService(typeof(DecompilerEventListener), listener); services.AddService(typeof(IConfigurationService), config); services.AddService(typeof(ITypeLibraryLoaderService), new TypeLibraryLoaderServiceImpl()); services.AddService(typeof(IDiagnosticsService), diagnosticSvc); var driver = new CmdLineDriver(services, config); driver.Execute(args); }
public void Setup() { mr = new MockRepository(); fakeArch = new FakeArchitecture(); importResolver = mr.StrictMock<IImportResolver>(); callSigs = new Dictionary<Address, ProcedureSignature>(); arch = fakeArch; var r1 = arch.GetRegister(1); reg1 = new Identifier(r1.Name, PrimitiveType.Word32, r1); this.sc = new ServiceContainer(); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener()); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); }
public void Setup() { mr = new MockRepository(); var cfgSvc = mr.Stub<IConfigurationService>(); var tlSvc = mr.Stub<ITypeLibraryLoaderService>(); var env = mr.Stub<OperatingEnvironment>(); env.Stub(e => e.TypeLibraries).Return(new TypeLibraryElementCollection()); env.CharacteristicsLibraries = new TypeLibraryElementCollection(); cfgSvc.Stub(c => c.GetEnvironment("ms-dos")).Return(env); sc = new ServiceContainer(); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); sc.AddService<IConfigurationService>(cfgSvc); sc.AddService<ITypeLibraryLoaderService>(tlSvc); }
protected Program RewriteProgram32(string sourceFilename, Address addrBase) { sc = new ServiceContainer(); sc.AddService<IConfigurationService>(new FakeDecompilerConfiguration()); sc.AddService<IFileSystemService>(new FileSystemServiceImpl()); sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener()); var ldr = new Loader(sc); var arch = new X86ArchitectureFlat32(); program = ldr.AssembleExecutable( FileUnitTester.MapTestPath(sourceFilename), new X86TextAssembler(sc, arch) { Platform = new DefaultPlatform(sc, arch) }, addrBase); return RewriteProgram(); }
protected Program RewriteProgramMsdos(string sourceFilename, Address addrBase) { sc = new ServiceContainer(); sc.AddService<IConfigurationService>(new FakeDecompilerConfiguration()); sc.AddService<DecompilerHost>(new FakeDecompilerHost()); sc.AddService<DecompilerEventListener>(new FakeDecompilerEventListener()); var ldr = new Loader(sc); var arch = new X86ArchitectureReal(); program = ldr.AssembleExecutable( FileUnitTester.MapTestPath(sourceFilename), new X86TextAssembler(arch) { Platform = new MsdosPlatform(null, arch) }, addrBase); return RewriteProgram(); }
public void Setup() { mr = new MockRepository(); sc = new ServiceContainer(); cfgSvc = mr.Stub<IConfigurationService>(); sc.AddService<IConfigurationService>(cfgSvc); }
public void Init() { ServiceContainer container = new ServiceContainer(); markerService = new MockTextMarkerService(); container.AddService(typeof(ITextMarkerService), markerService); // Add xpath marker to document. AvalonEditDocumentAdapter doc = new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container); doc.Text = "<Test/>"; XPathNodeTextMarker xpathNodeMarker = new XPathNodeTextMarker(doc); XPathNodeMatch nodeMatch = new XPathNodeMatch("Test", "<Test/>", 0, 1, XPathNodeType.Element); xpathNodeMarker.AddMarker(nodeMatch); // Add non text editor provider view to workbench. workbench = new MockWorkbench(); nonTextEditorProviderView = new MockViewContent(); workbench.ViewContentCollection.Add(nonTextEditorProviderView); // Add document to view content. textEditorView = new MockTextEditorProviderViewContent(); textEditorView.MockTextEditor.SetDocument(doc); workbench.ViewContentCollection.Add(textEditorView); command = new RemoveXPathHighlightingCommand(workbench); }
public void Setup() { mr = new MockRepository(); frame = mr.DynamicMock<IWindowFrame>(); sc = new ServiceContainer(); sc.AddService(typeof(IWindowFrame), frame); }
public void Setup() { mr = new MockRepository(); codeViewer = new CodeViewerPane(); decompilerSvc = mr.Stub<IDecompilerService>(); decompiler = mr.Stub<IDecompiler>(); uiPreferencesSvc = mr.Stub<IUiPreferencesService>(); uiSvc = mr.Stub<IDecompilerShellUiService>(); font = new Font("Arial", 10); var sc = new ServiceContainer(); decompilerSvc.Decompiler = decompiler; sc.AddService<IDecompilerService>(decompilerSvc); sc.AddService<IUiPreferencesService>(uiPreferencesSvc); sc.AddService<IDecompilerShellUiService>(uiSvc); codeViewer.SetSite(sc); }
public void Setup() { mr = new MockRepository(); dcSvc = mr.Stub<IConfigurationService>(); sc = new ServiceContainer(); sc.AddService(typeof(IConfigurationService), dcSvc); }
private void searchToolStripMenuItem_Click(object sender, EventArgs e) { var sc = new System.ComponentModel.Design.ServiceContainer(); sc.AddService(typeof(ISettingsService), new DummySettingsService()); using (var dlg = new Reko.UserInterfaces.WindowsForms.Forms.SearchDialog()) { dlg.Services = sc; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //string.foo(); } } }
private static ObjectContext GetObjectContext(UserSession session) { UserSession userSession = session; // Инициализация сервис-провайдера var sessionContainer = new System.ComponentModel.Design.ServiceContainer(); sessionContainer.AddService(typeof(DocsVision.Platform.ObjectManager.UserSession), userSession); // Инициализация контекста объектов // В качестве контейнера может выступать компонент карточки, унаследованный от DocsVision.Platform.WinForms.CardControl ObjectContext objectContext = new ObjectContext(sessionContainer); // Получение сервис-реестра и регистрация фабрик преобразователей IObjectMapperFactoryRegistry mapperFactoryRegistry = objectContext.GetService <IObjectMapperFactoryRegistry>(); mapperFactoryRegistry.RegisterFactory(typeof(SystemCardsMapperFactory)); mapperFactoryRegistry.RegisterFactory(typeof(BackOfficeMapperFactory)); mapperFactoryRegistry.RegisterFactory(typeof(ApprovalDesignerMapperFactory)); // Получение сервис-реестра и регистрация фабрик сервисов IServiceFactoryRegistry serviceFactoryRegistry = objectContext.GetService <IServiceFactoryRegistry>(); serviceFactoryRegistry.RegisterFactory(typeof(SystemCardsServiceFactory)); serviceFactoryRegistry.RegisterFactory(typeof(BackOfficeServiceFactory)); serviceFactoryRegistry.RegisterFactory(typeof(ApprovalDesignerServiceFactory)); // Регистрация сервиса для работы с хранилищем Docsvision objectContext.AddService <IPersistentStore>(DocsVisionObjectFactory.CreatePersistentStore(new SessionProvider(userSession), null)); // Регистрация поставщика метаданных карточек IMetadataProvider metadataProvider = DocsVisionObjectFactory.CreateMetadataProvider(userSession); objectContext.AddService <IMetadataManager>(DocsVisionObjectFactory.CreateMetadataManager(metadataProvider, userSession)); objectContext.AddService <IMetadataProvider>(metadataProvider); return(objectContext); }