Exemple #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="MainViewModel"/> class.
 /// For unit tests.
 /// </summary>
 protected internal MainViewModel(
     ILogService logService,
     INeuronService neuronService,
     IUiDispatcher uiDispatcher,
     ITagProfile tagProfile,
     INavigationService navigationService,
     INetworkService networkService,
     IImageCacheService imageCacheService,
     IContractOrchestratorService contractOrchestratorService,
     IThingRegistryOrchestratorService thingThingRegistryOrchestratorService)
     : base(neuronService ?? DependencyService.Resolve <INeuronService>(), uiDispatcher ?? DependencyService.Resolve <IUiDispatcher>())
 {
     this.logService                       = logService ?? DependencyService.Resolve <ILogService>();
     this.tagProfile                       = tagProfile ?? DependencyService.Resolve <ITagProfile>();
     this.navigationService                = navigationService ?? DependencyService.Resolve <INavigationService>();
     this.networkService                   = networkService ?? DependencyService.Resolve <INetworkService>();
     imageCacheService                     = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
     this.contractOrchestratorService      = contractOrchestratorService ?? DependencyService.Resolve <IContractOrchestratorService>();
     this.thingRegistryOrchestratorService = thingThingRegistryOrchestratorService ?? DependencyService.Resolve <IThingRegistryOrchestratorService>();
     this.photosLoader                     = new PhotosLoader(this.logService, this.networkService, this.NeuronService, this.UiDispatcher, imageCacheService);
     this.UpdateLoggedOutText(true);
     this.ViewMyContractsCommand = new Command(async() => await ViewMyContracts(), () => this.IsConnected);
     this.ScanQrCodeCommand      = new Command(async() => await ScanQrCode(), () => this.IsConnected);
     this.ViewWalletCommand      = new Command(async() => await ViewWallet(), () => this.IsConnected);
 }
Exemple #2
0
        /// <summary>
        /// Creates an instance of the <see cref="ViewContractViewModel"/> class.
        /// For unit tests.
        /// <param name="tagProfile">The tag profile to work with.</param>
        /// <param name="neuronService">The Neuron service for XMPP communication.</param>
        /// <param name="logService">The log service.</param>
        /// <param name="uiDispatcher">The UI dispatcher for alerts.</param>
        /// <param name="navigationService">The navigation service to use for app navigation</param>
        /// <param name="networkService">The network and connectivity service.</param>
        /// <param name="imageCacheService">The image cache to use.</param>
        /// <param name="contractOrchestratorService">The service to use for contract orchestration.</param>
        /// </summary>
        protected internal ViewContractViewModel(
            ITagProfile tagProfile,
            INeuronService neuronService,
            ILogService logService,
            IUiDispatcher uiDispatcher,
            INavigationService navigationService,
            INetworkService networkService,
            IImageCacheService imageCacheService,
            IContractOrchestratorService contractOrchestratorService)
        {
            this.tagProfile                  = tagProfile ?? DependencyService.Resolve <ITagProfile>();
            this.neuronService               = neuronService ?? DependencyService.Resolve <INeuronService>();
            this.logService                  = logService ?? DependencyService.Resolve <ILogService>();
            this.uiDispatcher                = uiDispatcher ?? DependencyService.Resolve <IUiDispatcher>();
            this.navigationService           = navigationService ?? DependencyService.Resolve <INavigationService>();
            networkService                   = networkService ?? DependencyService.Resolve <INetworkService>();
            imageCacheService                = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
            this.contractOrchestratorService = contractOrchestratorService ?? DependencyService.Resolve <IContractOrchestratorService>();

            this.Photos                  = new ObservableCollection <ImageSource>();
            this.photosLoader            = new PhotosLoader(this.logService, networkService, this.neuronService, this.uiDispatcher, imageCacheService, this.Photos);
            this.ObsoleteContractCommand = new Command(async _ => await ObsoleteContract());
            this.DeleteContractCommand   = new Command(async _ => await DeleteContract());
            this.GeneralInformation      = new ObservableCollection <PartModel>();
        }
        /// <summary>
        /// Creates a new instance of the <see cref="RegisterIdentityModel"/> class.
        /// <param name="tagProfile">The tag profile to work with.</param>
        /// <param name="uiDispatcher">The UI dispatcher for alerts.</param>
        /// <param name="neuronService">The Neuron service for XMPP communication.</param>
        /// <param name="navigationService">The navigation service to use for app navigation</param>
        /// <param name="settingsService">The settings service for persisting UI state.</param>
        /// <param name="networkService">The network service for network access.</param>
        /// <param name="logService">The log service.</param>
        /// <param name="imageCacheService">The image cache to use.</param>
        /// </summary>
        public RegisterIdentityViewModel(
            ITagProfile tagProfile,
            IUiDispatcher uiDispatcher,
            INeuronService neuronService,
            INavigationService navigationService,
            ISettingsService settingsService,
            INetworkService networkService,
            ILogService logService,
            IImageCacheService imageCacheService)
            : base(RegistrationStep.RegisterIdentity, tagProfile, uiDispatcher, neuronService, navigationService, settingsService, logService)
        {
            this.networkService = networkService;
            IDeviceInformation deviceInfo = DependencyService.Get <IDeviceInformation>();

            this.DeviceId  = deviceInfo?.GetDeviceId();
            this.Countries = new ObservableCollection <string>();
            foreach (string country in ISO_3166_1.Countries)
            {
                this.Countries.Add(country);
            }
            this.SelectedCountry    = null;
            this.RegisterCommand    = new Command(async _ => await Register(), _ => CanRegister());
            this.TakePhotoCommand   = new Command(async _ => await TakePhoto(), _ => !IsBusy);
            this.PickPhotoCommand   = new Command(async _ => await PickPhoto(), _ => !IsBusy);
            this.RemovePhotoCommand = new Command(_ => RemovePhoto(true));
            this.Title = AppResources.PersonalLegalInformation;
            this.PersonalNumberPlaceholder = AppResources.PersonalNumber;
            this.localPhotoFileName        = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ProfilePhotoFileName);
            imageCacheService = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
            this.photosLoader = new PhotosLoader(logService, networkService, neuronService, uiDispatcher, imageCacheService);
        }
Exemple #4
0
 /// <summary>
 /// Creates a new instance of the <see cref="ImageViewModel"/> class.
 /// </summary>
 public ImageViewModel()
 {
     this.uiDispatcher = DependencyService.Resolve <IUiDispatcher>();
     this.Photos       = new ObservableCollection <ImageSource>();
     this.photosLoader = new PhotosLoader(
         DependencyService.Resolve <ILogService>(),
         DependencyService.Resolve <INetworkService>(),
         DependencyService.Resolve <INeuronService>(),
         DependencyService.Resolve <IUiDispatcher>(),
         DependencyService.Resolve <IImageCacheService>(),
         this.Photos);
 }
Exemple #5
0
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateIdentityViewModel"/> class.
 /// <param name="tagProfile">The tag profile to work with.</param>
 /// <param name="uiDispatcher">The UI dispatcher for alerts.</param>
 /// <param name="neuronService">The Neuron service for XMPP communication.</param>
 /// <param name="navigationService">The navigation service to use for app navigation</param>
 /// <param name="settingsService">The settings service for persisting UI state.</param>
 /// <param name="networkService">The network service for network access.</param>
 /// <param name="logService">The log service.</param>
 /// <param name="imageCacheService">The image cache to use.</param>
 /// </summary>
 public ValidateIdentityViewModel(
     ITagProfile tagProfile,
     IUiDispatcher uiDispatcher,
     INeuronService neuronService,
     INavigationService navigationService,
     ISettingsService settingsService,
     INetworkService networkService,
     ILogService logService,
     IImageCacheService imageCacheService)
     : base(RegistrationStep.ValidateIdentity, tagProfile, uiDispatcher, neuronService, navigationService, settingsService, logService)
 {
     this.networkService        = networkService;
     this.InviteReviewerCommand = new Command(async _ => await InviteReviewer(), _ => this.State == IdentityState.Created && this.NeuronService.IsOnline);
     this.ContinueCommand       = new Command(_ => Continue(), _ => IsApproved);
     this.Title        = AppResources.ValidatingInformation;
     this.Photos       = new ObservableCollection <ImageSource>();
     imageCacheService = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
     this.photosLoader = new PhotosLoader(logService, networkService, neuronService, uiDispatcher, imageCacheService, this.Photos);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="PetitionIdentityViewModel"/> class.
 /// For unit tests.
 /// <param name="neuronService">The Neuron service for XMPP communication.</param>
 /// <param name="navigationService">The navigation service to use for app navigation</param>
 /// <param name="logService">The log service.</param>
 /// <param name="networkService">The network and connectivity service.</param>
 /// <param name="uiDispatcher">The UI dispatcher for alerts.</param>
 /// <param name="imageCacheService">The image cache to use.</param>
 /// </summary>
 protected internal PetitionIdentityViewModel(
     INeuronService neuronService,
     INavigationService navigationService,
     ILogService logService,
     INetworkService networkService,
     IUiDispatcher uiDispatcher,
     IImageCacheService imageCacheService)
 {
     this.neuronService     = neuronService ?? DependencyService.Resolve <INeuronService>();
     this.navigationService = navigationService ?? DependencyService.Resolve <INavigationService>();
     logService             = logService ?? DependencyService.Resolve <ILogService>();
     this.networkService    = networkService ?? DependencyService.Resolve <INetworkService>();
     uiDispatcher           = uiDispatcher ?? DependencyService.Resolve <IUiDispatcher>();
     imageCacheService      = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
     this.AcceptCommand     = new Command(async _ => await Accept());
     this.DeclineCommand    = new Command(async _ => await Decline());
     this.IgnoreCommand     = new Command(async _ => await Ignore());
     this.Photos            = new ObservableCollection <ImageSource>();
     this.photosLoader      = new PhotosLoader(logService, this.networkService, this.neuronService, uiDispatcher, imageCacheService, this.Photos);
 }
Exemple #7
0
 public PhotosLoaderTests()
 {
     this.logService      = new Mock <ILogService>();
     this.networkService  = new Mock <INetworkService>();
     this.neuronService   = new Mock <INeuronService>();
     this.neuronContracts = new Mock <INeuronContracts>();
     this.neuronContracts.SetupGet(x => x.IsOnline).Returns(true);
     this.neuronService.SetupGet(x => x.Contracts).Returns(this.neuronContracts.Object);
     this.networkService.SetupGet(x => x.IsOnline).Returns(true);
     this.uiDispatcher      = new Mock <IUiDispatcher>();
     this.imageCacheService = new Mock <IImageCacheService>();
     this.photos            = new ObservableCollection <ImageSource>();
     this.sut = new PhotosLoader(
         this.logService.Object,
         this.networkService.Object,
         this.neuronService.Object,
         this.uiDispatcher.Object,
         this.imageCacheService.Object,
         this.photos);
     // Short circuit the begin invoke calls, so they're executed synchronously.
     this.uiDispatcher.Setup(x => x.BeginInvokeOnMainThread(It.IsAny <Action>())).Callback <Action>(x => x());
 }
Exemple #8
0
 /// <summary>
 /// Creates an instance of the <see cref="ViewIdentityViewModel"/> class.
 /// </summary>
 public ViewIdentityViewModel(
     ITagProfile tagProfile,
     IUiDispatcher uiDispatcher,
     INeuronService neuronService,
     INavigationService navigationService,
     INetworkService networkService,
     ILogService logService,
     IImageCacheService imageCacheService)
     : base(neuronService, uiDispatcher)
 {
     this.tagProfile        = tagProfile;
     this.logService        = logService;
     this.navigationService = navigationService;
     this.networkService    = networkService;
     imageCacheService      = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
     this.ApproveCommand    = new Command(async _ => await Approve(), _ => IsConnected);
     this.RejectCommand     = new Command(async _ => await Reject(), _ => IsConnected);
     this.RevokeCommand     = new Command(async _ => await Revoke(), _ => IsConnected);
     this.CompromiseCommand = new Command(async _ => await Compromise(), _ => IsConnected);
     this.Photos            = new ObservableCollection <ImageSource>();
     this.photosLoader      = new PhotosLoader(this.logService, this.networkService, this.NeuronService, this.UiDispatcher, imageCacheService, this.Photos);
     this.CopyCommand       = new Command(_ => this.CopyHtmlToClipboard());
 }