public static void CheckAndFillUpHolder(AnnotatedItem item, ICommonNamesStorage commonNamesStorage) { if (item.Holder == null) { item.Holder = commonNamesStorage.DefaultHolder; } }
/// <summary> /// Removes an annotation of type T from a property. /// </summary> /// <param name="property">The property.</param> private static void RemoveVirtualAnnotationFromProperty(AnnotatedItem property) { foreach (var annotation in property.Annotations.OfType <VirtualAnnotation>().ToArray()) { property.Annotations.Remove(annotation); } }
/// <summary> /// Marks the given item as being type-backed. /// </summary> /// <param name="annotatedItem">The annotated item</param> public static void MakeTypeBacked(this AnnotatedItem annotatedItem) { if (!annotatedItem.IsTypeBacked()) { annotatedItem.Annotations.Add(new TypeBackedAnnotation()); } }
/// <summary> /// Parses an annotation element/attribute in the csdl/ssdl file. /// </summary> /// <param name="annotatedItem">the annotated item to add annotations to</param> /// <param name="xmlElement">the element to parse</param> protected void ParseAnnotations(AnnotatedItem annotatedItem, XElement xmlElement) { foreach (XElement element in xmlElement.Elements()) { if (this.IsXsdlElement(element, "Documentation")) { annotatedItem.Annotations.Add(this.ParseDocumentationAnnotation(element)); continue; } if (!this.IsXsdlNamespace(element.Name.NamespaceName)) { annotatedItem.Annotations.Add(new StructuralAnnotation { Content = element }); } } foreach (XAttribute attrib in xmlElement.Attributes()) { if (attrib.Name.NamespaceName == EdmConstants.CodegenNamespace) { continue; } if (!string.IsNullOrEmpty(attrib.Name.NamespaceName)) { annotatedItem.Annotations.Add(new AttributeAnnotation { Content = attrib }); continue; } } }
private static void FillAnnotationsModalitiesAndSections(AnnotatedItem source, AnnotatedItem dest, Dictionary <object, object> convertingContext) { if (dest.WhereSection == null) { dest.WhereSection = new List <Value>(); } if (!source.WhereSection.IsNullOrEmpty()) { foreach (var item in source.WhereSection) { dest.WhereSection.Add(item); } } dest.Holder = source.Holder; if (!source.Annotations.IsNullOrEmpty()) { dest.Annotations = new List <RuleInstance>(); var destAnnotationsList = dest.Annotations; foreach (var sourceAnnotation in source.Annotations) { var destAnnotation = Convert(sourceAnnotation, convertingContext); destAnnotationsList.Add(destAnnotation); } } }
/// <summary> /// Annotates a property with Annotation of type T /// </summary> /// <param name="property">The property.</param> private static void AnnotatePropertyAsVirtual(AnnotatedItem property) { if (!property.Annotations.Any(a => a is VirtualAnnotation)) { property.Annotations.Add(new VirtualAnnotation()); } }
protected void CompilePushAnnotation(AnnotatedItem annotatedItem) { var command = new IntermediateScriptCommand(); command.OperationCode = OperationCode.PushVal; command.Value = annotatedItem.GetAnnotationValue(); AddCommand(command); }
/// <summary> /// Converts mime type annotations from xml annotation to MimeType annotation /// </summary> /// <param name="annotatedItem">item to convert annotation on</param> private void ConvertMimeTypeAnnotations(AnnotatedItem annotatedItem) { ExceptionUtilities.CheckArgumentNotNull(annotatedItem, "annotatedItem"); var mimeTypeAnnotation = annotatedItem.Annotations.OfType <AttributeAnnotation>() .Where(ann => ann.Content.Name.LocalName.Equals("MimeType", StringComparison.OrdinalIgnoreCase)).SingleOrDefault(); if (mimeTypeAnnotation != null) { annotatedItem.Add(new MimeTypeAnnotation(mimeTypeAnnotation.Content.Value)); } }
private static void AddAnnotationIfDoesntExist(AnnotatedItem payload, AttributeAnnotation annotation) { var exists = payload.Annotations.OfType <AttributeAnnotation>().Any(a => { ExceptionUtilities.CheckObjectNotNull(a.Content, "Content expected for attribute"); return(a.Content.Name.Equals(annotation.Content.Name)); }); if (!exists) { payload.Annotations.Add(annotation); } }
public static void SetUpAnnotatedItem(AnnotatedItem item, DefaultSettingsOfCodeEntity defaultSettings, Dictionary <object, object> context) { if (defaultSettings == null) { return; } if (item.WhereSection.IsNullOrEmpty() && !defaultSettings.WhereSection.IsNullOrEmpty()) { item.WhereSection = defaultSettings.WhereSection.Select(p => p.CloneValue(context)).ToList(); } if (item.Holder == null && defaultSettings.Holder != null) { item.Holder = defaultSettings.Holder.Clone(context); } }
static void AddAnnotationTo(AnnotatedItem item, string annotation) { if (item.ManagedInfo.PropertyObject != null) { item.ManagedInfo.PropertyObject.Value().Annotation += annotation; } else if (item.ManagedInfo.MethodObject != null) { if (item.ParameterIndex < 0) { item.ManagedInfo.MethodObject.Value().Annotation += annotation; } else { item.ManagedInfo.MethodObject.Value().Parameters[item.ParameterIndex].Annotation += annotation; } } }
private void ConvertAnnotations(AnnotatedItem annotatedItem) { for (int index = 0; index < annotatedItem.Annotations.Count; index++) { var annotation = annotatedItem.Annotations[index]; var structuralAnnotation = annotation as StructuralAnnotation; if (structuralAnnotation != null) { annotatedItem.Annotations[index] = this.ConvertSingleAnnotation(structuralAnnotation); } var attributeAnnotation = annotation as AttributeAnnotation; if (attributeAnnotation != null) { annotatedItem.Annotations[index] = this.ConvertSingleAnnotation(attributeAnnotation); } } }
public static string AnnotatedItemToString(AnnotatedItem source) { var sb = new StringBuilder(); if (source.HasModalitiesOrSections) { sb.Append(" |:"); if (!source.WhereSection.IsNullOrEmpty()) { sb.Append(" "); sb.Append(WhereSectionToString(source.WhereSection)); } sb.Append(" :|"); } return(sb.ToString()); }
private static void AddCollectionContractTypeAnnotation(AnnotatedItem item, DataType dataType) { var collectionDataType = dataType as CollectionDataType; if (collectionDataType != null) { if (collectionDataType.ElementDataType is PrimitiveDataType) { item.Annotations.Add(new CollectionContractTypeAnnotation() { FullTypeName = "IEnumerable", IsGeneric = true }); } else { item.Annotations.Add(new CollectionContractTypeAnnotation() { FullTypeName = "IEnumerable", IsGeneric = true }); } } }
/// <summary> /// Generates the documentation element for given annotated item. /// </summary> /// <param name="xmlNamespace">The XML namespace.</param> /// <param name="annotatedItem">The annotated item.</param> /// <returns>Documentation XElement or null if <see cref="DocumentationAnnotation" /> is not present on the item.</returns> protected virtual XElement GenerateDocumentation(XNamespace xmlNamespace, AnnotatedItem annotatedItem) { var documentationAnnotation = annotatedItem.Annotations.OfType <DocumentationAnnotation>().SingleOrDefault(); if (documentationAnnotation == null) { return(null); } var element = new XElement(xmlNamespace + "Documentation"); if (documentationAnnotation.Summary != null) { element.Add(new XElement(xmlNamespace + "Summary", documentationAnnotation.Summary)); } if (documentationAnnotation.LongDescription != null) { element.Add(new XElement(xmlNamespace + "LongDescription", documentationAnnotation.LongDescription)); } return(element); }
private static bool DoesAnnotationExist <TAnnotation>(this AnnotatedItem metadataItem) { return(metadataItem.Annotations.OfType <TAnnotation>().Any()); }
/// <summary> /// Visits an annotated item /// </summary> /// <param name="item">item to visit</param> protected virtual void VisitAnnotatedItem(AnnotatedItem item) { // do nothing }
public static void SetUpAnnotatedItem(AnnotatedItem item, DefaultSettingsOfCodeEntity defaultSettings) { var context = new Dictionary <object, object>(); SetUpAnnotatedItem(item, defaultSettings, context); }
private static void FillAnnotationsModalitiesAndSections(AnnotatedItem source, AnnotatedItem dest, IMainStorageContext mainStorageContext) { dest.AppendAnnotations(source); }
/// <summary> /// Determines whether a EntityType, ComplexType, NavigationProperty, or MemberProperty are backed by a CLR type on the server /// </summary> /// <param name="annotatedItem">Annotated Item</param> /// <returns>true or false</returns> public static bool IsTypeBacked(this AnnotatedItem annotatedItem) { ExceptionUtilities.CheckArgumentNotNull(annotatedItem, "annotatedItem"); return(DoesAnnotationExist <TypeBackedAnnotation>(annotatedItem)); }