1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation.Annotations
9 using System.Diagnostics.CodeAnalysis;
14 /// Annotation class that contains methods to access annotation attached property
16 public static class Annotation
19 /// attachable property for annotation text
21 [SuppressMessage(FxCop.Category.Security, FxCop.Rule.DoNotDeclareReadOnlyMutableReferenceTypes, Justification = "XAML attached property declaration.")]
22 public static readonly AttachableMemberIdentifier AnnotationTextProperty = new AttachableMemberIdentifier(typeof(Annotation), "AnnotationText");
25 /// property name to access annotation in a ModelItem
27 public static readonly string AnnotationTextPropertyName = "AnnotationText";
30 /// property name to access dock annoation view state
32 internal static readonly string IsAnnotationDockedViewStateName = "IsAnnotationDocked";
35 /// Get annotation text of an object
37 /// <param name="instance">instance to get annotation</param>
38 /// <returns>annoation text</returns>
39 public static string GetAnnotationText(object instance)
43 throw FxTrace.Exception.AsError(new ArgumentNullException("instance"));
46 string annotationText;
47 AttachablePropertyServices.TryGetProperty<string>(instance, Annotation.AnnotationTextProperty, out annotationText);
48 return annotationText;
52 /// Set annotation of an object
54 /// <param name="instance">instance to set annotation text</param>
55 /// <param name="annotationText">annoatation text to be set</param>
56 public static void SetAnnotationText(object instance, string annotationText)
60 throw FxTrace.Exception.AsError(new ArgumentNullException("instance"));
63 if (annotationText != null)
65 AttachablePropertyServices.SetProperty(instance, Annotation.AnnotationTextProperty, annotationText);
69 AttachablePropertyServices.RemoveProperty(instance, Annotation.AnnotationTextProperty);