1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation.ViewState
9 using System.Diagnostics.CodeAnalysis;
14 /// Class defining ViewStateManager and ViewStateId attached properties.
16 public static class WorkflowViewState
19 /// Attachable property for ViewStateManager
21 [SuppressMessage(FxCop.Category.Security, FxCop.Rule.DoNotDeclareReadOnlyMutableReferenceTypes, Justification = "XAML attached property declaration.")]
22 public static readonly AttachableMemberIdentifier ViewStateManagerProperty = new AttachableMemberIdentifier(typeof(WorkflowViewState), "ViewStateManager");
25 /// Attachable property for IdRef
27 [SuppressMessage(FxCop.Category.Security, FxCop.Rule.DoNotDeclareReadOnlyMutableReferenceTypes, Justification = "XAML attached property declaration.")]
28 public static readonly AttachableMemberIdentifier IdRefProperty = new AttachableMemberIdentifier(typeof(WorkflowViewState), "IdRef");
31 /// Set ViewStateManager as an attached property on an object. This method is for XAML serialization purpose only and is not expected to be used by developers.
33 /// <param name="instance">Instance object to attach ViewStateManager property on</param>
34 /// <param name="viewStateManager">ViewStateManager object to attach</param>
35 public static void SetViewStateManager(object instance, ViewStateManager viewStateManager)
37 AttachablePropertyServices.SetProperty(instance, ViewStateManagerProperty, viewStateManager);
41 /// Get ViewStateManager attached property value from an object if set
43 /// <param name="instance">Instance object to retrieve ViewStateManager attached property from</param>
44 /// <returns>ViewStateManager object if set; null otherise</returns>
45 public static ViewStateManager GetViewStateManager(object instance)
47 ViewStateManager viewStateManager;
48 if (AttachablePropertyServices.TryGetProperty(instance, ViewStateManagerProperty, out viewStateManager))
50 return viewStateManager;
57 /// Set IdRef as an attached property on an object. This method is for XAML serialization purpose only and is not expected to be used by developers.
59 /// <param name="instance">Instance object to attach IdRef property on</param>
60 /// <param name="idRef">refId value to attach</param>
61 public static void SetIdRef(object instance, string idRef)
63 AttachablePropertyServices.SetProperty(instance, IdRefProperty, idRef);
67 /// Get RefId attached property value from an object if set
69 /// <param name="instance">Instance object to retrieve RefId attached property from</param>
70 /// <returns>RefId value if set; null otherise</returns>
71 public static string GetIdRef(object instance)
74 if (AttachablePropertyServices.TryGetProperty(instance, IdRefProperty, out idRef))