public RegisterViewModel(IUnityContainer container, IEventAggregator eventAggregator, ILoggerFacade logger, IRegionManager regionManager, AuthenticationService authenticationService, AddressStorage addressStorage, PasswordHashService passwordHashService) { if (container == null || eventAggregator == null || logger == null || regionManager == null || authenticationService == null || addressStorage == null || passwordHashService == null) { throw new ArgumentException(); } this._container = container; this._eventAggregator = eventAggregator; this._logger = logger; this._regionManager = regionManager; this._authenticationService = authenticationService; this._addressStorage = addressStorage; this._passwordHashService = passwordHashService; // Trigger the getter once in order to force the view to load // any existing selected addresses. SelectedServerAddress = this._addressStorage.ServerAddress; // Ensure that the visible servers are updated. this._eventAggregator.GetEvent <ServerAddedEvent>() .Subscribe(() => { RaisePropertyChanged(nameof(ServerAddresses)); }, ThreadOption.UIThread); // Ensure that existing information are removed when logging in. this._eventAggregator.GetEvent <LoginEvent>() .Subscribe(this.RemoveLoginInformation, ThreadOption.UIThread, false, (b) => { return(b); }); ButtonRegister = new DelegateCommand(async() => { await this.ButtonRegisterClicked(); }); PasswordChangedCommand = new DelegateCommand <PasswordBox>(async(box) => { await this.PasswordChangedFired(box); }); }
public ActionResult Create(CreateStorageViewModel storage) { if (ModelState.IsValid) { var sNew = new Storage { StorageName = storage.StorageName, CreatedDate = DateTime.Now }; var sn = db.Storage.Add(sNew); db.SaveChanges(); foreach (var item in storage.Addresses) { var n = new AddressStorage { AddressName = item.ToString(), Description = "DEFAULT DESCRIPTION", IdStorage = sn.IdStorage, }; this.db.AddressStorage.Add(n); this.db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(storage)); }
private IBlockchainUnit loadUnit(string unitPath, string addresserPath) { IIndexedStorage <long> addressStorage = new AddressStorage(addresserPath); BlockchainUnit unit = new BlockchainUnit(unitPath, addressStorage); return(unit); }
public AntiforgeryService(AntiforgeryStorage antiforgeryStorage, AddressStorage addressStorage, IUnityContainer container) { if (antiforgeryStorage == null || addressStorage == null || container == null) { throw new ArgumentException(); } this._antiforgeryStorage = antiforgeryStorage; this._addressStorage = addressStorage; this._container = container; }
public void InitializeServices() { var addressStorage = new AddressStorage(); // Default server address for testing locally. addressStorage.Servers.Add("http://localhost:5000/"); this._container.RegisterInstance <AuthenticationStorage>(new AuthenticationStorage()); this._container.RegisterInstance <AntiforgeryStorage>(new AntiforgeryStorage()); this._container.RegisterInstance <AddressStorage>(addressStorage); this._container.RegisterType <WsChatRequest>(); }
public AuthenticationService(AntiforgeryStorage storage, AntiforgeryService antiforgeryService, AddressStorage addressStorage, AuthenticationStorage authenticationStorage, IUnityContainer container) { if (storage == null || antiforgeryService == null || addressStorage == null || authenticationStorage == null || container == null) { throw new ArgumentException(); } this._storage = storage; this._antiforgeryService = antiforgeryService; this._addressStorage = addressStorage; this._authenticationStorage = authenticationStorage; this._container = container; }
static void Main(string[] args) { File.Create("addresses.dat").Close(); AddressStorage addressStorage = new AddressStorage("addresses.dat"); addressStorage.Add(13); addressStorage.Add(32); addressStorage.Add(6); Console.WriteLine($"Addres #2: {addressStorage[1]}"); Console.WriteLine(); foreach (long address in addressStorage) { Console.WriteLine($"Addres: {address}"); } }
private static void WriteAddresses(AddressStorage instance) { const string addressFormatLine1 = "{0} Dickinson"; for (var i = 1; i < 2000; i++) { var line1 = string.Format(addressFormatLine1, 300 + i); var tp = new ThreadParm { Storage = instance, Line1 = line1 }; var t = new Thread(WriteAddress) { Name = $"Thread {i}" }; t.Start(tp); } }
public ServerViewModel(IUnityContainer container, IEventAggregator eventAggregator, ILoggerFacade logger, AddressStorage addressStorage) { if (container == null || eventAggregator == null || logger == null || addressStorage == null) { throw new ArgumentException(); } this._container = container; this._eventAggregator = eventAggregator; this._logger = logger; this._addressStorage = addressStorage; // Only a shallow copy! New elements must also be added towards the model instance. ServerAddresses = new ObservableCollection <string>(this._addressStorage.Servers); ButtonAdd = new DelegateCommand(async() => { await this.ButtonAddClicked(); }); }
static void Main(string[] args) { #region Drive accessor debug. File.Create(Path).Close(); File.Create(AddressStoragePath).Close(); IIndexedStorage <long> addressStorage = new AddressStorage(AddressStoragePath); dataManager = new BinaryDriveAccessor <Person>(Path, addressStorage); people = new Person[] { new Person("John", "Doh", 37), new Person("Rick", "Morgan", 25), new Person("Joe", "Dash", 17) }; dataManager.AddRecord(people[0]); dataManager.AddRecord(people[1]); dataManager.AddRecord(people[2]); Person extracted = dataManager.GetNextRecord(); Console.WriteLine(extracted); Console.WriteLine(extracted.Equals(people[0])); Console.WriteLine(); extracted = dataManager.GetNextRecord(); Console.WriteLine(extracted); Console.WriteLine(extracted.Equals(people[1])); Console.WriteLine(); int i = 0; foreach (Person person in dataManager) { Console.WriteLine(person.Equals(people[i++])); } Console.WriteLine(dataManager.GetNextRecord().Equals(people[2])); Console.WriteLine(); try { Person guy = dataManager.GetNextRecord(); } catch (InvalidDataException) { Console.WriteLine("End of file"); } dataManager.Reset(); Person man = dataManager.GetNextRecord(); Console.WriteLine(man); Console.WriteLine(man.Equals(people[0])); Console.WriteLine(); List <Person> personList = new List <Person>(); for (int j = 0; j < 3; j++) { Console.WriteLine(dataManager[j]); } #endregion Console.WriteLine(); #region Indexed storage debug. File.Create(TestPath).Close(); IIndexedStorage <long> storage = new AddressStorage(TestPath) { 32, 13, 15 }; Console.WriteLine($"First address: {storage[0]}"); Console.WriteLine($"All: {String.Join(", ", storage)}"); Console.WriteLine($"Second address: {storage[1]}"); #endregion }
static void Main(string[] args) { File.Create(Path).Close(); File.Create(AddressStoragePath).Close(); IIndexedStorage <long> addressStorage = new AddressStorage(AddressStoragePath); dataManager = new JsonDriveAccessor <Person>(Path, addressStorage); people = new Person[] { new Person("John", "Doh", 37), new Person("Rick", "Morgan", 25), new Person("Joe", "Dash", 17) }; dataManager.AddRecord(people[0]); dataManager.AddRecord(people[1]); dataManager.AddRecord(people[2]); Person extracted = dataManager.GetNextRecord(); Console.WriteLine(extracted); Console.WriteLine(extracted.Equals(people[0])); Console.WriteLine(); extracted = dataManager.GetNextRecord(); Console.WriteLine(extracted); Console.WriteLine(extracted.Equals(people[1])); Console.WriteLine(); int i = 0; foreach (Person person in dataManager) { Console.WriteLine(person.Equals(people[i++])); } Console.WriteLine(dataManager.GetNextRecord().Equals(people[2])); Console.WriteLine(); try { Person guy = dataManager.GetNextRecord(); } catch (EndOfStreamException) { Console.WriteLine("End of file"); } dataManager.Reset(); Person man = dataManager.GetNextRecord(); Console.WriteLine(man); Console.WriteLine(man.Equals(people[0])); Console.WriteLine(); List <Person> personList = new List <Person>(); for (int j = 0; j < 3; j++) { Console.WriteLine(dataManager[j]); } }