1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.Model
8 using System.Collections.Generic;
13 public class AttachedPropertiesService
15 List<AttachedProperty> properties;
17 public AttachedPropertiesService()
19 this.properties = new List<AttachedProperty>();
22 public void AddProperty(AttachedProperty property)
26 throw FxTrace.Exception.AsError(new ArgumentNullException("property"));
28 if (string.IsNullOrEmpty(property.Name))
30 throw FxTrace.Exception.AsError(new ArgumentException(SR.AttachedPropertyNameShouldNotBeEmpty));
32 this.properties.Add(property);
35 internal IEnumerable<AttachedProperty> GetAttachedProperties(Type modelItemType)
37 var properties = from property in this.properties
38 where property.OwnerType.IsAssignableFrom(modelItemType) select property;
40 if (modelItemType.IsGenericType)
42 var propertiesFromGenericRoot = from property in this.properties
43 where property.OwnerType.IsAssignableFrom(modelItemType.GetGenericTypeDefinition())
45 properties = properties.Concat(propertiesFromGenericRoot).Distinct();