/// <summary>
        /// Creates a wrapper.
        /// </summary>
        /// <param name="policy">The reflection policy.</param>
        /// <param name="elementType">The element type.</param>
        /// <param name="arrayRank">The array rank.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="arrayRank"/> is less than 1.</exception>
        public StaticArrayTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType, int arrayRank)
            : base(policy, elementType)
        {
            if (arrayRank <= 0)
                throw new ArgumentOutOfRangeException("arrayRank", "The array rank must be at least 1.");

            this.arrayRank = arrayRank;
        }
Пример #2
0
        /// <summary>
        /// Creates a wrapper.
        /// </summary>
        /// <param name="policy">The reflection policy.</param>
        /// <param name="elementType">The element type.</param>
        /// <param name="arrayRank">The array rank.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="arrayRank"/> is less than 1.</exception>
        public StaticArrayTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType, int arrayRank)
            : base(policy, elementType)
        {
            if (arrayRank <= 0)
            {
                throw new ArgumentOutOfRangeException("arrayRank", "The array rank must be at least 1.");
            }

            this.arrayRank = arrayRank;
        }
Пример #3
0
        /// <summary>
        /// Applies a type substitution to the specified type.
        /// </summary>
        /// <param name="type">The type to substitute.</param>
        /// <returns>The substituted type.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="type"/> is null.</exception>
        public ITypeInfo Apply(StaticTypeWrapper type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (IsEmpty)
            {
                return(type);
            }

            return(type.ApplySubstitution(this));
        }
Пример #4
0
        /// <summary>
        /// Returns a new substitution formed by composing this substitution with the specified one.
        /// That is to say, each replacement type in this substitution is replaced as described
        /// in the specified substitution.
        /// </summary>
        /// <param name="substitution">The substitution to compose.</param>
        /// <returns>The new substitution.</returns>
        public StaticTypeSubstitution Compose(StaticTypeSubstitution substitution)
        {
            if (substitution.IsEmpty)
            {
                return(this);
            }

            Dictionary <StaticGenericParameterWrapper, ITypeInfo> newReplacements = new Dictionary <StaticGenericParameterWrapper, ITypeInfo>(replacements.Count);

            foreach (KeyValuePair <StaticGenericParameterWrapper, ITypeInfo> entry in replacements)
            {
                StaticTypeWrapper replacementType = entry.Value as StaticTypeWrapper;
                if (replacementType != null)
                {
                    newReplacements.Add(entry.Key, substitution.Apply(replacementType));
                }
                else
                {
                    newReplacements.Add(entry.Key, entry.Value);
                }
            }

            return(new StaticTypeSubstitution(newReplacements));
        }
Пример #5
0
 /// <summary>
 /// Creates a wrapper.
 /// </summary>
 /// <param name="policy">The reflection policy.</param>
 /// <param name="elementType">The element type.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
 public StaticByRefTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType)
     : base(policy, elementType)
 {
 }
 /// <summary>
 /// Creates a wrapper.
 /// </summary>
 /// <param name="policy">The reflection policy.</param>
 /// <param name="elementType">The element type.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
 protected StaticConstructedTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType)
     : base(policy, elementType, null)
 {
 }
 /// <summary>
 /// Creates a wrapper.
 /// </summary>
 /// <param name="policy">The reflection policy.</param>
 /// <param name="elementType">The element type.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
 public StaticPointerTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType)
     : base(policy, elementType)
 {
 }
 /// <summary>
 /// Creates a wrapper.
 /// </summary>
 /// <param name="policy">The reflection policy.</param>
 /// <param name="elementType">The element type.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="policy"/> or <paramref name="elementType" /> is null.</exception>
 protected StaticConstructedTypeWrapper(StaticReflectionPolicy policy, StaticTypeWrapper elementType)
     : base(policy, elementType, null)
 {
 }