示例#1
0
        private void AppInitialize()
        {
            AppContainer = ContainerHelper.SetupContainer(
                out var container
                , null
                , _containerHelperSettings
                );
            _container = container;

            SetupTracing();


            var loggerTracker = AppContainer.Resolve <ILoggerTracker>();
            var myLoggerName  = typeof(App).FullName;

            loggerTracker.LoggerRegistered += (sender, args) =>
            {
                if (args.Logger.Name == myLoggerName)
                {
                    args.Logger.Trace(
                        "Received logger for application in LoggerRegistered handler."
                        );
                }
                else
                {
                    if (Logger == null)
                    {
                        System.Diagnostics.Debug.WriteLine(
                            "got a logger but i don't have one yet"
                            );
                    }
                }
            };

            Logger = AppContainer.Resolve <ILogger>(
                new TypedParameter(
                    typeof(Type)
                    , typeof(App)
                    )
                );


            if (AppContainer.IsRegistered <IMenuItemCollection>())
            {
                var menuItemList = AppContainer.Resolve <IMenuItemCollection>();
                MenuItemListCollectionView  = new ListCollectionView(menuItemList);
                Resources["MyMenuItemList"] = menuItemList;
            }


            var handler = new RoutedEventHandler(MainWindowLoaded);

            EventManager.RegisterClassHandler(
                typeof(Window)
                , FrameworkElement.LoadedEvent
                , handler
                );



            // var converter = new RegistrationConverter ( AppContainer , objectIdProvider ) ;
            // Resources[ "RegistrationConverter" ] = converter ;
            Stage2Complete = true;
            TCS.SetResult(1);
        }