Пример #1
0
        /// <summary>
        /// Given a resource type and its resource proeperty builds the EntityPropertyMappingInfo for the EntityPropertyMappingAttribute on it
        /// </summary>
        /// <param name="propertyInformation">EPM information for current property</param>
        /// <param name="entityProperty">Property for which to get the information</param>
        /// <param name="typeDecl">Type declaration to add the attributes to</param>
        private void EmitEpmAttributeForEntityProperty(
            EpmPropertyInformation propertyInformation,
            EdmInfo entityProperty,
            CodeTypeDeclaration typeDecl)
        {
            if (propertyInformation.IsAtom)
            {
                if (entityProperty.IsComplex)
                {
                    throw new InvalidOperationException(Strings.ObjectContext_SyndicationMappingForComplexPropertiesNotAllowed);
                }
                else
                {
                    EntityPropertyMappingAttribute epmAttr = new EntityPropertyMappingAttribute(
                        propertyInformation.SourcePath,
                        propertyInformation.SyndicationItem,
                        propertyInformation.ContentKind,
                        propertyInformation.KeepInContent);

                    this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                }
            }
            else
            {
                if (entityProperty.IsComplex)
                {
                    foreach (EntityPropertyMappingAttribute epmAttr in GetEpmAttrsFromComplexProperty(
                                 entityProperty.Member,
                                 propertyInformation.SourcePath,
                                 propertyInformation.TargetPath,
                                 propertyInformation.NsPrefix,
                                 propertyInformation.NsUri,
                                 propertyInformation.KeepInContent))
                    {
                        this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                    }
                }
                else
                {
                    EntityPropertyMappingAttribute epmAttr = new EntityPropertyMappingAttribute(
                        propertyInformation.SourcePath,
                        propertyInformation.TargetPath,
                        propertyInformation.NsPrefix,
                        propertyInformation.NsUri,
                        propertyInformation.KeepInContent);

                    this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Given a resource type and its resource proeperty builds the EntityPropertyMappingInfo for the EntityPropertyMappingAttribute on it
        /// </summary>
        /// <param name="propertyInformation">EPM information for current property</param>
        /// <param name="entityProperty">Property for which to get the information</param>
        /// <param name="typeDecl">Type declaration to add the attributes to</param>
        private void EmitEpmAttributeForEntityProperty(
            EpmPropertyInformation propertyInformation, 
            EdmInfo entityProperty, 
            CodeTypeDeclaration typeDecl)
        {
            if (propertyInformation.IsAtom)
            {
                if (entityProperty.IsComplex)
                {
                    throw new InvalidOperationException(Strings.ObjectContext_SyndicationMappingForComplexPropertiesNotAllowed);
                }
                else
                {
                    EntityPropertyMappingAttribute epmAttr = new EntityPropertyMappingAttribute(
                                        propertyInformation.SourcePath,
                                        propertyInformation.SyndicationItem,
                                        propertyInformation.ContentKind,
                                        propertyInformation.KeepInContent);

                    this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                }
            }
            else
            {
                if (entityProperty.IsComplex)
                {
                    foreach (EntityPropertyMappingAttribute epmAttr in GetEpmAttrsFromComplexProperty(
                                                                        entityProperty.Member,
                                                                        propertyInformation.SourcePath,
                                                                        propertyInformation.TargetPath,
                                                                        propertyInformation.NsPrefix,
                                                                        propertyInformation.NsUri,
                                                                        propertyInformation.KeepInContent))
                    {
                        this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                    }
                }
                else
                {
                    EntityPropertyMappingAttribute epmAttr = new EntityPropertyMappingAttribute(
                                        propertyInformation.SourcePath,
                                        propertyInformation.TargetPath,
                                        propertyInformation.NsPrefix,
                                        propertyInformation.NsUri,
                                        propertyInformation.KeepInContent);

                    this.AddEpmAttributeToTypeDeclaration(epmAttr, typeDecl);
                }
            }
        }