Example #1
0
 public AuthService(ISyncLocalStorageService localstorage, IHttpClientFactory client, IJSRuntime runtime)
 {
     this._localstorage = localstorage;
     _js          = runtime;
     _httpFactory = client;
     this._localstorage.Changed += LocalStorageChanged;
 }
Example #2
0
 public Settings(ISyncLocalStorageService pLocalStorage)
 {
     IsSundayFirstDotw       = new LocalStorageSetting <bool>(pLocalStorage, nameof(IsSundayFirstDotw), true);
     PreferNumbericAnswers   = new LocalStorageSetting <bool>(pLocalStorage, nameof(PreferNumbericAnswers), false);
     PreferEfficientNumbers  = new LocalStorageSetting <bool>(pLocalStorage, nameof(PreferEfficientNumbers), true);
     IsStatisticsAreaVisible = new LocalStorageSetting <bool>(pLocalStorage, nameof(IsStatisticsAreaVisible), true);
 }
Example #3
0
        public NotesController(List <Note> notes, ISyncLocalStorageService localStorage)
        {
            LocalStorage = localStorage;
            var te = localStorage.GetItem <List <Note> >("notes");

            Notes = te ?? new List <Note>();
        }
 public LocalStorageFileManager(IEntityType _type, string _filetype, string _databasename, ISyncLocalStorageService localStorage)
 {
     type              = _type;
     filetype          = _filetype;
     databasename      = string.IsNullOrEmpty(_databasename) ? "" : _databasename + ".";
     this.localStorage = localStorage;
 }
Example #5
0
 public Storage(ISyncLocalStorageService localStorage, Options options)
 {
     this.localStorage = localStorage;
     this.options      = options;
     if (!localStorage.ContainKey(FirstRunKey))
     {
         SetDefault();
     }
 }
Example #6
0
        public LocalStorageRepository(ISyncLocalStorageService localStorageService)
        {
            if (localStorageService == null)
            {
                throw new ArgumentNullException(nameof(localStorageService));
            }

            LocalStorageService = localStorageService;
        }
Example #7
0
        public LazyLoaderService(ServiceContainer container, LazyAssemblyWebResolver assemblyLocationResolver, ISyncLocalStorageService localStorage)
        {
            this.container = container;
            this.assemblyLocationResolver = assemblyLocationResolver;
            this.localStorage             = localStorage;

            alreadyLazyLoaded = new Dictionary <string, Assembly>();
            //loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name + ".dll").ToHashSet();
            alreadyBaseLoaded = getLoadedAssemblies();
        }
        public AuthCredentialsKeeper(ISyncLocalStorageService localStorage)
        {
            _localStorage = localStorage;

            if (_localStorage.ContainKey(INDEX_USERNAME) && _localStorage.ContainKey(INDEX_TOKEN))
            {
                Username = _localStorage.GetItem <string>(INDEX_USERNAME);
                Token    = _localStorage.GetItem <string>(INDEX_TOKEN);
            }
        }
Example #9
0
        public UserIdentificationService(AuthenticationStateProvider authenticationStateProvider, ILocalStorageService localStorageService, ISyncLocalStorageService syncLocalStorageService, NavigationManager navigationManager)
        {
            _authenticationStateProvider = authenticationStateProvider;
            _localStorageService         = localStorageService;
            _syncLocalStorageService     = syncLocalStorageService;

            _localStorageKey = navigationManager.BaseUri + "MyChatApp-GuestUserName";;

            _authenticationStateProvider.AuthenticationStateChanged += authenticationStateProvider_AuthenticationStateChanged;
        }
        public SettingsProvider(
            ISyncLocalStorageService localStorage,
            UserProvider userProvider
            )
        {
            _localStorage = localStorage;
            _userProvider = userProvider;

            _userProvider.UserUpdated += UserUpdated;

            LoadSettings();
        }
Example #11
0
 public GameClientService(
     HttpClient httpClient,
     ISyncLocalStorageService localStorageService,
     IToasterService toasterService,
     IMapper mapper
     )
 {
     _httpClient          = httpClient;
     _localStorageService = localStorageService;
     _toasterService      = toasterService;
     _mapper = mapper;
 }
Example #12
0
 public AppState(HttpClient httpInstance
                 , ISyncLocalStorageService localStorage
                 , IUriHelper uriHelper
                 , IJSRuntime jsRuntime
                 , ILogger <AppState> logger
                 )
 {
     this._httpClient   = httpInstance;
     this._localStorage = localStorage;
     this._uriHelper    = uriHelper;
     this._jsRuntime    = jsRuntime;
     this._logger       = logger;
 }
        public static void RemoveAuthorizationTokens(this ISyncLocalStorageService localStorage)
        {
            if (localStorage.HasAccessToken())
            {
                localStorage.RemoveItem(LocalStorageConstants.TokenType);
                localStorage.RemoveItem(LocalStorageConstants.AccessToken);
            }

            if (localStorage.HasRefreshToken())
            {
                localStorage.RemoveItem(LocalStorageConstants.RefreshToken);
            }
        }
Example #14
0
        public StateContainer(ISyncLocalStorageService localStorage)
        {
            var data = localStorage.GetItemAsString("playerData");

            if (data != null)
            {
                var settings = new JsonSerializerSettings()
                {
                    ObjectCreationHandling = ObjectCreationHandling.Replace
                };
                PlayerData = JsonConvert.DeserializeObject <PlayerData>(data, settings);
            }
        }
Example #15
0
        public static Metadata GetRequestHeaders(ISyncLocalStorageService localStorage)
        {
            Metadata headers = null;

            if (localStorage.HasAccessToken())
            {
                var tokenType   = localStorage.GetTokenType();
                var accessToken = localStorage.GetAccessToken();

                headers = SetAuthorizationHeader(headers, tokenType, accessToken);
            }

            return(headers);
        }
Example #16
0
 public PunState(
     string initialTheme,
     PunCategory initialCategory,
     Action stateHasChanged,
     ISyncLocalStorageService storage)
 {
     WordNetEngine       = new WordNetEngine();
     PronunciationEngine = new PronunciationEngine();
     SpellingEngine      = new SpellingEngine();
     Theme           = initialTheme;
     StateHasChanged = stateHasChanged;
     Storage         = storage;
     PunCategory     = initialCategory;
     FavoritePuns    = GetFavoritePuns(storage);
 }
Example #17
0
        public Options(ISyncLocalStorageService localStorage, NavigationManager navigationManager, string inititalCosmos = null)
        {
            this.localStorage      = localStorage;
            this.navigationManager = navigationManager;
            IsHideValue            = localStorage.GetItem <bool>(HideValueKey);
            IsMonochrome           = localStorage.GetItem <bool>(MonochromeKey);

            if (inititalCosmos is null)
            {
                Cosmos = localStorage.GetItem <string>(CosmosKey);
            }
            else
            {
                Cosmos = inititalCosmos;
            }
        }
Example #18
0
        public static void AddSampleData(this IServiceProvider services)
        {
            ISyncLocalStorageService localStorage = services.GetService <ISyncLocalStorageService>();

            if (localStorage.HasDemoDataKey())
            {
                return;
            }

            ServiceProvider = services;
            ShowAlert();

            ConsoleLog("- Starting to generate demo data! -");

            List <Theatre>      theatres = createTheaters();
            List <Hall>         halls    = new List <Hall>();
            List <Play>         plays    = new List <Play>();
            List <PlayDateTime> playDateTimes;
            List <Ticket>       tickets;
            List <User>         users = new List <User>();

            ConsoleLog("Generated Theatres:", theatres);

            foreach (var theatre in theatres)
            {
                halls.AddRange(createHalls(theatre, 4));
                plays.AddRange(createPlays(theatre, 4));
            }
            ConsoleLog("Generated Halls:", halls);
            ConsoleLog("Generated Plays:", plays);

            playDateTimes = createPlayDateTimes(halls, plays);
            ConsoleLog("Generated PlayDateTimes:", playDateTimes);

            tickets = createTickets(playDateTimes, halls);
            ConsoleLog("Generated Tickets:", tickets);

            users.Add(createUser(Lorem.Words(2), Lorem.Email(), UserType.user));
            ConsoleLog("Generated Users:", users);

            ConsoleLog("Writting to DB!");

            WriteToDb(theatres, halls, plays, playDateTimes, tickets, users);
            localStorage.AddDemoDataKey();

            ConsoleLog("- Finished!! -");
        }
        public AutoRouteProvider(
            ISyncLocalStorageService localStorage,
            UserProvider userProvider,
            ShipsProvider shipProvider,
            ConsoleOutput console,
            CommandManager commandManager
            )
        {
            _localStorage   = localStorage;
            _userProvider   = userProvider;
            _shipProvider   = shipProvider;
            _console        = console;
            _commandManager = commandManager;

            _shipProvider.ShipsUpdated += UpdateRouteLinks;

            StartRouteRunner();
        }
Example #20
0
        public ControllerService(ISyncLocalStorageService localStorageService)
        {
            this.httpClient = new HttpClient
            {
                Timeout = TimeSpan.FromSeconds(3)
            };
            this.localStorageService = localStorageService;
            macAddress  = localStorageService.ContainKey(nameof(MacAddress)) ? localStorageService.GetItemAsString(nameof(MacAddress)) : "";
            baseAddress = localStorageService.ContainKey(nameof(BaseAddress)) ? localStorageService.GetItemAsString(nameof(BaseAddress)) : "";
            pin         = localStorageService.ContainKey(nameof(PIN)) ? localStorageService.GetItemAsString(nameof(PIN)) : "";

            var cmds = Enum.GetValues(typeof(ControllerCommandType)).Cast <ControllerCommandType>()
                       .Select(o => new LabeledCommand(o.ToString(), new Command(() => InvokeCommandInBackground(o))))
                       .ToList();

            SupportedCommands = new[]
            {
                new LabeledCommand("WoL", new Command(() => WakeOnLan()))
            }
            .Concat(cmds)
            .ToList();

            pinger = new Ping();

            Task.Run(async() =>
            {
                while (!isDisposed)
                {
                    var start = DateTime.Now;

                    (Status, ErrorMessage) = await GetStatusAsync();

                    var time = TimeSpan.FromSeconds(3) - (DateTime.Now - start);
                    if (time.Ticks > 0)
                    {
                        await Task.Delay(time);
                    }
                    else
                    {
                        await Task.Yield();
                    }
                }
            });
        }
Example #21
0
        public ShipsProvider(
            ISyncLocalStorageService localStorage,
            UserProvider userProvider,
            HttpClient http,
            JsonSerializerOptions serializerOptions,
            NavigationManager navManager
            )
        {
            _localStorage      = localStorage;
            _userProvider      = userProvider;
            _http              = http;
            _serializerOptions = serializerOptions;

            _appBase = navManager.BaseUri;
            _rand    = new Random();

            _userProvider.UserUpdated += HandleUserUpdate;

            LoadShipNames();
            StartFlightPlanUpdater();
        }
Example #22
0
        public UserProvider(
            ISyncLocalStorageService localStorage,
            HttpClient http,
            JsonSerializerOptions serializerOptions,
            IConfiguration config
            )
        {
            _localStorage      = localStorage;
            _http              = http;
            _serializerOptions = serializerOptions;
            _config            = config;

            if (_localStorage.ContainKey("Token"))
            {
                _ = SetDetailsAsync(_localStorage.GetItemAsString("Token"));
            }
            else
            {
                StartingDetailsChecked = true;
            }
        }
Example #23
0
 public CartService(ISyncLocalStorageService localStorage)
 {
     this.localStorage = localStorage;
     cartItems         = ReadCartItemsFromLocalStorage();
     listeners         = new List <Action>();
 }
 public TestLocalStorage(ISyncLocalStorageService localStorage)
 {
     this.localStorage = localStorage;
 }
Example #25
0
 public LocalStorageAuthStateProvider(ISyncLocalStorageService localStorage)
 {
     this.localStorage = localStorage;
 }
 public PersistStateMiddleware(ISyncLocalStorageService localStorage, ILogger <PersistStateMiddleware> logger)
 {
     _localStorage = localStorage;
     _logger       = logger;
 }
Example #27
0
        public static Guid GetUserIdSync(this ISyncLocalStorageService LocalStorage)
        {
            String userGuid = LocalStorage.GetItemAsString("userid");

            return(Guid.TryParse(userGuid, out Guid UserId) ? UserId : Guid.Empty);
        }
 public SuppliersManagerService(ISyncLocalStorageService localStorage, GrpcChannel channel)
 {
     this.localStorage     = localStorage;
     supplierServiceClient = new GrpcSupplierService.GrpcSupplierServiceClient(channel);
 }
 public LocalStorageConfiguration(ISyncLocalStorageService localStorage)
 {
     _localStorage = localStorage;
 }
 public ProfileService(ISyncLocalStorageService localStorage)
 {
     _localStorage = localStorage;
 }