/// <summary> /// Initializes a new instance of the <see cref="FileDialogViewModel"/> class. /// </summary> /// <param name="file"> /// The <see cref="File"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name=""></param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="FileDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="FileDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> /// </param> /// <param name="container"> /// The Container <see cref="Thing"/> of the created <see cref="Thing"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public FileDialogViewModel(File file, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(file, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.PopulatePossibleCategories(); this.WhenAnyValue( vm => vm.IsLocked).Subscribe( x => { this.SelectedLockedBy = x ? this.currentPerson : null; }); this.WhenAnyValue( vm => vm.SelectedLockedBy).Subscribe( x => { this.LockedBy = x?.Name; this.AllowEdit = !this.IsLockedByAnotherPerson(); }); this.WhenAnyValue( vm => vm.SelectedOwner, vm => vm.SelectedLockedBy, vm => vm.FileRevision) .Subscribe(_ => this.UpdateOkCanExecute()); this.Disposables.Add(this.FileRevision.Changed.Subscribe(_ => this.UpdateOkCanExecute())); }
/// <summary> /// Initializes a new instance of the <see cref="ElementUsageDialogViewModel"/> class /// </summary> /// <param name="elementUsage"> /// The <see cref="ElementUsage"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="permissionService"> /// The <see cref="IPermissionService"/> that is used to compute whether the current <see cref="ISession"/> can execute CRUD. /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="isNewContainer"> /// Value indicating whether the container of the <see cref="Thing"/> that is being created is new /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ElementUsageDialogViewModel(ElementUsage elementUsage, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers = null) : base(elementUsage, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.IncludeOption) .Subscribe( _ => this.ExcludeOption = new ReactiveList <Option>(this.PossibleExcludeOption.Except(this.IncludeOption))); }
/// <summary> /// Initializes a new instance of the <see cref="ParticipantDialogViewModel"/> class /// </summary> /// <param name="participant"> /// The <see cref="Participant"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ParticipantDialogViewModel(Participant participant, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(participant, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedPerson).Where(x => x != null).Subscribe(_ => { if (this.dialogKind == ThingDialogKind.Create) { if (this.SelectedPerson.DefaultDomain != null && this.PossibleDomain.Contains(this.SelectedPerson.DefaultDomain)) { this.Domain = new ReactiveList <DomainOfExpertise> { this.PossibleDomain.Single(x => x == this.SelectedPerson.DefaultDomain) }; } else { this.Domain = new ReactiveList <DomainOfExpertise>(); } } this.UpdateOkCanExecute(); }); this.WhenAnyValue(vm => vm.SelectedRole).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.SelectedSelectedDomain).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.Domain).Subscribe(_ => { this.domainSubScription?.Dispose(); this.domainSubScription = this.Domain?.Changed.Subscribe(x => this.SetSelectedDomain()); this.SetSelectedDomain(); }); }
/// <summary> /// Initializes a new instance of the <see cref="FileRevisionDialogViewModel"/> class. /// </summary> /// <param name="fileRevision"> /// The <see cref="FileRevision"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name=""></param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="FileRevisionDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="FileRevisionDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> /// </param> /// <param name="container"> /// The Container <see cref="Thing"/> of the created <see cref="Thing"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public FileRevisionDialogViewModel(FileRevision fileRevision, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(fileRevision, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (dialogKind == ThingDialogKind.Update) { throw new InvalidOperationException($"{nameof(ThingDialogKind.Update)} on a {nameof(FileRevision)} is not allowed."); } this.Disposables.Add( this.WhenAnyValue(x => x.Name, x => x.ContentHash) .Subscribe(_ => { this.UpdateOkCanExecute(); this.UpdatePath(); })); this.Disposables.Add( this.WhenAnyValue(x => x.SelectedFileType, x => x.FileType) .Subscribe(_ => { this.CanDeleteFileType = !this.IsReadOnly && (this.SelectedFileType != null); this.AfterUpdateFileType(); })); this.Disposables.Add(this.FileType.Changed.Subscribe(_ => this.AfterUpdateFileType())); this.Disposables.Add(this.WhenAnyValue(x => x.SelectedContainingFolder).Subscribe(_ => this.UpdatePath())); this.Disposables.Add(this.WhenAnyValue(x => x.LocalPath).Subscribe(async _ => { this.UpdateOkCanExecute(); this.SetContentHash(); })); }
/// <summary> /// Initializes a new instance of the <see cref="RequirementDialogViewModel"/> class. /// </summary> /// <param name="requirement"> /// The <see cref="Requirement"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param> /// <param name="container">The <see cref="RequirementsSpecificationDialogViewModel.container"/> for this <see cref="RequirementsSpecificationDialogViewModel.Thing"/></param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public RequirementDialogViewModel(Requirement requirement, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(requirement, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.SelectedOwner = this.Session.ActivePerson.DefaultDomain ?? this.PossibleOwner.First(); this.WhenAnyValue(vm => vm.RequirementText).Subscribe(_ => this.UpdateOkCanExecute()); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterOverrideDialogViewModel"/> class /// </summary> /// <param name="parameterOverride"> /// The parameterOverride. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The Container <see cref="Thing"/> of the created <see cref="MultiRelationshipRule"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ParameterOverrideDialogViewModel(ParameterOverride parameterOverride, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(parameterOverride, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedOwner).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.ValueSet).Subscribe(_ => this.PopulateValueSet()); this.IsNameVisible = this.Thing.ParameterType is CompoundParameterType || this.Thing.IsOptionDependent || this.Thing.StateDependence != null; this.CheckValueValidation(); }
/// <summary> /// Initializes a new instance of the <see cref="DerivedUnitDialogViewModel"/> class. /// </summary> /// <param name="derivedUnit"> /// The <see cref="DerivedUnit"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DerivedUnitDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DerivedUnitDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public DerivedUnitDialogViewModel(DerivedUnit derivedUnit, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(derivedUnit, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { var canCreateCondition = this.WhenAnyValue(vm => vm.Container).Select(x => x != null); this.CreateUnitFactorCommand = ReactiveCommand.Create(canCreateCondition); this.CreateUnitFactorCommand.Subscribe(_ => this.ExecuteCreateCommand <UnitFactor>(this.PopulateUnitFactor)); this.WhenAnyValue(vm => vm.Container).Subscribe(_ => this.UpdateOkCanExecute()); }
/// <summary> /// Initializes a new instance of the <see cref="IterationSetupDialogViewModel"/> class /// </summary> /// <param name="iterationSetup"> /// The <see cref="IterationSetup"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="thingTransaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public IterationSetupDialogViewModel(IterationSetup iterationSetup, IThingTransaction thingTransaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers = null) : base(iterationSetup, thingTransaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(x => x.SelectedSourceIterationSetupRow) .Subscribe(x => { this.SelectedSourceIterationSetup = (x == null) ? null : x.IterationSetup; this.UpdateOkCanExecute(); }); }
/// <summary> /// Update the <see cref="ThingTransaction"/> with new <see cref="ParameterSubscription"/>s /// </summary> /// <param name="transaction"> /// The subject <see cref="IThingTransaction"/> that is to be updated /// </param> /// <param name="owner"> /// The <see cref="DomainOfExpertise"/> that is be the owner of the created <see cref="ParameterSubscription"/>s and should therefore /// not be the owner of the <see cref="Parameter"/>s or <see cref="ParameterOverride"/>s that are subscribed to /// </param> /// <param name="parameterOrOverrides"> /// An <see cref="IEnumerable{ParameterOrOverrideBase}"/> for which new <see cref="ParameterSubscription"/>s will be created. /// </param> private void UpdateTransactionWithUpdatedParameters(IThingTransaction transaction, ActualFiniteStateList actualFiniteStateList, IEnumerable <Parameter> parameters) { foreach (var parameter in parameters) { var clone = parameter.Clone(false); clone.StateDependence = actualFiniteStateList; transaction.CreateOrUpdate(clone); } }
/// <summary> /// Update the <see cref="ThingTransaction"/> with updated <see cref="IOwnedThing"/>s /// </summary> /// <param name="transaction"> /// The subject <see cref="IThingTransaction"/> that is to be updated /// </param> /// <param name="ownedThings"> /// The <see cref="IEnumerable{IOwnedThing}"/> whose ownership needs to be updated /// </param> /// <param name="owner"> /// The <see cref="DomainOfExpertise"/> that is be the owner of the updated <see cref="IOwnedThing"/>s /// </param> private void UpdateTransactionWithUpdatedOwners(IThingTransaction transaction, IEnumerable <IOwnedThing> ownedThings, DomainOfExpertise owner) { foreach (var ownedThing in ownedThings) { var clone = ((Thing)ownedThing).Clone(false); var clonedOwnedThing = (IOwnedThing)clone; clonedOwnedThing.Owner = owner; transaction.CreateOrUpdate(clone); } }
public TestDialogViewModel(Person person, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNav, Thing container) : base(person, transaction, session, isRoot, dialogKind, thingDialogNav, container, null) { this.UpdateTransactionCalled = false; this.PopulateCalled = false; this.CreateCommand = ReactiveCommand.Create(); this.CreateCommand.Subscribe(_ => this.ExecuteCreateCommand <TelephoneNumber>(this.Populate)); this.Phone = new ContainerList <TelephoneNumber>(this.Thing); this.OrderedRows = new ReactiveList <OrderedRow>(); }
/// <summary> /// Initializes a new instance of the <see cref="LogarithmicScaleDialogViewModel"/> class. /// </summary> /// <param name="logarithmicScale"> /// The Simple quantity Kind. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="LogarithmicScaleDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="LogarithmicScaleDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> /// <exception cref="ArgumentException"> /// The container must be of type <see cref="ReferenceDataLibrary"/>. /// </exception> public LogarithmicScaleDialogViewModel(LogarithmicScale logarithmicScale, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(logarithmicScale, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.Container).Subscribe(_ => { this.PopulatePossibleUnit(); this.PopulatePossibleReferenceQuantityKind(); }); this.WhenAnyValue(vm => vm.SelectedUnit).Subscribe(_ => this.UpdateOkCanExecute()); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterDialogViewModel"/> class /// </summary> /// <param name="parameter"> /// The parameter. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The Container <see cref="Thing"/> of the created <see cref="MultiRelationshipRule"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ParameterDialogViewModel(Parameter parameter, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(parameter, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedOwner).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.SelectedScale).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.IsOptionDependent).Subscribe(_ => this.IsValueSetEditable = this.IsOptionDependent == this.Thing.IsOptionDependent && this.SelectedStateDependence == this.Thing.StateDependence); this.WhenAnyValue(vm => vm.SelectedStateDependence).Subscribe(_ => this.IsValueSetEditable = this.IsOptionDependent == this.Thing.IsOptionDependent && this.SelectedStateDependence == this.Thing.StateDependence); this.WhenAnyValue(vm => vm.SelectedScale).Where(x => x != null).Subscribe(_ => this.CheckValueValidation()); this.WhenAnyValue(vm => vm.SelectedGroupSelection).Subscribe(x => this.SelectedGroup = x != null ? x.Thing : null); this.IsNameVisible = this.Thing.ParameterType is CompoundParameterType || this.Thing.IsOptionDependent || this.Thing.StateDependence != null; }
/// <summary> /// Update the <see cref="ThingTransaction"/> with new <see cref="ParameterSubscription"/>s /// </summary> /// <param name="transaction"> /// The subject <see cref="IThingTransaction"/> that is to be updated /// </param> /// <param name="owner"> /// The <see cref="DomainOfExpertise"/> that is be the owner of the created <see cref="ParameterSubscription"/>s and should therefore /// not be the owner of the <see cref="Parameter"/>s or <see cref="ParameterOverride"/>s that are subscribed to /// </param> /// <param name="parameterOrOverrides"> /// An <see cref="Action{IThingTransaction, ParameterOrOverrideBase, ParameterSubscription}"/> for which new <see cref="ParameterSubscription"/>s will be created. /// </param> private void UpdateTransactionWithParameterSubscriptions(IThingTransaction transaction, DomainOfExpertise owner, IEnumerable <ParameterOrOverrideBase> parameterOrOverrides, Action <IThingTransaction, ParameterOrOverrideBase, ParameterSubscription> updateAction) { foreach (var parameterOrOverride in parameterOrOverrides) { var subscription = new ParameterSubscription { Owner = owner }; var clone = parameterOrOverride.Clone(false); updateAction(transaction, clone, subscription); } }
/// <summary> /// Initializes a new instance of the <see cref="PrefixedUnitDialogViewModel"/> class. /// </summary> /// <param name="prefixedUnit"> /// The <see cref="PrefixedUnit"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="PrefixedUnitDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="PrefixedUnitDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public PrefixedUnitDialogViewModel(PrefixedUnit prefixedUnit, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(prefixedUnit, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.Container).Subscribe(_ => this.PopulatePossiblePrefix()); this.WhenAnyValue(vm => vm.Container).Subscribe(_ => this.PopulatePossibleReferenceUnit()); this.WhenAnyValue(vm => vm.Container).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.SelectedPrefix).Subscribe(_ => this.SetShortNameAndName()); this.WhenAnyValue(vm => vm.SelectedPrefix).Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.SelectedReferenceUnit).Subscribe(_ => this.SetShortNameAndName()); this.WhenAnyValue(vm => vm.SelectedReferenceUnit).Subscribe(_ => this.UpdateOkCanExecute()); }
/// <summary> /// Initializes a new instance of the <see cref="DiagramShapeDialogViewModel{T}"/> class /// </summary> /// <param name="diagramShape"> /// The <see cref="DiagramShape"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> protected DiagramShapeDialogViewModel(T diagramShape, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(diagramShape, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as DiagramElementContainer; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type DiagramElementContainer", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="AndExpressionDialogViewModel"/> class /// </summary> /// <param name="andExpression"> /// The <see cref="AndExpression"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public AndExpressionDialogViewModel(AndExpression andExpression, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(andExpression, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as ParametricConstraint; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type ParametricConstraint", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="RequirementDialogViewModel"/> class /// </summary> /// <param name="requirement"> /// The <see cref="Requirement"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public RequirementDialogViewModel(Requirement requirement, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(requirement, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as RequirementsSpecification; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type RequirementsSpecification", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="DomainOfExpertiseDialogViewModel"/> class /// </summary> /// <param name="domainOfExpertise"> /// The <see cref="DomainOfExpertise"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public DomainOfExpertiseDialogViewModel(DomainOfExpertise domainOfExpertise, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(domainOfExpertise, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as SiteDirectory; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type SiteDirectory", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="ConstantDialogViewModel"/> class. /// </summary> /// <param name="constant"> /// The <see cref="Constant"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="CategoryDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="CategoryDialogViewModel"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> /// </param> /// <param name="container"> /// The Container <see cref="Thing"/> of the created <see cref="Thing"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ConstantDialogViewModel(Constant constant, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(constant, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.SelectedScale).Subscribe(_ => this.UpdateOkCanExecute()); this.Value.ChangeTrackingEnabled = true; this.Value.ItemChanged.Subscribe(_ => this.UpdateOkCanExecute()); this.WhenAnyValue(vm => vm.Container).Skip(1).Subscribe(_ => this.PopulatePossibleParameterType()); this.WhenAnyValue(vm => vm.SelectedParameterType).Subscribe(_ => { this.PopulatePossibleScale(); this.PopulateValue(); this.UpdateOkCanExecute(); }); }
/// <summary> /// Initializes a new instance of the <see cref="ApprovalDialogViewModel"/> class /// </summary> /// <param name="approval"> /// The <see cref="Approval"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ApprovalDialogViewModel(Approval approval, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(approval, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as ModellingAnnotationItem; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type ModellingAnnotationItem", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="CategoryDialogViewModel"/> class /// </summary> /// <param name="category"> /// The <see cref="Category"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public CategoryDialogViewModel(Category category, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(category, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as ReferenceDataLibrary; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type ReferenceDataLibrary", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="RequirementDialogViewModel"/> class. /// </summary> /// <param name="requirement"> /// The <see cref="Requirement"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param> /// <param name="container">The <see cref="RequirementsSpecificationDialogViewModel.container"/> for this <see cref="RequirementsSpecificationDialogViewModel.Thing"/></param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public RequirementDialogViewModel(Requirement requirement, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(requirement, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (dialogKind == ThingDialogKind.Create) { var iteration = (Iteration)container.Container; if (this.Session.OpenIterations.TryGetValue(iteration, out var domainOfExpertiseParticipantTuple)) { this.SelectedOwner = domainOfExpertiseParticipantTuple.Item1 ?? this.PossibleOwner.First(); } } this.WhenAnyValue(vm => vm.RequirementText).Subscribe(_ => this.UpdateOkCanExecute()); }
/// <summary> /// Initializes a new instance of the <see cref="IdCorrespondenceDialogViewModel"/> class /// </summary> /// <param name="idCorrespondence"> /// The <see cref="IdCorrespondence"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public IdCorrespondenceDialogViewModel(IdCorrespondence idCorrespondence, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(idCorrespondence, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as ExternalIdentifierMap; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type ExternalIdentifierMap", container.GetType()); throw new ArgumentException(errorMessage); } } }
/// <summary> /// Initializes a new instance of the <see cref="IterationSetupDialogViewModel"/> class /// </summary> /// <param name="iterationSetup"> /// The <see cref="IterationSetup"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public IterationSetupDialogViewModel(IterationSetup iterationSetup, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(iterationSetup, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as EngineeringModelSetup; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type EngineeringModelSetup", container.GetType()); throw new ArgumentException(errorMessage); } } }
public void SetUp() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.assembler = new Assembler(this.uri); this.cache = this.assembler.Cache; this.serviceLocator = new Mock <IServiceLocator>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.SetupIRuleVerificationService(); this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.systemDomainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "System", ShortName = "SYS" }; this.siteDirectory.Domain.Add(this.systemDomainOfExpertise); var engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.engineeringModel = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.engineeringModel.EngineeringModelSetup = engineeringModelSetup; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.engineeringModel.Iteration.Add(this.iteration); this.ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri) { Owner = this.systemDomainOfExpertise }; this.builtInRuleVerification = new BuiltInRuleVerification(Guid.NewGuid(), this.cache, this.uri); this.ruleVerificationList.RuleVerification.Add(this.builtInRuleVerification); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, null); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); }
/// <summary> /// Initializes a new instance of the <see cref="DialogViewModelBase{T}"/> class /// </summary> /// <param name="thingClone">The clone of the <see cref="Thing"/> that this dialog belongs to.</param> /// <param name="parentTransaction"> /// The parent <see cref="ThingTransaction"/> that contains the log of recorded changes at the previous level. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param> /// <param name="container">The <see cref="Thing"/> that contains the created one in this <see cref="DialogViewModelBase{T}"/></param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> /// <remarks> /// <paramref name="thingClone"/> shall always be a clone when opening a dialog to create or edit a thing. /// </remarks> protected DialogViewModelBase(T thingClone, IThingTransaction parentTransaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(thingClone, session) { // add the animation uri path this.AnimationUri = $"{Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)}{CdpLogoAnimationPath}"; this.LoadingMessage = "Processing..."; this.InitializeSpellingChecker(); this.thingDialogNavigationService = thingDialogNavigationService; this.PossibleContainer = new ReactiveList <Thing>(); this.Container = container; this.parentTransaction = parentTransaction; this.isRoot = isRoot; this.dialogKind = dialogKind; this.serializer = new Cdp4JsonSerializer(this.Session.Dal.MetaDataProvider, this.Session.DalVersion); this.ChainOfContainer = (chainOfContainers != null) ? chainOfContainers.ToList() : new List <Thing>(); this.ChainOfContainer.Add(this.Container); this.WhenAnyValue(vm => vm.Container) .Where(x => x != null) .Subscribe(_ => this.UpdateChainOfContainer()); this.Initialize(); this.InitializeCommands(); this.UpdateProperties(); this.WhenAnyValue(x => x.WriteException).Select(x => x != null).ToProperty(this, x => x.HasException, out this.hasException); switch (this.dialogKind) { case ThingDialogKind.Create: this.transaction = new ThingTransaction(this.Thing, parentTransaction, container); break; case ThingDialogKind.Update: this.transaction = new ThingTransaction(this.Thing, parentTransaction, container); break; case ThingDialogKind.Inspect: break; default: throw new InvalidEnumArgumentException("The provided dialogKind is Invalid"); } }
/// <summary> /// Add the contained <see cref="Thing"/> in a <see cref="IThingTransaction"/> object /// </summary> /// <param name="transaction">The <see cref="IThingTransaction"/></param> /// <param name="thing">The <see cref="Thing"/></param> protected void AddContainedThingToTransaction(IThingTransaction transaction, Thing thing) { var cloneType = thing.GetType(); var containersInfo = cloneType.GetProperties().Where(x => x.PropertyType.IsGenericType && (x.PropertyType.GetGenericTypeDefinition() == typeof(ContainerList <>) || x.PropertyType.GetGenericTypeDefinition() == typeof(OrderedItemList <>)) && typeof(Thing).IsAssignableFrom(x.PropertyType.GetGenericArguments().Single())).ToList(); foreach (var containerInfo in containersInfo) { var container = (IEnumerable)containerInfo.GetValue(thing); foreach (Thing containedThing in container) { transaction.Create(containedThing); this.AddContainedThingToTransaction(transaction, containedThing); } } }
public void VerifyThatPropertiesAreSet() { var clone = this.ruleVerificationList; var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, clone); var viewModel = new BuiltInRuleVerificationDialogViewModel(this.builtInRuleVerification, this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.ruleVerificationList, null); Assert.AreEqual("System [SYS]", viewModel.Owner); Assert.IsFalse(viewModel.IsActive); Assert.AreEqual(this.builtInRuleVerification.Status, viewModel.Status); Assert.AreEqual(2, viewModel.AvailableBuiltInRules.Count()); Assert.AreEqual("-", viewModel.SelectedBuiltInRuleMetaData.Name); Assert.IsFalse(viewModel.IsNameReadOnly); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterTypeDialogViewModel{T}"/> class /// </summary> /// <param name="parameterType"> /// The <see cref="ParameterType"/> that is the subject of the current view-model. This is the object /// that will be either created, or edited. /// </param> /// <param name="transaction"> /// The <see cref="ThingTransaction"/> that contains the log of recorded changes. /// </param> /// <param name="session"> /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="DialogViewModelBase{T}"/> is the root of all <see cref="DialogViewModelBase{T}"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="DialogViewModelBase{T}"/> performs /// </param> /// <param name="thingDialogNavigationService"> /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>. /// </param> /// <param name="container"> /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> protected ParameterTypeDialogViewModel(T parameterType, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container, IEnumerable <Thing> chainOfContainers) : base(parameterType, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { if (container != null) { var containerThing = container as ReferenceDataLibrary; if (containerThing == null) { var errorMessage = string.Format( "The container parameter is of type {0}, it shall be of type ReferenceDataLibrary", container.GetType()); throw new ArgumentException(errorMessage); } } this.WhenAnyValue(vm => vm.Container).Subscribe(_ => { this.UpdateOkCanExecute(); this.PopulatePossibleCategories(); }); }