public void CreatePropertyFinder()
        {
            IPropertyFinder finder = BindableObjectMetadataFactory.Create().CreatePropertyFinder(typeof(TestClass));

            Assert.That(finder.GetType(), Is.SameAs(typeof(ReflectionBasedPropertyFinder)));
            Assert.That(new List <IPropertyInformation> (finder.GetPropertyInfos())[0].DeclaringType, Is.SameAs(TypeAdapter.Create(typeof(TestClass))));
        }
Exemple #2
0
        protected IEnumerable <PropertyBase> GetProperties()
        {
            IPropertyFinder propertyFinder = _metadataFactory.CreatePropertyFinder(_concreteType);

            Dictionary <string, PropertyBase> propertiesByName = new Dictionary <string, PropertyBase>();

            foreach (IPropertyInformation propertyInfo in propertyFinder.GetPropertyInfos())
            {
                PropertyReflector propertyReflector = _metadataFactory.CreatePropertyReflector(_concreteType, propertyInfo, _businessObjectProvider);
                PropertyBase      property          = propertyReflector.GetMetadata();
                if (propertiesByName.ContainsKey(property.Identifier))
                {
                    string message = string.Format(
                        "Type '{0}' has two properties called '{1}', this is currently not supported.",
                        TargetType.FullName,
                        property.Identifier);
                    throw new NotSupportedException(message);
                }
                else
                {
                    propertiesByName.Add(property.Identifier, property);
                }
            }

            return(propertiesByName.Values);
        }