public static void ReactToChanges <T>(this InteractiveCollectionBase <T> col, SHDObject <T> so)
        {
            //so.IsSelected
            //      .Throttle(TimeSpan.FromMilliseconds(250))
            //         .Subscribe(b =>
            //         {
            //             if (col.Items?.FirstOrDefault(sof =>((SHDObject<T>) sof).IsSelected.Value == true) != (null))
            //                 ((System.Reactive.Subjects.ISubject<T>)col.Selected).OnNext(col.Items.FirstOrDefault(sof => ((SHDObject<T>)sof).IsSelected.Value == true).Object);
            //         });

            so.WhenPropertyChanged(_ => _.IsSelected).Select(_ => _.Value).Buffer(TimeSpan.FromMilliseconds(250)).Where(_ => _.Count > 0).Where(_ => _.All(a => a == true))
            //.Throttle(TimeSpan.FromMilliseconds(250))
            .Subscribe(b =>
            {
                //if (col.Items?.FirstOrDefault(sof => ((SHDObject<T>)sof).IsSelected.Value == true) != (null))
                //{
                //    ((System.Reactive.Subjects.ISubject<T>)col.Selected).OnNext(col.Items.FirstOrDefault(sof => ((SHDObject<T>)sof).IsSelected.Value == true).Object);
                ((System.Reactive.Subjects.ISubject <KeyValuePair <T, InteractionArgs> >)col.Interactions).OnNext(new KeyValuePair <T, InteractionArgs>(so.Object, new InteractionArgs {
                    Interaction = Interaction.Select, Value = b.Count
                }));
            });

            so.WhenPropertyChanged(_ => _.IsExpanded).Select(_ => _.Value).Subscribe(_ =>
            {
                if (_ != null)
                {
                    //((System.Reactive.Subjects.ISubject<T>)col.IsExpanded).OnNext(so == default(SHDObject<T>) ? default(T) : so.Object);
                    ((System.Reactive.Subjects.ISubject <KeyValuePair <T, InteractionArgs> >)col.Interactions).OnNext(new KeyValuePair <T, InteractionArgs>(so.Object, new InteractionArgs {
                        Interaction = Interaction.Expand, Value = _
                    }));
                    ((ISubject <KeyValuePair <IContain <T>, ChangeReason> >)col.Changes).OnNext(new KeyValuePair <IContain <T>, ChangeReason>(so, ChangeReason.Update));
                }
            });

            //so.DoubleClickCommand.Subscribe(_ =>
            //{
            //    ((System.Reactive.Subjects.ISubject<KeyValuePair<T, InteractionArgs>>)col.Interactions).OnNext(new KeyValuePair<T, InteractionArgs>(_, new InteractionArgs { Interaction = Interaction.Click, Value = 2 }));
            //    //((System.Reactive.Subjects.ISubject<T>)col.DoubleClicked).OnNext(so == default(SHDObject<T>) ? default(T) : so.Object);
            //});

            so.Deletions.Subscribe(_ =>
            {
                ((System.Reactive.Subjects.ISubject <UserCommandArgs>)col.UserCommands).OnNext(new UserCommandArgs {
                    UserCommand = UserCommand.Delete, Parameter = so.Object
                });
                //((System.Reactive.Subjects.ISubject<T>)col.Deleted).OnNext(so == default(SHDObject<T>) ? default(T) : so.Object);
            });

            so.WhenPropertyChanged(_ => _.IsChecked).StartWith(new PropertyValue <SHDObject <T>, bool?>(so, so.IsChecked)).Subscribe(_ =>
            {
                if (_.Value != null)
                {
                    ((System.Reactive.Subjects.ISubject <KeyValuePair <T, InteractionArgs> >)col.Interactions).OnNext(new KeyValuePair <T, InteractionArgs>(so.Object, new InteractionArgs {
                        Interaction = Interaction.Check, Value = _.Value
                    }));
                    ((ISubject <KeyValuePair <IContain <T>, ChangeReason> >)col.Changes).OnNext(new KeyValuePair <IContain <T>, ChangeReason>(so, ChangeReason.Update));
                }
            });
        }
 public static IObservable <T> GetAdded <T>(this InteractiveCollectionBase <T> bse)
 {
     return(bse.Interactions.Where(_ => _.Value.Interaction == Interaction.Include && _.Value.Value.Equals(true)).Select(_ => _.Key));
 }
 public static IObservable <T> GetRemoved <T>(this InteractiveCollectionBase <T> bse)
 {
     return(bse.UserCommands.Where(_ => _.UserCommand == UserCommand.Delete).Select(_ => (T)_.Parameter));
 }
        //public static IObservable<T> GetChecked<T>(this InteractiveCollectionBase<T> bse)
        //{
        //    return [email protected]().Select(_=>_.);
        //}

        public static IObservable <T> GetUnChecked <T>(this InteractiveCollectionBase <T> bse)
        {
            return(bse.Interactions.Where(_ => _.Value.Interaction == Interaction.Check && _.Value.Value.Equals(false)).Select(_ => _.Key));
        }