Esempio n. 1
0
        /// <summary>
        ///     This method lets you change aspects of a ResultBinding.
        /// </summary>
        /// <param name="sp">Must point to a valid ResultBinding</param>
        /// <param name="entityProperty">Can be null</param>
        /// <param name="columnName">Can be null</param>
        internal ChangeResultBindingCommand(ResultBinding binding, Property entityProperty, string columnName)
        {
            Debug.Assert(!(entityProperty == null && columnName == null), "All optional arguments can't be null");
            CommandValidation.ValidateResultBinding(binding);
            if (entityProperty != null)
            {
                CommandValidation.ValidateConceptualEntityProperty(entityProperty);
            }

            _binding        = binding;
            _entityProperty = entityProperty;
            _columnName     = columnName;
        }
        /// <summary>
        ///     This method lets you change aspects of a ResultBinding.
        /// </summary>
        /// <param name="sp">Must point to a valid ResultBinding</param>
        /// <param name="entityProperty">Can be null</param>
        /// <param name="columnName">Can be null</param>
        internal ChangeResultBindingCommand(ResultBinding binding, Property entityProperty, string columnName)
        {
            Debug.Assert(!(entityProperty == null && columnName == null), "All optional arguments can't be null");
            CommandValidation.ValidateResultBinding(binding);
            if (entityProperty != null)
            {
                CommandValidation.ValidateConceptualEntityProperty(entityProperty);
            }

            _binding = binding;
            _entityProperty = entityProperty;
            _columnName = columnName;
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(
                _conceptualEntityType != null && _function != null,
                "InvokeInternal is called when _conceptualEntityType or _function is null.");
            if (_conceptualEntityType == null ||
                _function == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _conceptualEntityType or _function is null");
            }

            // find the parent item to put this in
            var mf = ModelHelper.FindModificationFunction(cpc, _conceptualEntityType, _function, _functionType);

            Debug.Assert(mf != null, "Couldn't find the ModificationFunction to house this ResultBinding");
            if (mf == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create it
            _binding = new ResultBinding(mf, null);
            if (_entityProperty != null)
            {
                _binding.Name.SetRefName(_entityProperty);
            }
            if (string.IsNullOrEmpty(_columnName) == false)
            {
                _binding.ColumnName.Value = _columnName;
            }
            mf.AddResultBinding(_binding);

            XmlModelHelper.NormalizeAndResolve(_binding);

            // if we passed in a property, validate that the binding worked
            if (_entityProperty != null)
            {
                Debug.Assert(
                    _binding.Name.Target != null && _binding.Name.Target.LocalName.Value == _binding.Name.RefName,
                    "Broken entity property resolution");
            }
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // safety check, this should never be hit
            Debug.Assert(
                _conceptualEntityType != null && _function != null,
                "InvokeInternal is called when _conceptualEntityType or _function is null.");
            if (_conceptualEntityType == null
                || _function == null)
            {
                throw new InvalidOperationException("InvokeInternal is called when _conceptualEntityType or _function is null");
            }

            // find the parent item to put this in
            var mf = ModelHelper.FindModificationFunction(cpc, _conceptualEntityType, _function, _functionType);
            Debug.Assert(mf != null, "Couldn't find the ModificationFunction to house this ResultBinding");
            if (mf == null)
            {
                throw new CannotLocateParentItemException();
            }

            // create it
            _binding = new ResultBinding(mf, null);
            if (_entityProperty != null)
            {
                _binding.Name.SetRefName(_entityProperty);
            }
            if (string.IsNullOrEmpty(_columnName) == false)
            {
                _binding.ColumnName.Value = _columnName;
            }
            mf.AddResultBinding(_binding);

            XmlModelHelper.NormalizeAndResolve(_binding);

            // if we passed in a property, validate that the binding worked
            if (_entityProperty != null)
            {
                Debug.Assert(
                    _binding.Name.Target != null && _binding.Name.Target.LocalName.Value == _binding.Name.RefName,
                    "Broken entity property resolution");
            }
        }
Esempio n. 5
0
        // <summary>
        //     NOTE: We don't call this.Parent.RemoveChild(this) here because this is always called from the MappingEFElement.Delete() method
        //     which will remove this item from the parent.
        // </summary>
        internal override void DeleteModelItem(CommandProcessorContext cpc)
        {
            Debug.Assert(ModelItem != null, "We are trying to delete a null ModelItem");
            if (IsModelItemDeleted() == false)
            {
                if (cpc == null)
                {
                    cpc = new CommandProcessorContext(
                        Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_DeleteResultBinding);
                }

                // use the item's delete command
                var deleteCommand = ResultBinding.GetDeleteCommand();
                deleteCommand.PostInvokeEvent += (o, eventsArgs) => { ModelItem = null; };

                DeleteEFElementCommand.DeleteInTransaction(cpc, deleteCommand);
            }

            // if IsModelItemDeleted == true, just make sure that it is null anyways
            ModelItem = null;
        }
Esempio n. 6
0
 public MappingResultBinding(EditingContext context, ResultBinding binding, MappingEFElement parent)
     : base(context, binding, parent)
 {
 }
Esempio n. 7
0
 internal static void ValidateResultBinding(ResultBinding binding)
 {
     ValidateEFElement(binding);
 }
 internal static void ValidateResultBinding(ResultBinding binding)
 {
     ValidateEFElement(binding);
 }
 public MappingResultBinding(EditingContext context, ResultBinding binding, MappingEFElement parent)
     : base(context, binding, parent)
 {
 }
        internal override bool ParseSingleElement(ICollection<XName> unprocessedElements, XElement elem)
        {
            if (elem.Name.LocalName == FunctionScalarProperty.ElementName)
            {
                var prop = new FunctionScalarProperty(this, elem);
                _scalarProperties.Add(prop);
                prop.Parse(unprocessedElements);
            }
            else if (elem.Name.LocalName == FunctionComplexProperty.ElementName)
            {
                var prop = new FunctionComplexProperty(this, elem);
                _complexProperties.Add(prop);
                prop.Parse(unprocessedElements);
            }
            else if (elem.Name.LocalName == FunctionAssociationEnd.ElementName)
            {
                var end = new FunctionAssociationEnd(this, elem);
                _ends.Add(end);
                end.Parse(unprocessedElements);
            }
            else if (elem.Name.LocalName == ResultBinding.ElementName)
            {
                var resultBinding = new ResultBinding(this, elem);
                _resultBindings.Add(resultBinding);
                resultBinding.Parse(unprocessedElements);
            }
            else
            {
                return base.ParseSingleElement(unprocessedElements, elem);
            }

            return true;
        }
 internal void AddResultBinding(ResultBinding resultBinding)
 {
     _resultBindings.Add(resultBinding);
 }