Inheritance: IServiceContainer, IDisposable
        public FormsDesignerContent(FormsDesignerExtension parent, OpenedFile sourceFile)
            : base(parent)
        {
            _language = (NetLanguageDescriptor)LanguageDescriptor.GetLanguageByPath(sourceFile.FilePath);
            if (!(_language is NetLanguageDescriptor))
                throw new ArgumentException("File must be a .NET source file.");
            
            _extensionHost = parent.ExtensionHost;
            _extensionHost.ControlManager.AppearanceChanged += ControlManager_AppearanceChanged;

            _propertyContainer = new PropertyContainer();

            _serviceContainer = new ServiceContainer();
            _surfaceManager = parent.DesignerSurfaceManager;

            _codeReader = new DesignerCodeReader(_extensionHost, _language);
            _codeWriter = new DesignerCodeWriter(_language);

            this.Text = sourceFile.FilePath.FileName + sourceFile.FilePath.Extension + " [Design]";
            this.AssociatedFile = sourceFile;
            this.AssociatedFile.FilePathChanged += AssociatedFile_FilePathChanged;
            
            _errorControl = new ErrorControl()
            {
                Dock = DockStyle.Fill,
            };
            _errorControl.ReloadRequested += _errorControl_ReloadRequested;

            SetupDesigner();
        }
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new X86ArchitectureReal();
     this.platform = new MsdosPlatform(sc, arch);
 }
Beispiel #3
0
		public void Setup()
		{
            this.sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            this.arch = new X86ArchitectureReal();
            this.platform = new MsdosPlatform(sc, arch);

            ArgumentSerializer argSer = new ArgumentSerializer(arch);

            svc = new SerializedService
            {
                Name = "msdos_ioctl_get_device_info",
                SyscallInfo = new SerializedSyscallInfo
                {
                    Vector = "21",
                    RegisterValues = new[] {
                        new SerializedRegValue("ah", "44"),
                        new SerializedRegValue("al", "00"),
                    }
                },
                Signature = new SerializedSignature
                {
                    ReturnValue = argSer.Serialize(
                        new Identifier("C", PrimitiveType.Bool,
                        new FlagGroupStorage(Registers.eflags, (uint)FlagM.CF, "C", PrimitiveType.Byte)))
                }
            };
		}
 public void Setup()
 {
     var sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     var arch = new IntelArchitecture(ProcessorMode.Real);
     this.platform = new MsdosPlatform(sc, arch);
 }
        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);
        }
Beispiel #6
0
 public void Setup()
 {
     mr = new MockRepository();
     var eventListener = mr.Stub<DecompilerEventListener>();
     sc = new ServiceContainer();
     sc.AddService<DecompilerEventListener>(eventListener);
 }
        //private IProgressReporterService ProgressReporter
        //{
        //    get
        //    {
        //        return (IProgressReporterService)GetService(typeof(IProgressReporterService));
        //    }
        //}

        //public ILoggingService LoggingService
        //{
        //    get
        //    {
        //        return (ILoggingService)GetService(typeof(ILoggingService));
        //    }
        //}
        #endregion

        #region Constructors
        public dloDataApplication()
        {
            //Create a new instance of our service container
            ServiceContainer = new System.ComponentModel.Design.ServiceContainer();

            IsLoaded = false;

            //  AuthTypes = RuntimeAuthTypes.None;

            SyncStatus = Data.SyncStatus.Unknown;

            DbInfo = new dloDbInfo(this);

            Configuration = new Configuration();

            _users   = new dloUsers(this);
            _groups  = new dloUserGroups(this);
            _devices = new dloDevices(this);

            Queries = new DatabaseQueries();
            //CurrentUser = new dloUser(_users);

            //_currentDevice = new dloDevice(this);

            //DoHouseKeeping();

            //Register services
        }
 public void FindByType()
 {
     ServiceContainer container = new ServiceContainer();
     object service = new object();
     container.AddService(typeof(object), service);
     Assert.AreSame(service, ServiceQuery.FindByType(container, typeof(object)));
 }
Beispiel #9
0
 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()
 {
     arch = new X86ArchitectureFlat32();
     var services = new ServiceContainer();
     services.AddService<IFileSystemService>(new FileSystemServiceImpl());
     asm = new X86Assembler(services, new DefaultPlatform(services, arch), loadAddress, new List<ImageSymbol>());
 }
Beispiel #11
0
 private static void CleanupFields()
 {
     if (container != null)
     {
         container.Dispose();
         container = null;
     }
     if (serviceProvider != null)
     {
         serviceProvider.Dispose();
         serviceProvider = null;
     }
     if (composition != null)
     {
         composition.Dispose();
         composition = null;
     }
     if (globalCatalog != null)
     {
         globalCatalog.Dispose();
         globalCatalog = null;
     }
     componentHost       = null;
     catalogProvider     = null;
     localComponentModel = null;
 }
Beispiel #12
0
        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");
        }
Beispiel #13
0
 private void BuildTest16(Action<X86Assembler> asmProg)
 {
     sc = new ServiceContainer();
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
     arch = new X86ArchitectureReal();
     BuildTest(Address.SegPtr(0x0C00, 0x0000), new MsdosPlatform(sc, arch), asmProg);
 }
Beispiel #14
0
 public void Setup()
 {
     mr = new MockRepository();
     program = new Program();
     proc = new Procedure("testProc", new Frame(PrimitiveType.Word32));
     block = proc.AddBlock("l00100000");
     trace = new RtlTrace(0x00100000);
     r0 = new Identifier("r0", PrimitiveType.Word32, new RegisterStorage("r0", 0, 0, PrimitiveType.Word32));
     r1 = new Identifier("r1", PrimitiveType.Word32, new RegisterStorage("r1", 1, 0, PrimitiveType.Word32));
     r2 = new Identifier("r2", PrimitiveType.Word32, new RegisterStorage("r2", 2, 0, PrimitiveType.Word32));
     sp = new Identifier("sp", PrimitiveType.Word32, new RegisterStorage("sp", 15, 0, PrimitiveType.Word32));
     grf = proc.Frame.EnsureFlagGroup(Registers.eflags, 3, "SCZ", PrimitiveType.Byte);
     var sc = new ServiceContainer();
     var listener = mr.Stub<DecompilerEventListener>();
     scanner = mr.StrictMock<IScanner>();
     arch = mr.Stub<IProcessorArchitecture>();
     program.Architecture = arch;
     program.SegmentMap = new SegmentMap(
         Address.Ptr32(0x00100000),
         new ImageSegment(
             ".text",
             new MemoryArea(Address.Ptr32(0x00100000), new byte[0x20000]),
             AccessMode.ReadExecute));
     arch.Replay();
     program.Platform = new DefaultPlatform(null, arch);
     arch.BackToRecord();
     arch.Stub(s => s.StackRegister).Return((RegisterStorage)sp.Storage);
     arch.Stub(s => s.PointerType).Return(PrimitiveType.Pointer32);
     scanner.Stub(s => s.Services).Return(sc);
     sc.AddService<DecompilerEventListener>(listener);
 }
Beispiel #15
0
		public Workspace ()
		{
			_documents = new List<Document>();
			_activeDocument = null;
			_references = new References ();
			_serviceContainer = new ServiceContainer ();
		}
        public SerializedSignatureTests()
		{
            this.sc = new ServiceContainer();
            this.sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
			this.arch = new X86ArchitectureReal();
            this.platform = new MsdosPlatform(sc, arch);
		}
Beispiel #17
0
        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.");
        }
Beispiel #18
0
		public HostForm()
		{
			InitializeComponent();

			mServiceContainer = new ServiceContainer();
			mServiceContainer.AddService(typeof(ISampleHostService), this);
		}
 public void Setup()
 {
     mr = new MockRepository();
     dcSvc = mr.Stub<IConfigurationService>();
     sc = new ServiceContainer();
     sc.AddService(typeof(IConfigurationService), dcSvc);
 }
Beispiel #20
0
		public void Setup()
		{
            this.sc = new ServiceContainer();
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            arch = new IntelArchitecture(ProcessorMode.Real);
            asm = new X86TextAssembler(sc, arch);
        }
		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>();
            arch.Stub(a => a.CreateRegisterBitset()).Return(new BitSet(32));
            arch.Replay();
            var platform = mr.StrictMock<Platform>(null, arch);
            arch.BackToRecord();
            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);

            i = new TestInitialPageInteractor(sc, dec);

		}
Beispiel #22
0
		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 Setup()
 {
     this.mr = new MockRepository();
     this.sc = new ServiceContainer();
     loader = mr.Stub<ILoader>();
     arch = mr.StrictMock<IProcessorArchitecture>();
     Address dummy;
     arch.Stub(a => a.TryParseAddress(null, out dummy)).IgnoreArguments().WhenCalled(m =>
     {
         Address addr;
         var sAddr = (string)m.Arguments[0];
         var iColon = sAddr.IndexOf(':');
         if (iColon > 0)
         {
             addr = Address.SegPtr(
                 Convert.ToUInt16(sAddr.Remove(iColon)),
                 Convert.ToUInt16(sAddr.Substring(iColon+1)));
             m.ReturnValue = true;
         }
         else
         {
             m.ReturnValue = Address32.TryParse32((string)m.Arguments[0], out addr);
         }
         m.Arguments[1] = addr;
     }).Return(false);
 }
		public static IDocument CreateDocumentWithMockService()
		{
			ServiceContainer container = new ServiceContainer();
			container.AddService(typeof(ITextMarkerService), new MockTextMarkerService());
			
			return new AvalonEditDocumentAdapter(new ICSharpCode.AvalonEdit.Document.TextDocument(), container);
		}
Beispiel #25
0
		public static void Main(string [] args)
		{
            var services = new ServiceContainer();
            if (args.Length == 0)
			{
                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();
            }
			else
			{
                var host = NullDecompilerHost.Instance;
                var listener = NullDecompilerEventListener.Instance;

                services.AddService(typeof (DecompilerEventListener), listener);
                services.AddService(typeof(IRegistryService), new WindowsFormsRegistryService());
                services.AddService(typeof(IConfigurationService), new DecompilerConfiguration());
                var ldr = new Loader(services);
				var dec = new DecompilerDriver(ldr, services);
				dec.Decompile(args[0]);
			}
		}
Beispiel #26
0
		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();
     frame = mr.DynamicMock<IWindowFrame>();
     sc = new ServiceContainer();
     sc.AddService(typeof(IWindowFrame), frame);
 }
Beispiel #28
0
		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 void Setup()
 {
     this.sc = new ServiceContainer();
     this.x86 = new X86ArchitectureFlat32();
     this.ppc = new PowerPcArchitecture32();
     this.m = new ProcedureBuilder();
     this.printfChr = new ProcedureCharacteristics()
     {
         VarargsParserClass =
             "Reko.Libraries.Libc.PrintfFormatParser,Reko.Libraries.Libc"
     };
     this.x86PrintfSig = new FunctionType(
         null,
         StackId(null,   4, CStringType()),
         StackId("...",  8, new UnknownType()));
     this.x86SprintfSig = new FunctionType(
         null,
         StackId(null,   4, CStringType()),
         StackId(null,   8, CStringType()),
         StackId("...", 12, new UnknownType()));
     this.ppcPrintfSig = new FunctionType(
         null,
         RegId(null,  ppc, "r3", CStringType()),
         RegId("...", ppc, "r4", new UnknownType()));
     this.addrInstr = Address.Ptr32(0x123400);
 }
Beispiel #30
0
 public void Setup()
 {
     mr = new MockRepository();
     sc = new ServiceContainer();
     cfgSvc = mr.Stub<IConfigurationService>();
     sc.AddService<IConfigurationService>(cfgSvc);
 }
 public void Setup()
 {
     repository = new MockRepository();
     sc = new ServiceContainer();
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     dcSvc = repository.StrictMock<IConfigurationService>();
 }
        public JsonRpcDispatcher(IService service, IServiceProvider serviceProvider)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;

            if (serviceProvider == null)
            {
                //
                // No service provider supplied so check if the RPC service
                // itself is our service provider.
                //

                serviceProvider = service as IServiceProvider;

                //
                // If no service provider found so far, then create a default
                // one.
                //

                if (serviceProvider == null)
                    serviceProvider = new ServiceContainer();
            }

            _serviceProvider = serviceProvider;
        }
		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);
		}
Beispiel #34
0
        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();
                }
            }
        }
Beispiel #35
0
    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);
    }