Esempio n. 1
0
        public CodeFeatureStateCodeSwitch(ICodeFeatureStateCache cache)
        {
            _cache = cache;

            _evaluated = new CodeSwitchEvaluatedObservable <TFeature>();
            _enabled   = new Lazy <bool>(Evaluate);
        }
Esempio n. 2
0
        public async Task Connect(string hostAddress)
        {
            var hubConnection = new HubConnection(hostAddress);

            hubConnection.Headers.Add(Headers.FooidityAppKey, _applicationKey);


            hubConnection.Error          += x => Console.WriteLine(x.Message);
            hubConnection.ConnectionSlow += () => Console.WriteLine("Connection is slow");
            hubConnection.StateChanged   += x => Console.WriteLine("state changed from {0} to {1}", x.OldState, x.NewState);
            hubConnection.Closed         += () => Console.WriteLine("connection closed");
            hubConnection.Received       += x => Console.WriteLine("received: {0}", x);

            IHubProxy applicationHub = hubConnection.CreateHubProxy("ApplicationHub");

            applicationHub.On("notifyMissingAppKey", OnMissingAppKey);
            applicationHub.On("notifyInvalidAppKey", OnInvalidAppKey);

            applicationHub.On <CodeFeatureStateUpdated>("notifyCodeFeatureStateUpdated", OnCodeFeatureStateUpdated);

            await hubConnection.Start();

            _hubConnection  = hubConnection;
            _applicationHub = applicationHub;
            _reporter       = new CodeSwitchEvaluationApplicationReporter(_applicationHub);

            await Task.Run(() =>
            {
                var cache = new CodeFeatureStateCache(new ApplicationHubProvider(applicationHub));

                _cache       = cache;
                _updateCache = cache;
            });
        }
Esempio n. 3
0
        public ContextFeatureStateCodeSwitch(ICodeFeatureStateCache cache,
                                             IContextFeatureStateCache <TContext> contextCache, TContext context)
        {
            _cache        = cache;
            _contextCache = contextCache;
            _context      = context;

            _evaluated = new CodeSwitchEvaluatedObservable <TFeature>();
            _enabled   = new Lazy <bool>(Evaluate);
        }