/// <summary> /// Gets whether the software is currently in design mode. /// <para /> /// Note that unless the <see cref="IsInDesignMode" />, the value is not cached but always determined at runtime. /// </summary> /// <param name="initializeDesignTime">if set to <c>true</c>, automatically call <see cref="DesignTimeHelper.InitializeDesignTime"/> if in design mode.</param> /// <returns><c>true</c> if the software is in design mode, <c>false</c> otherwise.</returns> public static bool GetIsInDesignMode(bool initializeDesignTime) { bool?isInDesignMode = null; #if NET var prop = DesignerProperties.IsInDesignModeProperty; isInDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue; if (!isInDesignMode.Value) { isInDesignMode = DesignerProperties.GetIsInDesignMode(new DependencyObject()); } if (!BypassDevEnvCheck && !isInDesignMode.Value && EnvironmentHelper.IsProcessHostedByTool) { isInDesignMode = true; } #elif NETFX_CORE isInDesignMode = global::Windows.ApplicationModel.DesignMode.DesignModeEnabled; #elif XAMARIN || XAMARIN_FORMS isInDesignMode = false; #else isInDesignMode = DesignerProperties.IsInDesignTool; #endif if (initializeDesignTime && isInDesignMode.Value) { DesignTimeHelper.InitializeDesignTime(); } return(isInDesignMode.Value); }
/// <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(); }
/// <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(); }
/// <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(); }