public void GetAnnotation_ChildAnnotationFromInstance_ResultIsAnnotationAttribute(String name, String display, String remarks) { AnnotationAttribute actual = (new TestStructWtithAnnotation()).GetAnnotation(name); Assert.That(actual, Is.Not.Null); Assert.That(actual.Display, Is.EqualTo(display)); Assert.That(actual.Remarks, Is.EqualTo(remarks)); }
public void GetAnnotation_StructAnnotationFromInstance_ResultIsAnnotationAttribute() { AnnotationAttribute actual = (new TestStructWtithAnnotation()).GetAnnotation(); Assert.That(actual, Is.Not.Null); Assert.That(actual.Display, Is.EqualTo(TestStructDisplay)); Assert.That(actual.Remarks, Is.EqualTo(TestStructRemarks)); }
public void GetAnnotation_ClassAnnotationFromTypeof_ResultIsAnnotationAttribute() { AnnotationAttribute actual = typeof(TestClassWtithAnnotation).GetAnnotation(); Assert.That(actual, Is.Not.Null); Assert.That(actual.Display, Is.EqualTo(TestClassDisplay)); Assert.That(actual.Remarks, Is.EqualTo(TestClassRemarks)); }
public void TestEquality() { var value = new AnnotationAttribute("value"); Assert.AreEqual(AnnotationAttribute.Value, value, "AreEqual"); Assert.IsTrue(AnnotationAttribute.Value.Equals(value), ".Equals"); Assert.IsTrue(value == AnnotationAttribute.Value, "value == value"); Assert.IsTrue(AnnotationAttribute.PrivateValue != AnnotationAttribute.SharedValue, "value.priv != value.shared"); Assert.IsFalse(AnnotationAttribute.Value.Equals((object)null), "value.Equals ((object) null)"); Assert.IsFalse(AnnotationAttribute.Value.Equals((AnnotationAttribute)null), "value.Equals ((AnnotationAttribute) null)"); Assert.IsFalse(AnnotationAttribute.Value == null, "value == null"); Assert.IsTrue(AnnotationAttribute.Value != null, "/comment != null"); }
private IEnumerable <CommonSubset> GetDataSource() { List <CommonSubset> result = new List <CommonSubset>(); foreach (CommonType current in Enum.GetValues(typeof(CommonType))) { AnnotationAttribute attribute = current.GetAnnotation <CommonType>(); if (attribute == null || !attribute.Visible) { continue; } result.Add(new CommonSubset(current, attribute)); } return(result); }
public CommonSubset(CommonType type, AnnotationAttribute source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } this.Display = source.Display; this.Remarks = source.Remarks; this.Type = type; this.IsLengthEnabled = this.GetLengthEnabled(type); this.IsAmountEnabled = this.GetAmountEnabled(type); this.IsPhraseEnabled = this.GetPhraseEnabled(type); this.LengthMinimum = this.GetLengthMinimum(type); this.LengthMaximum = this.GetLengthMaximum(type); this.LengthValue = this.GetLengthValue(type); this.IsPoolsEnabled = this.GetPoolsEnabled(type); }
public void TestBasicFunctionality() { AnnotationAttribute attr; attr = new AnnotationAttribute("value"); Assert.AreEqual("value", attr.Name, "Name"); Assert.AreEqual("value", attr.Specifier, "Specifier"); Assert.AreEqual(AnnotationScope.Both, attr.Scope, "Scope"); attr = new AnnotationAttribute("value.priv"); Assert.AreEqual("value", attr.Name, "Name"); Assert.AreEqual("value.priv", attr.Specifier, "Specifier"); Assert.AreEqual(AnnotationScope.Private, attr.Scope, "Scope"); attr = new AnnotationAttribute("value.shared"); Assert.AreEqual("value", attr.Name, "Name"); Assert.AreEqual("value.shared", attr.Specifier, "Specifier"); Assert.AreEqual(AnnotationScope.Shared, attr.Scope, "Scope"); }
/// <summary> /// Initializes a new instance of the <see cref="MailKit.Search.OrderByAnnotation"/> class. /// </summary> /// <param name="entry">The annotation entry to sort by.</param> /// <param name="attribute">The annotation attribute to use for sorting.</param> /// <param name="order">The sort order.</param> /// <exception cref="System.ArgumentNullException"> /// <para><paramref name="entry"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><paramref name="attribute"/>is <c>null</c>.</para> /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="attribute"/> is not a valid attribute for sorting. /// </exception> public OrderByAnnotation(AnnotationEntry entry, AnnotationAttribute attribute, SortOrder order) : base(OrderByType.Annotation, order) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (attribute.Name != "value" || attribute.Scope == AnnotationScope.Both) { throw new ArgumentException("Only the \"value.priv\" and \"value.shared\" attributes can be used for sorting.", nameof(attribute)); } Entry = entry; Attribute = attribute; }
public static object Load(Type clrType, Type dataContractType, AnnotationAttribute annotation) { if (annotation != null && annotation.ExportXmlDoc) { XElement element = Load(string.Concat("T:", clrType.FullName), dataContractType); if (element != null) { element.AddFirst(annotation.Annotation); } return(annotation.ExportAsText ? (object)element.ToString() : new Annotation(element)); } else if (annotation != null && annotation.ExportXmlDoc == false) { return(annotation.Annotation); } else { return(new Annotation(Load(string.Concat("T:", clrType.FullName), dataContractType))); } }
public static object Load(MemberInfo memberInfo, Type dataContractType, AnnotationAttribute annotation) { if (annotation != null && annotation.ExportXmlDoc) { XElement element = Load(CreateMemberName(memberInfo), memberInfo.DeclaringType); if (element != null) { element.AddFirst(annotation.Annotation); } return(annotation.ExportAsText ? (object)element.ToString() : new Annotation(element)); } else if (annotation != null && annotation.ExportXmlDoc == false) { return(annotation.Annotation); } else { return(new Annotation(Load(CreateMemberName(memberInfo), memberInfo.DeclaringType))); } }
/// <summary> /// Initializes a new instance of the <see cref="T:MailKit.Search.AnnotationSearchQuery"/> class. /// </summary> /// <remarks> /// Creates a new annotation-based search query. /// </remarks> /// <param name="entry">The annotation entry.</param> /// <param name="attribute">The annotation attribute.</param> /// <param name="value">The annotation attribute value.</param> /// <exception cref="System.ArgumentNullException"> /// <para><paramref name="entry"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><paramref name="attribute"/> is <c>null</c>.</para> /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="attribute"/> is not a valid attribute for searching. /// </exception> public AnnotationSearchQuery(AnnotationEntry entry, AnnotationAttribute attribute, string value) : base(SearchTerm.Annotation) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } if (attribute.Name != "value") { throw new ArgumentException("Only the \"value\", \"value.priv\", and \"value.shared\" attributes can be searched.", nameof(attribute)); } Attribute = attribute; Entry = entry; Value = value; }
private static bool TryGetAttribute(AttributeData attributeData, out AnnotationAttribute attribute) { var @namespace = attributeData.AttributeClass.ContainingNamespace.ToDisplayString(); if ([email protected]("JetBrains.Annotations")) { attribute = null; return false; } var arguments = attributeData.ConstructorArguments .Select(GetArgumentValue) .ToImmutableArray(); var constructor = attributeData.AttributeConstructor.GetDocumentationCommentId(); attribute = new AnnotationAttribute(constructor, arguments); return true; }
private static XElement CreateAttributeElement(AnnotationAttribute attribute) { var arguments = attribute.Arguments .Select(argument => new XElement("argument", argument)) .ToList(); var attributeElement = new XElement("attribute", arguments); attributeElement.SetAttributeValue("ctor", attribute.Constructor); return attributeElement; }
/// <summary> /// Match messages with the specified annotation. /// </summary> /// <remarks> /// <para>Matches messages with the specified annotation.</para> /// <note type="warning">This feature is not supported by all IMAP servers.</note> /// </remarks> /// <param name="entry">The annotation entry.</param> /// <param name="attribute">The annotation attribute.</param> /// <param name="value">The annotation attribute value.</param> /// <returns>A <see cref="AnnotationSearchQuery"/>.</returns> /// <exception cref="System.ArgumentNullException"> /// <para><paramref name="entry"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><paramref name="attribute"/> is <c>null</c>.</para> /// </exception> /// <exception cref="System.ArgumentException"> /// <paramref name="attribute"/> is not a valid attribute for searching. /// </exception> public static AnnotationSearchQuery AnnotationsContain(AnnotationEntry entry, AnnotationAttribute attribute, string value) { return(new AnnotationSearchQuery(entry, attribute, value)); }