Esempio n. 1
0
        public void RegisterType_Singleton()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Singleton);

            var actual1 = injector.Resolve(typeof(ITimer));
            var actual2 = injector.Resolve(typeof(ITimer));

            Assert.IsInstanceOf<ITimer>(actual1);
            Assert.IsInstanceOf<ITimer>(actual2);
            Assert.AreSame(actual1, actual2);
        }
Esempio n. 2
0
        public void RegisterType_Transient()
        {
            var injector = new Injection();

            injector.Register <ITimer, MyTimer>(LifestyleType.Transient);

            var actual1 = injector.Resolve(typeof(ITimer));
            var actual2 = injector.Resolve(typeof(ITimer));

            Assert.IsInstanceOf <ITimer>(actual1);
            Assert.IsInstanceOf <ITimer>(actual2);
            Assert.AreNotSame(actual1, actual2);
        }
Esempio n. 3
0
        public void RegisterComplexType_TransientWithSingletonDependency()
        {
            var injector = new Injection();

            injector.Register <ITimer, MyTimer>(LifestyleType.Singleton);
            //The Injector container will handel unregistered resolves but the
            //following line could be uncommented to officially register the "Complex" type.
            //injector.Register<IComplex, Complex>(LifestyleType.Transient);

            var actual1 = (Complex)injector.Resolve(typeof(Complex));
            var actual2 = (Complex)injector.Resolve(typeof(Complex));

            Assert.AreNotSame(actual1, actual2);
            Assert.AreSame(actual1.Timer, actual2.Timer);
        }
Esempio n. 4
0
        public void RegisterComplexType_Singleton()
        {
            var injector = new Injection();

            injector.Register <ITimer, MyTimer>(LifestyleType.Transient);
            //Here we fully register the complex type to utilize the container LSM for singleton
            injector.Register <IComplex, Complex>(LifestyleType.Singleton);

            var actual1 = injector.Resolve(typeof(IComplex));
            var actual2 = injector.Resolve(typeof(IComplex));

            Assert.IsInstanceOf <IComplex>(actual1);
            Assert.IsInstanceOf <IComplex>(actual2);
            Assert.AreSame(actual1, actual2);
        }
Esempio n. 5
0
        public void RegisterComplexType_TransientWithSingletonDependency()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Singleton);
            //The Injector container will handel unregistered resolves but the
            //following line could be uncommented to officially register the "Complex" type.
            //injector.Register<IComplex, Complex>(LifestyleType.Transient);

            var actual1 = (Complex)injector.Resolve(typeof(Complex));
            var actual2 = (Complex)injector.Resolve(typeof(Complex));

            Assert.AreNotSame(actual1, actual2);
            Assert.AreSame(actual1.Timer, actual2.Timer);
        }
Esempio n. 6
0
        public void RegisterComplexType_Singleton()
        {
            var injector = new Injection();

            injector.Register<ITimer, MyTimer>(LifestyleType.Transient);
            //Here we fully register the complex type to utilize the container LSM for singleton
            injector.Register<IComplex, Complex>(LifestyleType.Singleton);

            var actual1 = injector.Resolve(typeof(IComplex));
            var actual2 = injector.Resolve(typeof(IComplex));

            Assert.IsInstanceOf<IComplex>(actual1);
            Assert.IsInstanceOf<IComplex>(actual2);
            Assert.AreSame(actual1, actual2);
        }
Esempio n. 7
0
        public App()
        {
            if (!InjectionInitilaized)
            {
                Injection.RegisterTypes(RegisterTypes);
            }

            InitializeComponent();

            var navigationService = Injection.Resolve <INavigationService>();

            if (!InjectionInitilaized)
            {
                navigationService.Register <LoginViewModel, LoginPage>(() => Injection.Resolve <LoginPage>());
                navigationService.Register <SignupViewModel, SignupPage>(() => Injection.Resolve <SignupPage>());
                navigationService.Register <BrowseGroupViewModel, BrowseGroupPage, Group>(group => Injection.Resolve <Func <Group, BrowseGroupPage> >()(group));
                InjectionInitilaized = true;
            }

            var mainPage = Injection.Resolve <MainPage>();

            navigationService.AddRootPage(mainPage);

            MainPage = mainPage;
        }
Esempio n. 8
0
        public IMatrix Restore(string path)
        {
            int[,] array = null;

            using (var reader = new StreamReader(path))
            {
                int lineCount = 0;
                while (!reader.EndOfStream)
                {
                    var values = reader.ReadLine().Split(' ');

                    if (lineCount == 0)
                    {
                        array = new int[values.Count(), values.Count()];
                    }

                    for (int i = 0; i < values.Length; i++)
                    {
                        array[lineCount, i] = int.Parse(values[i]);
                    }
                    lineCount++;
                }
            }

            if (array == null)
            {
                throw new IOException("File is empty");
            }

            var matrix = Injection.Resolve <IMatrix>();

            matrix.SetArray(array);

            return(matrix);
        }
Esempio n. 9
0
        public async Task NavigateFromMenu(int id)
        {
            if (!MenuPages.ContainsKey(id))
            {
                switch (id)
                {
                case (int)MenuItemType.Browse:
                    MenuPages.Add(id, new NavigationPage(_itemsPageFactory()));
                    break;

                case (int)MenuItemType.About:
                    MenuPages.Add(id, new NavigationPage(new AboutPage()));
                    break;

                case (int)MenuItemType.Ptt:
                    MenuPages.Add(id, new NavigationPage(Injection.Resolve <PttPage>()));
                    break;
                }
            }

            var newPage = MenuPages[id];

            if (newPage != null && Detail != newPage)
            {
                Detail = newPage;

                if (Device.RuntimePlatform == Device.Android)
                {
                    await Task.Delay(100);
                }

                IsPresented = false;
            }
        }
Esempio n. 10
0
        public void GetStringValue_ArrayExist_StringValueEqual()
        {
            var array = new int[, ]
            {
                { 1, 2 },
                { 3, 4 },
            };

            var matrix = Injection.Resolve <IMatrix>();

            matrix.SetArray(array);

            Assert.That(matrix.GetStringValue(), Is.EqualTo("1 2\n3 4\n"));
        }
Esempio n. 11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            var viewModel = Injection.Resolve <MainWindowViewModel>();

            MainWindow = new MainWindow(viewModel);

            MainWindow.Closing += MainWindowClosing;

            _notifyIcon              = new NotifyIcon();
            _notifyIcon.DoubleClick += (s, args) => ShowMainWindow();
            _notifyIcon.Icon         = new Icon(typeof(App), "Hamzasaleem-Stock-Dashboard.ico");
            _notifyIcon.Visible      = true;

            CreateContextMenu();
        }
Esempio n. 12
0
        private IMatrix CreateMatrix(int demension, Func <int> func)
        {
            var array = new int[demension, demension];

            for (int row = 0; row < demension; row++)
            {
                for (int column = 0; column < demension; column++)
                {
                    array[row, column] = func();
                }
            }

            var matrix = Injection.Resolve <IMatrix>();

            matrix.SetArray(array);

            return(matrix);
        }
Esempio n. 13
0
        public void Setup()
        {
            var path =
                Directory.GetCurrentDirectory()
                .Split("bin")[0]
                + Path.DirectorySeparatorChar
                + "TestFiles"
                + Path.DirectorySeparatorChar;

            _fileRestore = string.Concat(path, "FileRestore", Path.DirectorySeparatorChar);
            _fileSave    = string.Concat(path, "FileSave", Path.DirectorySeparatorChar);


            var matrix = new Mock <IMatrix>();

            matrix.Setup(p => p.GetStringValue()).Returns("1 2\n3 4\n");
            _mockFilledMatrix = matrix.Object;

            _matrixStore = Injection.Resolve <IMatrixStore>();
        }
 private void SaveProcess(object state)
 {
     lock (Lock)
     {
         using (var scope1 = Injection.BeginLifetimeScope())
             using (var clientProcessRepository = Injection.Resolve <IClientProcessRepository>())
                 using (var qualityTimeRepository = Injection.Resolve <IQualityTimeRepository>())
                 {
                     Debug.WriteLine("Process in data base: " + clientProcessRepository.GetList().Count() + "(old)");
                     foreach (var process in _clientProcesses)
                     {
                         var processUpdate = clientProcessRepository.Get(process);
                         var qualityTime   = qualityTimeRepository.Get(process.QualityTime);
                         if (processUpdate == null)
                         {
                             //clientProcessRepository.Save();
                             if (qualityTime != null)
                             {
                                 //qualityTime.ClientProcesses.Add(process);
                                 //qualityTimeRepository.Update(qualityTime);
                                 //qualityTimeRepository.Save();
                                 process.QualityTime = qualityTime;
                             }
                             clientProcessRepository.Create(process);
                         }
                         else
                         {
                             processUpdate.ProcessTime += process.ProcessTime;
                             if (processUpdate.QualityTime.Id != qualityTime.Id)
                             {
                                 process.QualityTime = qualityTime;
                             }
                         }
                         clientProcessRepository.Save();
                     }
                     _clientProcesses.Clear();
                     Debug.WriteLine("Process in data base: " + clientProcessRepository.GetList().Count() + "(new)");
                 }
     }
 }
Esempio n. 15
0
 public AppointmentRepository GetAppointmentRepository()
 {
     return(Injection.Resolve <AppointmentRepository>());
 }
Esempio n. 16
0
 public UserRepository GetUserRepository()
 {
     return(Injection.Resolve <UserRepository>());
 }
Esempio n. 17
0
 public ServiceTypeRepository GetServiceType()
 {
     return(Injection.Resolve <ServiceTypeRepository>());
 }
Esempio n. 18
0
 public CarRepository GetCarRepository()
 {
     return(Injection.Resolve <CarRepository>());
 }
Esempio n. 19
0
        public void SetArray_ArrayDemensionsIsOneToOne_ThrowArgumentException()
        {
            var array = new int[1, 1];

            Assert.Throws <ArgumentException>(() => Injection.Resolve <IMatrix>().SetArray(array));
        }
Esempio n. 20
0
 protected override async void OnStart()
 {
     //var navigationService = Injection.Get<INavigationService>();
     //await navigationService.ShowModal<LoginViewModel>();
     await Injection.Resolve <MainViewModel>().Initialize();
 }
Esempio n. 21
0
 public void Setup()
 {
     _matrixGenerator = Injection.Resolve <IMatrixGenerator>();
 }
Esempio n. 22
0
 public MatrixController()
 {
     _matrixStore     = Injection.Resolve <IMatrixStore>();
     _matrixGenerator = Injection.Resolve <IMatrixGenerator>();
 }
Esempio n. 23
0
 public void SetArray_ArrayIsNull_ThrowArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(
         () => Injection.Resolve <IMatrix>().SetArray(null));
 }
Esempio n. 24
0
        public void SetArray_ArrayDemensionsNotEquals_ThrowArgumentException()
        {
            var array = new int[3, 2];

            Assert.Throws <ArgumentException>(() => Injection.Resolve <IMatrix>().SetArray(array));
        }
 public BaseRepository()
 {
     _db = Injection.Resolve <TimeDirectorDataContext>();
 }