コード例 #1
0
        /// <summary>
        /// Creates instance of EntityPropertyMappingInfo class.
        /// </summary>
        /// <param name="attribute">The <see cref="EntityPropertyMappingAttribute"/> corresponding to this object</param>
        /// <param name="definingType">Type the <see cref="EntityPropertyMappingAttribute"/> was defined on.</param>
        /// <param name="actualTypeDeclaringProperty">Type whose property is to be read. This can be different from defining type when inheritance is involved.</param>
        internal EntityPropertyMappingInfo(EntityPropertyMappingAttribute attribute, IEdmEntityType definingType, IEdmEntityType actualTypeDeclaringProperty)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(attribute != null, "attribute != null");
            Debug.Assert(definingType != null, "definingType != null");
            Debug.Assert(actualTypeDeclaringProperty != null, "actualTypeDeclaringProperty != null");

            this.attribute = attribute;
            this.definingType = definingType;
            this.actualPropertyType = actualTypeDeclaringProperty;

            // Infer the mapping type from the attribute
            this.isSyndicationMapping = this.attribute.TargetSyndicationItem != SyndicationItemProperty.CustomProperty;
        }
コード例 #2
0
        /// <summary>
        /// Creates instance of EntityPropertyMappingInfo class.
        /// </summary>
        /// <param name="attribute">The <see cref="EntityPropertyMappingAttribute"/> corresponding to this object</param>
        /// <param name="definingType">Type the <see cref="EntityPropertyMappingAttribute"/> was defined on.</param>
        /// <param name="actualPropertyType">ClientType whose property is to be read.</param>
        public EntityPropertyMappingInfo(EntityPropertyMappingAttribute attribute, Type definingType, ClientTypeAnnotation actualPropertyType)
        {
#endif
            Debug.Assert(attribute != null, "attribute != null");
            Debug.Assert(definingType != null, "definingType != null");
            Debug.Assert(actualPropertyType != null, "actualPropertyType != null");

            this.attribute = attribute;
            this.definingType = definingType;
            this.actualPropertyType = actualPropertyType;

            Debug.Assert(!string.IsNullOrEmpty(attribute.SourcePath), "Invalid source path");
            this.propertyValuePath = attribute.SourcePath.Split('/');

            // Infer the mapping type from the attribute
            this.isSyndicationMapping = this.attribute.TargetSyndicationItem != SyndicationItemProperty.CustomProperty;
        }
コード例 #3
0
 /// <summary>
 /// Creates instance of EntityPropertyMappingInfo class.
 /// </summary>
 /// <param name="attribute">The <see cref="EntityPropertyMappingAttribute"/> corresponding to this object</param>
 /// <param name="definingType">Type the <see cref="EntityPropertyMappingAttribute"/> was defined on.</param>
 /// <param name="actualPropertyType">Type whose property is to be read. This can be different from defining type when inheritance is involved.</param>
 /// <param name="isEFProvider">Whether the current data source is an EF provider. Needed for error reporting.</param>
 public EntityPropertyMappingInfo(EntityPropertyMappingAttribute attribute, ResourceType definingType, ResourceType actualPropertyType, bool isEFProvider)
 {
     this.isEFProvider = isEFProvider;
コード例 #4
0
        /// <summary>
        /// Does given property in the attribute exist in the specified type.
        /// </summary>
        /// <param name="structuredType">The type to inspect.</param>
        /// <param name="epmAttribute">Attribute which has PropertyName.</param>
        /// <returns>true if property exists in the specified type, false otherwise.</returns>
        private static bool PropertyExistsOnType(IEdmStructuredType structuredType, EntityPropertyMappingAttribute epmAttribute)
        {
            Debug.Assert(structuredType != null, "structuredType != null");
            Debug.Assert(epmAttribute != null, "epmAttribute != null");

            int indexOfSeparator = epmAttribute.SourcePath.IndexOf('/');
            String propertyToLookFor = indexOfSeparator == -1 ? epmAttribute.SourcePath : epmAttribute.SourcePath.Substring(0, indexOfSeparator);
            return structuredType.DeclaredProperties.Any(p => p.Name == propertyToLookFor);
        }