예제 #1
0
파일: MVVMModule.cs 프로젝트: wushian/Catel
        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered <IDataContextSubscriptionService, DataContextSubscriptionService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewLoadManager, ViewLoadManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelWrapperService, ViewModelWrapperService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IAutoCompletionService, AutoCompletionService>();

#if NET || NETCORE
            serviceLocator.RegisterTypeIfNotYetRegistered <IWrapControlService, WrapControlService>();
#endif

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);

#if !XAMARIN
            var typeFactory = serviceLocator.ResolveType <ITypeFactory>();
            var auditor     = typeFactory.CreateInstance <InvalidateCommandManagerOnViewModelInitializationAuditor>();
            AuditingManager.RegisterAuditor(auditor);
#endif

            DesignTimeHelper.InitializeDesignTime();
        }
예제 #2
0
파일: MVVMModule.cs 프로젝트: yicong/Catel
        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered <ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewLoadManager, ViewLoadManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelWrapperService, ViewModelWrapperService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IAutoCompletionService, AutoCompletionService>();

#if !XAMARIN && !WIN80
            serviceLocator.RegisterTypeIfNotYetRegistered <IInteractivityManager, InteractivityManager>();
#endif

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);

            // Don't use property, we cannot trust the cached property here yet in Visual Studio
            if (CatelEnvironment.GetIsInDesignMode())
            {
                foreach (var assembly in AssemblyHelper.GetLoadedAssemblies())
                {
                    var attributes = assembly.GetCustomAttributesEx(typeof(DesignTimeCodeAttribute));
                    foreach (var attribute in attributes)
                    {
                        // No need to do anything
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes the module
        /// </summary>
        public static void Initialize()
        {
            var serviceLocator = ServiceLocator.Default;

#if !NET
            serviceLocator.RegisterTypeIfNotYetRegistered <IFrameworkElementLoadedManager, FrameworkElementLoadedManager>();
#endif

            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);
        }
예제 #4
0
        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

#if !NET
            serviceLocator.RegisterTypeIfNotYetRegistered <IFrameworkElementLoadedManager, FrameworkElementLoadedManager>();
#endif

            serviceLocator.RegisterTypeIfNotYetRegistered <ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);
        }
예제 #5
0
        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered <IDataContextSubscriptionService, DataContextSubscriptionService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewLoadManager, ViewLoadManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelWrapperService, ViewModelWrapperService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IAutoCompletionService, AutoCompletionService>();

#if !XAMARIN && !WIN80
            serviceLocator.RegisterTypeIfNotYetRegistered <IInteractivityManager, InteractivityManager>();
#endif

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);

            DesignTimeHelper.InitializeDesignTime();
        }
예제 #6
0
        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            serviceLocator.RegisterTypeIfNotYetRegistered <IDataContextSubscriptionService, DataContextSubscriptionService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <ICommandManager, CommandManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewLoadManager, ViewLoadManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelWrapperService, ViewModelWrapperService>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewManager, ViewManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IViewModelManager, ViewModelManager>();
            serviceLocator.RegisterTypeIfNotYetRegistered <IAutoCompletionService, AutoCompletionService>();

#if NET
            serviceLocator.RegisterTypeIfNotYetRegistered <IWrapControlService, WrapControlService>();
#endif

            ViewModelServiceHelper.RegisterDefaultViewModelServices(serviceLocator);

            DesignTimeHelper.InitializeDesignTime();
        }
예제 #7
0
 /// <summary>
 /// Registers the default view model services in the default <see cref="ServiceLocator"/>. This call can come in handy when the
 /// services should be accessed before any view model is created.
 /// </summary>
 public static void RegisterDefaultViewModelServices()
 {
     ViewModelServiceHelper.RegisterDefaultViewModelServices(ServiceLocator.Default);
 }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BootstrapperBase"/> class.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        protected BootstrapperBase(IServiceLocator serviceLocator = null)
        {
            _serviceLocator = serviceLocator ?? ServiceLocator.Default;

            ViewModelServiceHelper.RegisterDefaultViewModelServices(_serviceLocator);
        }