public InterceptingCatalogContext()
 {
     var innerCatalog = new TypeCatalog(typeof(Logger));
     MockInterceptor = new Mock<IExportedValueInterceptor>();
     Catalog = new InterceptingCatalog(innerCatalog, MockInterceptor.Object);
     Context();
 }
 public ConcreteTypeExportHandlerContext()
 {
     ConcreteTypeHandler = new ConcreteTypeExportHandler();
     var typeCatalog = new TypeCatalog(typeof(OrderProcessor));
     var orderProcessorContract = AttributedModelServices.GetContractName(typeof(OrderProcessor));
     var orderProcessPartDefinition = typeCatalog.Parts.Single(p => p.ExportDefinitions.Any(d => d.ContractName == orderProcessorContract));
     RepositoryImportDefinition = orderProcessPartDefinition.ImportDefinitions.First();
     Context();
 }
 public DynamicProxyValueInterceptorContext()
 {
     var innerCatalog = new TypeCatalog(typeof(Customer));
     var interceptor = new FreezableInterceptor();
     interceptor.Freeze();
     var valueInterceptor = new DynamicProxyInterceptor(interceptor);
     Catalog = new InterceptingCatalog(innerCatalog, valueInterceptor);
     Container = new CompositionContainer(Catalog);
     Context();
 }
        public void WhenItemsNotInCollection_GetThrows()
        {
            // Prepare
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            ComposablePartCatalog catalog1 = new TypeCatalog();
            ComposablePartCatalog catalog2 = new TypeCatalog();

            DownloadedPartCatalogCollection target = new DownloadedPartCatalogCollection();

            target.Add(moduleInfo1, catalog1);
            target.Add(moduleInfo2, catalog2);

            // Act
            Assert.ThrowsException<KeyNotFoundException>(() => target.Get(moduleInfo3));
        
            // Verify
            
        }
        public void WhenItemsAdded_GetReturnsItems()
        {
            // Prepare
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            ComposablePartCatalog catalog1 = new TypeCatalog();
            ComposablePartCatalog catalog2 = new TypeCatalog();
            ComposablePartCatalog catalog3 = new TypeCatalog();

            DownloadedPartCatalogCollection target = new DownloadedPartCatalogCollection();

            // Act
            target.Add(moduleInfo1, catalog1);
            target.Add(moduleInfo2, catalog2);
            target.Add(moduleInfo3, catalog3);

            // Verify
            Assert.AreSame(catalog1, target.Get(moduleInfo1));
            Assert.AreSame(catalog2, target.Get(moduleInfo2));
            Assert.AreSame(catalog3, target.Get(moduleInfo3));
        }
Пример #6
0
        public void ConventionCatalog_should_export_conventionpart()
        {
            // Setup conventions using the semantic model
            // This is NOT the API that the user will be exposed to,
            // there will be a DSL at the front

            var exportConvention =
                new ExportConvention
            {
                Members      = t => new[] { t },
                ContractType = x => typeof(IConventionPart),
            };

            var importConvention =
                new ImportConvention
            {
                Members      = t => new[] { ReflectionServices.GetProperty <IConventionPart>(p => p.Logger) },
                ContractType = x => typeof(ILogger)
            };

            var convention =
                new PartConvention();

            convention.Imports.Add(importConvention);
            convention.Exports.Add(exportConvention);
            convention.Condition = t => t.GetInterfaces().Contains(typeof(IConventionPart));

            var exportConvention2 =
                new ExportConvention
            {
                Members      = t => new[] { typeof(NullLogger) },
                ContractType = x => typeof(ILogger),
            };

            var convention2 =
                new PartConvention();

            convention2.Exports.Add(exportConvention2);
            convention2.Condition = t => t.GetInterfaces().Contains(typeof(ILogger));

            var model =
                new FakePartRegistry2(convention, convention2);

            // Setup container
            ConventionCatalog conventionCatalog =
                new ConventionCatalog(model);

            var typeCatalog =
                new TypeCatalog(typeof(AttributedPart));

            var aggregated =
                new AggregateCatalog(typeCatalog, conventionCatalog);

            var container =
                new CompositionContainer(aggregated);

            var part = new AttributedPart();

            var batch =
                new CompositionBatch();

            batch.AddPart(part);

            container.Compose(batch);

            // Assert
            part.Part.Count().ShouldEqual(2);
            part.Part[0].Logger.ShouldNotBeNull();
            part.Part[1].Logger.ShouldNotBeNull();
        }
Пример #7
0
        static void Main(string[] args)
        {
            // important to call these before creating application host
            Application.EnableVisualStyles();
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable Ctrl+tab selection of documents and controls within the app

                typeof(DomNodeNameSearchService),       // simple example of search input, results, and replacement, for DomNode names only
                typeof(DomNodePropertySearchService),   // complex example of search input, results, and replacement of any DomNode property

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(HelpAboutCommand),               // Help -> About command

                typeof(PaletteService),                 // global palette, for drag/drop instancing
                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(Outputs),                        // passes messages to all log writers
                typeof(ErrorDialogService),             // displays errors to the user in a message box

                typeof(HelpAboutCommand),               // custom command component to display Help/About dialog
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(Editor),                         // editor which manages event sequence documents
                typeof(SchemaLoader),                   // loads schema and extends types
                typeof(PaletteClient),                  // component which adds items to palette
                typeof(EventListEditor),                // adds drag/drop and context menu to event sequence ListViews
                typeof(ResourceListEditor),             // adds "slave" resources ListView control, drag/drop and context menu
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form
            var batch = new CompositionBatch();
            var toolStripContainer = new ToolStripContainer();
            var mainForm           = new MainForm(toolStripContainer)
            {
                Text = "Simple DOM Editor Sample".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Add the main Form instance to the container
            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Simple-DOM-Editor-Sample".Localize()));
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
Пример #8
0
        private static CompositionContainer CreateWithAttributedCatalog(params Type[] types)
        {
            var catalog = new TypeCatalog(types);

            return(new CompositionContainer(catalog));
        }
Пример #9
0
 public StartupController()
 {
     catalog = new TypeCatalog(_Startup.Parts)
               .EnsureInitialized();
 }
Пример #10
0
 /// <summary>
 /// Test case.
 /// </summary>
 static void RunImplicitArrayTest()
 {
     var type    = typeof(CecilComponent);
     var typeCat = new TypeCatalog(type);
 }
        public void Constructor2_EmptyEnumerableAsTypesArgument_ShouldSetPartsPropertyToEmptyEnumerable()
        {
            var catalog = new TypeCatalog(Enumerable.Empty <Type>());

            Assert.Empty(catalog.Parts);
        }
Пример #12
0
        static void  Main()
        {
            double start = LevelEditorCore.Timing.GetHiResCurrentTime();

#if DEBUG
            AllocConsole();
#endif

            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

#if !DEBUG
            SplashForm.ShowForm(typeof(LevelEditorApplication), "LevelEditor.Resources.SplashImg.png");
#endif

            // Register the embedded image resources so that they will be available for all users of ResourceUtil,
            //  such as the PaletteService.
            ResourceUtil.Register(typeof(Resources));

            // enable metadata driven property editing
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Add selected ATF components.
            TypeCatalog AtfCatalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(Outputs),                        // service that provides static methods for writing to IOutputWriter objects.
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.
                typeof(CommandService),                 // menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),
                typeof(AtfScriptVariables),
                typeof(AutomationService),
                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardViewCommands),           // standard View commands: frame selection, frame all
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(StandardLockCommands),           // standard Edit menu lock/unlock commands
                typeof(PaletteService),                 // global palette, for drag/drop instancing
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor
                typeof(PropertyEditor),
                typeof(GridPropertyEditor),
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                typeof(HistoryLister),                  // visual undo/redo
                typeof(SkinService),
                typeof(ResourceService)
                );

            TypeCatalog LECoreCatalog = new TypeCatalog(
                typeof(LevelEditorCore.DesignViewSettings),
                typeof(LevelEditorCore.ResourceLister),
                typeof(LevelEditorCore.ThumbnailService),
                typeof(LevelEditorCore.ResourceMetadataEditor),
                typeof(LevelEditorCore.LayerLister),
                typeof(LevelEditorCore.ResourceConverterService),

                typeof(LevelEditorCore.Commands.PickFilterCommands),
                typeof(LevelEditorCore.Commands.DesignViewCommands),
                typeof(LevelEditorCore.Commands.ManipulatorCommands),
                typeof(LevelEditorCore.Commands.ShowCommands),
                typeof(LevelEditorCore.Commands.GroupCommands),
                typeof(LevelEditorCore.Commands.CameraCommands),
                typeof(LevelEditorCore.MayaStyleCameraController),
                typeof(LevelEditorCore.ArcBallCameraController),
                typeof(LevelEditorCore.WalkCameraController),
                typeof(LevelEditorCore.FlyCameraController)
                );

            TypeCatalog thisAssemCatalog = new TypeCatalog(
                typeof(LevelEditor.GameLoopService),
                typeof(LevelEditor.GameEditor),
                typeof(LevelEditor.BookmarkLister),
                typeof(LevelEditor.GameDocumentRegistry),
                typeof(LevelEditor.SchemaLoader),
                typeof(LevelEditor.PrototypingService),
                typeof(LevelEditor.PrefabService),
                typeof(LevelEditor.GameProjectLister),
                typeof(LevelEditor.ResourceMetadataService),
                typeof(LevelEditor.ResourceConverter),
                typeof(LevelEditor.Terrain.TerrainEditor),
                typeof(LevelEditor.Terrain.TerrainManipulator),
                typeof(LevelEditor.SnapFilter),
                typeof(LevelEditor.PickFilters.LocatorPickFilter),
                typeof(LevelEditor.PickFilters.BasicShapePickFilter),
                typeof(LevelEditor.PickFilters.NoCubePickFilter),
                typeof(LevelEditor.Commands.PaletteCommands),
                typeof(LevelEditor.Commands.LevelEditorFileCommands),
                typeof(LevelEditor.Commands.HelpAboutCommand),
                typeof(LevelEditor.Commands.LevelEditorCommands),
                typeof(LevelEditor.Commands.LayeringCommands),
                typeof(LevelEditor.Commands.PivotCommands)
                // To use Open Sound Control (OSC), enable these three components:
                //,
                //typeof(LevelEditor.OSC.OscClient),
                //typeof(OscCommands),                    // Provides a GUI for configuring OSC support and to diagnose problems.
                //typeof(OscCommandReceiver)              // Executes this app's commands in response to receiving matching OSC messages.
                // Needs to come after all the other ICommandClients in the catalog.
                );

            TypeCatalog renderingInteropCatalog = new TypeCatalog(
                typeof(RenderingInterop.GameEngine),
                typeof(RenderingInterop.NativeGameEditor),
                typeof(RenderingInterop.ThumbnailResolver),
                typeof(RenderingInterop.RenderCommands),
                typeof(RenderingInterop.AssetResolver),
                typeof(RenderingInterop.NativeDesignView),
                typeof(RenderingInterop.ResourcePreview),
                typeof(RenderingInterop.TranslateManipulator),
                typeof(RenderingInterop.ExtensionManipulator),
                typeof(RenderingInterop.ScaleManipulator),
                typeof(RenderingInterop.RotateManipulator),
                typeof(RenderingInterop.TranslatePivotManipulator),
                typeof(RenderingInterop.TextureThumbnailResolver)
                );


            List <ComposablePartCatalog> catalogs = new List <ComposablePartCatalog>();
            catalogs.Add(AtfCatalog);
            catalogs.Add(LECoreCatalog);
            catalogs.Add(renderingInteropCatalog);
            catalogs.Add(thisAssemCatalog);


            // temp solution, look for statemachine plugin by name.
            string pluginDir = Application.StartupPath;
            string stmPlg    = pluginDir + "\\StateMachinePlugin.dll";
            if (File.Exists(stmPlg))
            {
                Assembly stmPlgAssem = Assembly.LoadFrom(stmPlg);
                catalogs.Add(new AssemblyCatalog(stmPlgAssem));
            }

            // load all dlls in \MEFPlugin
            string mefpluginDir = pluginDir + "\\MEFPlugin";
            if (Directory.Exists(mefpluginDir))
            {
                var filepaths = Directory.GetFiles(mefpluginDir).Where(path => path.EndsWith(".dll"));
                foreach (var filepath in filepaths)
                {
                    Assembly filepathAssembly = Assembly.LoadFrom(filepath);
                    catalogs.Add(new AssemblyCatalog(filepathAssembly));
                }
            }

            AggregateCatalog catalog = new AggregateCatalog(catalogs);


            // Initialize ToolStripContainer container and MainForm
            ToolStripContainer toolStripContainer = new ToolStripContainer();
            toolStripContainer.Dock = DockStyle.Fill;
            MainForm mainForm = new MainForm(toolStripContainer);
            mainForm.Text = "LevelEditor".Localize("the name of this application, on the title bar");

            CompositionContainer container = new CompositionContainer(catalog);
            CompositionBatch     batch     = new CompositionBatch();
            AttributedModelServices.AddPart(batch, mainForm);
            container.Compose(batch);

            LevelEditorCore.Globals.InitializeComponents(container);
            // Initialize components

            var gameEngine = container.GetExportedValue <IGameEngineProxy>();
            foreach (IInitializable initializable in container.GetExportedValues <IInitializable>())
            {
                initializable.Initialize();
            }
            GC.KeepAlive(gameEngine);

            AutoDocumentService autoDocument = container.GetExportedValue <AutoDocumentService>();
            autoDocument.AutoLoadDocuments = false;
            autoDocument.AutoNewDocument   = true;
            mainForm.Shown += delegate { SplashForm.CloseForm(); };

            // The settings file is incompatible between languages that LevelEditor and ATF are localized to.
            // For example, the LayoutService saves different Control names depending on the language and so
            //  the Windows layout saved in one language can't be loaded correctly in another language.
            string language = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; //"en" or "ja"
            if (language == "ja")
            {
                var    settingsService = container.GetExportedValue <SettingsService>();
                string nonEnglishPath  = settingsService.SettingsPath;
                nonEnglishPath = Path.Combine(Path.GetDirectoryName(nonEnglishPath), "AppSettings_" + language + ".xml");
                settingsService.SettingsPath = nonEnglishPath;
            }

            Application.Run(mainForm); // MAIN LOOP

            container.Dispose();
            GC.KeepAlive(start);
        }
Пример #13
0
        public override void Prepare()
        {
            var dummyCatalog = new TypeCatalog(
                typeof(DummyOne),
                typeof(DummyTwo),
                typeof(DummyThree),
                typeof(DummyFour),
                typeof(DummyFive),
                typeof(DummySix),
                typeof(DummySeven),
                typeof(DummyEight),
                typeof(DummyNine),
                typeof(DummyTen));

            var standardCatalog = new TypeCatalog(
                typeof(Singleton1),
                typeof(Singleton2),
                typeof(Singleton3),
                typeof(Transient1),
                typeof(Transient2),
                typeof(Transient3),
                typeof(Combined1),
                typeof(Combined2),
                typeof(Combined3));

            var complexCatalog = new TypeCatalog(
                typeof(FirstService),
                typeof(SecondService),
                typeof(ThirdService),
                typeof(SubObjectOne),
                typeof(SubObjectTwo),
                typeof(SubObjectThree),
                typeof(Complex1),
                typeof(Complex2),
                typeof(Complex3));

            var propertyInjectionCatalog = new TypeCatalog(
                typeof(ComplexPropertyObject1),
                typeof(ComplexPropertyObject2),
                typeof(ComplexPropertyObject3),
                typeof(ServiceA),
                typeof(ServiceB),
                typeof(ServiceC),
                typeof(SubObjectA),
                typeof(SubObjectB),
                typeof(SubObjectC));

            var multipleCatalog = new TypeCatalog(
                typeof(SimpleAdapterOne),
                typeof(SimpleAdapterTwo),
                typeof(SimpleAdapterThree),
                typeof(SimpleAdapterFour),
                typeof(SimpleAdapterFive),
                typeof(ImportMultiple1),
                typeof(ImportMultiple2),
                typeof(ImportMultiple3));

            var openGenericCatalog = new TypeCatalog(typeof(ImportGeneric <>), typeof(GenericExport <>));

            this.container = new CompositionContainer(
                new AggregateCatalog(dummyCatalog, standardCatalog, complexCatalog, propertyInjectionCatalog, multipleCatalog, openGenericCatalog), true);
        }
Пример #14
0
        static void Main()
        {
            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            Engine engine = new Engine();

            engine.StartEngine("TongCompiler", null);

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(

                typeof(SettingsService),                // persistent settings and user preferences dialog
                //typeof(StatusService),                  // status bar at bottom of main Form
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DomNodeRefDictionary),           // Reference dictionary
                typeof(TongScriptCompilerTypeManager),
                typeof(ScriptNodeDefinitionManager),
                //typeof(ZooKeeperSession),
                typeof(TongCompilerStart),
                typeof(TongCompilerBatchRead),
                typeof(TongCompilerBatchGenerateBytecode),

                typeof(Outputs),                        // passes messages to all log writers
                typeof(ErrorDialogService),             // displays errors to the user in a message box
                typeof(ConsoleOutputWriter)

                );

            // enable use of the system clipboard
            StandardEditCommands.UseSystemClipboard = true;

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form
            var batch    = new CompositionBatch();
            var mainForm = new ConsoleMainForm()
            {
                Text = Application.ProductName,
            };

            // Add the main Form instance, etc., to the container
            batch.AddPart(mainForm);
            container.Compose(batch);

            container.InitializeAll();

            mainForm.Run();
            mainForm.Close();

            // Give components a chance to clean up.
            container.Dispose();

            engine.StopEngine();
        }
Пример #15
0
        public void Prepare()
        {
            var catalog = new TypeCatalog(typeof(Singleton), typeof(Transient), typeof(Combined));

            this.container = new CompositionContainer(catalog);
        }
Пример #16
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(

                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),
                typeof(SkinService),
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditHistoryCommands),    // tracks document changes and updates main form title
                typeof(HelpAboutCommand),               // Help -> About command
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor
                typeof(SettingsService),
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService),              // provides facilities to run an automated script using the .NET remoting service

                typeof(SchemaLoader),                   // component that loads XML schema and sets up types
                typeof(Editor)                          // component that manages UI documents
                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form

            // Configure the main Form with a ToolStripContainer so the CommandService can
            //  generate toolbars.
            var toolStripContainer = new ToolStripContainer();

            toolStripContainer.Dock = DockStyle.Fill;
            var mainForm = new MainForm(toolStripContainer)
            {
                Text = "DOM Property Editor".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Add the main Form instance to the container
            var batch = new CompositionBatch();

            batch.AddPart(mainForm);
            // batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-DOM-Tree-Editor-Sample".Localize()));
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            var propEditor = container.GetExportedValue <PropertyEditor>();

            propEditor.PropertyGrid.PropertySorting = Sce.Atf.Controls.PropertyEditing.PropertySorting.Categorized;
            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
Пример #17
0
        static void Main()
        {
            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Register the embedded image resources so that they will be available for all users of ResourceUtil,
            //  such as the PaletteService.
            ResourceUtil.Register(typeof(Resources));

            // enable metadata driven property editing
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                //typeof(LiveConnectService),             // allows easy interop between apps on same router subnet
                typeof(Outputs),                        // passes messages to all IOutputWriter components
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(RenameCommand),                  // allows for renaming of multiple selected objects

                //StandardPrintCommands does not currently work with Direct2D
                //typeof(StandardPrintCommands),        // standard File menu print commands

                typeof(PaletteService),                 // global palette, for drag/drop instancing
                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All
                typeof(PerformanceMonitor),             // displays the frame rate and memory usage
                typeof(FileWatcherService),             // service to watch for changes to files
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(SkinService),                    // allows for customization of an application appearance by using inheritable properties that can be applied at run-time

                // Client-specific plug-ins
                typeof(TimelineEditor),                 // timeline editor component
                typeof(TimelineCommands),               // defines Timeline-specific commands
                typeof(HelpAboutCommand),               // Help -> About command

                // Testing related
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );

            var container = new CompositionContainer(catalog);

            var toolStripContainer = new ToolStripContainer();

            toolStripContainer.Dock = DockStyle.Fill;

            var mainForm = new MainForm(toolStripContainer)
            {
                Text = "RobotDirector".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            var batch = new CompositionBatch();

            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Timeline-Editor-Sample".Localize()));

            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            container.Dispose();
        }
Пример #18
0
        static void AddTool1()
        {
            // Create a type catalog with the types of components we want in the application
            TypeCatalog catalog = new TypeCatalog(

                typeof(SettingsServiceCommands),        // Setting service commands
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(StandardLayoutCommands),         // standard Format menu layout commands
                typeof(StandardViewCommands),           // standard View menu commands

                //StandardPrintCommands does not currently work with Direct2D
                //typeof(StandardPrintCommands),        // standard File menu print commands

                typeof(PaletteService),                 // global palette, for drag/drop instancing

                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PrototypeLister),                // editable palette of instantiable item groups
                typeof(LayerLister),                    // editable tree view of layers

                typeof(Outputs),                        // passes messages to all log writers

                typeof(DiagramTheme),                   // rendering theme for diagrams
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls

                // Editors
                typeof(StatechartEditorSample.Editor),          // sample statechart editor
                typeof(StatechartEditorSample.SchemaLoader),    // loads statechart schema and extends types
                typeof(StatechartEditorSample.PaletteClient),   // component which adds palette items

                typeof(PythonService),                          // scripting service for automated tests
                typeof(AtfScriptVariables),                     // exposes common ATF services as script variables
                typeof(ScriptConsole),                          // provides a dockable command console for entering Python commands
                typeof(AutomationService)                       // provides facilities to run an automated script using the .NET remoting service
                );

            // Configure the main Form
            var mainForm = new MainForm(new ToolStripContainer())
            {
                Text = "State Chart Editor".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            var batchObjects = m_SharedComponents != null ? new List <object>(m_SharedComponents) : new List <object>();

            batchObjects.Add(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Diagram-Editor-Sample".Localize()));

            mainForm.InitializeComposition(catalog, batchObjects);

            //InitializeScriptingVariables(mainForm.ComponentContainer);

            // Add to tab
            m_toolMainForm.Tabs.Add(new Sce.Atf.Gui.TitleBarTab.TitleBarTabItem(m_toolMainForm)
            {
                Content = mainForm,
            });
        }
Пример #19
0
        static void Main()
        {
            // important to call these before creating application host
            Application.EnableVisualStyles();
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
#if !DEBUG
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
#endif
                typeof(DomExplorer),                    //Debug view the DOM
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable Ctrl+tab selection of documents and controls within the app

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(HelpAboutCommand),               // Help -> About command


                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor

                typeof(Outputs),                        // passes messages to all log writers
                typeof(ErrorDialogService),             // displays errors to the user a in message box

                typeof(HelpAboutCommand),               // custom command component to display Help/About dialog
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService),              // provides facilities to run an automated script using the .NET remoting service



                //Worldsmith stuff
                typeof(SchemaLoader),                   //Loads the schema
                typeof(Project.DotaVPKService),         //Handles the VPK stuff, including reading from the VPK and building the DOM node

                //UI Elements
                typeof(ProjectTreeLister),
                typeof(UnitTreeLister),
                typeof(TextEditing.TextEditor),
                typeof(DotaVPKTreeLister),
                typeof(KeyValueEditor),
                // typeof(UnitPropertyEditor),

                //Commands
                typeof(ProjectCommands),
                typeof(TreeListCommands),
                typeof(KeyValueCommands)
                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form
            var batch = new CompositionBatch();
            var toolStripContainer = new ToolStripContainer();
            var mainForm           = new MainForm(toolStripContainer)
            {
                Text = "Worldsmith".Localize(),
                Icon = GdiUtil.CreateIcon(WorldsmithATF.Properties.Resources.WSIcon32)
            };

            // Add the main Form instance to the container
            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("http://www.worldsmith.net".Localize()));
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
Пример #20
0
 public TypeCatalogTests()
 {
     catalog = new TypeCatalog();
 }
Пример #21
0
        static void Main()
        {
            // important to call these before creating application host
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714
#if true
            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(Outputs),                        // service that provides static methods for writing to IOutputWriter objects.
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.

                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(HelpAboutCommand),               // Help -> About command

                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls

                typeof(PropertyEditor),                 // property grid for editing selected objects
                //typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(Editor),                         // code editor component
                typeof(SchemaLoader),                   // loads schema and extends types
                typeof(CharacterEditor),
                typeof(CharacterSettingsCommands)

                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            var toolStripContainer = new ToolStripContainer();
            toolStripContainer.Dock = DockStyle.Fill;

            var mainForm = new MainForm(toolStripContainer);
            mainForm.Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage));

            mainForm.Text = "Butterfly Engine".Localize();

            var batch = new CompositionBatch();
            batch.AddPart(mainForm);
            container.Compose(batch);

            // To make the tab commands (e.g., "Copy Full Path", "Open Containing Folder") available, we have to change
            //  the default behavior to work with this sample app's unusual Editor. In most cases, an editor like this
            //  would implement IDocumentClient and this customization of DefaultTabCommands wouldn't be necessary.
            var tabCommands = container.GetExportedValue <DefaultTabCommands>();
            tabCommands.IsDocumentControl = controlInfo => controlInfo.Client is Editor;

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
#else
            var mainForm = new FormTest
            {
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            Application.Run(mainForm);
#endif
        }
Пример #22
0
        public void Export <T>()
        {
            var typeCatalog = new TypeCatalog(typeof(T));

            _catalog.Catalogs.Add(typeCatalog);
        }
Пример #23
0
        public void Should_be_able_to_cast_implicitly_to_type_catalog()
        {
            TypeCatalog catalog = builder;

            Assert.NotNull(catalog);
        }
        public void Constructor3_EmptyArrayAsTypesArgument_ShouldSetPartsPropertyToEmpty()
        {
            var catalog = new TypeCatalog(new Type[0]);

            Assert.Empty(catalog.Parts);
        }
Пример #25
0
        public void Should_be_able_to_add_assembly_by_name()
        {
            TypeCatalog catalog = builder.Add(GetType().Assembly.FullName);

            Assert.Contains(GetType().Assembly, catalog.Assemblies);
        }
Пример #26
0
 public void CompositionPoint_TypeArgument(Type type)
 {
     var x = new TypeCatalog(type);
 }
Пример #27
0
        public void Should_be_able_to_include_types()
        {
            TypeCatalog catalog = builder.Include(typeof(Controller));

            Assert.Equal(1, catalog.IncludeFilters.Count);
        }
Пример #28
0
        static void Main(string[] args)
        {
            // important to call these before creating application host
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(SettingsServiceCommands),        // Setting service commands
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(Outputs),                        // service that provides static methods for writing to IOutputWriter objects.
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(HelpAboutCommand),               // Help -> About command
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(Editor),                         // code editor component
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService),              // provides facilities to run an automated script using the .NET remoting service
#if PERFORCE_VERSION_CONTROL
                typeof(PerforceService),                // Perforce plugin
#else
                typeof(SubversionService),              // SVN plugin
#endif
                typeof(SourceControlCommands),          // source control commmands to interact with Perforce plugin
                typeof(SourceControlContext)            // source control context component
                );

            var container = new CompositionContainer(catalog);

            var toolStripContainer = new ToolStripContainer();

            toolStripContainer.Dock = DockStyle.Fill;

            var mainForm = new MainForm(toolStripContainer);
            var image    = GdiUtil.GetImage("CodeEditor.Resources.File_edit.ico");

            mainForm.Icon = GdiUtil.CreateIcon(image, 32, true);

            mainForm.Text = "Code Editor".Localize();

            var batch = new CompositionBatch();

            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Code-Editor-Sample".Localize()));
            container.Compose(batch);

            // To make the tab commands (e.g., "Copy Full Path", "Open Containing Folder") available, we have to change
            //  the default behavior to work with this sample app's unusual Editor. In most cases, an editor like this
            //  would implement IDocumentClient and this customization of DefaultTabCommands wouldn't be necessary.
            var tabCommands = container.GetExportedValue <DefaultTabCommands>();

            tabCommands.IsDocumentControl = controlInfo => controlInfo.Client is Editor;

#if !PERFORCE_VERSION_CONTROL
            var sourceControlCommands = container.GetExportedValue <SourceControlCommands>();
            sourceControlCommands.RefreshStatusOnSave = true;
#endif

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            container.Dispose();
        }
Пример #29
0
        public void Should_be_able_to_exclude_type_by_name()
        {
            TypeCatalog catalog = builder.Exclude(typeof(Controller).FullName);

            Assert.Equal(1, catalog.ExcludeFilters.Count);
        }
Пример #30
0
        static void Main()
        {
            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(

                typeof(SingleInstanceService),          // enforces the single-instance constraint on a GUI application

                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(StandardLockCommands),           // standard Edit menu lock/unlock commands
                typeof(StandardLayoutCommands),         // standard Format menu layout commands
                typeof(StandardViewCommands),           // standard View menu commands

                //StandardPrintCommands does not currently work with Direct2D
                //typeof(StandardPrintCommands),        // standard File menu print commands

                typeof(HelpAboutCommand),               // Help -> About command

                typeof(PaletteService),                 // global palette, for drag/drop instancing
                typeof(HistoryLister),                  // vistual list of undo/redo stack
                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(PrototypeLister),                // editable palette of instantiable item groups

                typeof(Outputs),                        // service that provides static methods for writing to IOutputWriter objects.
                typeof(ErrorDialogService),             // displays errors to the user in a message box. Implements IOutputWriter.
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.

                typeof(DiagramTheme),                   // rendering theme for diagrams

                typeof(Editor),                         // editor which manages statechart documents and controls
                typeof(PaletteClient),                  // component which adds items to palette
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(SchemaLoader),                   // loads schema and extends types
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form
            var batch    = new CompositionBatch();
            var mainForm = new MainForm(new ToolStripContainer())
            {
                Text = Application.ProductName,
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle);

            // Add the main Form instance to the container
            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-State-Chart-Editor-Sample".Localize()));
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
        public void WhenItemsInCollection_TryGetReturnsTrueAndCatalog()
        {
            // Prepare
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            ComposablePartCatalog catalog1 = new TypeCatalog();
            ComposablePartCatalog catalog2 = new TypeCatalog();
            ComposablePartCatalog catalog3 = new TypeCatalog();

            DownloadedPartCatalogCollection target = new DownloadedPartCatalogCollection();

            target.Add(moduleInfo1, catalog1);
            target.Add(moduleInfo2, catalog2);
            target.Add(moduleInfo3, catalog3);

            // Act
            bool actual = target.TryGet(moduleInfo3, out catalog3);    
        
            // Verify
            Assert.IsTrue(actual);
            Assert.AreSame(catalog3, target.Get(moduleInfo3));
            
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TypeCatalogBuilder"/> class.
        /// </summary>
        /// <param name="typeCatalog">The type catalog.</param>
        public TypeCatalogBuilder(TypeCatalog typeCatalog)
        {
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            TypeCatalog = typeCatalog;
        }
Пример #33
0
        private static TypeCatalog CreateTypeCatalog()
        {
            var catalog = new TypeCatalog();

            catalog.Assemblies.Add(typeof(FilterRegistryTests).Assembly);
            catalog.IncludeFilters.Add(type => ((typeof(Dummy1Controller) == type) || (typeof(Dummy2Controller) == type)));

            return catalog;
        }
        public void WhenItemsCleared_TryGetReturnsFalse()
        {
            // Prepare
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            ComposablePartCatalog catalog1 = new TypeCatalog();
            ComposablePartCatalog catalog2 = new TypeCatalog();
            ComposablePartCatalog catalog3 = new TypeCatalog();

            DownloadedPartCatalogCollection target = new DownloadedPartCatalogCollection();

            target.Add(moduleInfo1, catalog1);
            target.Add(moduleInfo2, catalog2);
            target.Add(moduleInfo3, catalog3);

            // Act
            target.Clear();

            ComposablePartCatalog catalog1b;
            ComposablePartCatalog catalog2b;
            ComposablePartCatalog catalog3b;

            bool actual1 = target.TryGet(moduleInfo1, out catalog1b);
            bool actual2 = target.TryGet(moduleInfo2, out catalog2b);
            bool actual3 = target.TryGet(moduleInfo3, out catalog3b);
            

            // Verify
            Assert.IsFalse(actual1);
            Assert.IsFalse(actual2);
            Assert.IsFalse(actual3);

        }
Пример #35
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(
                typeof(SettingsService),                 // persistent settings and user preferences dialog
                typeof(StatusService),                   // status bar at bottom of main Form
                typeof(CommandService),                  // handles commands in menus and toolbars
                typeof(ControlHostService),              // docking control host
                typeof(AtfUsageLogger),                  // logs computer info to an ATF server
                typeof(CrashLogger),                     // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),       // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),               // standard Windows file dialogs
                typeof(DocumentRegistry),                // central document registry with change notification
                typeof(RecentDocumentCommands),          // standard recent document commands in File menu
                typeof(StandardFileCommands),            // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),          // tracks document changes and updates main form title
                typeof(StandardFileExitCommand),         // standard File exit menu command
                typeof(HelpAboutCommand),                // Help -> About command
                typeof(PythonService),                   // scripting service for automated tests
                typeof(ScriptConsole),                   // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),              // exposes common ATF services as script variables
                typeof(AutomationService),               // provides facilities to run an automated script using the .NET remoting service
                typeof(Outputs),                         // passes messages to all IOutputWriter components
                typeof(ShoutOutputService),              // rich text box for displaying error and warning messages. Implements IOutputWriter

                typeof(Sce.Atf.Atgi.AtgiResolver),       // loads ATGI resources from a file
                typeof(Sce.Atf.Collada.ColladaResolver), // loads Collada resources from a file

                // this sample
                typeof(ModelViewer),                    // recognizes model file extensions and uses the above model resolvers to load models
                typeof(RenderCommands),                 // provides commands for switching the RenderView's rendering mode, etc.
                typeof(RenderView)                      // displays a 3D scene in a Windows Control
                );


            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form
            var batch    = new CompositionBatch();
            var mainForm = new MainForm(new ToolStripContainer())
            {
                Text = "Model Viewer".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Add the main Form instance to the container
            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Model-Viewer-Sample".Localize()));
            container.Compose(batch);

            var stdfile = container.GetExportedValue <StandardFileCommands>();

            stdfile.RegisterCommands = StandardFileCommands.CommandRegister.FileOpen;

            // Initialize components
            foreach (IInitializable initializable in container.GetExportedValues <IInitializable>())
            {
                initializable.Initialize();
            }

            // Show the main form and start message handling. The main Form Load event provides a final chance
            // for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
Пример #36
0
        public void Should_be_able_to_exclude_type_flter()
        {
            TypeCatalog catalog = builder.Exclude(type => typeof(Controller).IsAssignableFrom(type));

            Assert.Equal(1, catalog.ExcludeFilters.Count);
        }
Пример #37
0
        static void Main()
        {
            // It's important to call these before starting the app; otherwise theming and bitmaps
            // may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Register the embedded image resources so that they will be available for all users of ResourceUtil,
            //  such as the PaletteService.
            ResourceUtil.Register(typeof(Resources));

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(StatusService),                  // status bar at bottom of main Form
                typeof(Outputs),                        // service that provides static methods for writing to IOutputWriter objects.
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(SkinService),
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(StandardFileExitCommand),        // standard File exit menu command
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(HelpAboutCommand),               // Help -> About command

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands

                typeof(PaletteService),                 // global palette, for drag/drop instancing
                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        //  Reset All, Copy Value, Paste Value, Copy All, Paste All
                typeof(CurveEditor),                    // edits curves using the CurveEditingControl

                typeof(SchemaLoader),                   // component that loads XML schema and sets up types
                typeof(Editor),                         // component that manages UI documents
                typeof(PaletteClient),                  // component that adds UI types to palette
                typeof(TreeLister),                     // component that displays the UI in a tree control
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                typeof(DomExplorer),                    // component that gives diagnostic view of DOM
                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // Configure the main Form with a ToolStripContainer so the CommandService can
            //  generate toolbars.
            var toolStripContainer = new ToolStripContainer();

            toolStripContainer.Dock = DockStyle.Fill;
            var mainForm = new MainForm(toolStripContainer)
            {
                Text = "Dom Tree Editor".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Add the main Form instance to the container
            var batch = new CompositionBatch();

            batch.AddPart(mainForm);
            batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-DOM-Tree-Editor-Sample".Localize()));
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            //// Example of programmatic layout creation:
            //{
            //    var windowLayoutService = container.GetExportedValue<IWindowLayoutService>();
            //    var dockStateProvider = container.GetExportedValue<IDockStateProvider>();

            //    // Load custom XML and add it to the Window Layout Service
            //    int layoutNum = 0;
            //    Assembly assembly = Assembly.GetExecutingAssembly();
            //    foreach (string resourceName in assembly.GetManifestResourceNames())
            //    {
            //        if (resourceName.Contains("Layout") && resourceName.EndsWith(".xml"))
            //        {
            //            var xmlDoc = new XmlDocument();
            //            xmlDoc.Load(assembly.GetManifestResourceStream(resourceName));

            //            layoutNum++;
            //            windowLayoutService.SetOrAddLayout(dockStateProvider, "Programmatic Layout " + layoutNum, xmlDoc.InnerXml);
            //        }
            //    }
            //}

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
 public TypeCatalogTests()
 {
     catalog = new TypeCatalog();
 }
Пример #39
0
        static void Main()
        {
            // Important to call these before starting the app.  Otherwise theming and bitmaps may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // Using MEF, declare the composable parts that will make up this application
            TypeCatalog catalog = new TypeCatalog(
                typeof(SettingsService),                // persistent settings and user preferences dialog
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command

                typeof(FileDialogService),              // standard Windows file dialogs
                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                typeof(WindowLayoutService),            // service to allow multiple window layouts
                typeof(WindowLayoutServiceCommands),    // command layer to allow easy switching between and managing of window layouts

                // Client-specific plug-ins
                typeof(Editor),                         // editor class component that creates and saves application documents
                typeof(SchemaLoader),                   // loads schema and extends types

                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService)               // provides facilities to run an automated script using the .NET remoting service
                );

            // Create the MEF container for the composable parts
            CompositionContainer container = new CompositionContainer(catalog);

            // Create the main form, give it a toolstrip
            ToolStripContainer toolStripContainer = new ToolStripContainer();

            toolStripContainer.Dock = DockStyle.Fill;
            MainForm mainForm = new MainForm(toolStripContainer)
            {
                Text = "Sample Application".Localize(),
                Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Create an MEF composable part from the main form, and add into container
            CompositionBatch batch = new CompositionBatch();

            AttributedModelServices.AddPart(batch, mainForm);
            container.Compose(batch);

            // Initialize components that require it. Initialization often can't be done in the constructor,
            //  or even after imports have been satisfied by MEF, since we allow circular dependencies between
            //  components, via the System.Lazy class. IInitializable allows components to defer some operations
            //  until all MEF composition has been completed.
            container.InitializeAll();

            // Show the main form and start message handling. The main Form Load event provides a final chance
            //  for components to perform initialization and configuration.
            Application.Run(mainForm);

            // Give components a chance to clean up.
            container.Dispose();
        }
Пример #40
0
 public TypeHelperContext()
 {
     var catalog = new TypeCatalog(typeof(DummyPart));
     var part = catalog.Parts.First();
     DummyPartImports = part.ImportDefinitions;
 }
Пример #41
0
        static Global()
        {
            var catalog = new TypeCatalog(typeof(MyReportsResolver), typeof(MyTypeResolveService));

            container = new CompositionContainer(catalog);
        }