Esempio n. 1
0
        private static bool IsValid(this PropertyInfo info)
        {
            var isValid = info.AccessModifier() == AccessModifier.Public && !ReservedPropertyNames.Contains(info.Name);

            if (!isValid)
            {
                return(false);
            }
            if (typeof(IEnumerable).IsAssignableFrom(info.PropertyType))
            {
                return(true);
            }

            if (info.PropertyType.IsInterface || info.PropertyType.IsAbstract)
            {
                return(false);
            }
            return(!(typeof(IEnumerable).IsAssignableFrom(info.PropertyType) && info.PropertyType != typeof(string)));
        }
Esempio n. 2
0
        private static IEnumerable <PropertyInfo> PublicProperties(this Type type)
        {
            return(type.Properties(Flags.AllMembers)
                   .Where(info => {
                if (info.PropertyType.IsValueType || info.PropertyType == typeof(string))
                {
                    return info.CanRead && info.CanWrite;
                }

                return true;
            })
                   .Where(info => info.AccessModifier() == AccessModifier.Public && !ReservedPropertyNames.Contains(info.Name) && !typeof(ICollection).IsAssignableFrom(info.PropertyType))
                   .Where(info => {
                if (info.PropertyType == typeof(string) || info.PropertyType.IsNullableType())
                {
                    return true;
                }
                return !info.PropertyType.IsGenericType && info.PropertyType != type &&
                info.PropertyType != typeof(object) && ReservedPropertyTypes.Any(_ => info.PropertyType != _);
            })
                   .DistinctBy(info => info.Name));
        }
        /// <summary>
        /// Creates an unparented ProjectPropertyElement, wrapping an unparented XmlElement.
        /// Validates name.
        /// Caller should then ensure the element is added to the XmlDocument in the appropriate location.
        /// </summary>
        internal static ProjectPropertyElement CreateDisconnected(string name, ProjectRootElement containingProject)
        {
            XmlUtilities.VerifyThrowArgumentValidElementName(name);

            ErrorUtilities.VerifyThrowInvalidOperation(XMakeElements.IllegalItemPropertyNames[name] == null && !ReservedPropertyNames.IsReservedProperty(name), "OM_CannotCreateReservedProperty", name);

            XmlElementWithLocation element = containingProject.CreateElement(name);

            return(new ProjectPropertyElement(element, containingProject));
        }