示例#1
0
            private static IElementFactory GetDeferredKeyFactory(XamlElement xamlElement)
            {
                Type elementType = xamlElement.GetElementType();

                IDeferredValueKeyProvider provider = DeferredValueKeyProviders.GetDeferredValueKeyProvider(elementType);

                if (provider != null)
                {
                    return(new DeferredKeyFactory(provider, xamlElement));
                }

                string keyPropertyName = DictionaryKeyPropertyAttribute.GetPropertyName(elementType);

                if (!keyPropertyName.IsNullOrWhiteSpace())
                {
                    XamlMember keyMember = xamlElement.Members.FirstOrDefault(member => member.Name.LocalName == keyPropertyName);
                    if (keyMember != null)
                    {
                        IPropertyAdapter keyProperty = PropertyAdapter.CreateAdapter(elementType, keyPropertyName);
                        return(ElementFactory.FromValue(keyMember.Values.Single(), keyProperty.PropertyType, xamlElement.Namespaces, xamlElement.SourceUri));
                    }
                }

                return(null);
            }
        public static IElementInitializer Create(XamlName memberName, Type containingType, IEnumerable <object> values, XamlNamespaces namespaces)
        {
            IEventAdapter eventAdapter = EventAdapter.CreateAdapter(containingType, memberName);

            if (eventAdapter != null)
            {
                return(new ElementEventMemberInitializer(eventAdapter, GetEventHandlerName(memberName, values)));
            }

            IPropertyAdapter propertyAdapter = PropertyAdapter.CreateAdapter(containingType, memberName);

            if (propertyAdapter != null)
            {
                return(ElementPropertyMemberInitializer.Create(propertyAdapter, values, namespaces));
            }

            throw new Granular.Exception("Type \"{0}\" does not contain a member named \"{1}\"", containingType.Name, memberName);
        }
 private static IPropertyAdapter GetKeyProperty(Type type)
 {
     return(PropertyAdapter.CreateAdapter(type, new XamlName(PropertyAttribute.GetPropertyName <DictionaryKeyPropertyAttribute>(type))));
 }
 private static IPropertyAdapter GetNameProperty(Type type)
 {
     return(PropertyAdapter.CreateAdapter(type, new XamlName(PropertyAttribute.GetPropertyName <RuntimeNamePropertyAttribute>(type))));
 }
示例#5
0
            private static IPropertyAdapter GetKeyProperty(Type type)
            {
                string propertyName = DictionaryKeyPropertyAttribute.GetPropertyName(type);

                return(!propertyName.IsNullOrWhiteSpace() ? PropertyAdapter.CreateAdapter(type, propertyName) : null);
            }