public RemoveBuildingBlockCommand(T buildingBlock)
 {
     ObjectType     = new ObjectTypeResolver().TypeFor <T>();
     CommandType    = AppConstants.Commands.DeleteCommand;
     Description    = AppConstants.Commands.RemoveFromProjectDescription(ObjectType, buildingBlock.Name);
     _buildingBlock = buildingBlock;
 }
Exemple #2
0
        private void setCommandConstants()
        {
            ObjectType  = new ObjectTypeResolver().TypeFor <TStartValue>();
            CommandType = AppConstants.Commands.EditCommand;
            var newStartValuePath = _newContainerPath.Clone <IObjectPath>().AndAdd(_originalStartValue.Name);

            Description = AppConstants.Commands.EditPath(ObjectType, _originalStartValue.Path, newStartValuePath);
        }
Exemple #3
0
 /// <summary>
 ///    Will create a command that will swap out the template building block <paramref name="templateBuildingBlock" /> with
 ///    the <paramref name="simulationBuildingBlockClone" />
 /// </summary>
 /// <param name="templateBuildingBlock">Template building block to remove</param>
 /// <param name="simulationBuildingBlockClone">Clone of simulation building block to use to replace the template</param>
 /// <param name="simulation">
 ///    Simulation containing the building block that was cloned and that will be replacing the
 ///    template building block
 /// </param>
 public UpdateTemplateBuildingBlockFromSimulationBuildingBlockCommand(T templateBuildingBlock, T simulationBuildingBlockClone, IMoBiSimulation simulation)
     : base(templateBuildingBlock, simulationBuildingBlockClone)
 {
     _simulation = simulation;
     CommandType = AppConstants.Commands.UpdateCommand;
     ObjectType  = new ObjectTypeResolver().TypeFor <T>();
     Description = AppConstants.Commands.UpdateTemplateBuildingCommandDescription(ObjectType, templateBuildingBlock.Name);
 }
Exemple #4
0
 protected AddItemCommand(TParent parent, TChild itemToAdd, TBuildingBlock buidingBlock) : base(buidingBlock)
 {
     CommandType = AppConstants.Commands.AddCommand;
     ObjectType  = new ObjectTypeResolver().TypeFor <TChild>();
     _parent     = parent;
     _parentId   = _parent.Id;
     _itemToAdd  = itemToAdd;
 }
        protected override void ExecuteWith(IMoBiContext context)
        {
            base.ExecuteWith(context);
            var parentType = new ObjectTypeResolver().TypeFor(_parent);

            Description = AppConstants.Commands.RemoveMoleculeFromListDescription(_itemToRemove, parentType, _parent.EntityPath(), _listType);
            RemoveMoleculeName(_parent, _itemToRemove);
        }
Exemple #6
0
        public RemoveStartValueFromBuildingBlockCommand(IStartValuesBuildingBlock <T> parent, IObjectPath path) : base(parent)
        {
            CommandType = AppConstants.Commands.DeleteCommand;

            ObjectType          = new ObjectTypeResolver().TypeFor <T>();
            _originalStartValue = _buildingBlock[path];
            Description         = AppConstants.Commands.RemoveStartValue(_originalStartValue, parent.Name);
        }
        public UpdateValueOriginInStartValueCommand(T startValue, ValueOrigin newValueOrigin, IStartValuesBuildingBlock <T> startValuesBuildingBlock) : base(startValuesBuildingBlock)
        {
            _startValue     = startValue;
            _newValueOrigin = newValueOrigin;

            ObjectType  = new ObjectTypeResolver().TypeFor(startValue);
            CommandType = AppConstants.Commands.EditCommand;
        }
 public SwapBuildingBlockCommand(T oldBuildingBlock, T newBuildingBlock)
 {
     _oldBuildingBlock = oldBuildingBlock;
     _newBuildingBlock = newBuildingBlock;
     CommandType       = AppConstants.Commands.UpdateCommand;
     ObjectType        = new ObjectTypeResolver().TypeFor <T>();
     Description       = AppConstants.Commands.SwapBuildingCommandDescription(ObjectType, _oldBuildingBlock.Name);
 }
Exemple #9
0
 protected EditQuantityInBuildingBlockCommand(TQuantity quantity, IBuildingBlock buildingBlock)
     : base(buildingBlock)
 {
     _quantity   = quantity;
     _quantityId = quantity.Id;
     CommandType = AppConstants.Commands.EditCommand;
     ObjectType  = new ObjectTypeResolver().TypeFor(quantity);
 }
 public SetForAllCommand(IMoleculeDependentBuilder moleculeDependentBuilder, bool forAll, IBuildingBlock buildingBlock) : base(buildingBlock)
 {
     _moleculeDependentBuilder = moleculeDependentBuilder;
     _forAll     = forAll;
     _objectId   = _moleculeDependentBuilder.Id;
     CommandType = AppConstants.Commands.EditCommand;
     ObjectType  = new ObjectTypeResolver().TypeFor(_moleculeDependentBuilder);
     Description = AppConstants.Commands.EditDescription(ObjectType, AppConstants.Captions.ForAll, (!_forAll).ToString(), forAll.ToString(), moleculeDependentBuilder.Name);
 }
Exemple #11
0
 protected SetQuantityPropertyInSimulationCommandBase(TQuantity quantity, IMoBiSimulation simulation)
     : base(quantity, simulation)
 {
     _quantity   = quantity;
     ObjectType  = new ObjectTypeResolver().TypeFor(quantity);
     _quantityId = _quantity.Id;
     _simulation = simulation;
     CommandType = AppConstants.Commands.EditCommand;
 }
 public AddBuildingBlockCommand(T buildingBlock)
 {
     ObjectType      = new ObjectTypeResolver().TypeFor <T>();
     CommandType     = AppConstants.Commands.AddCommand;
     _buildingBlock  = buildingBlock;
     BuildingBlockId = buildingBlock.Id;
     Description     = AppConstants.Commands.AddToProjectDescription(ObjectType, buildingBlock.Name);
     Silent          = false;
 }
 protected RemoveItemCommand(TParent parent, TChild itemToRemove, TBuildingBlock buildingBlock)
     : base(buildingBlock)
 {
     CommandType   = AppConstants.Commands.DeleteCommand;
     ObjectType    = new ObjectTypeResolver().TypeFor <TChild>();
     _parent       = parent;
     _parentId     = _parent.Id;
     _itemToRemove = itemToRemove;
 }
 public ResetQuantityValueInBuildingBlockCommand(IQuantity quantity, IBuildingBlock buildingBlock) :
     base(buildingBlock)
 {
     _quantity         = quantity;
     _quantityId       = _quantity.Id;
     _oldQuantityValue = quantity.Value;
     CommandType       = AppConstants.Commands.EditCommand;
     ObjectType        = new ObjectTypeResolver().TypeFor(quantity);
 }
 public AddStartValueToBuildingBlockCommand(IStartValuesBuildingBlock <T> startValuesBuildingBlock, T startValue)
     : base(startValuesBuildingBlock)
 {
     _startValue = startValue;
     CommandType = AppConstants.Commands.AddCommand;
     Description = AppConstants.Commands.AddedStartValue(startValue, startValuesBuildingBlock.Name);
     ObjectType  = new ObjectTypeResolver().TypeFor <T>();
     _objectPath = startValue.Path;
 }
Exemple #16
0
        public EditFormulaAliasCommand(IFormula formula, string newAlias, string oldAlias, IBuildingBlock buildingBlock) : base(buildingBlock)
        {
            _newAlias  = newAlias;
            _oldAlias  = oldAlias;
            _formulaId = formula.Id;

            ObjectType  = new ObjectTypeResolver().TypeFor(formula);
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.ChangeFormulaAlias(formula.Name, _oldAlias, _newAlias, buildingBlock.Name);
        }
 public SetMoleculeListsCommand(IMoleculeDependentBuilder targetBuilder, MoleculeList newMoleculeList, IBuildingBlock targetBuildingBlock)
     : base(targetBuildingBlock)
 {
     _targetBuilder   = targetBuilder;
     _targetBuilderId = _targetBuilder.Id;
     _newMoleculeList = newMoleculeList;
     CommandType      = AppConstants.Commands.EditCommand;
     ObjectType       = new ObjectTypeResolver().TypeFor(targetBuilder);
     Description      = AppConstants.Commands.EditDescriptionMoleculeList(ObjectType, newMoleculeList, _targetBuilder.Name);
 }
Exemple #18
0
        protected SetTableFormulaDisplayUnitCommand(Unit newDisplayUnit, Unit oldDisplayUnit, TableFormula tableFormula, IBuildingBlock buildingBlock)
            : base(buildingBlock)
        {
            _newDisplayUnit = newDisplayUnit;
            _oldDisplayUnit = oldDisplayUnit;
            _tableFormula   = tableFormula;
            _tableFormulaId = _tableFormula.Id;

            ObjectType  = new ObjectTypeResolver().TypeFor(tableFormula);
            CommandType = AppConstants.Commands.EditCommand;
        }
        public UpdateDimensionOfFormulaUsablePathCommand(IDimension newDimension, IFormula formula, string alias, IBuildingBlock buildingBlock) : base(buildingBlock)
        {
            _alias        = alias;
            _oldDimension = formula.FormulaUsablePathBy(_alias).Dimension.ToString();
            _newDimension = newDimension.ToString();
            _formulaId    = formula.Id;

            ObjectType  = new ObjectTypeResolver().TypeFor(formula);
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.ChangeFormulaPathDimension(formula.Name, _oldDimension, _newDimension, buildingBlock.Name, alias);
        }
Exemple #20
0
        public EditFormulaStringCommand(string newFormulaString, string oldFormulaString, ExplicitFormula formula, IBuildingBlock buildingBlock)
            : base(buildingBlock)
        {
            _formulaId        = formula.Id;
            _newFormulaString = newFormulaString;
            _oldFormulaString = oldFormulaString;

            ObjectType  = new ObjectTypeResolver().TypeFor(formula);
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.ChangeFormulaString(formula.Name, _newFormulaString, _oldFormulaString, buildingBlock.Name);
        }
 protected EditObjectPropertyInBuildingBlockCommand(string propertyName, object newValue,
                                                    object oldValue, object objectToUpdate, TBuildingBlock buildingBlock, string objectName)
     : base(buildingBlock)
 {
     _newValue       = newValue;
     _oldValue       = oldValue;
     _objectToUpdate = objectToUpdate;
     PropertyName    = propertyName;
     ObjectType      = new ObjectTypeResolver().TypeFor(_objectToUpdate);
     CommandType     = AppConstants.Commands.EditCommand;
     Description     = AppConstants.Commands.EditDescription(ObjectType, PropertyName.SplitToUpperCase(), _oldValue?.ToString() ?? string.Empty, _newValue?.ToString() ?? string.Empty, objectName);
 }
Exemple #22
0
 public Converter313To32(IDimensionConverter dimensionConverter, IMoBiDimensionFactory dimensionFactory,
                         IObjectBaseFactory objectBaseFactory, IFormulaMapper formulaMapper, IDimensionMapper dimensionMapper, IEventPublisher eventPublisher)
 {
     _dimensionConverter = dimensionConverter;
     _dimensionFactory   = dimensionFactory;
     _objectBaseFactory  = objectBaseFactory;
     _formulaMapper      = formulaMapper;
     _dimensionMapper    = dimensionMapper;
     _eventPublisher     = eventPublisher;
     _objectTypeResolver = new ObjectTypeResolver();
     _suspendWarning     = false;
 }
        public UpdateDimensionInStartValueCommand(T startValue, IDimension newDimension, Unit newDisplayUnit, IStartValuesBuildingBlock <T> startValuesBuildingBlock)
            : base(startValuesBuildingBlock)
        {
            _startValue     = startValue;
            _oldDimension   = startValue.Dimension;
            _oldDisplayUnit = startValue.DisplayUnit;
            _newDimension   = newDimension;
            _newDisplayUnit = newDisplayUnit;

            ObjectType  = new ObjectTypeResolver().TypeFor(startValue);
            CommandType = AppConstants.Commands.EditCommand;
            Description = AppConstants.Commands.UpdateDimensions(startValue.Path.PathAsString, ObjectType, _oldDimension, newDimension, startValuesBuildingBlock.Name);
        }
 /// <summary>
 /// Sets a constant value into a constant value formula
 /// </summary>
 /// <param name="constantFormula">The constant formula being edited</param>
 /// <param name="newValue">The new value being applied to the formula</param>
 /// <param name="displayUnit">The new value new display unit</param>
 /// <param name="oldUnit">The old value display unit</param>
 /// <param name="buildingBlock">The building block that this formula is a member of</param>
 /// <param name="formulaOwner">The entity that owns the formula</param>
 public SetConstantFormulaValueCommand(ConstantFormula constantFormula, double newValue, Unit displayUnit, Unit oldUnit, IBuildingBlock buildingBlock, IEntity formulaOwner) : base(buildingBlock)
 {
     _constantFormula = constantFormula;
     _newValue        = newValue;
     _oldValue        = _constantFormula.Value;
     FormulaId        = _constantFormula.Id;
     ObjectType       = new ObjectTypeResolver().TypeFor(formulaOwner);
     CommandType      = AppConstants.Commands.EditCommand;
     _ownerId         = formulaOwner.Id;
     _owner           = formulaOwner;
     _displayUnit     = displayUnit;
     _oldDisplayUnit  = oldUnit;
 }
        public ChangeStartValueFormulaCommand(IStartValuesBuildingBlock <T> buildingBlock, T startValue, IFormula newFormula, IFormula oldFormula) : base(buildingBlock)
        {
            _newFormula        = newFormula;
            _oldFormula        = oldFormula;
            _objectBaseId      = _buildingBlock.Id;
            _changedStartValue = startValue;
            ObjectType         = new ObjectTypeResolver().TypeFor(startValue);

            Description = AppConstants.Commands.EditDescription(ObjectType, AppConstants.Captions.FormulaName, _oldFormula?.ToString() ?? AppConstants.NullString, _newFormula?.ToString() ?? AppConstants.NullString, _changedStartValue.Path.PathAsString);

            CommandType = AppConstants.Commands.EditCommand;

            _oldFormulaId = GetFormulaId(_oldFormula);
            _newFormulaId = GetFormulaId(_newFormula);
        }
            protected override Type ResolveComponent()
            {
                Type result = null;

                if (ContextObject is TContext)
                {
                    result = ObjectTypeResolver.ResolveComponentTypeForObject <TContext, TModel>(ContextObject, Model ?? default, AssignableFrom);
                }
                if (result is null && TypeTypeResolver != ObjectTypeResolver)
                {
                    result = TypeTypeResolver.ResolveComponentTypeForContext <TContext, TModel>(Model ?? default, AssignableFrom);
                }
                if (result is null && TypeResolver != ObjectTypeResolver && TypeResolver != TypeTypeResolver)
                {
                    result = base.ResolveComponent(); //already uses the model if provided
                }
                return(result);
            }
        protected Type ResolveComponent()
        {
            Type result = null;

            //Don't try to resolve the template multiple times if the injected resolvers are the same object that just implements the different interfaces, like the DefaultComponentTypeResolver
            if (ContextObject is object)
            {
                result = ObjectTypeResolver.ResolveComponentTypeForObject(ContextObject, Model ?? default, AssignableFrom);
            }
            if (result is null && TypeTypeResolver != ObjectTypeResolver)
            {
                result = TypeTypeResolver.ResolveComponentTypeFor(Model ?? default);
            }
            if (result is null && TypeResolver != ObjectTypeResolver && TypeResolver != TypeTypeResolver)
            {
                result = TypeResolver.ResolveComponentTypeFor(Model ?? default);
            }
            return(result);
        }
Exemple #28
0
        public StartValueValueOrUnitChangedCommand(TStartValue startValue, double?newBaseValue, Unit newDisplayUnit, TStartValueBuildingBlock buildingBlock)
            : base(buildingBlock)
        {
            _startValue     = startValue;
            _newDisplayUnit = newDisplayUnit;
            _oldDisplayUnit = _startValue.DisplayUnit;

            _newBaseValue = newBaseValue;
            _oldBaseValue = startValue.StartValue;

            _startValuePath = _startValue.Path;
            CommandType     = AppConstants.Commands.EditCommand;
            ObjectType      = new ObjectTypeResolver().TypeFor(startValue);
            Description     = AppConstants.Commands.SetQuantityValueInBuildingBlock(
                ObjectType,
                startValue.Dimension.BaseUnitValueToUnitValue(_newDisplayUnit, newBaseValue.GetValueOrDefault(double.NaN)),
                _newDisplayUnit.Name,
                startValue.ConvertToDisplayUnit(_oldBaseValue.GetValueOrDefault(double.NaN)),
                _oldDisplayUnit.Name,
                startValue.Path.PathAsString, _buildingBlock.Name);
        }
Exemple #29
0
 protected override void Context()
 {
     sut = new ObjectTypeResolver();
 }
 protected void SetCommandParameters(string newValue, string oldValue)
 {
     CommandType = AppConstants.Commands.EditCommand;
     ObjectType  = new ObjectTypeResolver().TypeFor <TStartValue>();
     Description = AppConstants.Commands.SetDescription(ObjectType, AppConstants.Commands.Name, newValue, oldValue);
 }