Пример #1
0
        IEnumerable <XamlMember> DoLookupAllMembers()
        {
            // This is a hack that is likely required due to internal implementation difference in System.Uri. Our Uri has two readonly collection properties
            if (ReferenceEquals(this, XamlLanguage.Uri))
            {
                yield break;
            }

            //var bf = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;

            foreach (var pi in UnderlyingType.GetRuntimeProperties())
            {
                if (pi.GetPrivateGetMethod()?.IsStatic ?? pi.GetPrivateSetMethod()?.IsStatic ?? false)
                {
                    continue;
                }
                if (pi.Name.Contains("."))                 // exclude explicit interface implementations.
                {
                    continue;
                }
                if (                /*pi.CanRead &&*/
                    (
                        pi.CanWrite ||
                        IsCollectionType(pi.PropertyType)
#if NETSTANDARD1_0
                        || (ReflectionHelpers.IXmlSerializableType?.GetTypeInfo().IsAssignableFrom(pi.PropertyType.GetTypeInfo()) ?? false)
#else
                        || typeof(IXmlSerializable).GetTypeInfo().IsAssignableFrom(pi.PropertyType.GetTypeInfo())
#endif
                        || pi.GetCustomAttribute <ConstructorArgumentAttribute>() != null
                    ) &&
                    pi.GetIndexParameters().Length == 0)
                {
                    yield return(SchemaContext.GetProperty(pi));
                }
            }
            foreach (var ei in UnderlyingType.GetRuntimeEvents())
            {
                yield return(SchemaContext.GetEvent(ei));
            }
        }