internal MetadataPropertyValue(PropertyInfo propertyInfo, MetadataItem item)
 {
     Debug.Assert(null != propertyInfo);
     Debug.Assert(null != item);
     _propertyInfo = propertyInfo;
     _item = item;
 }
 internal MetadataPropertyValue(PropertyInfo propertyInfo, MetadataItem item)
 {
     DebugCheck.NotNull(propertyInfo);
     DebugCheck.NotNull(item);
     _propertyInfo = propertyInfo;
     _item = item;
 }
 private void EvaluateItem(MetadataItem item)
 {
     foreach (var rule in _ruleSet.GetRules(item))
     {
         rule.Evaluate(_context, item);
     }
 }
 protected override void VisitMetadataItem(MetadataItem item)
 {
     if (_visitedItems.Add(item))
     {
         EvaluateItem(item);
     }
 }
Beispiel #5
0
 /// <summary>
 ///     Throws an appropriate exception if the given item is a readonly, used when an attempt is made to change
 ///     a property
 /// </summary>
 /// <param name="item"> The item whose readonly is being tested </param>
 internal static void ThrowIfReadOnly(MetadataItem item)
 {
     DebugCheck.NotNull(item);
     if (item.IsReadOnly)
     {
         throw new InvalidOperationException(Strings.OperationOnReadOnlyItem);
     }
 }
Beispiel #6
0
 /// <summary>
 /// Throws an appropriate exception if the given item is a readonly, used when an attempt is made to change
 /// a property
 /// </summary>
 /// <param name="item">The item whose readonly is being tested</param>
 internal static void ThrowIfReadOnly(MetadataItem item)
 {
     Debug.Assert(item != null, "The given item is null");
     if (item.IsReadOnly)
     {
         throw new InvalidOperationException(Strings.OperationOnReadOnlyItem);
     }
 }
        protected internal override void VisitMetadataItem(MetadataItem item)
        {
            DebugCheck.NotNull(item);

            if (_visitedItems.Add(item))
            {
                EvaluateItem(item);
            }
        }
        private void EvaluateItem(MetadataItem item)
        {
            DebugCheck.NotNull(item);

            foreach (var rule in _ruleSet.GetRules(item))
            {
                rule.Evaluate(_context, item);
            }
        }
Beispiel #9
0
 internal static MetadataProperty FindExtendedProperty(MetadataItem metadataItem, string propertyName)
 {
     MetadataProperty property;
     string identity = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata:" + propertyName;
     if (metadataItem.MetadataProperties.TryGetValue(identity, false, out property))
     {
         return property;
     }
     return null;
 }
        public static bool IsInvalid(MetadataItem instance)
        {
            Debug.Assert(instance != null, "instance != null");

            MetadataProperty property;
            if (!instance.MetadataProperties.TryGetValue(SchemaInvalidMetadataPropertyName, false, out property)
                || property == null)
            {
                return false;
            }

            return (bool)property.Value;
        }
        public static IEnumerable<EdmSchemaError> GetSchemaErrors(MetadataItem instance)
        {
            Debug.Assert(instance != null, "instance != null");

            MetadataProperty property;
            if (!instance.MetadataProperties.TryGetValue(SchemaErrorsMetadataPropertyName, false, out property)
                || property == null)
            {
                return Enumerable.Empty<EdmSchemaError>();
            }

            return (IEnumerable<EdmSchemaError>)property.Value;
        }
        public void AddError(MetadataItem item, string propertyName, string errorMessage)
        {
            DebugCheck.NotNull(item);
            DebugCheck.NotEmpty(errorMessage);

            RaiseDataModelValidationEvent(
                new DataModelErrorEventArgs
                    {
                        ErrorMessage = errorMessage,
                        Item = item,
                        PropertyName = propertyName,
                    }
                );
        }
Beispiel #13
0
        /// <summary>
        ///     Override EdmEquals to support value comparison of TypeUsage property
        /// </summary>
        internal override bool EdmEquals(MetadataItem item)
        {
            // short-circuit if this and other are reference equivalent
            if (ReferenceEquals(this, item))
            {
                return(true);
            }

            // check type of item
            if (null == item ||
                BuiltInTypeKind.CollectionType != item.BuiltInTypeKind)
            {
                return(false);
            }
            var other = (CollectionType)item;

            // compare type usage
            return(TypeUsage.EdmEquals(other.TypeUsage));
        }
Beispiel #14
0
        // <summary>
        // EdmEquals override verifying the equivalence of all members and their type usages.
        // </summary>
        internal override bool EdmEquals(MetadataItem item)
        {
            // short-circuit if this and other are reference equivalent
            if (ReferenceEquals(this, item))
            {
                return(true);
            }

            // check type of item
            if (null == item ||
                BuiltInTypeKind.RowType != item.BuiltInTypeKind)
            {
                return(false);
            }
            var other = (RowType)item;

            // check each row type has the same number of members
            if (Members.Count
                != other.Members.Count)
            {
                return(false);
            }

            // verify all members are equivalent
            for (var ordinal = 0; ordinal < Members.Count; ordinal++)
            {
                var thisMember  = Members[ordinal];
                var otherMember = other.Members[ordinal];

                // if members are different, return false
                if (!thisMember.EdmEquals(otherMember)
                    ||
                    !thisMember.TypeUsage.EdmEquals(otherMember.TypeUsage))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Gets the string property.
        /// Will work witn EF Version 6.
        /// </summary>
        /// <param name="entitySet">The entity set.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>Table name for entity set.</returns>
        /// <exception cref="System.ArgumentNullException">Value of entitySet is null.</exception>
        private static string GetStringProperty(System.Data.Entity.Core.Metadata.Edm.MetadataItem entitySet, string propertyName)
        {
            System.Data.Entity.Core.Metadata.Edm.MetadataProperty property;
            if (entitySet == null)
            {
                throw new ArgumentNullException("entitySet");
            }

            if (entitySet.MetadataProperties.TryGetValue(propertyName, false, out property))
            {
                string str = null;
                if (((property != null) &&
                     (property.Value != null)) &&
                    (((str = property.Value as string) != null) &&
                     !string.IsNullOrWhiteSpace(str)))
                {
                    return(str);
                }
            }

            return(string.Empty);
        }
Beispiel #16
0
        // <summary>
        // EdmEquals override verifying the equivalence of all members and their type usages.
        // </summary>
        internal override bool EdmEquals(MetadataItem item)
        {
            // short-circuit if this and other are reference equivalent
            if (ReferenceEquals(this, item))
            {
                return true;
            }

            // check type of item
            if (null == item
                || BuiltInTypeKind.RowType != item.BuiltInTypeKind)
            {
                return false;
            }
            var other = (RowType)item;

            // check each row type has the same number of members
            if (Members.Count
                != other.Members.Count)
            {
                return false;
            }

            // verify all members are equivalent
            for (var ordinal = 0; ordinal < Members.Count; ordinal++)
            {
                var thisMember = Members[ordinal];
                var otherMember = other.Members[ordinal];

                // if members are different, return false
                if (!thisMember.EdmEquals(otherMember)
                    ||
                    !thisMember.TypeUsage.EdmEquals(otherMember.TypeUsage))
                {
                    return false;
                }
            }

            return true;
        }
Beispiel #17
0
 private static IEnumerable <MetadataProperty> GetSystemMetadataProperties(
     MetadataItem item)
 {
     return(MetadataPropertyCollection.GetItemTypeInformation(item.GetType()).GetItemAttributes(item));
 }
 internal void SetParameterMode(ParameterMode mode)
 {
     this._flags = (int)((MetadataItem.MetadataFlags)(this._flags & -3585) | MetadataItem.MetadataFlags.ParameterMode & MetadataItem.Convert(mode));
 }
Beispiel #19
0
 internal MetadataProperty GetMetadataProperty(MetadataItem item)
 {
     return(new MetadataProperty(this._propertyInfo.Name, this._attribute.Type, this._attribute.IsCollectionType, (object)new MetadataPropertyValue(this._propertyInfo, item)));
 }
 // <summary>
 // Initializes a new attribute with built in type kind
 // </summary>
 // <param name="builtInTypeKind"> Built in type setting Type property </param>
 // <param name="isCollectionType"> Sets IsCollectionType property </param>
 internal MetadataPropertyAttribute(BuiltInTypeKind builtInTypeKind, bool isCollectionType)
     : this(MetadataItem.GetBuiltInType(builtInTypeKind), isCollectionType)
 {
 }
Beispiel #21
0
        /// <summary>
        ///     Override EdmEquals to support value comparison of TypeUsage property
        /// </summary>
        /// <param name="item"> </param>
        /// <returns> </returns>
        internal override bool EdmEquals(MetadataItem item)
        {
            // short-circuit if this and other are reference equivalent
            if (ReferenceEquals(this, item))
            {
                return true;
            }

            // check type of item
            if (null == item
                || BuiltInTypeKind.CollectionType != item.BuiltInTypeKind)
            {
                return false;
            }
            var other = (CollectionType)item;

            // compare type usage
            return TypeUsage.EdmEquals(other.TypeUsage);
        }
 /// <summary>
 ///     Just checks for identities to be equal
 /// </summary>
 /// <param name="item"> </param>
 /// <returns> </returns>
 internal virtual bool EdmEquals(MetadataItem item)
 {
     return ((null != item) &&
             ((this == item) || // same reference
              (BuiltInTypeKind == item.BuiltInTypeKind &&
               Identity == item.Identity)));
 }
Beispiel #23
0
        private void InternalValidate(
            MetadataItem item,
            List <EdmItemError> errors,
            HashSet <MetadataItem> validatedItems)
        {
            if (item.IsReadOnly && this.SkipReadOnlyItems || validatedItems.Contains(item))
            {
                return;
            }
            validatedItems.Add(item);
            if (string.IsNullOrEmpty(item.Identity))
            {
                this.AddError(errors, new EdmItemError(Strings.Validator_EmptyIdentity));
            }
            switch (item.BuiltInTypeKind)
            {
            case BuiltInTypeKind.CollectionType:
                this.ValidateCollectionType((CollectionType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.ComplexType:
                this.ValidateComplexType((ComplexType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.EntityType:
                this.ValidateEntityType((EntityType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.Facet:
                this.ValidateFacet((Facet)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.MetadataProperty:
                this.ValidateMetadataProperty((MetadataProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.NavigationProperty:
                this.ValidateNavigationProperty((NavigationProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.PrimitiveType:
                this.ValidatePrimitiveType((PrimitiveType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.EdmProperty:
                this.ValidateEdmProperty((EdmProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.RefType:
                this.ValidateRefType((RefType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.TypeUsage:
                this.ValidateTypeUsage((TypeUsage)item, errors, validatedItems);
                break;
            }
            IEnumerable <EdmItemError> collection = this.CustomValidate(item);

            if (collection == null)
            {
                return;
            }
            errors.AddRange(collection);
        }
        /// <summary>
        ///     Validate an item object
        /// </summary>
        /// <param name="item"> The item to validate </param>
        /// <param name="errors"> An error collection for adding validation errors </param>
        /// <param name="validatedItems"> A dictionary keeping track of items that have been validated </param>
        private void InternalValidate(MetadataItem item, List <EdmItemError> errors, HashSet <MetadataItem> validatedItems)
        {
            DebugCheck.NotNull(item);

            // If the item has already been validated or we need to skip readonly items, then skip
            if ((item.IsReadOnly && SkipReadOnlyItems) ||
                validatedItems.Contains(item))
            {
                return;
            }

            // Add this item to the dictionary so we won't validate this again.  Note that we only do this
            // in this function because every other function should eventually delegate to here
            validatedItems.Add(item);

            // Check to make sure the item has an identity
            if (string.IsNullOrEmpty(item.Identity))
            {
                AddError(errors, new EdmItemError(Strings.Validator_EmptyIdentity));
            }

            switch (item.BuiltInTypeKind)
            {
            case BuiltInTypeKind.CollectionType:
                ValidateCollectionType((CollectionType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.ComplexType:
                ValidateComplexType((ComplexType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.EntityType:
                ValidateEntityType((EntityType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.Facet:
                ValidateFacet((Facet)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.MetadataProperty:
                ValidateMetadataProperty((MetadataProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.NavigationProperty:
                ValidateNavigationProperty((NavigationProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.PrimitiveType:
                ValidatePrimitiveType((PrimitiveType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.EdmProperty:
                ValidateEdmProperty((EdmProperty)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.RefType:
                ValidateRefType((RefType)item, errors, validatedItems);
                break;

            case BuiltInTypeKind.TypeUsage:
                ValidateTypeUsage((TypeUsage)item, errors, validatedItems);
                break;

            // Abstract classes
            case BuiltInTypeKind.EntityTypeBase:
            case BuiltInTypeKind.EdmType:
            case BuiltInTypeKind.MetadataItem:
            case BuiltInTypeKind.EdmMember:
            case BuiltInTypeKind.RelationshipEndMember:
            case BuiltInTypeKind.RelationshipType:
            case BuiltInTypeKind.SimpleType:
            case BuiltInTypeKind.StructuralType:
                Debug.Assert(
                    false,
                    "An instance with a built in type kind refering to the abstract type " + item.BuiltInTypeKind + " is encountered");
                break;

            default:
                //Debug.Assert(false, String.Format(CultureInfo.InvariantCulture, "Validate not implemented for {0}", item.BuiltInTypeKind));
                break;
            }

            // Performs other custom validation
            var customErrors = CustomValidate(item);

            if (customErrors != null)
            {
                errors.AddRange(customErrors);
            }
        }
 internal abstract void Evaluate(EdmModelValidationContext context, MetadataItem item);
            internal AnnotationCollection(MetadataItem metadataItem)
            {
                DebugCheck.NotNull(metadataItem);

                _metadataItem = metadataItem;
            }
Beispiel #27
0
 internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
 {
     Debug.Assert(!string.IsNullOrEmpty(item.Identity), "Item has empty identity.");
     EntityUtil.GenericCheckArgumentNull(item, argumentName);
 }
 internal IEnumerable <DataModelValidationRule> GetRules(
     MetadataItem itemToValidate)
 {
     return(this._rules.Where <DataModelValidationRule>((Func <DataModelValidationRule, bool>)(r => r.ValidatedType.IsInstanceOfType((object)itemToValidate))));
 }
 internal virtual IEnumerable <FacetDescription> GetAssociatedFacetDescriptions()
 {
     return((IEnumerable <FacetDescription>)MetadataItem.GetGeneralFacetDescriptions());
 }
Beispiel #30
0
 /// <summary>
 ///     Given an item, returns an instance of the item attribute described by this class.
 /// </summary>
 /// <param name="item"> Item from which to retrieve attribute. </param>
 /// <returns> Item attribute. </returns>
 internal MetadataProperty GetMetadataProperty(MetadataItem item)
 {
     return(new MetadataProperty(
                _propertyInfo.Name, _attribute.Type, _attribute.IsCollectionType,
                new MetadataPropertyValue(_propertyInfo, item)));
 }
        public static bool HasSchemaErrors(MetadataItem instance)
        {
            Debug.Assert(instance != null, "instance != null");

            return instance.MetadataProperties.Contains(SchemaErrorsMetadataPropertyName);
        }
Beispiel #32
0
 /// <summary>
 ///     Constructor taking item.
 /// </summary>
 /// <param name="item"> Item with which the collection is associated. </param>
 internal MetadataPropertyCollection(MetadataItem item)
     : base(GetSystemMetadataProperties(item))
 {
 }
 internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
 {
     DebugCheck.NotEmpty(item.Identity);
     Check.NotNull(item, argumentName);
 }
 public static bool HasSchemaErrors(MetadataItem instance)
 {
     return(instance.MetadataProperties.Contains("EdmSchemaErrors"));
 }
 internal IEnumerable<DataModelValidationRule> GetRules(MetadataItem itemToValidate)
 {
     return _rules.Where(r => r.ValidatedType.IsInstanceOfType(itemToValidate));
 }
 private static MetadataProperty GetAnnotationMetadataProperty(MetadataItem item, string metadataPropertyName)
 {
     return item
         .MetadataProperties
         .SingleOrDefault(
             p => p.Name == "http://schemas.microsoft.com/ado/2009/02/edm/annotation:" + metadataPropertyName);
 }
 internal void SetDataSpace(DataSpace space)
 {
     this._flags = (int)((MetadataItem.MetadataFlags)(this._flags & -8) | MetadataItem.MetadataFlags.DataSpace & MetadataItem.Convert(space));
 }
Beispiel #38
0
 internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
 {
     DebugCheck.NotEmpty(item.Identity);
     Check.NotNull(item, argumentName);
 }
        static MetadataItem()
        {
            MetadataItem._builtInTypes[0]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[2]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[1]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[3]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[3]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[7]  = (EdmType) new EnumType();
            MetadataItem._builtInTypes[6]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[8]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[9]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[10] = (EdmType) new EnumType();
            MetadataItem._builtInTypes[11] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[12] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[13] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[14] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[4]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[5]  = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[15] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[16] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[17] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[18] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[19] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[20] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[21] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[22] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[23] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[24] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[25] = (EdmType) new EnumType();
            MetadataItem._builtInTypes[26] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[27] = (EdmType) new EnumType();
            MetadataItem._builtInTypes[28] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[29] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[30] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[31] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[32] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[33] = (EdmType) new EnumType();
            MetadataItem._builtInTypes[34] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[35] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[36] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[37] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[38] = (EdmType) new ComplexType();
            MetadataItem._builtInTypes[39] = (EdmType) new ComplexType();
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem), "ItemType", false, (ComplexType)null);
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataProperty), "MetadataProperty", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.GlobalItem), "GlobalItem", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.TypeUsage), "TypeUsage", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType), "EdmType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.GlobalItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.SimpleType), "SimpleType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EnumType), "EnumType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.SimpleType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.PrimitiveType), "PrimitiveType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.SimpleType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.CollectionType), "CollectionType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RefType), "RefType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember), "EdmMember", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmProperty), "EdmProperty", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.NavigationProperty), "NavigationProperty", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.ProviderManifest), "ProviderManifest", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipEndMember), "RelationshipEnd", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.AssociationEndMember), "AssociationEnd", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipEndMember));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EnumMember), "EnumMember", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.ReferentialConstraint), "ReferentialConstraint", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.StructuralType), "StructuralType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RowType), "RowType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.StructuralType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.ComplexType), "ComplexType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.StructuralType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityTypeBase), "ElementType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.StructuralType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityType), "EntityType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityTypeBase));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipType), "RelationshipType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityTypeBase));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.AssociationType), "AssociationType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.Facet), "Facet", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityContainer), "EntityContainerType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.GlobalItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySetBase), "BaseEntitySetType", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySet), "EntitySetType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySetBase));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipSet), "RelationshipSet", true, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySetBase));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.AssociationSet), "AssocationSetType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipSet));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.AssociationSetEnd), "AssociationSetEndType", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.FunctionParameter), "FunctionParameter", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmFunction), "EdmFunction", false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            MetadataItem.InitializeBuiltInTypes((ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.Documentation), nameof(Documentation), false, (ComplexType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataItem));
            MetadataItem.InitializeEnumType(BuiltInTypeKind.OperationAction, "DeleteAction", new string[2]
            {
                "None",
                "Cascade"
            });
            MetadataItem.InitializeEnumType(BuiltInTypeKind.RelationshipMultiplicity, "RelationshipMultiplicity", new string[3]
            {
                "One",
                "ZeroToOne",
                "Many"
            });
            MetadataItem.InitializeEnumType(BuiltInTypeKind.ParameterMode, "ParameterMode", new string[3]
            {
                "In",
                "Out",
                "InOut"
            });
            MetadataItem.InitializeEnumType(BuiltInTypeKind.CollectionKind, "CollectionKind", new string[3]
            {
                "None",
                "List",
                "Bag"
            });
            MetadataItem.InitializeEnumType(BuiltInTypeKind.PrimitiveTypeKind, "PrimitiveTypeKind", Enum.GetNames(typeof(PrimitiveTypeKind)));
            FacetDescription[] facetDescriptionArray = new FacetDescription[2];
            MetadataItem._nullableFacetDescription = new FacetDescription("Nullable", (EdmType)MetadataItem.EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.Boolean), new int?(), new int?(), (object)true);
            facetDescriptionArray[0] = MetadataItem._nullableFacetDescription;
            MetadataItem._defaultValueFacetDescription = new FacetDescription("DefaultValue", MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType), new int?(), new int?(), (object)null);
            facetDescriptionArray[1] = MetadataItem._defaultValueFacetDescription;
            MetadataItem._generalFacetDescriptions       = new ReadOnlyCollection <FacetDescription>((IList <FacetDescription>)facetDescriptionArray);
            MetadataItem._collectionKindFacetDescription = new FacetDescription("CollectionKind", MetadataItem.GetBuiltInType(BuiltInTypeKind.EnumType), new int?(), new int?(), (object)null);
            TypeUsage typeUsage1 = TypeUsage.Create((EdmType)MetadataItem.EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.String));
            TypeUsage typeUsage2 = TypeUsage.Create((EdmType)MetadataItem.EdmProviderManifest.GetPrimitiveType(PrimitiveTypeKind.Boolean));
            TypeUsage typeUsage3 = TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType));
            TypeUsage typeUsage4 = TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.TypeUsage));
            TypeUsage typeUsage5 = TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.ComplexType));

            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.MetadataProperty, new EdmProperty[3]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("TypeUsage", typeUsage4),
                new EdmProperty("Value", typeUsage5)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.MetadataItem, new EdmProperty[2]
            {
                new EdmProperty(nameof(MetadataProperties), TypeUsage.Create((EdmType)MetadataItem.GetBuiltInType(BuiltInTypeKind.MetadataProperty).GetCollectionType())),
                new EdmProperty(nameof(Documentation), TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.Documentation)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.TypeUsage, new EdmProperty[2]
            {
                new EdmProperty("EdmType", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType))),
                new EdmProperty("Facets", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.Facet)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EdmType, new EdmProperty[5]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("Namespace", typeUsage1),
                new EdmProperty("Abstract", typeUsage2),
                new EdmProperty("Sealed", typeUsage2),
                new EdmProperty("BaseType", typeUsage5)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EnumType, new EdmProperty[1]
            {
                new EdmProperty("EnumMembers", typeUsage1)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.CollectionType, new EdmProperty[1]
            {
                new EdmProperty("TypeUsage", typeUsage4)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.RefType, new EdmProperty[1]
            {
                new EdmProperty("EntityType", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityType)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EdmMember, new EdmProperty[2]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("TypeUsage", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.TypeUsage)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EdmProperty, new EdmProperty[2]
            {
                new EdmProperty("Nullable", typeUsage1),
                new EdmProperty("DefaultValue", typeUsage5)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.NavigationProperty, new EdmProperty[2]
            {
                new EdmProperty("RelationshipTypeName", typeUsage1),
                new EdmProperty("ToEndMemberName", typeUsage1)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.RelationshipEndMember, new EdmProperty[2]
            {
                new EdmProperty("OperationBehaviors", typeUsage5),
                new EdmProperty("RelationshipMultiplicity", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EnumType)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EnumMember, new EdmProperty[1]
            {
                new EdmProperty("Name", typeUsage1)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.ReferentialConstraint, new EdmProperty[4]
            {
                new EdmProperty("ToRole", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipEndMember))),
                new EdmProperty("FromRole", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.RelationshipEndMember))),
                new EdmProperty("ToProperties", TypeUsage.Create((EdmType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmProperty).GetCollectionType())),
                new EdmProperty("FromProperties", TypeUsage.Create((EdmType)MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmProperty).GetCollectionType()))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.StructuralType, new EdmProperty[1]
            {
                new EdmProperty("Members", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EntityTypeBase, new EdmProperty[1]
            {
                new EdmProperty("KeyMembers", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmMember)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.Facet, new EdmProperty[3]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("EdmType", typeUsage3),
                new EdmProperty("Value", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EdmType)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EntityContainer, new EdmProperty[2]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("EntitySets", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySet)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EntitySetBase, new EdmProperty[4]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("EntityType", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EntityType))),
                new EdmProperty("Schema", typeUsage1),
                new EdmProperty("Table", typeUsage1)
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.AssociationSet, new EdmProperty[1]
            {
                new EdmProperty("AssociationSetEnds", TypeUsage.Create((EdmType)MetadataItem.GetBuiltInType(BuiltInTypeKind.AssociationSetEnd).GetCollectionType()))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.AssociationSetEnd, new EdmProperty[2]
            {
                new EdmProperty("Role", typeUsage1),
                new EdmProperty("EntitySetType", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EntitySet)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.FunctionParameter, new EdmProperty[3]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("Mode", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.EnumType))),
                new EdmProperty("TypeUsage", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.TypeUsage)))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.EdmFunction, new EdmProperty[4]
            {
                new EdmProperty("Name", typeUsage1),
                new EdmProperty("Namespace", typeUsage1),
                new EdmProperty("ReturnParameter", TypeUsage.Create(MetadataItem.GetBuiltInType(BuiltInTypeKind.FunctionParameter))),
                new EdmProperty("Parameters", TypeUsage.Create((EdmType)MetadataItem.GetBuiltInType(BuiltInTypeKind.FunctionParameter).GetCollectionType()))
            });
            MetadataItem.AddBuiltInTypeProperties(BuiltInTypeKind.Documentation, new EdmProperty[2]
            {
                new EdmProperty("Summary", typeUsage1),
                new EdmProperty("LongDescription", typeUsage1)
            });
            for (int index = 0; index < MetadataItem._builtInTypes.Length; ++index)
            {
                MetadataItem._builtInTypes[index].SetReadOnly();
            }
        }
Beispiel #40
0
 internal MetadataPropertyValue(PropertyInfo propertyInfo, MetadataItem item)
 {
     this._propertyInfo = propertyInfo;
     this._item         = item;
 }
 private static void AddOtherContent(Som.SchemaElement element, MetadataItem item)
 {
     if (element.OtherContent.Count > 0)
     {
         item.AddMetadataProperties(element.OtherContent);
     }
 }
Beispiel #42
0
 internal override void Evaluate(EdmModelValidationContext context, MetadataItem item)
 {
     Debug.Assert(item is TItem);
     _validate(context, item as TItem);
 }
Beispiel #43
0
 private static IEnumerable<EpmPropertyInformation> GetEpmPropertyInformation(MetadataItem metadataItem, string typeName, string memberName)
 {
     EpmAttributeNameBuilder iteratorVariable0 = new EpmAttributeNameBuilder();
     while (true)
     {
         string iteratorVariable6;
         bool iteratorVariable1 = true;
         MetadataProperty iteratorVariable2 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmTargetPath);
         if (iteratorVariable2 == null)
         {
             break;
         }
         bool result = true;
         MetadataProperty iteratorVariable4 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmKeepInContent);
         if ((iteratorVariable4 != null) && !bool.TryParse(Convert.ToString(iteratorVariable4.Value, CultureInfo.InvariantCulture), out result))
         {
             throw new InvalidOperationException((memberName == null) ? Strings.ObjectContext_InvalidValueForEpmPropertyType(iteratorVariable0.EpmKeepInContent, typeName) : Strings.ObjectContext_InvalidValueForEpmPropertyMember(iteratorVariable0.EpmKeepInContent, memberName, typeName));
         }
         MetadataProperty iteratorVariable5 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmSourcePath);
         if (iteratorVariable5 == null)
         {
             if (memberName == null)
             {
                 throw new InvalidOperationException(Strings.ObjectContext_MissingExtendedAttributeType(iteratorVariable0.EpmSourcePath, typeName));
             }
             iteratorVariable1 = false;
             iteratorVariable6 = memberName;
         }
         else
         {
             iteratorVariable6 = Convert.ToString(iteratorVariable5.Value, CultureInfo.InvariantCulture);
         }
         string targetPath = Convert.ToString(iteratorVariable2.Value, CultureInfo.InvariantCulture);
         SyndicationItemProperty iteratorVariable8 = EpmTranslate.MapEpmTargetPathToSyndicationProperty(targetPath);
         MetadataProperty iteratorVariable9 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmContentKind);
         MetadataProperty iteratorVariable10 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmNsPrefix);
         MetadataProperty iteratorVariable11 = EdmUtil.FindExtendedProperty(metadataItem, iteratorVariable0.EpmNsUri);
         if ((iteratorVariable9 != null) && ((iteratorVariable10 != null) || (iteratorVariable11 != null)))
         {
             string str = (iteratorVariable10 != null) ? iteratorVariable0.EpmNsPrefix : iteratorVariable0.EpmNsUri;
             throw new InvalidOperationException((memberName == null) ? Strings.ObjectContext_InvalidAttributeForNonSyndicationItemsType(str, typeName) : Strings.ObjectContext_InvalidAttributeForNonSyndicationItemsMember(str, memberName, typeName));
         }
         if (((iteratorVariable10 != null) || (iteratorVariable11 != null)) || (iteratorVariable8 == SyndicationItemProperty.CustomProperty))
         {
             string iteratorVariable12 = (iteratorVariable10 != null) ? Convert.ToString(iteratorVariable10.Value, CultureInfo.InvariantCulture) : null;
             string iteratorVariable13 = (iteratorVariable11 != null) ? Convert.ToString(iteratorVariable11.Value, CultureInfo.InvariantCulture) : null;
             EpmPropertyInformation iteratorVariable14 = new EpmPropertyInformation {
                 IsAtom = false,
                 KeepInContent = result,
                 SourcePath = iteratorVariable6,
                 PathGiven = iteratorVariable1,
                 TargetPath = targetPath,
                 NsPrefix = iteratorVariable12,
                 NsUri = iteratorVariable13
             };
             yield return iteratorVariable14;
         }
         else
         {
             SyndicationTextContentKind plaintext;
             if (iteratorVariable9 != null)
             {
                 plaintext = EpmTranslate.MapEpmContentKindToSyndicationTextContentKind(Convert.ToString(iteratorVariable9.Value, CultureInfo.InvariantCulture), typeName, memberName);
             }
             else
             {
                 plaintext = SyndicationTextContentKind.Plaintext;
             }
             EpmPropertyInformation iteratorVariable16 = new EpmPropertyInformation {
                 IsAtom = true,
                 KeepInContent = result,
                 SourcePath = iteratorVariable6,
                 PathGiven = iteratorVariable1,
                 SyndicationItem = iteratorVariable8,
                 ContentKind = plaintext
             };
             yield return iteratorVariable16;
         }
         iteratorVariable0.MoveNext();
     }
 }
        public static bool HasSchemaErrors(MetadataItem instance)
        {
            Debug.Assert(instance != null, "instance != null");

            return(instance.MetadataProperties.Contains(SchemaErrorsMetadataPropertyName));
        }
        internal void WriteExtendedProperties(MetadataItem item)
        {
            DebugCheck.NotNull(item);

            foreach (var extendedProperty in item.MetadataProperties.Where(p => p.PropertyKind == PropertyKind.Extended))
            {
                // We have to special case StoreGeneratedPattern because even though it is an "extended" property we have
                // special handling for it elsewhere, which means if we try to serialize it like a normal extended property
                // we might end up with duplicate attributes in the XML.
                string xmlNamespaceUri, attributeName;
                if (TrySplitExtendedMetadataPropertyName(extendedProperty.Name, out xmlNamespaceUri, out attributeName)
                    && extendedProperty.Name != XmlConstants.StoreGeneratedPatternAnnotation)
                {
                    DebugCheck.NotNull(extendedProperty.Value);

                    var serializer = _resolver.GetService<Func<IMetadataAnnotationSerializer>>(attributeName);

                    var value = serializer == null 
                        ? extendedProperty.Value.ToString()
                        : serializer().Serialize(attributeName, extendedProperty.Value);

                    _xmlWriter.WriteAttributeString(attributeName, xmlNamespaceUri, value);
                }
            }
        }
        private void WriteExtendedProperties(MetadataItem item)
        {
            DebugCheck.NotNull(item);

            foreach (var extendedProperty in item.MetadataProperties.Where(p => p.PropertyKind == PropertyKind.Extended))
            {
                string xmlNamespaceUri, attributeName;
                if (TrySplitExtendedMetadataPropertyName(extendedProperty.Name, out xmlNamespaceUri, out attributeName))
                {
                    DebugCheck.NotNull(extendedProperty.Value);

                    _xmlWriter.WriteAttributeString(attributeName, xmlNamespaceUri, extendedProperty.Value.ToString());
                }
            }
        }
 internal static void AssertItemHasIdentity(MetadataItem item, string argumentName)
 {
     Check.NotNull <MetadataItem>(item, argumentName);
 }
        internal IEnumerable <DataModelValidationRule> GetRules(MetadataItem itemToValidate)
        {
            DebugCheck.NotNull(itemToValidate);

            return(_rules.Where(r => r.ValidatedType.IsInstanceOfType(itemToValidate)));
        }
        internal static void CopyExtendedPropertiesToSsdlElement(MetadataItem metadataItem, XContainer xContainer)
        {
            foreach (var extendedProperty in metadataItem.MetadataProperties.Where(mp => mp.PropertyKind == PropertyKind.Extended))
            {
                var exPropertyElement = extendedProperty.Value as XElement;
                if (exPropertyElement != null)
                {
                    // find the CopyToSSDL attribute - if it exists it can be in any EDMX namespace
                    var copyToSSDLAttribute = exPropertyElement.Attributes().FirstOrDefault(
                        attr => attr.Name.LocalName.Equals("CopyToSSDL", StringComparison.Ordinal)
                                && SchemaManager.GetEDMXNamespaceNames().Contains(attr.Name.NamespaceName));
                    if (copyToSSDLAttribute != null)
                    {
                        if ((bool?)copyToSSDLAttribute == true)
                        {
                            // CopyToSsdl is true, so let's copy this extended property
                            var exAttributeNamespace = copyToSSDLAttribute.Name.Namespace;
                            var newExPropertyElement = new XElement(exPropertyElement);
                            var newCopyToSsdlAttribute = newExPropertyElement.Attribute(exAttributeNamespace + "CopyToSSDL");
                            newCopyToSsdlAttribute.Remove();

                            var namespacePrefix = newExPropertyElement.GetPrefixOfNamespace(exAttributeNamespace);
                            if (namespacePrefix != null)
                            {
                                var xmlnsEdmxAttr = newExPropertyElement.Attribute(XNamespace.Xmlns + namespacePrefix);
                                if (xmlnsEdmxAttr != null)
                                {
                                    xmlnsEdmxAttr.Remove();
                                }
                            }
                            xContainer.Add(newExPropertyElement);
                        }
                    }
                }
            }
        }
Beispiel #50
0
 protected virtual IEnumerable <EdmItemError> CustomValidate(
     MetadataItem item)
 {
     return((IEnumerable <EdmItemError>)null);
 }