コード例 #1
0
        internal static void LoadManagedComponent(string assemblyName, string managedInterface)
        {
            IManagedComponent instance = (IManagedComponent)Activator.CreateInstance(AssemblyLoader.LoadFrom(ManagedDllFolder.Name + assemblyName + ".dll").GetType(managedInterface));

            Managed._components.Add(instance);
            instance.OnStart();
        }
コード例 #2
0
            private IModule CreateViewModels()
            {
                var enterVm          = this.CreateViewModel(typeof(EnterPageViewModel));
                var loginVm          = this.CreateViewModel(typeof(LoginPageViewModel));
                var registrationVm   = this.CreateViewModel(typeof(RegistrationPageViewModel));
                var contactsVm       = this.CreateViewModel(typeof(ContactsPageViewModel));
                var contactDefaultVm = this.CreateViewModel(typeof(ContactDefaultPageViewModel));
                var contactDataVm    = this.CreateViewModel(typeof(ContactDataPageViewModel));
                var telegramVm       = this.CreateViewModel(typeof(TelegramAccountPageViewModel));
                var noteVm           = this.CreateViewModel(typeof(NoteWindowViewModel));
                var adminVm          = this.CreateViewModel(typeof(AdminPageViewModel));

                var enumerable = new IManagedComponent[]
                {
                    enterVm,
                    loginVm,
                    registrationVm,
                    contactsVm,
                    contactDefaultVm,
                    contactDataVm,
                    telegramVm,
                    noteVm,
                    adminVm,
                };

                return(new StdModule(enumerable));
            }
コード例 #3
0
            private IModule CreateServices()
            {
                var resource      = this.CreateServiceComponent(typeof(ApplicationResourceService), typeof(IResourceService), RegistrationFlag.Singleton);
                var searcher      = this.CreateServiceComponent(typeof(ObjectSearcher), typeof(IObjectSearcher), RegistrationFlag.Singleton);
                var dialog        = this.CreateServiceComponent(typeof(DialogService), typeof(IDialogService), RegistrationFlag.Singleton);
                var messanger     = this.CreateServiceComponent(typeof(MessageBoxService), typeof(IMessageBoxService), RegistrationFlag.Singleton);
                var cmdProvider   = this.CreateServiceComponent(typeof(DefaultCommandProvider), typeof(ICommandProvider), RegistrationFlag.PerDependency);
                var navigation    = this.CreateServiceComponent(typeof(UiNavigation), typeof(IUiNavigation), RegistrationFlag.PerDependency);
                var windowStarter = this.CreateServiceComponent(typeof(WindowStarter), typeof(IWindowStarter), RegistrationFlag.PerDependency);

                const string localDb    = @"(LocalDB)\MSSQLLocalDB";
                const bool   initialize = false; // :-)
                var          context    = this.CreateServiceComponent(typeof(ApplicationContext), typeof(DbContext), RegistrationFlag.PerDependency);

                context.SetCtorArgs(new Autofac.Core.Parameter[]
                {
                    new NamedParameter("info", new MsSqlStorageInfo("A_Contacts_G", localDb)),
                    new NamedParameter("initialize", initialize)
                });

                var container = this.CreateServiceComponent(typeof(SqlContainer), typeof(ISqlContainer), RegistrationFlag.PerDependency);

                container.SetCtorArgs(new Autofac.Core.Parameter[]
                {
                    new Autofac.Core.ResolvedParameter(this.GetPredicate(typeof(DbContext), "context"), this.GetValueAccessor <DbContext>()),
                    new NamedParameter("repositoryRealizationType", typeof(SqlRepository <>))
                });

                var enumerable = new IManagedComponent[]
                {
                    resource,
                    searcher,
                    dialog,
                    messanger,
                    cmdProvider,
                    navigation,
                    windowStarter,

                    context,
                    container
                };

                return(new StdModule(enumerable));
            }
コード例 #4
0
        public static void RegisterArgsEmpty(this ContainerBuilder @this, IManagedComponent component)
        {
            var target        = component.GetTarget();
            var classType     = target.Key;
            var interfaceType = target.Value;

            if (component.Info.RegistrationFlag.IsPerDependency())
            {
                @this.RegisterType(classType).As(interfaceType).InstancePerDependency();
            }
            else if (component.Info.RegistrationFlag.IsSingleton())
            {
                @this.RegisterType(classType).As(interfaceType).SingleInstance();
            }
            else if (component.Info.RegistrationFlag.IsSelf())
            {
                @this.RegisterType(classType).AsSelf();
            }
        }