예제 #1
0
                public bool AddSource(IEventSource source)
                {
                    if (this.sources_.ContainsKey(source))
                    {
                        return(false);
                    }

                    var subscription =
                        (source.AddListener(this.parent_.listener_,
                                            this.eventType_,
                                            this.convertSourceToThisEmit_) as EventSubscription <TEvent>) !;

                    this.sources_.TryAdd(source, subscription);

                    var contract = subscription.Contract !;

                    if (this.sourcesSuperContract_ == null ||
                        !this.sourcesSuperContract_.IsActive)
                    {
                        this.sourcesSuperContract_ =
                            IContractFactory.INSTANCE.NewSuperContract(contract);
                    }
                    else
                    {
                        this.sourcesSuperContract_.Add(contract);
                    }

                    contract.OnBreak += _ => this.RemoveSource(source);
                    return(true);
                }