Ejemplo n.º 1
0
        /// <summary>
        /// Specifies how type mappings are created, including default type mappings. Calling this method will
        /// clear all existing name transformation rules and create new default type mappings according to the
        /// configuration.
        /// </summary>
        /// <param name="config">An instance of TypeMappingConfiguration that provides the settings for configuration</param>
        public static void ConfigureTypeMappings(TypeMappingConfiguration config)
        {
            if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
            {
                throw new ArgumentException("DefaultSubNamespaceForViews field cannot be blank.");
            }

            if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
            {
                throw new ArgumentException("DefaultSubNamespaceForViewModels field cannot be blank.");
            }

            if (String.IsNullOrEmpty(config.NameFormat))
            {
                throw new ArgumentException("NameFormat field cannot be blank.");
            }

            NameTransformer.Clear();
            ViewSuffixList.Clear();

            defaultSubNsViews = config.DefaultSubNamespaceForViews;
            defaultSubNsViewModels = config.DefaultSubNamespaceForViewModels;
            nameFormat = config.NameFormat;
            useNameSuffixesInMappings = config.UseNameSuffixesInMappings;
            viewModelSuffix = config.ViewModelSuffix;
            ViewSuffixList.AddRange(config.ViewSuffixList);
            includeViewSuffixInVmNames = config.IncludeViewSuffixInViewModelNames;

            SetAllDefaults();
        }
        /// <summary>
        /// Specifies how type mappings are created, including default type mappings. Calling this method will
        /// clear all existing name transformation rules and create new default type mappings according to the
        /// configuration.
        /// </summary>
        /// <param name="config">An instance of TypeMappingConfiguration that provides the settings for configuration</param>
        public static void ConfigureTypeMappings(TypeMappingConfiguration config)
        {
            if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViews))
            {
                throw new ArgumentException("DefaultSubNamespaceForViews field cannot be blank.");
            }

            if (String.IsNullOrEmpty(config.DefaultSubNamespaceForViewModels))
            {
                throw new ArgumentException("DefaultSubNamespaceForViewModels field cannot be blank.");
            }

            if (String.IsNullOrEmpty(config.NameFormat))
            {
                throw new ArgumentException("NameFormat field cannot be blank.");
            }

            NameTransformer.Clear();
            ViewSuffixList.Clear();

            defaultSubNsViews         = config.DefaultSubNamespaceForViews;
            defaultSubNsViewModels    = config.DefaultSubNamespaceForViewModels;
            nameFormat                = config.NameFormat;
            useNameSuffixesInMappings = config.UseNameSuffixesInMappings;
            viewModelSuffix           = config.ViewModelSuffix;
            ViewSuffixList.AddRange(config.ViewSuffixList);
            includeViewSuffixInVmNames = config.IncludeViewSuffixInViewModelNames;

            SetAllDefaults();
        }
Ejemplo n.º 3
0
 private static void ConfigureTypeMapping()
 {
     var config = new TypeMappingConfiguration
     {
         DefaultSubNamespaceForViews = "InstantDelivery.Views",
         DefaultSubNamespaceForViewModels = "InstantDelivery.ViewModel"
     };
     ViewLocator.ConfigureTypeMappings(config);
     ViewModelLocator.ConfigureTypeMappings(config);
 }
        static ActivityLocator() {

            var configuration = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews = "Activities", 
                IncludeViewSuffixInViewModelNames = false
            };

            configuration.ViewSuffixList.Add("Activity");

            ConfigureTypeMappings(configuration);
        }
Ejemplo n.º 5
0
        static ActivityLocator()
        {
            var configuration = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews       = "Activities",
                IncludeViewSuffixInViewModelNames = false
            };

            configuration.ViewSuffixList.Add("Activity");

            ConfigureTypeMappings(configuration);
        }
        public AppBootstrapper()
        {
            var config = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews = "MvvmCaliburnTemplate.View",
                DefaultSubNamespaceForViewModels = "MvvmCaliburnTemplate.ViewModel"
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);

            Initialize();
        }
        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            var config = new TypeMappingConfiguration
                             {
                                 DefaultSubNamespaceForViewModels = typeof(MainWindowViewModel).Namespace,
                                 DefaultSubNamespaceForViews = typeof(MainWindowView).Namespace
                             };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);

            base.OnStartup(sender, e);

            DisplayRootViewFor<IMainWindowViewModel>();
        }
Ejemplo n.º 8
0
        protected override void Configure()
        {
            var config = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews = "Views",
                DefaultSubNamespaceForViewModels = "ModelViews"
            };
            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);
            container = new WinRTContainer();

            container.RegisterWinRTServices();

            container.PerRequest<FirstViewModel>();
        }
Ejemplo n.º 9
0
        static ViewModelLocator()
        {
            var configuration = new TypeMappingConfiguration();

#if ANDROID
            configuration.DefaultSubNamespaceForViews = "Activities";
            configuration.ViewSuffixList.Add("Activity");
            configuration.IncludeViewSuffixInViewModelNames = false;
#elif IOS
            configuration.DefaultSubNamespaceForViews = "ViewControllers";
            configuration.ViewSuffixList.Add("ViewController");
            configuration.IncludeViewSuffixInViewModelNames = false;
#endif

            ConfigureTypeMappings(configuration);
        }
Ejemplo n.º 10
0
        static ViewModelLocator()
        {
            var configuration = new TypeMappingConfiguration();

            ConfigureTypeMappings(configuration);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Override this to add custom behavior to execute after the application starts.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The args.</param>
        protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
        {
            var config = new TypeMappingConfiguration()
            {
                //ToDo: Namespace anpassen:
                DefaultSubNamespaceForViewModels = "OctaSweeper.ViewModel.ViewModels",
                DefaultSubNamespaceForViews = "OctaSweeper.Views"
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);

            base.OnStartup(sender, e);

            this.DisplayRootViewFor<MainViewModel>();
        }
Ejemplo n.º 12
0
        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            var config = new TypeMappingConfiguration
                             {
                                 DefaultSubNamespaceForViewModels = "ViewModels",
                                 DefaultSubNamespaceForViews = "Views"
                             };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);

            base.OnStartup(sender, e);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Caliburn.Micro configuration, 
        /// </summary>
        protected override void Configure()
        {
            // Logging configuration
            LogManager.GetLog = t => new DebugLog(t);

            // IoC configuration
            container = new WinRTContainer();

            container.RegisterWinRTServices();

            container
                .Singleton<IAuthenticationService, AuthenticationService>()
                .Singleton<ITeamService, TeamService>()
                .Singleton<INotificationService, NotificationService>()
                .Singleton<IPersistenceService, PersistenceService>()

                .PerRequest<LoginViewModel>()
                .PerRequest<MapViewModel>()
                .PerRequest<PasswordReminderViewModel>()
                .PerRequest<PasswordReminderSentViewModel>()
                .PerRequest<RegisterViewModel>()
                .PerRequest<TeamAdminViewModel>()
                .PerRequest<TeamCreatedViewModel>()
                .PerRequest<TeamCreationViewModel>()
                .PerRequest<TeamJoinViewModel>()
                .PerRequest<TeamSearchViewModel>()
                .PerRequest<TeamViewModel>();

            var config = new TypeMappingConfiguration
            {
                NameFormat = "{0}{1}",
                IncludeViewSuffixInViewModelNames = false
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);

            // Navigation configuration
            PrepareViewFirst();
        }