コード例 #1
0
 public void Init()
 {
     _fixture = new Fixture().Customize(new AutoRhinoMockCustomization());
     _storage = _fixture.Create<IStateStorage>();
     _accessorFactory = _fixture.Create<IStateAccessorFactory>();
     _sut = new StateService(_storage);
 }
コード例 #2
0
        public void Ctor_NullStorage_ShouldThrowException()
        {
            // Arrange
            _storage = null;

            // Act
            _sut = new StateService(_storage, _accessorFactory);
        }
コード例 #3
0
        public void Ctor_ParameterLess_ShouldNotThrowException()
        {
            // Act
            _sut = new StateService();

            // Assert
            Assert.IsNotNull("No exception");
        }
コード例 #4
0
 public StateContextExtension(StateService stateService,
     StateRepository stateRepo,
     JqGridCustomCriteria<StateBoxMap, StateEntity> jqgridCriteria)
 {
     _stateRepo = stateRepo;
     _jqgridCriteria = jqgridCriteria;
     _stateService = stateService;
 }
コード例 #5
0
        public HttpProxyDecoratorBase(
            HttpProxyRepository repo, 
            TaxonomyTree tree,
            StateService stateService, 
            ILog log)
        {
            _repo = repo;
            _tree = tree;
            _stateService = stateService;
            _log = log;

            StoringDuration = TimeSpan.FromHours(3); //default storing duration 3 hours //one day
            RootDescriminatorStateTriggers =
                tree.GetOrCreatePath(STATE_TRIGGER_PATH, "Trigger to flush all Browsing cache");
        }
コード例 #6
0
        public static void Main(string[] args)
        {
            StateService stateService = new StateService();

            Console.WriteLine("Menu .....");
            Console.WriteLine("1. Add A new State");
            Console.WriteLine("2. Delete a State");
            Console.WriteLine("3. Update a State");

            int choice = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
                case 1:
                    {
                        State newState = new State();
                        Console.WriteLine("enter the State Id");
                        newState.StateId = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("enter the State Name");
                        newState.StateName = Console.ReadLine();
                        stateService.Add(newState);
                        break;
                    }
                case 2:
                    {
                        Console.WriteLine("enter the State Id");
                        int StateId = Convert.ToInt32(Console.ReadLine());
                        stateService.Delete(StateId);
                        break;
                    }
                case 3:
                    {
                        State updatedState = new State();
                        Console.WriteLine("enter the State Id");
                        updatedState.StateId = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine("enter the State Name");
                        updatedState.StateName = Console.ReadLine();
                        stateService.update(updatedState);
                        break;
                    }
            }
        }
コード例 #7
0
ファイル: frmState.cs プロジェクト: thankosein/GitWindow
 private void AutoFillStateId()
 {
     txtStateId.Text = StateService.GetStateId().ToString();
 }
コード例 #8
0
        public void SignUp()
        {
            var result = MessageBox.Show(
                AppResources.ConfirmAgeMessage,
                AppResources.ConfirmAgeTitle,
                MessageBoxButton.OKCancel);

            if (result != MessageBoxResult.OK)
            {
                return;
            }

            IsWorking = true;
            NotifyOfPropertyChange(() => CanSignUp);
            MTProtoService.SignUpAsync(
                StateService.PhoneNumber, StateService.PhoneCodeHash, StateService.PhoneCode,
                new TLString(FirstName), new TLString(LastName),
                auth => BeginOnUIThread(() =>
            {
                TLUtils.IsLogEnabled = false;
                TLUtils.LogItems.Clear();

                result = MessageBox.Show(
                    AppResources.ConfirmPushMessage,
                    AppResources.ConfirmPushTitle,
                    MessageBoxButton.OKCancel);

                if (result != MessageBoxResult.OK)
                {
                    StateService.GetNotifySettingsAsync(settings =>
                    {
                        var s                   = settings ?? new Settings();
                        s.ContactAlert          = false;
                        s.ContactMessagePreview = true;
                        s.ContactSound          = StateService.Sounds[0];
                        s.GroupAlert            = false;
                        s.GroupMessagePreview   = true;
                        s.GroupSound            = StateService.Sounds[0];

                        s.InAppMessagePreview = true;
                        s.InAppSound          = true;
                        s.InAppVibration      = true;

                        StateService.SaveNotifySettingsAsync(s);
                    });

                    MTProtoService.UpdateNotifySettingsAsync(
                        new TLInputNotifyUsers(),
                        new TLInputPeerNotifySettings
                    {
                        EventsMask   = new TLInt(1),
                        MuteUntil    = new TLInt(int.MaxValue),
                        ShowPreviews = new TLBool(true),
                        Sound        = new TLString(StateService.Sounds[0])
                    },
                        r => { });

                    MTProtoService.UpdateNotifySettingsAsync(
                        new TLInputNotifyChats(),
                        new TLInputPeerNotifySettings
                    {
                        EventsMask   = new TLInt(1),
                        MuteUntil    = new TLInt(int.MaxValue),
                        ShowPreviews = new TLBool(true),
                        Sound        = new TLString(StateService.Sounds[0])
                    },
                        r => { });
                }
                else
                {
                    StateService.GetNotifySettingsAsync(settings =>
                    {
                        var s                   = settings ?? new Settings();
                        s.ContactAlert          = true;
                        s.ContactMessagePreview = true;
                        s.ContactSound          = StateService.Sounds[0];
                        s.GroupAlert            = true;
                        s.GroupMessagePreview   = true;
                        s.GroupSound            = StateService.Sounds[0];

                        s.InAppMessagePreview = true;
                        s.InAppSound          = true;
                        s.InAppVibration      = true;

                        StateService.SaveNotifySettingsAsync(s);
                    });

                    MTProtoService.UpdateNotifySettingsAsync(
                        new TLInputNotifyUsers(),
                        new TLInputPeerNotifySettings
                    {
                        EventsMask   = new TLInt(1),
                        MuteUntil    = new TLInt(0),
                        ShowPreviews = new TLBool(true),
                        Sound        = new TLString(StateService.Sounds[0])
                    },
                        r => { });

                    MTProtoService.UpdateNotifySettingsAsync(
                        new TLInputNotifyChats(),
                        new TLInputPeerNotifySettings
                    {
                        EventsMask   = new TLInt(1),
                        MuteUntil    = new TLInt(0),
                        ShowPreviews = new TLBool(true),
                        Sound        = new TLString(StateService.Sounds[0])
                    },
                        r => { });
                }
                MTProtoService.SetInitState();

                StateService.CurrentUserId        = auth.User.Index;
                StateService.ClearNavigationStack = true;
                StateService.FirstRun             = true;
                SettingsHelper.SetValue(Constants.IsAuthorizedKey, true);


                NavigationService.UriFor <ShellViewModel>().Navigate();
                IsWorking = false;
                NotifyOfPropertyChange(() => CanSignUp);

                if (StateService.ProfilePhotoBytes != null)
                {
                    var bytes = StateService.ProfilePhotoBytes;
                    StateService.ProfilePhotoBytes = null;
                    var fileId = TLLong.Random();
                    FileManager.UploadFile(fileId, new TLUserSelf(), bytes);
                }
            }),
                error =>
            {
                IsWorking = false;
                NotifyOfPropertyChange(() => CanSignUp);

                if (error.TypeEquals(ErrorType.PHONE_NUMBER_INVALID))
                {
                    MessageBox.Show(AppResources.PhoneNumberInvalidString, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_INVALID))
                {
                    MessageBox.Show(AppResources.PhoneCodeInvalidString, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_EMPTY))
                {
                    MessageBox.Show(AppResources.PhoneCodeEmpty, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.PHONE_CODE_EXPIRED))
                {
                    MessageBox.Show(AppResources.PhoneCodeExpiredString, AppResources.Error, MessageBoxButton.OK);
                    ClearViewModel();
                    NavigationService.GoBack();
                }
                else if (error.CodeEquals(ErrorCode.FLOOD))
                {
                    MessageBox.Show(AppResources.FloodWaitString, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.FIRSTNAME_INVALID))
                {
                    MessageBox.Show(AppResources.FirstNameInvalidString, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.LASTNAME_INVALID))
                {
                    MessageBox.Show(AppResources.LastNameInvalidString, AppResources.Error, MessageBoxButton.OK);
                }
                else
                {
#if DEBUG
                    MessageBox.Show(error.ToString());
#endif
                }
            });
        }
コード例 #9
0
ファイル: ServiceContainer.cs プロジェクト: dai640/mobile
        public static void Init(HttpClientHandler httpClientHandler = null)
        {
            if (Inited)
            {
                return;
            }
            Inited = true;

            var           platformUtilsService   = Resolve <IPlatformUtilsService>("platformUtilsService");
            var           storageService         = Resolve <IStorageService>("storageService");
            var           secureStorageService   = Resolve <IStorageService>("secureStorageService");
            var           cryptoPrimitiveService = Resolve <ICryptoPrimitiveService>("cryptoPrimitiveService");
            var           i18nService            = Resolve <II18nService>("i18nService");
            var           messagingService       = Resolve <IMessagingService>("messagingService");
            SearchService searchService          = null;

            var stateService          = new StateService();
            var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService);
            var cryptoService         = new CryptoService(storageService, secureStorageService, cryptoFunctionService);
            var tokenService          = new TokenService(storageService);
            var apiService            = new ApiService(tokenService, platformUtilsService, (bool expired) => Task.FromResult(0),
                                                       httpClientHandler);
            var appIdService    = new AppIdService(storageService);
            var userService     = new UserService(storageService, tokenService);
            var settingsService = new SettingsService(userService, storageService);
            var cipherService   = new CipherService(cryptoService, userService, settingsService, apiService,
                                                    storageService, i18nService, () => searchService);
            var folderService = new FolderService(cryptoService, userService, apiService, storageService,
                                                  i18nService, cipherService);
            var collectionService = new CollectionService(cryptoService, userService, storageService, i18nService);

            searchService = new SearchService(cipherService);
            var lockService = new LockService(cryptoService, userService, platformUtilsService, storageService,
                                              folderService, cipherService, collectionService, searchService, messagingService, null);
            var syncService = new SyncService(userService, apiService, settingsService, folderService,
                                              cipherService, cryptoService, collectionService, storageService, messagingService,
                                              () => messagingService.Send("logout"));
            var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService,
                                                                          cryptoFunctionService);
            var totpService = new TotpService(storageService, cryptoFunctionService);
            var authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService,
                                              i18nService, platformUtilsService, messagingService);
            // TODO: export service
            var auditService       = new AuditService(cryptoFunctionService, apiService);
            var environmentService = new EnvironmentService(apiService, storageService);

            Register <IStateService>("stateService", stateService);
            Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService);
            Register <ICryptoService>("cryptoService", cryptoService);
            Register <ITokenService>("tokenService", tokenService);
            Register <IApiService>("apiService", apiService);
            Register <IAppIdService>("appIdService", appIdService);
            Register <IUserService>("userService", userService);
            Register <ISettingsService>("settingsService", settingsService);
            Register <ICipherService>("cipherService", cipherService);
            Register <IFolderService>("folderService", folderService);
            Register <ICollectionService>("collectionService", collectionService);
            Register <ISearchService>("searchService", searchService);
            Register <ISyncService>("syncService", syncService);
            Register <ILockService>("lockService", lockService);
            Register <IPasswordGenerationService>("passwordGenerationService", passwordGenerationService);
            Register <ITotpService>("totpService", totpService);
            Register <IAuthService>("authService", authService);
            Register <IAuditService>("auditService", auditService);
            Register <IEnvironmentService>("environmentService", environmentService);
        }
コード例 #10
0
        public void set_async_throws_if_key_is_null()
        {
            var service = new StateService(new BlobCacheMock(), new LoggerServiceMock(MockBehavior.Loose));

            Assert.ThrowsAsync <ArgumentNullException>(() => service.SetAsync <string>(null, "foo")).Wait();
        }
コード例 #11
0
        public static void Init(string customUserAgent = null)
        {
            if (Inited)
            {
                return;
            }
            Inited = true;

            var           platformUtilsService   = Resolve <IPlatformUtilsService>("platformUtilsService");
            var           storageService         = Resolve <IStorageService>("storageService");
            var           secureStorageService   = Resolve <IStorageService>("secureStorageService");
            var           cryptoPrimitiveService = Resolve <ICryptoPrimitiveService>("cryptoPrimitiveService");
            var           i18nService            = Resolve <II18nService>("i18nService");
            var           messagingService       = Resolve <IMessagingService>("messagingService");
            SearchService searchService          = null;

            var stateService          = new StateService();
            var cryptoFunctionService = new PclCryptoFunctionService(cryptoPrimitiveService);
            var cryptoService         = new CryptoService(storageService, secureStorageService, cryptoFunctionService);
            var tokenService          = new TokenService(storageService);
            var apiService            = new ApiService(tokenService, platformUtilsService, (bool expired) =>
            {
                messagingService.Send("logout", expired);
                return(Task.FromResult(0));
            }, customUserAgent);
            var appIdService    = new AppIdService(storageService);
            var userService     = new UserService(storageService, tokenService);
            var settingsService = new SettingsService(userService, storageService);
            var cipherService   = new CipherService(cryptoService, userService, settingsService, apiService,
                                                    storageService, i18nService, () => searchService);
            var folderService = new FolderService(cryptoService, userService, apiService, storageService,
                                                  i18nService, cipherService);
            var collectionService = new CollectionService(cryptoService, userService, storageService, i18nService);

            searchService = new SearchService(cipherService);
            var vaultTimeoutService = new VaultTimeoutService(cryptoService, userService, platformUtilsService,
                                                              storageService, folderService, cipherService, collectionService, searchService, messagingService, tokenService,
                                                              null, (expired) =>
            {
                messagingService.Send("logout", expired);
                return(Task.FromResult(0));
            });
            var policyService = new PolicyService(storageService, userService);
            var syncService   = new SyncService(userService, apiService, settingsService, folderService,
                                                cipherService, cryptoService, collectionService, storageService, messagingService, policyService,
                                                (bool expired) =>
            {
                messagingService.Send("logout", expired);
                return(Task.FromResult(0));
            });
            var passwordGenerationService = new PasswordGenerationService(cryptoService, storageService,
                                                                          cryptoFunctionService, policyService);
            var totpService = new TotpService(storageService, cryptoFunctionService);
            var authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService,
                                              i18nService, platformUtilsService, messagingService, vaultTimeoutService);
            var exportService      = new ExportService(folderService, cipherService);
            var auditService       = new AuditService(cryptoFunctionService, apiService);
            var environmentService = new EnvironmentService(apiService, storageService);
            var eventService       = new EventService(storageService, apiService, userService, cipherService);

            Register <IStateService>("stateService", stateService);
            Register <ICryptoFunctionService>("cryptoFunctionService", cryptoFunctionService);
            Register <ICryptoService>("cryptoService", cryptoService);
            Register <ITokenService>("tokenService", tokenService);
            Register <IApiService>("apiService", apiService);
            Register <IAppIdService>("appIdService", appIdService);
            Register <IUserService>("userService", userService);
            Register <ISettingsService>("settingsService", settingsService);
            Register <ICipherService>("cipherService", cipherService);
            Register <IFolderService>("folderService", folderService);
            Register <ICollectionService>("collectionService", collectionService);
            Register <ISearchService>("searchService", searchService);
            Register <IPolicyService>("policyService", policyService);
            Register <ISyncService>("syncService", syncService);
            Register <IVaultTimeoutService>("vaultTimeoutService", vaultTimeoutService);
            Register <IPasswordGenerationService>("passwordGenerationService", passwordGenerationService);
            Register <ITotpService>("totpService", totpService);
            Register <IAuthService>("authService", authService);
            Register <IExportService>("exportService", exportService);
            Register <IAuditService>("auditService", auditService);
            Register <IEnvironmentService>("environmentService", environmentService);
            Register <IEventService>("eventService", eventService);
        }
コード例 #12
0
 public void SetUp()
 {
     _repo    = new Mock <IRepository <State> >();
     _service = new StateService(_repo.Object);
 }
コード例 #13
0
 public StatesController(StateService service)
 {
     _service = service;
 }
コード例 #14
0
ファイル: MainDialog.cs プロジェクト: ShilpaGill/Dialog
 public MainDialog(StateService stateService) : base(nameof(MainDialog))
 {
     _stateService = stateService ?? throw new System.ArgumentNullException(nameof(stateService));
     InitializeWaterfallDialog();
 }
コード例 #15
0
        public MainWindowViewModel()
        {
            _searchResults = new ReactiveList <DirectoryEntryInfo>();
            _history       = new ReactiveList <string>();

            Search = ReactiveCommand.Create(
                () => _searchQuery.IsIPAddress()
                    ? Observable.FromAsync(() => NavigationService.ShowWindow <IPAddressWindow>(_searchQuery)).SelectMany(_ => Observable.Empty <DirectoryEntryInfo>())
                    : _adFacade.SearchDirectory(_searchQuery.Trim(), TaskPoolScheduler.Default).Take(1000).Select(directoryEntry => new DirectoryEntryInfo(directoryEntry)),
                this.WhenAnyValue(vm => vm.SearchQuery).Select(query => query.HasValue(3)));
            Search
            .Do(_ => _searchResults.Clear())
            .Switch()
            .ObserveOnDispatcher()
            .Subscribe(directoryEntryInfo => _searchResults.Add(directoryEntryInfo));

            Paste = ReactiveCommand.Create(() => { SearchQuery = Clipboard.GetText().Trim().ToUpperInvariant(); });

            Open = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var principal = await _adFacade.GetPrincipal(_selectedSearchResult.CN);

                await NavigationService.ShowPrincipalWindow(principal);

                if (!_history.Contains(_selectedSearchResult.CN))
                {
                    _history.Insert(0, _selectedSearchResult.CN);
                }
            },
                this.WhenAnyValue(vm => vm.SelectedSearchResult).IsNotNull());

            OpenSettings = ReactiveCommand.CreateFromTask(() => NavigationService.ShowDialog <SettingsWindow>());

            _isNoResults = Search
                           .Select(searchResults => Observable.Concat(
                                       Observable.Return(false),
                                       searchResults.Aggregate(0, (acc, curr) => acc + 1).Select(resultCount => resultCount == 0)))
                           .Switch()
                           .ObserveOnDispatcher()
                           .ToProperty(this, vm => vm.IsNoResults);

            Observable.Merge <(string Title, string Message)>(
                Search.ThrownExceptions.Select(ex => ("Could not complete search", ex.Message)),
                Paste.ThrownExceptions.Select(ex => ("Could not not paste text", ex.Message)),
                Open.ThrownExceptions.Select(ex => ("Could not open AD object", ex.Message)),
                OpenSettings.ThrownExceptions.Select(ex => ("Could not open settings", ex.Message)))
            .SelectMany(dialogContent => _messages.Handle(new MessageInfo(MessageType.Error, dialogContent.Message, dialogContent.Title)))
            .Subscribe();

            StateService.Get(nameof(_history), Enumerable.Empty <string>())
            .SubscribeOn(TaskPoolScheduler.Default)
            .ObserveOnDispatcher()
            .Subscribe(historyList => { using (_history.SuppressChangeNotifications()) _history.AddRange(historyList); });

            _history.CountChanged
            .Throttle(TimeSpan.FromSeconds(1))
            .SelectMany(_ => Observable.Start(() => StateService.Set(nameof(_history), _history.Take(Locator.Current.GetService <SettingsFacade>().HistoryCountLimit)), TaskPoolScheduler.Default))
            .Subscribe();

            SearchQuery = Environment.GetCommandLineArgs().Skip(1).FirstOrDefault();
        }
コード例 #16
0
        private void BindTreeToZipCodes(RadTreeViewItem parentNode)
        {
            if (parentNode == null)
            {
                trvZipCodes.Items.Clear();

                List <State> _states;

                try
                {
                    _states = StateService.GetWithinDistance((float)_selectedDealer.Latitude, (float)_selectedDealer.Longitude, (float)_selectedDealer.MaxDistance);
                }
                catch
                {
                    _states = StateService.GetActive();
                }

                foreach (State _state in _states)
                {
                    //ZipGeoCodeService.UpdateStatsForState(_state);
                    RadTreeViewItem node = new RadTreeViewItem()
                    {
                        Header = _state.StateDescription
                    };
                    node.DefaultImageSrc = "/Resources/folder.png";

                    node.Tag = "State";

                    if (_state.StateCode == _selectedDealer.StateCode)
                    {
                        node.IsExpanded = true;
                        _selectedPath   = _state.StateDescription;
                    }
                    else
                    {
                        node.IsExpanded = false;
                    }

                    trvZipCodes.Items.Add(node);

                    //call recursively to add zip parts
                    BindTreeToZipCodes(node);
                }


                //save while the form is open
                blnLoadStates = true;
            }
            else //parent node is not null - what level is it
            {
                if (((string)parentNode.Tag) == "State")
                {
                    List <ZipCodePart> _zipParts = ZipCodePartService.GetForState(parentNode.Header.ToString().Substring(0, 2));
                    foreach (ZipCodePart _zipPart in _zipParts)
                    {
                        RadTreeViewItem node = new RadTreeViewItem()
                        {
                            Header = _zipPart.ZipPart
                        };
                        node.Tag = "ZipPart";
                        parentNode.Items.Add(node);
                    }
                    if (parentNode.IsExpanded == true)
                    {
                        ((RadTreeViewItem)parentNode.Items[0]).IsSelected = true;
                        _selectedPath += " | " + _zipParts[_zipParts.Count - 1].ZipPart;
                    }
                }
            }
        }
コード例 #17
0
        public ChoiceKormsViewModel(NavigationService navigationService, IKormsService kormsService, StateService stateService)
        {
            _navigationService = navigationService;
            _kormsService      = kormsService;
            _stateService      = stateService;

            ChoiceKormDtos = _kormsService.GetAll()
                             .Select(korm => new ChoiceKormDto
            {
                Id          = korm.Id,
                Name        = korm.Name,
                IsCheck     = false,
                Cost        = korm.Cost,
                Energy      = korm.Energy,
                RawMaterial = korm.RawMaterial,
                Protein     = korm.Protein
            })
                             .ToObservable();

            NaviagationToChoiceEquantityKormsCommand = new RelayCommand(() => NaviagationToChoiceEquantityKorms());
            NavigationToUserHomePageCommand          = new RelayCommand(() => NavigationToUserHomePage());
        }
コード例 #18
0
 public async Task <IHttpActionResult> GetStateByName(string stateName)
 => Ok(await StateService.GetByNameAsync(stateName));
コード例 #19
0
 public async Task <IHttpActionResult> GetState(int id)
 => Ok(await StateService.GetByIdAsync(id));
コード例 #20
0
 public ParallelHttpProxyDecorator(HttpProxyRepository repo, TaxonomyTree tree, StateService stateService, ILog log) : base(repo, tree, stateService, log)
 {
     proxySwitcher = new ParallelHttpProxyBrowsing(this);
 }
コード例 #21
0
 public GreetingBot(StateService stateService)
 {
     _stateService = stateService ?? throw new System.ArgumentNullException(nameof(stateService));
 }
コード例 #22
0
 public async Task <IHttpActionResult> GetStates([FromUri] Pagination paginationModel)
 => Ok(await StateService.GetAllAsync(paginationModel.Page, paginationModel.PageSize));
コード例 #23
0
 public StateManager()
 {
     _stateService = new StateService();
 }
 public DialogBot(StateService stateService, T dialog, ILogger <DialogBot <T> > logger)
 {
     _stateService = stateService ?? throw new ArgumentNullException(nameof(stateService));
     _dialog       = dialog ?? throw new ArgumentNullException(nameof(dialog));
     _logger       = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #25
0
 public StateBrowsingService(StateService stateService, StateRepository stateRepo)
 {
     _stateService = stateService;
     _stateRepo    = stateRepo;
 }
コード例 #26
0
 public GreetingDialog(string dialogId, StateService stateService) : base(dialogId)
 {
     _botStateService = stateService ?? throw new System.ArgumentNullException(nameof(StateService));
     InitializeWaterfallDialog();
 }
コード例 #27
0
 public CallsSecurityViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
     : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
 {
     _callsSecurity = StateService.GetCallsSecurity(true);
 }
コード例 #28
0
        /// <summary>
        /// Transfers the client.
        /// </summary>
        /// <param name="identityProvider">The identity provider.</param>
        /// <param name="request">The request.</param>
        /// <param name="context">The context.</param>
        private void TransferClient(IdentityProvider identityProvider, Saml20AuthnRequest request, HttpContext context)
        {
            // Set the last IDP we attempted to login at.
            StateService.Set(IdpTempSessionKey, identityProvider.Id);

            // Determine which endpoint to use from the configuration file or the endpoint metadata.
            var destination = DetermineEndpointConfiguration(BindingType.Redirect, identityProvider.SignOnEndpoint, identityProvider.Metadata.SSOEndpoints);

            request.Destination = destination.Url;

            if (identityProvider.ForceAuth)
            {
                request.ForceAuthn = true;
            }

            // Check isPassive status
            var isPassiveFlag = StateService.Get <bool?>(IdpIsPassive);

            if (isPassiveFlag != null && (bool)isPassiveFlag)
            {
                request.IsPassive = true;
                StateService.Set(IdpIsPassive, null);
            }

            if (identityProvider.IsPassive)
            {
                request.IsPassive = true;
            }

            // Check if request should forceAuthn
            var forceAuthnFlag = StateService.Get <bool?>(IdpForceAuthn);

            if (forceAuthnFlag != null && (bool)forceAuthnFlag)
            {
                request.ForceAuthn = true;
                StateService.Set(IdpForceAuthn, null);
            }

            // Check if protocol binding should be forced
            if (identityProvider.SignOnEndpoint != null)
            {
                if (!string.IsNullOrEmpty(identityProvider.SignOnEndpoint.ForceProtocolBinding))
                {
                    request.ProtocolBinding = identityProvider.SignOnEndpoint.ForceProtocolBinding;
                }
            }

            // Save request message id to session
            StateService.Set(ExpectedInResponseToSessionKey, request.Id);

            switch (destination.Binding)
            {
            case BindingType.Redirect:
                Logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpRedirect);

                var redirectBuilder = new HttpRedirectBindingBuilder
                {
                    SigningKey = _certificate.PrivateKey,
                    Request    = request.GetXml().OuterXml
                };

                Logger.DebugFormat(TraceMessages.AuthnRequestSent, redirectBuilder.Request);

                var redirectLocation = request.Destination + (request.Destination.Contains("?") ? "&" : "?") + redirectBuilder.ToQuery();
                context.Response.Redirect(redirectLocation, true);
                break;

            case BindingType.Post:
                Logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpPost);

                var postBuilder = new HttpPostBindingBuilder(destination);

                // Honor the ForceProtocolBinding and only set this if it's not already set
                if (string.IsNullOrEmpty(request.ProtocolBinding))
                {
                    request.ProtocolBinding = Saml20Constants.ProtocolBindings.HttpPost;
                }

                var requestXml = request.GetXml();
                XmlSignatureUtils.SignDocument(requestXml, request.Id);
                postBuilder.Request = requestXml.OuterXml;

                Logger.DebugFormat(TraceMessages.AuthnRequestSent, postBuilder.Request);

                postBuilder.GetPage().ProcessRequest(context);
                break;

            case BindingType.Artifact:
                Logger.DebugFormat(TraceMessages.AuthnRequestPrepared, identityProvider.Id, Saml20Constants.ProtocolBindings.HttpArtifact);

                var artifactBuilder = new HttpArtifactBindingBuilder(context);

                // Honor the ForceProtocolBinding and only set this if it's not already set
                if (string.IsNullOrEmpty(request.ProtocolBinding))
                {
                    request.ProtocolBinding = Saml20Constants.ProtocolBindings.HttpArtifact;
                }

                Logger.DebugFormat(TraceMessages.AuthnRequestSent, request.GetXml().OuterXml);

                artifactBuilder.RedirectFromLogin(destination, request);
                break;

            default:
                Logger.Error(ErrorMessages.EndpointBindingInvalid);
                throw new Saml20Exception(ErrorMessages.EndpointBindingInvalid);
            }
        }
コード例 #29
0
        protected override void OnDeactivate(bool close)
        {
            base.OnDeactivate(close);

            StateService.SaveCallsSecurity(_callsSecurity);
        }
コード例 #30
0
        public void register_save_callback_throws_if_save_task_factory_is_null()
        {
            var service = new StateService(new BlobCacheMock(), new LoggerServiceMock(MockBehavior.Loose));

            Assert.Throws <ArgumentNullException>(() => service.RegisterSaveCallback(null));
        }
コード例 #31
0
        public async Task <IHttpActionResult> PostState(StatePostDto state)
        {
            var newState = await StateService.AddAsync(state);

            return(CreatedAtRoute("StateRoute", new { id = newState.Id }, newState));
        }
コード例 #32
0
ファイル: frmState.cs プロジェクト: thankosein/GitWindow
 private void btnDelete_Click(object sender, EventArgs e)
 {
     lblResult.Text = StateService.Remove(stateId);
     StateService.ReadData(dgv);
     AutoFillStateId();
 }
コード例 #33
0
 public HttpProxyDecorator(HttpProxyRepository repo, TaxonomyTree tree, StateService stateService, ILog log) : base(repo, tree, stateService, log)
 {
     Attempts = 0;
 }
コード例 #34
0
ファイル: AddRule.aspx.cs プロジェクト: daniela12/gooptic
    /// <summary>
    /// Bind the States
    /// </summary>
    private void BindStates()
    {
        StateService stateService = new StateService();
        StateQuery filters = new StateQuery();

        // Parameters
        filters.Append(StateColumn.CountryCode, lstCountries.SelectedItem.Value);

        // Get States list
        TList<State> StatesList = stateService.Find(filters.GetParameters());

        lstStateOption.DataSource = StatesList;
        lstStateOption.DataTextField = "Name";
        lstStateOption.DataValueField = "Code";
        lstStateOption.DataBind();
        ListItem li = new ListItem("Apply to ALL States", "0");
        lstStateOption.Items.Insert(0, li);
    }
コード例 #35
0
        // Initializes a new instance of the "WelcomeUserBot" class.

        public WelcomeUserBot(UserState userState, IMailService mailService, AppSettings appSetting, StateService stateService, BotServices botServices)//, IAppServices appServices
        {
            _userState       = userState;
            this.mailService = mailService;
            //_appServices = appServices;
            _appSetting   = appSetting;
            _stateService = stateService ?? throw new System.ArgumentNullException(nameof(stateService));
            _botServices  = botServices ?? throw new System.ArgumentNullException(nameof(stateService));
        }
コード例 #36
0
 public void GivenIHaveAStateService()
 {
     _storage = new StateConcurrentStorage();
     _stateService = new StateService(_storage);
 }
コード例 #37
0
 public MandalController()
 {
     _mandalService = new MandalService();
     _stateService = new StateService();
     _districtService = new DistrictService();
 }
コード例 #38
0
        public BugReportDialog(string dialogId, StateService stateService) : base(dialogId)
        {
            _stateService = stateService ?? throw new ArgumentNullException(nameof(stateService));

            InitializeWaterfallDialog();
        }
コード例 #39
0
        public async Task <IHttpActionResult> DeleteState(int id)
        {
            await StateService.RemoveAsync(id);

            return(Ok());
        }
コード例 #40
0
 public void Contacts()
 {
     StateService.GetContactsSettings();
     NavigationService.UriFor <ContactsSecurityViewModel>().Navigate();
 }
コード例 #41
0
 public StateBrowsingService(StateService stateService, StateRepository stateRepo)
 {
     _stateService = stateService;
     _stateRepo = stateRepo;
 }