1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation
9 using System.Collections.Generic;
12 internal static class PropertyReferenceUtilities
14 public static string GetPropertyReference(object instance, string targetProperty)
16 Fx.Assert(instance != null, "instance should not be null.");
17 Fx.Assert(!string.IsNullOrEmpty(targetProperty), "targetProperty should not be null or empty.");
19 IList<ActivityPropertyReference> references = ActivityBuilder.GetPropertyReferences(instance);
21 Fx.Assert(references != null, "references should not be null");
23 foreach (ActivityPropertyReference reference in references)
25 if (StringComparer.Ordinal.Equals(reference.TargetProperty, targetProperty))
27 return reference.SourceProperty;
34 public static void SetPropertyReference(object instance, string targetProperty, string sourceProperty)
36 Fx.Assert(instance != null, "instance should not be null.");
37 Fx.Assert(!string.IsNullOrEmpty(targetProperty), "targetProperty should not be null or empty.");
39 ActivityPropertyReference entry = null;
40 IList<ActivityPropertyReference> references = ActivityBuilder.GetPropertyReferences(instance);
42 Fx.Assert(references != null, "references should not be null");
44 foreach (ActivityPropertyReference reference in references)
46 if (StringComparer.Ordinal.Equals(reference.TargetProperty, targetProperty))
53 if (string.IsNullOrEmpty(sourceProperty))
57 references.Remove(entry);
64 entry.SourceProperty = sourceProperty;
68 entry = new ActivityPropertyReference();
69 entry.TargetProperty = targetProperty;
70 entry.SourceProperty = sourceProperty;
71 references.Add(entry);