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); }
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)); }
public static ObservableStateVariable CreateNew(IsDirtyChangedEventHandler onIsDirtyChanged = null) { return(CreateNew <ObservableStateVariable, StateVariable>(() => new ObservableStateVariable(new StateVariable()), onIsDirtyChanged)); }
public static ObservableStateVariable Create(StateVariable item, IsDirtyChangedEventHandler onIsDirtyChanged = null) { return(Create(item, item => new ObservableStateVariable(item), onIsDirtyChanged)); }
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); }
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); }