src/Misc/EFTools/EntityDesign/UI/ViewModels/MappingDetails/Function/MappingFunctionScalarProperty.cs
// <summary>
//     The mapping view model contains a MappingFunctionScalarProperty for every parameter in the function.  The user can clear out the
//     underlying scalar property, but that doesn't remove or add the MappingFunctionScalarProperty.  We need the placeholder
//     in the view model to show the nodes in the Trid even if there isn't a mapping.  Thus, we don't need to call
//     this.Parent.AddChild(this) since its already there.
// </summary>
The mapping view model contains a MappingFunctionScalarProperty for every parameter in the function.  The user can clear out the
underlying scalar property, but that doesn't remove or add the MappingFunctionScalarProperty.  We need the placeholder
in the view model to show the nodes in the Trid even if there isn't a mapping.  Thus, we don't need to call
this.Parent.AddChild(this) since its already there.
The mapping view model contains a MappingFunctionScalarProperty for every parameter in the function . The user can clear out the underlying scalar property but that doesn ' t remove or add the MappingFunctionScalarProperty . We need the placeholder in the view model to show the nodes in the Trid even if there isn ' t a mapping . Thus we don ' t need to call this . Parent . AddChild ( this ) since its already there .
internal void CreateModelItem(CommandProcessorContext cpc, EditingContext context, List<Property> propertiesChain)
        {
            Debug.Assert(propertiesChain != null, "The propertiesChain cannot be null");
            Debug.Assert(context != null, "The context argument cannot be null");
            Debug.Assert(ScalarProperty == null, "Don't call this method if we already have a ModelItem");
            Debug.Assert(MappingModificationFunctionMapping.Function != null, "The parent item isn't set up correctly");
            if (propertiesChain == null
                || context == null
                || ScalarProperty != null
                || MappingModificationFunctionMapping == null)
            {
                return;
            }
            Debug.Assert(propertiesChain.Count > 0, "propertiesChain cannot be empty");
            if (propertiesChain.Count <= 0)
            {
                return;
            }
            Context = context;
            var mf = MappingModificationFunctionMapping.ModificationFunction;
            if (null == mf)
            {
                Debug.Fail("this.MappingModificationFunctionMapping.ModificationFunction is null");
                return;
            }
            var parameter = StoreParameter;
            if (parameter == null)
            {
                return;
            }
            if (cpc == null)
            {
                cpc = new CommandProcessorContext(
                    Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_CreateScalarProperty);
            }
            var version = (MappingModificationFunctionMapping.ModificationFunctionType == ModificationFunctionType.Update
                               ? ModelConstants.FunctionScalarPropertyVersionCurrent
                               : null);
            var cmd =
                new CreateFunctionScalarPropertyTreeCommand(mf, propertiesChain, _pointingNavProperty, parameter, version);
            cmd.PostInvokeEvent += (o, eventsArgs) =>
                {
                    var fsp = cmd.FunctionScalarProperty;
                    Debug.Assert(fsp != null, "CreateFunctionScalarPropertyTreeCommand did not create a FunctionScalarProperty");
                    ModelItem = fsp;
                };
            try
            {
                var cp = new CommandProcessor(cpc, cmd);
                cp.Invoke();
            }
            catch
            {
                ModelItem = null;
                throw;
            }
        }
internal void CreateModelItem ( CommandProcessorContext cpc , EditingContext context , List < Property > propertiesChain ) { Debug . Assert ( propertiesChain != null , " " ) ; Debug . Assert ( context != null , " " ) ; Debug . Assert ( ScalarProperty == null , " " ) ; Debug . Assert ( MappingModificationFunctionMapping . Function != null , " " ) ; if ( propertiesChain == null || context == null || ScalarProperty != null || MappingModificationFunctionMapping == null ) { return ; } Debug . Assert ( propertiesChain . Count > 0 , " " ) ; if ( propertiesChain . Count <= 0 ) { return ; } Context = context ; var mf = MappingModificationFunctionMapping . ModificationFunction ; if ( null == mf ) { Debug . Fail ( " " ) ; return ; } var parameter = StoreParameter ; if ( parameter == null ) { return ; } if ( cpc == null ) { cpc = new CommandProcessorContext ( Context , EfiTransactionOriginator . MappingDetailsOriginatorId , Resources . Tx_CreateScalarProperty ) ; } var version = ( MappingModificationFunctionMapping . ModificationFunctionType == ModificationFunctionType . Update ? ModelConstants . FunctionScalarPropertyVersionCurrent : null ) ; var cmd = new CreateFunctionScalarPropertyTreeCommand ( mf , propertiesChain , _pointingNavProperty , parameter , version ) ; cmd . PostInvokeEvent += ( o , eventsArgs ) => { var fsp = cmd . FunctionScalarProperty ; Debug . Assert ( fsp != null , " " ) ; ModelItem = fsp ; } ; try { var cp = new CommandProcessor ( cpc , cmd ) ; cp . Invoke ( ) ; } catch { ModelItem = null ; throw ; } }
The mapping view model contains a MappingFunctionScalarProperty for every parameter in the function.
The mapping view model contains a MappingFunctionScalarProperty for every parameter in the function .
// use the stored Parameter // create a context if we weren't passed one // create the FunctionScalarProperty command (including any intermediate ComplexProperty's or AssociationEnd's) // set up our post event to fix up the view model // fix up our view model (we don't have to add this to the parent's children collection // because we created a placeholder row already for every parameter in the function) // now make the change
cpc
CommandProcessorContext
context
EditingContext
propertiesChain
List<Property>