1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.PropertyEditing
8 using System.Collections;
10 [Fx.Tag.XamlVisible(false)]
11 [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
12 public sealed class EditorOptionAttribute : Attribute
14 public string Name { get; set; }
15 public object Value { get; set; }
16 //TypeId is needed so that multiple EditorOptionsAttribute could be added to the same property
17 public override object TypeId
21 return new EditorOptionsAttributeTypeId
23 BaseTypeId = base.TypeId,
30 public static bool TryGetOptionValue(IEnumerable attributes, string optionName, out object optionValue)
32 foreach (Attribute attribute in attributes)
34 EditorOptionAttribute optionAttribute = attribute as EditorOptionAttribute;
35 if (optionAttribute != null && optionAttribute.Name.Equals(optionName))
37 optionValue = optionAttribute.Value;
45 //A class to uniquely identify a name-value pair
46 class EditorOptionsAttributeTypeId
48 public object BaseTypeId { get; set; }
49 public string Name { get; set; }
50 public object Value { get; set; }
52 public override bool Equals(object obj)
54 EditorOptionsAttributeTypeId that = obj as EditorOptionsAttributeTypeId;
55 if (that == null) return false;
56 return this.BaseTypeId == that.BaseTypeId &&
57 string.Equals(this.Name, that.Name) &&
58 object.Equals(this.Value, that.Value);
61 public override int GetHashCode()
64 (BaseTypeId == null ? 0 : BaseTypeId.GetHashCode()) ^
65 (Name == null ? 0 : Name.GetHashCode()) ^
66 (Value == null ? 0 : Value.GetHashCode());