Exemplo n.º 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);
            }
Exemplo n.º 2
0
            private static IPropertyAdapter GetKeyProperty(Type type)
            {
                string propertyName = DictionaryKeyPropertyAttribute.GetPropertyName(type);

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