NuGet.TypeHelper.IsMultiValuedProperty C# (CSharp) Method

IsMultiValuedProperty() public static method

public static IsMultiValuedProperty ( PropertyInfo property ) : bool
property System.Reflection.PropertyInfo
return bool
        public static bool IsMultiValuedProperty(PropertyInfo property)
        {
            return GetGenericCollectionType(property.PropertyType) != null || IsKeyValueProperty(property);
        }
    }

Usage Example

Exemplo n.º 1
0
        public IDictionary <OptionAttribute, PropertyInfo> GetCommandOptions(ICommand command)
        {
            var result = new Dictionary <OptionAttribute, PropertyInfo>();

            foreach (PropertyInfo propInfo in command.GetType().GetProperties())
            {
                if (!command.IncludedInHelp(propInfo.Name))
                {
                    continue;
                }

                foreach (OptionAttribute attr in propInfo.GetCustomAttributes(typeof(OptionAttribute), inherit: true))
                {
                    if (!propInfo.CanWrite && !TypeHelper.IsMultiValuedProperty(propInfo))
                    {
                        // If the property has neither a setter nor is of a type that can be cast to ICollection<> then there's no way to assign
                        // values to it. In this case throw.
                        throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                          LocalizedResourceManager.GetString("OptionInvalidWithoutSetter"), command.GetType().FullName + "." + propInfo.Name));
                    }
                    result.Add(attr, propInfo);
                }
            }

            return(result);
        }
All Usage Examples Of NuGet.TypeHelper::IsMultiValuedProperty