Exemple #1
0
        public ShoppingList()
        {
            this.InitializeComponent();

            ViewModel = new ShoppingListViewModel(ServiceRegistrar.ShoppingService(App.SqliteConnection));
            ShoppingListView.ItemsSource = ViewModel.Items;

            // Developer will want to return to none selection when selected items are zero
            ShoppingListView.SelectionChanged += OnSelectionChanged;

            // With this property we enable that the left edge tap visual indicator shows
            // when user press the listviewitem left edge
            // and also the ItemLeftEdgeTapped event will be fired
            // when user releases the pointer
            ShoppingListView.IsItemLeftEdgeTapEnabled = true;

            // This is event that will be fired when user releases the pointer after
            // pressing on the left edge of the ListViewItem
            ShoppingListView.ItemLeftEdgeTapped += OnEdgeTapped;

            // We set the state of the commands on the appbar
            SetCommandsVisibility(ShoppingListView);

            // This is how devs can handle the back button
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
        }
Exemple #2
0
        public void FindAndRegister_ExecutingAssembly_RegistersAllComponents()
        {
            var services = new ServiceCollection();
            var options  = new IntermediumOptions();

            options.Scan(typeof(ServiceRegistrarTests));
            ServiceRegistrar.FindAndRegister(services, options);

            var provider = services.BuildServiceProvider();

            provider.GetService <Core.ServiceProvider>().Should().NotBeNull();
            provider.GetService <IMediator>().Should().BeOfType <Mediator>();

            new[]
            {
                typeof(ExceptionHandlingMiddleware <,>),
                typeof(PostProcessingMiddleware <,>),
                typeof(PreProcessingMiddleware <,>)
            }
            .All(middleware => services.Any(x => x.ImplementationType == middleware))
            .Should()
            .BeTrue();

            provider.GetServices <IQueryHandler <QueryTest, int> >().Should().HaveCount(1);
            provider.GetServices <IQueryHandler <CommandTest, VoidUnit> >().Should().HaveCount(1);
            provider.GetServices <INotificationHandler <NotificationTest> >().Should().HaveCount(2);
            provider.GetServices <IQueryExceptionHandler <CommandTest, VoidUnit> >().Should().HaveCount(3);
        }
Exemple #3
0
        public static IServiceCollection AddNotificationHandlers(this IServiceCollection services, params Type[] markerTypes)
        {
            var assemblies = markerTypes.Select(x => x.GetTypeInfo().Assembly);

            ServiceRegistrar.AddMediatRClasses(services, assemblies, new MediatRServiceConfiguration());
            return(services);
        }
Exemple #4
0
        /// <summary>
        /// Override on create to instantiate the service container to be persistant.
        /// </summary>
        public override void OnCreate()
        {
            base.OnCreate();

            //Registers services for core library
            ServiceRegistrar.Startup();
        }
Exemple #5
0
        public App()
        {
            InitializeComponent();

            ServiceRegistrar.Startup();

            MainPage = new LoginView();
        }
Exemple #6
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name='args'>
        /// The command-line arguments.
        /// </param>
        static void Main(string[] args)
        {
            //Setup our services for core library
            ServiceRegistrar.Startup();

            // if you want to use a different Application Delegate class from "AppDelegate" you can specify it here.
            UIApplication.Main(args, null, "AppDelegate");
        }
Exemple #7
0
 public async Task <RegistrarDocument> GetDocumentsByAccountAndClients1CAndDocumentIDAsync(string adLogin,
                                                                                           string account1CCode, Client user, int documentID) =>
 await ExecuteWithTryCatchAsync <RegistrarDocument, WCFServiceRegistrar>(() =>
                                                                         ServiceRegistrar.GetDocumentsByAccountAndClients1CAndDocumentIDAsync(adLogin, account1CCode, user,
                                                                                                                                              documentID),
                                                                         new LogShortMessage("Ошибка вызова метода. Метод: {methodName}, adLogin: {adLogin}," +
                                                                                             " account1CCode: {account1CCode}, client: {clients}, documentID: {documentID}.",
                                                                                             "GetDocumentsByAccountAndClients1CAndDocumentIDAsync", adLogin, account1CCode, user, documentID));
Exemple #8
0
 private string[] GetSuggestions(string text)
 {
     return
         (ServiceRegistrar.ShoppingService(App.SqliteConnection).BoughtItems
          .Where(boughtItem => boughtItem.Title.ToLower().Contains(text.ToLower()) &&
                 ServiceRegistrar.ShoppingService(App.SqliteConnection).Items.All(x => !string.Equals(x.Title, boughtItem.Title, StringComparison.CurrentCultureIgnoreCase)))
          .Select(x => x.Title)
          .ToArray());
 }
        public void RegisterAssembly(Assembly assembly)
        {
            IList <Assembly> assemblies = new List <Assembly>()
            {
                assembly
            };

            ServiceRegistrar.AddMediatRClasses(HostManager.Context.ServiceDescriptors, assemblies);
        }
        public static void AddStatistics(this IServiceCollection serviceCollection, string connectionString)
        {
            ServiceRegistrar.AddMediatRClasses(serviceCollection, new[] { Assembly });

            serviceCollection.AddDbContext <StatisticsDbContext>(options =>
                                                                 options.UseSqlServer(connectionString,
                                                                                      x => x.MigrationsHistoryTable("__EFMigrationsHistory", "Stats")),
                                                                 ServiceLifetime.Transient);
        }
        public override void OnCreate()
        {
            base.OnCreate();
            var platform = new Microsoft.WindowsAzure.MobileServices.CurrentPlatform();

            System.Diagnostics.Debug.WriteLine(platform);
            CurrentPlatform.Init();
            ServiceRegistrar.Startup();
        }
Exemple #12
0
        public MediatorHandlerTests()
        {
            services = new ServiceContainer();

            ServiceRegistrar.AddMediatRClasses(services, new[] { Assembly.GetExecutingAssembly() });
            ServiceRegistrar.AddRequiredServices(services);

            mediator = services.GetInstance <IMediator>();
        }
        public static void AddLeeliteCore(this IServiceCollection services)
        {
            services.AddMapper();

            var serviceConfig = new MediatRServiceConfiguration();

            serviceConfig.AsScoped();

            ServiceRegistrar.AddRequiredServices(services, serviceConfig);
        }
        public static ElsaOptionsBuilder UseIndexing(this ElsaOptionsBuilder options, Action <ElsaIndexingOptions> configure)
        {
            var indexingOptions = new ElsaIndexingOptions(options.Services);

            configure.Invoke(indexingOptions);

            ServiceRegistrar.AddMediatRClasses(options.Services, new[] { Assembly.GetExecutingAssembly() });

            return(options);
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            string libraryPath   = Path.Combine(documentsPath, "..", "Library");                  // Library folder instead
            var    path          = Path.Combine(libraryPath, ServiceRegistrar.DbFileName);

            ServiceRegistrar.Initialize(path);

            return(true);
        }
        public void AddRequiredServices_WhenCalled_ShouldContainExpectedInstances()
        {
            ServiceRegistrar.AddMediatRClasses(services, assemblies);
            ServiceRegistrar.AddRequiredServices(services);

            services.GetInstance <IMediator>().ShouldBeOfType <Mediator>();
            services.GetInstance <ISender>().ShouldBeOfType <Mediator>();
            services.GetInstance <IPublisher>().ShouldBeOfType <Mediator>();
            services.AvailableServices.Where(x => x.ServiceType == typeof(INotificationHandler <PingNotification>)).Count().ShouldBe(3);
        }
Exemple #17
0
        public static IServiceCollection AddMediatRCore(this IServiceCollection services, Action <MediatRServiceConfiguration> configuration = null)
        {
            var serviceConfig = new MediatRServiceConfiguration();

            configuration?.Invoke(serviceConfig);

            ServiceRegistrar.AddRequiredServices(services, serviceConfig);

            return(services);
        }
Exemple #18
0
 public async Task UploadRegistrarFilesAsync(string adLogin, string account1CCode, string client1CCode,
                                             int idFileDescription, Dictionary <string, byte[]> files, int clientTimeZone) =>
 await ExecuteWithTryCatchAsync <WCFServiceRegistrar>(() =>
                                                      ServiceRegistrar.UploadRegistrarFilesAsync(adLogin, account1CCode, client1CCode, idFileDescription,
                                                                                                 files, clientTimeZone),
                                                      new LogShortMessage("Ошибка вызова метода. Метод: {methodName}, adLogin: {adLogin}," +
                                                                          " account1CCode: {account1CCode}, client1CCode: {client1CCode}," +
                                                                          " idFileDescription: {idFileDescription}, clientTimeZone: {clientTimeZone}, files: {files}.",
                                                                          "UploadRegistrarFilesAsync", adLogin, client1CCode, adLogin, idFileDescription,
                                                                          clientTimeZone, string.Join(", ", files?.Keys.ToArray() ?? new [] { "null" })));
Exemple #19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            AddNewItemButton.TouchUpInside += (sender, e) => {
                var title = NewItemTextField.Text;
                ServiceRegistrar.ShoppingService(Application.SqliteConnection).TryAddItemToShoppingList(new Item(title));
                NavigationController.PopToRootViewController(true);
            };
        }
        protected void RegisterServiceHolidayCamp(SetupData setup)
        {
            if (setup.HolidayCamp != null)
            {
                return;
            }
            var holidayCamp = new ServiceHolidayCamp();

            ServiceRegistrar.RegisterService(holidayCamp, setup.Business);
            setup.HolidayCamp = holidayCamp;
        }
        protected void RegisterServiceMiniRed(SetupData setup)
        {
            if (setup.MiniRed != null)
            {
                return;
            }
            var miniRed = new ServiceMiniRed();

            ServiceRegistrar.RegisterService(miniRed, setup.Business);
            setup.MiniRed = miniRed;
        }
Exemple #22
0
        private static void AddDefaultServices(AddRemotiatrOptions options)
        {
            options.Services.TryAddScoped <IApplicationServiceProviderAccessor, ApplicationServiceProviderAccessor>();

            options.Services.TryAddTransient(typeof(IApplicationService <>), typeof(ApplicationService <>));

            options.Services.AddScoped <IMessageMetadata, MessageMetadata>();

            options.Services.AddSingleton <IMessageHostInfoLookup, MessageHostInfoLookup>();

            ServiceRegistrar.AddRequiredServices(options.Services, new MediatRServiceConfiguration());
        }
Exemple #23
0
 public static IServiceCollection AddJsonRpcMediatR(this IServiceCollection services, IEnumerable <Assembly> assemblies)
 {
     ServiceRegistrar.AddRequiredServices(services, new MediatRServiceConfiguration());
     ServiceRegistrar.AddMediatRClasses(services, assemblies);
     services.AddScoped <IRequestContext, RequestContext>();
     services.RemoveAll <ServiceFactory>();
     services.AddScoped <ServiceFactory>(
         serviceProvider => {
         return(serviceType => GetHandler(serviceProvider, serviceType));
     }
         );
     return(services);
 }
Exemple #24
0
        public void ConfigureServices(IServiceCollection services)
        {
            ServiceRegistrar.RegisterCustomServices(services);

            services.AddMvc();
            services.AddAutoMapper(typeof(Startup));
            services.AddControllers();
            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo {
                    Title = "Hepsi API", Version = "V1"
                });
            });
        }
        protected override TestServer CreateServer(IWebHostBuilder builder)
        {
            builder.ConfigureTestServices(services =>
            {
                ServiceRegistrar.AddMediatRClasses(services, new[] { typeof(TestWebApplicationFactory).Assembly });

                var serviceDescriptor = services.FirstOrDefault(descriptor => descriptor.ServiceType == typeof(IGetPagedFileListQueryFactory));
                services.Remove(serviceDescriptor);

                services.AddTransient <IGetPagedFileListQueryFactory, GetPagedFileListQueryFactoryMock>();
            });
            return(base.CreateServer(builder));
        }
        /// <summary>
        /// Class constructor
        /// </summary>
        public LoginActivity()
        {
            ServiceRegistrar.Startup();
            loginViewModel = ServiceContainer.Resolve <LoginViewModel> ();

            //sets valid changed to show the login button.
            loginViewModel.IsValidChanged += (sender, e) => {
                if (login != null)
                {
                    login.Enabled = loginViewModel.IsValid ? true : false;
                }
            };
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            ServiceRegistrar.Startup();

            navigationController = new UINavigationController(new ExpensesViewController());
            // If you have defined a view, add it here:
            window.RootViewController = navigationController;

            // make the window visible
            window.MakeKeyAndVisible();

            return(true);
        }
Exemple #28
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.Configure <ApiBehaviorOptions>(options => {
                options.SuppressModelStateInvalidFilter = true;
            });

            services.AddMvc().AddFluentValidation(c =>
            {
                c.RegisterValidatorsFromAssemblyContaining <ProjectModelValidation>();
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddMediatR(typeof(Startup));
            return(ServiceRegistrar.RegisterDependencies(services, Configuration));
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ServiceRegistrar.SetServiceProvider(app.ApplicationServices);

            var appLifetime = app.ApplicationServices.GetRequiredService <IApplicationLifetime>();

            appLifetime.ApplicationStopping.Register(OnShuttingDown);

            // global hanlder for any uncaught exceptions
            app.UseExceptionHandler(new ExceptionHandlerOptions()
            {
                ExceptionHandler = GlobalErrorHandler.ExceptionHandlerDelegate
            });

            app.UseMvc(ConfigureRoutes);
        }
Exemple #30
0
        /// <summary>
        /// Registers handlers and mediator types from the specified assemblies
        /// </summary>
        /// <param name="services">Service collection</param>
        /// <param name="assemblies">Assemblies to scan</param>
        /// <param name="configuration">The action used to configure the options</param>
        /// <returns>Service collection</returns>
        public static IServiceCollection AddMediatR(this IServiceCollection services, IEnumerable <Assembly> assemblies, Action <MediatRServiceConfiguration> configuration)
        {
            if (!assemblies.Any())
            {
                throw new ArgumentException("No assemblies found to scan. Supply at least one assembly to scan for handlers.");
            }
            var serviceConfig = new MediatRServiceConfiguration();

            configuration?.Invoke(serviceConfig);

            ServiceRegistrar.AddRequiredServices(services, serviceConfig);

            ServiceRegistrar.AddMediatRClasses(services, assemblies);

            return(services);
        }