protected AppendEntryBaseTest()
        {
            // Arrange  
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();

            mocker.Use(ServerIdentifier);

            mocker.Setup<ISubject<AppendEntryMessage>>(p => p.Subscribe(It.IsAny<IObserver<AppendEntryMessage>>()))
                .Callback<IObserver<AppendEntryMessage>>((o) =>
                {
                    AppendEntryCallback = o;
                });
            AppendEntryCallback = mocker.Get<ISubject<AppendEntryMessage>>();

            AppendEntryResult = new Subject<AppendEntryResultMessage>();
            Election = new Election();
            LogReplication = new LogReplication();
            
            AppendEntry = new Rafting.AppendEntry(AppendEntryResult,
                mocker.Get<ISubject<AppendEntryMessage>>(),
                mocker.Get<IHartbeatTimer>(),
                LogReplication,
                Election,
                mocker.Get<ILoggerFactory>(),
                new RaftOptions(),
                mocker.Get<ServerIdentifier>(),
                null);
        }
예제 #2
0
        public ConnectivityService()
        {
            updateSubject = new Subject<Unit>();

            status =
            Observable.FromEventPattern<NetworkNotificationEventArgs>(h => DeviceNetworkInformation.NetworkAvailabilityChanged += h, h => DeviceNetworkInformation.NetworkAvailabilityChanged -= h)
                .Select(_ => 0L)
                .Merge(Observable.Interval(TimeSpan.FromSeconds(10), ThreadPoolScheduler.Instance))
                .Merge(updateSubject.Select(_ => 0L))
                .StartWith(0L)
                .Select(_ =>
                {
                    if (NetworkInterface.GetIsNetworkAvailable())
                    {
                        var it = NetworkInterface.NetworkInterfaceType;

                        if (it == NetworkInterfaceType.Wireless80211 || it == NetworkInterfaceType.Ethernet)
                            return ConnectionStatus.Wifi;
                        if (it == NetworkInterfaceType.MobileBroadbandGsm || it == NetworkInterfaceType.MobileBroadbandCdma)
                            return ConnectionStatus.MobileBroadband;
                    }
                    return ConnectionStatus.None;
                })
                .DistinctUntilChanged()
                .Replay(1)
                .RefCount();
        }
예제 #3
0
 public PriceGrabber(ISubject subject, double usaPrice, double israelPrice)
 {
     _subject = subject;
     _subject.Register(this);
     USAPrice = usaPrice;
     IsraelPrice = israelPrice;
 }
예제 #4
0
파일: Field.cs 프로젝트: AdamCollings/dbqf
 public Field(ISubject parent, string sourceName, string displayName, Type type)
 {
     Subject = parent;
     SourceName = sourceName;
     DisplayName = displayName;
     DataType = type;
 }
예제 #5
0
    public void SetUp() {
      callback_ = new NopAuthCallbackHandler();
      shared_ = new Dictionary<string, string>();
      options_ = new Dictionary<string, string>();

      module_ = Mock.Create<ILoginModule>();
      Mock
        .Arrange(
          () => module_.Login(Arg.IsAny<IAuthCallbackHandler>(), subject_))
        .Returns(AuthenticationInfos.Sucessful());
      Mock
        .Arrange(() => module_.Commit(Arg.IsAny<IAuthenticationInfo>()))
        .Returns(true);
      Mock
        .Arrange(() => module_.ControlFlag)
        .Returns(LoginModuleControlFlag.Required);

      subject_ = Mock.Create<ISubject>();
      Mock
        .Arrange(() => subject_.Permissions)
        .Returns(new HashSet<IPermission>());
      Mock
        .Arrange(() => subject_.Principals)
        .Returns(new HashSet<IPrincipal>());
    }
예제 #6
0
        public CandidateBaseTests()
        {
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();
            mocker.Use(ServerIdentifier);


            Election = new Election();
            RequestVoteResult = new Subject<RequestVoteResultMessage>();
            RequestVote = new Subject<RequestVoteMessage>();
            MockVotingSystem = mocker.GetMock<IVotingSystem>();


            Candidate = new Rafting.States.Candidate(mocker.Get<ServerIdentifier>(),
                mocker.Get<IElectionTimer>(),
                RequestVote,
                RequestVoteResult,
                MockVotingSystem.Object,
                Election,
                mocker.Get<ILogReplication>(),
                mocker.Get<Nodes>(),
                mocker.Get<ILoggerFactory>(),
                new RaftOptions());
        }
예제 #7
0
        private DenyResult[] GetDenyActions(ISubject subject, IAction[] actions, ISecurityObjectId objectId, ISecurityObjectProvider securityObjProvider)
        {
            var denyActions = new List<DenyResult>();
            if (actions == null) actions = new IAction[0];

            if (subject == null)
            {
                denyActions = actions.Select(a => new DenyResult(a, null, null)).ToList();
            }
            else if (subject is ISystemAccount && subject.ID == Constants.CoreSystem.ID)
            {
                // allow all
            }
            else
            {
                ISubject denySubject = null;
                IAction denyAction = null;
                foreach (var action in actions)
                {
                    var allow = azManager.CheckPermission(subject, action, objectId, securityObjProvider, out denySubject, out denyAction);
                    if (!allow)
                    {
                        denyActions.Add(new DenyResult(action, denySubject, denyAction));
                        break;
                    }
                }
            }
            return denyActions.ToArray();
        }
        public SettingsService(
            ICurrentProfile Profile,
            [Dispatcher] IScheduler Dispatcher,
            [ThreadPool] IScheduler ThreadPool
            )
        {
            Contract.Requires(Profile != null);
            Contract.Requires(Dispatcher != null);
            Contract.Requires(ThreadPool != null);

            this.Profile = Profile;
            this.SettingsSerializer = new XmlSerializer(typeof(AppSettings));

            _SettingsReplay = _SettingsOut
                .ObserveOn(Dispatcher)
                .Replay(1)
                .RefCount();

            _SettingsIn = new Subject<AppSettings>();

            _SettingsIn
                .ObserveOn(ThreadPool)
                .Select(PersistSettings)
                .ObserveOn(Dispatcher)
                .Subscribe(_SettingsOut);

            Profile
                .CurrentProfilePathObservable()
                .Select(ProfileToSettingsPath)
                .ObserveOn(ThreadPool)
                .Select(LoadSettingsFromFile)
                .ObserveOn(Dispatcher)
                .Subscribe(_SettingsOut);
        }
예제 #9
0
        public RulerBase(IModifierBus bus, IRules rules, ISubject<IInfo> infoChannel)
        {
            _bus = bus;
            _rules = rules;

            _infoChannel = infoChannel;
        }
 public void Initializing_a_dynamic_object_implementation()
 {
     _subject = (ISubject)typeof(ISubject).InitializeProxy(new
         {
             Value = _stringValue,
         });
 }
예제 #11
0
 public void AddSubject(ISubject s)
 {
     if (!IsSubjectListened(s))
     {
         subjectList.Add(s);
     }
 }
예제 #12
0
 public FriendObserver(ListBox displayBox, ISubject friendSubject)
 {
     status = "";
     this.friendSubject = friendSubject;
     this.displayBox = displayBox;
     friendSubject.addObserver(this);
 }
예제 #13
0
파일: MacroPlayer.cs 프로젝트: ray2k/Maacro
 public MacroPlayer()
 {
     _iterationStartedSubject = new ScheduledSubject<int>(RxApp.DeferredScheduler);
     _stepCompletedSubject = new ScheduledSubject<int>(RxApp.DeferredScheduler);
     _stepStartedSubject = new ScheduledSubject<StepStartedInfo>(RxApp.DeferredScheduler);
     _stepProgressUpdatedSubject = new ScheduledSubject<int>(RxApp.DeferredScheduler);
 }
예제 #14
0
 public void RemoveSubject(ISubject s)
 {
     if (IsSubjectListened(s))
     {
         subjectList.Remove(s);
     }
 }
예제 #15
0
 public void Add(ISubject subject)
 {
    if(this.DoesNotContain(subject) || subject == null)
    {
        this.subjects.Add(subject);
    }    
 }
        public VirtualListVewModel(SynchronizationContext bindingContext, DataService service)
        {
            _virtualRequest = new BehaviorSubject<VirtualRequest>(new VirtualRequest(0,10));

            Items = new BindingList<Poco>();

            var sharedDataSource = service
                .DataStream
                .Do(x => Trace.WriteLine($"Service -> {x}"))
                .ToObservableChangeSet()
                .Publish();

            var binding = sharedDataSource
                          .Virtualise(_virtualRequest)
                          .ObserveOn(bindingContext)
                          .Bind(Items)
                          .Subscribe();
            
            //the problem was because Virtualise should fire a noticiation if count changes, but it does not [BUG]
            //Therefore take the total count from the underlying data NB: Count is DD.Count() not Observable.Count()
            Count = sharedDataSource.Count().DistinctUntilChanged();

            Count.Subscribe(x => Trace.WriteLine($"Count = {x}"));

            var connection = sharedDataSource.Connect();
            _disposables = new CompositeDisposable(binding, connection);
        }
예제 #17
0
        public ProcessManager() {
            var launched = new Subject<Tuple<ProcessStartInfo, int>>();
            _launched = Subject.Synchronize(launched);
            Launched = _launched.AsObservable();
            _subjects.Add(launched);

            var killed = new Subject<Tuple<ProcessStartInfo, int, TimeSpan, string>>();
            _monitorKilled = Subject.Synchronize(killed);
            MonitorKilled = _monitorKilled.AsObservable();
            _subjects.Add(killed);

            var started = new Subject<Tuple<ProcessStartInfo, int, string>>();
            _monitorStarted = Subject.Synchronize(started);
            MonitorStarted = _monitorStarted.AsObservable();
            _subjects.Add(started);

            var stopped = new Subject<Tuple<ProcessStartInfo, int, string>>();
            _monitorStopped = Subject.Synchronize(stopped);
            MonitorStopped = _monitorStopped.AsObservable();
            _subjects.Add(stopped);

            var terminated = new Subject<Tuple<ProcessStartInfo, int, int>>();
            _terminated = Subject.Synchronize(terminated);
            Terminated = _terminated.AsObservable();
            _subjects.Add(terminated);
        }
 public void MyTestInitialize()
 {
     _pausingSubject = new Subject<bool>();
     _scheduler = new TestScheduler();
     _source = new SourceList<Person>();
     _results = _source.Connect().BufferIf(_pausingSubject,TimeSpan.FromMinutes(1), _scheduler).AsAggregator();
 }
예제 #19
0
 public void UnSubscribe(ISubject<IObserver> topic, IObserver follower)
 {
     if (pushsubMapping.ContainsKey(topic.ToString()))
     {
         pushsubMapping[topic.ToString()].Remove(follower);
     }
 }
예제 #20
0
        internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject<object> subject)
        {
            var mode = BindingMode == BindingMode.Default ?
                property.DefaultBindingMode : BindingMode;

            switch (mode)
            {
                case BindingMode.Default:
                case BindingMode.OneWay:
                    target.Bind(property, subject);
                    break;
                case BindingMode.TwoWay:
                    target.BindTwoWay(property, subject);
                    break;
                case BindingMode.OneTime:
                    target.GetObservable(Control.DataContextProperty).Subscribe(dataContext =>
                    {
                        subject.Take(1).Subscribe(x => target.SetValue(property, x));
                    });                    
                    break;
                case BindingMode.OneWayToSource:
                    target.GetObservable(property).Subscribe(subject);
                    break;
            }
        }
예제 #21
0
 public void MyTestInitialize()
 {
     _pausingSubject = new Subject<bool>();
     _scheduler = new TestScheduler();
     _source = new SourceCache<Person, string>(p => p.Key);
     _results = _source.Connect().BatchIf(_pausingSubject, _scheduler).AsAggregator();
 }
        public void YieldObservable()
        {
            coroutine = YieldObservableBlock().AsCoroutine<object>();

            subject = new Subject<object>();

            Subscribe();

            expectedResults.Add(t1);
            expectedResults.Add(t2);

            AssertExpectedResults();

            subject.OnNext(t3);

            // don't want to include results from observables yielded
            //expectedResults.Add(t3);

            AssertExpectedResults();

            subject.OnCompleted();

            expectedResults.Add(t4);

            AssertExpectedResults();
            AssertExpectedErrors();
            AssertCompleted();
        }
예제 #23
0
        public VideoService(
            Rectangle viewFinder,
            MediaElement player
            )
        {
            // Initial State
            _State = PlayState.Paused;
            _CanRecord = false;

            _Record = new SwitchableCommand(OnRecord);
            _Play = new SwitchableCommand(OnPlay);
            _Stop = new SwitchableCommand(OnPause);

            _ViewFinder = viewFinder;

            _Player = player;
            _Player.MediaEnded += MediaEnded;

            _CaptureSource = new CaptureSource();
            _CaptureSource.CaptureFailed += CaptureFailed;

            _FileSink = new FileSink();
            _Brush = new VideoBrush();

            _HasRecording = new BehaviorSubject<bool>(false);
        }
예제 #24
0
        public ViewModel()
        {
            Users = new ObservableCollection<UserFullInfo>();

            Countries = new ObservableCollection<Country>(countryService.GetCountries());

            UserProvider userP = new UserProvider();
            //AsyncUser = new AsyncVirtualizingCollection<UserFullInfo>(userP, 100, 30);
            AsyncUser = new AsyncVirtualizingCollection<UserFullInfo>(userP, 100, 30000);

            var usersObservable = userService.GetUsers().ToObservable();
            usersObservable.SubscribeOn(ThreadPoolScheduler.Instance).ObserveOn(DispatcherScheduler.Current).Subscribe(userInfo => Users.Add(userInfo));

            userSubject = new Subject<UserFullInfo>();
            userSubject.Subscribe(x =>
            {
                if (x == null)
                    return;
                x.CountrySubject.OnNext(x.Country);
                x.SubdivisionSubject.OnNext(x.Subdivision);
            });

            //var countrySubj = new Subject<UserFullInfo>();

            currentUser = new UserFullInfo();

            NewCommand = new RelayCommand(arg => NewMethod());
            SaveCommand = new RelayCommand(arg => SaveMethod());
            CloseComman = new RelayCommand(arg => CloseMethod());
        }
예제 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FantasyTeamPresenter"/> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="owningPerson">The owning person.</param>
 /// <param name="subject">The subject.</param>
 public FantasyTeamPresenter(IFantasyTeamView view, string owningPerson, ISubject subject)
 {
     _View = view;
     _View.Unsubscribing += Unsubscribing;
     FantasyTeam = owningPerson;
     _Subject = subject;
 }
예제 #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SuspensionService"/> class.
        /// Based on WinRTSuspensionHost in ReactiveUI.Mobile
        /// </summary>
        public SuspensionService(Application app, ISubject<LaunchActivatedEventArgs> launched)
        {
            var launchNew = new[] { ApplicationExecutionState.ClosedByUser, ApplicationExecutionState.NotRunning, };
            this.IsLaunchingNew = launched
                .Where(x => launchNew.Contains(x.PreviousExecutionState))
                .Select(x => x.Arguments);

            this.IsResuming = launched
                .Where(x => x.PreviousExecutionState == ApplicationExecutionState.Terminated)
                .Select(x => x.Arguments);

            var unpausing = new[] { ApplicationExecutionState.Suspended, ApplicationExecutionState.Running, };
            this.IsUnpausing = launched
                .Where(x => unpausing.Contains(x.PreviousExecutionState))
                .Select(x => x.Arguments);

            var shouldPersistState = new Subject<SuspendingEventArgs>();
            app.Suspending += (o, e) => shouldPersistState.OnNext(e);
            this.ShouldPersistState =
                shouldPersistState.Select(x =>
                {
                    var deferral = x.SuspendingOperation.GetDeferral();
                    return Disposable.Create(deferral.Complete);
                });

            var shouldInvalidateState = new Subject<Unit>();
            app.UnhandledException += (o, e) => shouldInvalidateState.OnNext(Unit.Default);
            this.ShouldInvalidateState = shouldInvalidateState;
        }
 internal static string FormatErrorMessage(ISubject subject, IAction[] actions, ISubject[] denySubjects,
                                           IAction[] denyActions)
 {
     if (subject == null) throw new ArgumentNullException("subject");
     if (actions == null || actions.Length == 0) throw new ArgumentNullException("actions");
     if (denySubjects == null || denySubjects.Length == 0) throw new ArgumentNullException("denySubjects");
     if (denyActions == null || denyActions.Length == 0) throw new ArgumentNullException("denyActions");
     if (actions.Length != denySubjects.Length || actions.Length != denyActions.Length)
         throw new ArgumentException();
     string reasons = "";
     for (int i = 0; i < actions.Length; i++)
     {
         string reason = "";
         if (denySubjects[i] != null && denyActions[i] != null)
             reason = String.Format("{0}:{1} access denied {2}.",
                                    actions[i].Name,
                                    (denySubjects[i] is IRole ? "role:" : "") + denySubjects[i].Name,
                                    denyActions[i].Name
                 );
         else
             reason = String.Format("{0}: access denied.", actions[i].Name);
         if (i != actions.Length - 1)
             reason += ", ";
         reasons += reason;
     }
     string sactions = "";
     Array.ForEach(actions, action => { sactions += action.ToString() + ", "; });
     string message = String.Format(
         "\"{0}\" access denied \"{1}\". Cause: {2}.",
         (subject is IRole ? "role:" : "") + subject.Name,
         sactions,
         reasons
         );
     return message;
 }
        public IEnumerable<IRole> GetObjectRoles(ISubject account, ISecurityObjectId objectId, SecurityCallContext callContext)
        {
 
          //   Constants.Everyone
          // if (_daoFactory.GetManagerDao().GetAll(false).Contains(ASC.Core.CoreContext.UserManager.GetUsers(account.ID)))
          //   return new Action[]
            throw new NotImplementedException();
        }
예제 #29
0
 public void Update(ISubject subject)
 {
     var boxFight = (BoxFight)subject;
     if (boxFight.BoxerAScore < boxFight.BoxerBScore)
     BoxerToPutMoneyOn = "I put on boxer B, better be safe!";
     else BoxerToPutMoneyOn = "I put on boxer A, better be safe!";
     Console.WriteLine("CONSERVATIVEPLAYER:{0}", BoxerToPutMoneyOn);
 }
예제 #30
0
파일: GroupBy.cs 프로젝트: ufcpp/UniRx
 public GroupedObservable(TKey key, ISubject <TElement> subject, RefCountDisposable refCount)
 {
     this.key      = key;
     this.subject  = subject;
     this.refCount = refCount;
 }
예제 #31
0
        /// <summary>Draw debug metadata to the screen.</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        public void Draw(SpriteBatch spriteBatch)
        {
            if (!this.Enabled)
            {
                return;
            }

            this.Monitor.InterceptErrors("drawing debug info", () =>
            {
                // get location info
                GameLocation currentLocation = Game1.currentLocation;
                Vector2 cursorTile           = Game1.currentCursorTile;
                Vector2 cursorPosition       = GameHelper.GetScreenCoordinatesFromCursor();

                // show 'debug enabled' warning + cursor position
                {
                    string metadata = $"{this.WarningText} Cursor tile ({cursorTile.X}, {cursorTile.Y}), position ({cursorPosition.X}, {cursorPosition.Y}).";
                    GameHelper.DrawHoverBox(spriteBatch, metadata, Vector2.Zero, Game1.viewport.Width);
                }

                // show cursor pixel
                spriteBatch.DrawLine(cursorPosition.X - 1, cursorPosition.Y - 1, new Vector2(Game1.pixelZoom, Game1.pixelZoom), Color.DarkRed);

                // show targets within detection radius
                Rectangle tileArea            = GameHelper.GetScreenCoordinatesFromTile(Game1.currentCursorTile);
                IEnumerable <ITarget> targets = this.TargetFactory
                                                .GetNearbyTargets(currentLocation, cursorTile, includeMapTile: false)
                                                .OrderBy(p => p.Type == TargetType.Unknown ? 0 : 1);
                // if targets overlap, prioritise info on known targets
                foreach (ITarget target in targets)
                {
                    // get metadata
                    bool spriteAreaIntersects = target.GetSpriteArea().Intersects(tileArea);
                    ISubject subject          = this.TargetFactory.GetSubjectFrom(target);

                    // draw tile
                    {
                        Rectangle tile = GameHelper.GetScreenCoordinatesFromTile(target.GetTile());
                        Color color    = (subject != null ? Color.Green : Color.Red) * .5f;
                        spriteBatch.DrawLine(tile.X, tile.Y, new Vector2(tile.Width, tile.Height), color);
                    }

                    // draw sprite box
                    if (subject != null)
                    {
                        int borderSize    = 3;
                        Color borderColor = Color.Green;
                        if (!spriteAreaIntersects)
                        {
                            borderSize   = 1;
                            borderColor *= 0.5f;
                        }

                        Rectangle spriteBox = target.GetSpriteArea();
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y, new Vector2(spriteBox.Width, borderSize), borderColor);                    // top
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y, new Vector2(borderSize, spriteBox.Height), borderColor);                   // left
                        spriteBatch.DrawLine(spriteBox.X + spriteBox.Width, spriteBox.Y, new Vector2(borderSize, spriteBox.Height), borderColor); // right
                        spriteBatch.DrawLine(spriteBox.X, spriteBox.Y + spriteBox.Height, new Vector2(spriteBox.Width, borderSize), borderColor); // bottom
                    }
                }

                // show current target name (if any)
                {
                    ISubject subject = this.TargetFactory.GetSubjectFrom(Game1.player, currentLocation, LookupMode.Cursor, includeMapTile: false);
                    if (subject != null)
                    {
                        GameHelper.DrawHoverBox(spriteBatch, subject.Name, new Vector2(Game1.getMouseX(), Game1.getMouseY()) + new Vector2(Game1.tileSize / 2f), Game1.viewport.Width / 4f);
                    }
                }
            }, this.OnDrawError);
        }
예제 #32
0
 /// <summary>
 /// Creates an observable progress that uses the specified subject.
 /// </summary>
 /// <param name="subject">The subject used for progress updates.</param>
 public ObservableProgress(ISubject <T> subject)
 {
     _subject = subject;
 }
 public ReactiveEventBus()
 {
     _bus = new Subject <object>();
 }
예제 #34
0
 public SimpleRating(IRater rater, ISubject subject, double value)
 {
     Rater   = rater;
     Subject = subject;
     Value   = value;
 }
예제 #35
0
 public RelationField(ISubject parent, string sourceName, string displayName)
     : this(parent, sourceName, displayName, null)
 {
 }
예제 #36
0
 public void DetachFrom(ISubject subject)
 {
     subject.Attach(this);
 }
예제 #37
0
 public WrappedSubject(ISubject <T> inner, IDisposable disposable)
 {
     this.inner      = inner;
     this.disposable = disposable;
 }
예제 #38
0
 public StatisticsDisplay(ISubject weatherData)
 {
     _weatherData = weatherData;
     _weatherData.RegisterObserver(this);
 }
예제 #39
0
 public bool Update(ISubject sender, string data, short objState)
 {
     _newData.Add(data);
     return(true);
 }
예제 #40
0
 public StatisticsDisplay()
 {
     _subject = new WeatherData();
 }
 public SubscriptionService()
 {
     _subject = new Subject <Object>();
     _publisherSubscriptions = new List <IDisposable>();
 }
예제 #42
0
 public void Update(ISubject subject)
 {
     throw new System.NotImplementedException();
 }
예제 #43
0
 public RelationField(ISubject parent, string sourceName, string displayName, ISubject linkedSubject)
     : this(parent, sourceName, displayName, typeof(object), linkedSubject)
 {
 }
예제 #44
0
 public Observer(string userName, ISubject subject)
 {
     UserName = userName;
     subject.RegisterObserver(this);
 }
예제 #45
0
 public Proxy(ISubject subject, bool condition)
 {
     this.subject   = subject;
     this.condition = condition;
 }
예제 #46
0
 public void AttachTo(ISubject subject)
 {
     subject.Attach(this);
 }
 public FilterControllerFixtureWithClearAndReplace()
 {
     _source  = new SourceList <Person>();
     _filter  = new BehaviorSubject <Func <Person, bool> >(p => p.Age > 20);
     _results = _source.Connect().Filter(_filter).AsAggregator();
 }
예제 #48
0
        public IBuilder BuildSubject()
        {
            _subject = new Subject();

            return(this);
        }
예제 #49
0
 public ForcastDisplay(ISubject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.RegisterObserver(this);
 }
예제 #50
0
 public WebSocketController(IRepository repository, Action <string> logger, ISubject <string> mesgChain)
 {
     _repository   = repository;
     _log          = logger;
     _messageChain = mesgChain;
 }
예제 #51
0
 public void Update(ISubject subject)
 {
     Count += subject.Count;
 }
예제 #52
0
        public TimeSeriesController(ISubject <IEnumerable <KeyValuePair <DateTime, double> > > observable, Dispatcher dis)
        {
            Buttons = VMFactory.BuildButtons(observable);

            TimeValueSeries = observable.Select(_ => new CollectionViewModel <KeyValuePair <DateTime, double> >(_, dis));
        }
예제 #53
0
파일: GroupBy.cs 프로젝트: ufcpp/UniRx
            public override void OnNext(TSource value)
            {
                var key = default(TKey);

                try
                {
                    key = parent.keySelector(value);
                }
                catch (Exception exception)
                {
                    Error(exception);
                    return;
                }

                var fireNewMapEntry = false;
                var writer          = default(ISubject <TElement>);

                try
                {
                    if (key == null)
                    {
                        if (nullKeySubject == null)
                        {
                            nullKeySubject  = new Subject <TElement>();
                            fireNewMapEntry = true;
                        }

                        writer = nullKeySubject;
                    }
                    else
                    {
                        if (!map.TryGetValue(key, out writer))
                        {
                            writer = new Subject <TElement>();
                            map.Add(key, writer);
                            fireNewMapEntry = true;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Error(exception);
                    return;
                }

                if (fireNewMapEntry)
                {
                    var group = new GroupedObservable <TKey, TElement>(key, writer, refCountDisposable);
                    observer.OnNext(group);
                }

                var element = default(TElement);

                try
                {
                    element = parent.elementSelector(value);
                }
                catch (Exception exception)
                {
                    Error(exception);
                    return;
                }

                writer.OnNext(element);
            }
예제 #54
0
 public CurrentConditions(ISubject newWeatherData)
 {
     this.weatherData = newWeatherData;
     this.weatherData.Register(this);
 }
예제 #55
0
 public MainViewModel()
 {
     _currentViewChanged = new Subject <Context>();
     _receivedPlaySignal = new Subject <Uri>();
 }
예제 #56
0
 public Statistics(ISubject newWeatherData)
 {
     this.weatherData = newWeatherData;
     this.weatherData.Register(this);
 }
 public CurrentConditionsDisplay(ISubject weatherData)
 {
     this.weatherData = weatherData;
     weatherData.registerObserver(this);
 }
예제 #58
0
 public Forecast(ISubject newWeatherData)
 {
     this.weatherData = newWeatherData;
     this.weatherData.Register(this);
 }
 // TODO: Lock?
 ISubject <PropertyChangingInfo, PropertyChangingInfo> GetChangingSubject()
 => _changingSubject ?? (_changingSubject = Subject.Synchronize(new Subject <PropertyChangingInfo>()));
예제 #60
-1
        public LeaderBaseTests()
        {
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();
            mocker.Use(ServerIdentifier);

            Election = new Election();
            AppendEntryResult = new Subject<AppendEntryResultMessage>();
            AppendEntry = new Subject<AppendEntryMessage>();
            LogReplication = new LogReplication();
            Nodes = new Nodes();

            Leader = new Rafting.States.Leader(
                Election,
                mocker.Get<IHartbeatTimer>(),
                AppendEntryResult,
                AppendEntry,
                mocker.Get<IObserver<ClientResultMessage>>(),
                mocker.Get<IObservable<ClientMessage>>(),
                LogReplication,
                Nodes,
                mocker.Get<ILoggerFactory>(),
                new RaftOptions(),
                mocker.Get<ServerIdentifier>());
        }