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);
            }
Esempio n. 2
0
            public override void OnNext(TSource value)
            {
                TKey val = default(TKey);

                try
                {
                    val = parent.keySelector(value);
                }
                catch (Exception exception)
                {
                    Error(exception);
                    return;
                }
                bool flag = false;
                ISubject <TElement> value2 = null;

                try
                {
                    if (val == null)
                    {
                        if (nullKeySubject == null)
                        {
                            nullKeySubject = new Subject <TElement>();
                            flag           = true;
                        }
                        value2 = nullKeySubject;
                    }
                    else if (!map.TryGetValue(val, out value2))
                    {
                        value2 = new Subject <TElement>();
                        map.Add(val, value2);
                        flag = true;
                    }
                }
                catch (Exception exception2)
                {
                    Error(exception2);
                    return;
                }
                if (flag)
                {
                    GroupedObservable <TKey, TElement> value3 = new GroupedObservable <TKey, TElement>(val, value2, refCountDisposable);
                    observer.OnNext(value3);
                }
                TElement val2 = default(TElement);

                try
                {
                    val2 = parent.elementSelector(value);
                }
                catch (Exception exception3)
                {
                    Error(exception3);
                    return;
                }
                value2.OnNext(val2);
            }
Esempio n. 3
0
            public override void OnNext(TSource value)
            {
                TKey tkey = default(TKey);

                try
                {
                    tkey = this.parent.keySelector(value);
                }
                catch (Exception exception)
                {
                    this.Error(exception);
                    return;
                }
                bool flag = false;
                ISubject <TElement> subject = null;

                try
                {
                    if (tkey == null)
                    {
                        if (this.nullKeySubject == null)
                        {
                            this.nullKeySubject = new Subject <TElement>();
                            flag = true;
                        }
                        subject = this.nullKeySubject;
                    }
                    else if (!this.map.TryGetValue(tkey, out subject))
                    {
                        subject = new Subject <TElement>();
                        this.map.Add(tkey, subject);
                        flag = true;
                    }
                }
                catch (Exception exception2)
                {
                    this.Error(exception2);
                    return;
                }
                if (flag)
                {
                    GroupedObservable <TKey, TElement> value2 = new GroupedObservable <TKey, TElement>(tkey, subject, this.refCountDisposable);
                    this.observer.OnNext(value2);
                }
                TElement value3 = default(TElement);

                try
                {
                    value3 = this.parent.elementSelector(value);
                }
                catch (Exception exception3)
                {
                    this.Error(exception3);
                    return;
                }
                subject.OnNext(value3);
            }