Esempio n. 1
0
        /// <summary>
        /// Creates a new <see cref="ModelAttributes"/>.
        /// </summary>
        /// <param name="typeAttributes">
        /// If this instance represents a type, the set of attributes for that type.
        /// If this instance represents a property, the set of attributes for the property's <see cref="Type"/>.
        /// Otherwise, <c>null</c>.
        /// </param>
        /// <param name="propertyAttributes">
        /// If this instance represents a property, the set of attributes for that property.
        /// Otherwise, <c>null</c>.
        /// </param>
        /// <param name="parameterAttributes">
        /// If this instance represents a parameter, the set of attributes for that parameter.
        /// Otherwise, <c>null</c>.
        /// </param>
        public ModelAttributes(IEnumerable <object> typeAttributes, IEnumerable <object> propertyAttributes, IEnumerable <object> parameterAttributes)
        {
            if (propertyAttributes != null)
            {
                // Represents a property
                if (typeAttributes == null)
                {
                    throw new ArgumentNullException(nameof(typeAttributes));
                }

                PropertyAttributes = propertyAttributes.ToArray();
                TypeAttributes     = typeAttributes.ToArray();
                Attributes         = PropertyAttributes.Concat(TypeAttributes).ToArray();
            }
            else if (parameterAttributes != null)
            {
                // Represents a parameter
                Attributes = ParameterAttributes = parameterAttributes.ToArray();
            }
            else if (typeAttributes != null)
            {
                // Represents a type
                if (typeAttributes == null)
                {
                    throw new ArgumentNullException(nameof(typeAttributes));
                }

                Attributes = TypeAttributes = typeAttributes.ToArray();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new <see cref="ModelAttributes"/> for a property.
        /// </summary>
        /// <param name="propertyAttributes">The set of attributes for the property.</param>
        /// <param name="typeAttributes">
        /// The set of attributes for the property's <see cref="Type"/>. See <see cref="PropertyInfo.PropertyType"/>.
        /// </param>
        public ModelAttributes(IEnumerable <object> propertyAttributes, IEnumerable <object> typeAttributes)
        {
            PropertyAttributes = propertyAttributes?.ToArray()
                                 ?? throw new ArgumentNullException(nameof(propertyAttributes));

            TypeAttributes = typeAttributes?.ToArray()
                             ?? throw new ArgumentNullException(nameof(typeAttributes));

            Attributes = PropertyAttributes.Concat(TypeAttributes).ToArray();
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new <see cref="ModelAttributes"/> for a property.
 /// </summary>
 /// <param name="propertyAttributes">The set of attributes for the property.</param>
 /// <param name="typeAttributes">
 /// The set of attributes for the property's <see cref="Type"/>. See <see cref="PropertyInfo.PropertyType"/>.
 /// </param>
 public ModelAttributes([NotNull] IEnumerable <object> propertyAttributes, [NotNull] IEnumerable <object> typeAttributes)
 {
     PropertyAttributes = propertyAttributes.ToArray();
     TypeAttributes     = typeAttributes.ToArray();
     Attributes         = PropertyAttributes.Concat(TypeAttributes).ToArray();
 }