当前位置: 首页>>代码示例>>C#>>正文


C# IEdmElement类代码示例

本文整理汇总了C#中IEdmElement的典型用法代码示例。如果您正苦于以下问题:C# IEdmElement类的具体用法?C# IEdmElement怎么用?C# IEdmElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IEdmElement类属于命名空间,在下文中一共展示了IEdmElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EdmDirectValueAnnotationBinding

		public EdmDirectValueAnnotationBinding(IEdmElement element, string namespaceUri, string name)
		{
			EdmUtil.CheckArgumentNull<IEdmElement>(element, "element");
			EdmUtil.CheckArgumentNull<string>(namespaceUri, "namespaceUri");
			EdmUtil.CheckArgumentNull<string>(name, "name");
			this.element = element;
			this.namespaceUri = namespaceUri;
			this.name = name;
		}
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:EdmDirectValueAnnotationBinding.cs

示例2: SetODataAnnotation

 internal static void SetODataAnnotation(this IEdmModel model, IEdmElement annotatable, string localName, string value)
 {
     IEdmStringValue value2 = null;
     if (value != null)
     {
         value2 = new EdmStringConstant(EdmCoreModel.Instance.GetString(true), value);
     }
     model.SetAnnotationValue(annotatable, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", localName, value2);
 }
开发者ID:nickchal,项目名称:pash,代码行数:9,代码来源:MetadataUtils.cs

示例3: GetAttachedAnnotations

        protected override IEnumerable<IEdmDirectValueAnnotation> GetAttachedAnnotations(IEdmElement element)
        {
            CsdlSemanticsElement csdlElement = element as CsdlSemanticsElement;
            if (csdlElement != null)
            {
                return csdlElement.DirectValueAnnotations;
            }

            return Enumerable.Empty<IEdmDirectValueAnnotation>();
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:10,代码来源:CsdlSemanticsDirectValueAnnotationsManager.cs

示例4: GetODataAnnotations

 internal static IEnumerable<IEdmDirectValueAnnotation> GetODataAnnotations(this IEdmModel model, IEdmElement annotatable)
 {
     IEnumerable<IEdmDirectValueAnnotation> enumerable = model.DirectValueAnnotations(annotatable);
     if (enumerable == null)
     {
         return null;
     }
     return (from a in enumerable
         where a.NamespaceUri == "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
         select a);
 }
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:MetadataUtils.cs

示例5: SetImmediateAnnotations

        private void SetImmediateAnnotations(IEdmElement edmAnnotatable, IEdmElement stockAnnotatable, IEdmModel edmModel, EdmModel stockModel)
        {
            IEnumerable<IEdmDirectValueAnnotation> annotations = edmModel.DirectValueAnnotations(edmAnnotatable);

            foreach (IEdmDirectValueAnnotation annotation in annotations)
            {
                var annotationValue = annotation.Value;
                string annotationNamespace = annotation.NamespaceUri;
                string annotationName = annotation.Name;
                stockModel.SetAnnotationValue(stockAnnotatable, annotationNamespace, annotationName, annotationValue);
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:EdmToStockModelConverter.cs

示例6: Annotate

 public void Annotate(IMetadataElement metadataElement, IEdmElement edmElement, IEdmModel edmModel)
 {
     if (metadataElement is EntityElement || metadataElement is EnumTypeElement)
     {
         var typeName = metadataElement.Identity.Id.Segments.Last();
         var clrType = _clrTypes.SingleOrDefault(x => x.Name.Equals(typeName, StringComparison.OrdinalIgnoreCase));
         if (clrType != null)
         {
             edmModel.SetAnnotationValue(edmElement, new ClrTypeAnnotation(clrType));
         }
     }
 }
开发者ID:2gis,项目名称:nuclear-river,代码行数:12,代码来源:EdmModelAnnotator.cs

示例7: Annotate

        public void Annotate(IMetadataElement metadataElement, IEdmElement edmElement, IEdmModel edmModel)
        {
            if (metadataElement is EntityElement || metadataElement is EnumTypeElement)
            {
                edmModel.SetAnnotationValue(edmElement, AnnotationNamespace, AnnotationAttribute, metadataElement.Identity.Id);

                var clrType = _clrTypeProvider.Get(metadataElement.Identity);
                if (clrType != null)
                {
                    edmModel.SetAnnotationValue(edmElement, new ClrTypeAnnotation(clrType));
                }
            }
        }
开发者ID:2gis,项目名称:nuclear-river,代码行数:13,代码来源:EdmModelAnnotator.cs

示例8: GetODataAnnotations

        /// <summary>
        /// Gets all the serializable annotations in the OData metadata namespace on the <paramref name="annotatable"/>.
        /// </summary>
        /// <param name="model">The <see cref="IEdmModel"/> containing the annotations."/></param>
        /// <param name="annotatable">The <see cref="IEdmElement"/> to get the annotations from.</param>
        /// <returns>All annotations in the OData metadata namespace; or null if no annotations are found.</returns>
        internal static IEnumerable<IEdmDirectValueAnnotation> GetODataAnnotations(this IEdmModel model, IEdmElement annotatable)
        {
            Debug.Assert(model != null, "model != null");
            Debug.Assert(annotatable != null, "annotatable != null");
            
            IEnumerable<IEdmDirectValueAnnotation> annotations = model.DirectValueAnnotations(annotatable);
            if (annotations == null)
            {
                return null;
            }

            return annotations.Where(a => a.NamespaceUri == AtomConstants.ODataMetadataNamespace);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:19,代码来源:MetadataUtils.cs

示例9: GetMimeType

 public static string GetMimeType(this IEdmModel model, IEdmElement annotatable)
 {
     string str;
     ExceptionUtils.CheckArgumentNotNull<IEdmModel>(model, "model");
     ExceptionUtils.CheckArgumentNotNull<IEdmElement>(annotatable, "annotatable");
     if (!model.TryGetODataAnnotation(annotatable, "MimeType", out str))
     {
         return null;
     }
     if (str == null)
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ODataUtils_NullValueForMimeTypeAnnotation);
     }
     return str;
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:ODataUtils.cs

示例10: SetODataAnnotation

        /// <summary>
        /// Sets the annotation with the OData metadata namespace and the specified <paramref name="localName" /> on the <paramref name="annotatable"/>.
        /// </summary>
        /// <param name="model">The <see cref="IEdmModel"/> containing the annotations."/></param>
        /// <param name="annotatable">The <see cref="IEdmElement"/> to set the annotation on.</param>
        /// <param name="localName">The local name of the annotation to set.</param>
        /// <param name="value">The value of the annotation to set.</param>
        internal static void SetODataAnnotation(this IEdmModel model, IEdmElement annotatable, string localName, string value)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(model != null, "model != null"); 
            Debug.Assert(annotatable != null, "annotatable != null");
            Debug.Assert(!string.IsNullOrEmpty(localName), "!string.IsNullOrEmpty(localName)");

            IEdmStringValue stringValue = null;
            if (value != null)
            {
                IEdmStringTypeReference typeReference = EdmCoreModel.Instance.GetString(/*nullable*/true);
                stringValue = new EdmStringConstant(typeReference, value);
            }

            model.SetAnnotationValue(annotatable, AtomConstants.ODataMetadataNamespace, localName, stringValue);
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:23,代码来源:MetadataUtils.cs

示例11: ConvertToStockVocabularyAnnotatable

        private IEdmVocabularyAnnotatable ConvertToStockVocabularyAnnotatable(IEdmElement edmAnnotatable, EdmModel stockModel)
        {
            // TODO: Need to provide a better way to get more details on IEdmVocabularyAnnotation.Target.
            IEdmVocabularyAnnotatable stockAnnotatable = null;
            if (edmAnnotatable is IEdmEntityType)
            {
                var edmEntityType = edmAnnotatable as IEdmEntityType;
                stockAnnotatable = stockModel.FindType(edmEntityType.FullName()) as IEdmVocabularyAnnotatable;
                ExceptionUtilities.CheckObjectNotNull(stockAnnotatable, "The FindType method must be successful.");
            }
            else if (edmAnnotatable is IEdmProperty)
            {
                var edmProperty = edmAnnotatable as IEdmProperty;
                if (edmProperty.DeclaringType is IEdmSchemaElement)
                {
                    var stockSchemaElement = stockModel.FindType(((IEdmSchemaElement)edmProperty.DeclaringType).FullName());
                    ExceptionUtilities.CheckObjectNotNull(stockAnnotatable, "The FindType method must be successful.");
                    stockAnnotatable = ((IEdmStructuredType)stockSchemaElement).FindProperty(edmProperty.Name);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            else if (edmAnnotatable is IEdmEntitySet)
            {
                var edmEntitySet = edmAnnotatable as IEdmEntitySet;
                // TODO: No backpointer to the Entity Container from EntitySet in the API. Is this OK?
                stockAnnotatable = stockModel.EntityContainer.EntitySets().Single(m => m.Name == edmEntitySet.Name);
            }
            else if (edmAnnotatable is IEdmEnumType)
            {
                var edmEnumType = edmAnnotatable as IEdmEnumType;
                stockAnnotatable = stockModel.FindType(edmEnumType.FullName());
            }
            else
            {
                throw new NotImplementedException();
            }

            return stockAnnotatable;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:42,代码来源:EdmToStockModelConverter.cs

示例12: GetDirectValueAnnotations

        /// <summary>
        /// Gets annotations associated with an element.
        /// </summary>
        /// <param name="element">The annotated element.</param>
        /// <returns>The immediate value annotations for the element.</returns>
        public IEnumerable<IEdmDirectValueAnnotation> GetDirectValueAnnotations(IEdmElement element)
        {
            // Fetch the annotations dictionary once and only once, because this.annotationsDictionary might get updated by another thread.
            VersioningDictionary<IEdmElement, object> annotationsDictionary = this.annotationsDictionary;

            IEnumerable<IEdmDirectValueAnnotation> immutableAnnotations = this.GetAttachedAnnotations(element);
            object transientAnnotations = GetTransientAnnotations(element, annotationsDictionary);

            if (immutableAnnotations != null)
            {
                foreach (IEdmDirectValueAnnotation existingAnnotation in immutableAnnotations)
                {
                    if (!IsDead(existingAnnotation.NamespaceUri, existingAnnotation.Name, transientAnnotations))
                    {
                        yield return existingAnnotation;
                    }
                }
            }

            foreach (IEdmDirectValueAnnotation existingAnnotation in TransientAnnotations(transientAnnotations))
            {
                yield return existingAnnotation;
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:29,代码来源:EdmDirectValueAnnotationsManager.cs

示例13: TryGetODataAnnotation

        /// <summary>
        /// Returns the annotation in the OData metadata namespace with the specified <paramref name="localName" />.
        /// </summary>
        /// <param name="model">The <see cref="IEdmModel"/> containing the annotation.</param>
        /// <param name="annotatable">The <see cref="IEdmElement"/> to get the annotation from.</param>
        /// <param name="localName">The local name of the annotation to find.</param>
        /// <param name="value">The value of the annotation in the OData metadata namespace and with the specified <paramref name="localName"/>.</param>
        /// <returns>true if an annotation with the specified local name was found; otherwise false.</returns>
        internal static bool TryGetODataAnnotation(this IEdmModel model, IEdmElement annotatable, string localName, out string value)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(model != null, "model != null"); 
            Debug.Assert(annotatable != null, "annotatable != null");
            Debug.Assert(!string.IsNullOrEmpty(localName), "!string.IsNullOrEmpty(localName)");

            object annotationValue = model.GetAnnotationValue(annotatable, AtomConstants.ODataMetadataNamespace, localName);
            if (annotationValue == null)
            {
                value = null;
                return false;
            }

            IEdmStringValue annotationStringValue = annotationValue as IEdmStringValue;
            if (annotationStringValue == null)
            {
                // invalid annotation type found
                throw new ODataException(Strings.ODataAtomWriterMetadataUtils_InvalidAnnotationValue(localName, annotationValue.GetType().FullName));
            }

            value = annotationStringValue.Value;
            return true;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:32,代码来源:MetadataUtils.cs

示例14: GetDirectValueAnnotations

 public IEnumerable<IEdmDirectValueAnnotation> GetDirectValueAnnotations(IEdmElement element)
 {
     throw new NotImplementedException();
 }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:4,代码来源:ODataEntityTypeSerializerTests.cs

示例15: SetAnnotationValue

 public void SetAnnotationValue(IEdmElement element, string namespaceName, string localName, object value)
 {
     annotations[CreateKey(element, namespaceName, localName)] = value;
 }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:4,代码来源:ODataEntityTypeSerializerTests.cs


注:本文中的IEdmElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。