protected static ObservableType CreateNew <ObservableType, InternalType>(Func <ObservableType> createNew, IsDirtyChangedEventHandler onIsDirtyChanged) where ObservableType : ObservableObject <InternalType>, IComparable <ObservableObject <InternalType> >, IEquatable <ObservableObject <InternalType> > where InternalType : IComparable <InternalType>, IEquatable <InternalType>, ICloneable <InternalType>
        {
            if (null == createNew)
            {
                throw new ArgumentNullException(nameof(createNew));
            }

            var observableItem = createNew();

            if (null != onIsDirtyChanged)
            {
                observableItem.IsDirtyChanged += onIsDirtyChanged;
            }

            return(observableItem);
        }
예제 #2
0
        public static ObservableCollection <ObservableStateVariable> MakeObservableCollection(ObservableGraph graph, bool clone, IsDirtyChangedEventHandler onIsDirtyChanged = null)
        {
            if (graph is null)
            {
                throw new ArgumentNullException(nameof(graph));
            }

            return(MakeObservableCollection(graph.InternalObject.StateVariables, item => new ObservableStateVariable(item), clone, onIsDirtyChanged));
        }
예제 #3
0
 public static ObservableStateVariable CreateNew(IsDirtyChangedEventHandler onIsDirtyChanged = null)
 {
     return(CreateNew <ObservableStateVariable, StateVariable>(() => new ObservableStateVariable(new StateVariable()), onIsDirtyChanged));
 }
예제 #4
0
 public static ObservableStateVariable Create(StateVariable item, IsDirtyChangedEventHandler onIsDirtyChanged = null)
 {
     return(Create(item, item => new ObservableStateVariable(item), onIsDirtyChanged));
 }
예제 #5
0
        protected static ObservableCollection <ObservableType> MakeObservableCollection <ObservableType, InternalType>(ICollection <InternalType> source, Func <InternalType, ObservableType> create, bool clone, IsDirtyChangedEventHandler onIsDirtyChanged) where ObservableType : ObservableObject <T>, IComparable <ObservableType>, IEquatable <ObservableType> where InternalType : IComparable <InternalType>, IEquatable <InternalType>, ICloneable <InternalType>
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (create is null)
            {
                throw new ArgumentNullException(nameof(create));
            }

            var target = new ObservableCollection <ObservableType>();

            foreach (var item in source)
            {
                var observableItem = create(clone ? item.Clone() : item);
                target.SortedInsert(observableItem);

                if (onIsDirtyChanged is not null)
                {
                    observableItem.IsDirtyChanged += onIsDirtyChanged;
                }
            }

            return(target);
        }
예제 #6
0
        protected static ObservableType Create <ObservableType, InternalType>(InternalType item, Func <InternalType, ObservableType> create, IsDirtyChangedEventHandler onIsDirtyChanged) where ObservableType : ObservableObject <InternalType>, IComparable <ObservableObject <InternalType> >, IEquatable <ObservableObject <InternalType> > where InternalType : IComparable <InternalType>, IEquatable <InternalType>, ICloneable <InternalType>
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (create is null)
            {
                throw new ArgumentNullException(nameof(create));
            }

            var observableItem = create(item);

            if (onIsDirtyChanged is not null)
            {
                observableItem.IsDirtyChanged += onIsDirtyChanged;
            }

            return(observableItem);
        }