Exemplo n.º 1
0
        /// <summary>
        /// Determines a type (e.g. class, enum, typedef) as if it was used directly at a certain position in the code
        /// (i.e. from the type definition's perspective). Consider the following C# code example:
        ///
        /// <code>
        /// namespace MyNamespace {
        ///   public class MyClass {
        ///   }
        ///
        ///   public class MySecondClass {
        ///     public MyClass MyVar; // Using MyClass
        ///   }
        ///
        ///   public class MyThirdClass {
        ///     public MyClass MyVar; // Using MyClass
        ///
        ///     public class MyClass {
        ///     }
        ///   }
        /// }
        /// </code>
        ///
        /// The type returned for <c>MyClass</c> will be different depending on where the type is used.
        /// If it's used by <c>MySecondClass</c> it's the first class <c>MyClass</c>. If it's used
        /// by <c>MyThirdClass</c> it's the inner class.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">the name of the type. Can be fully qualified (i.e. with namespace and surrounding
        /// class).</param>
        /// <param name="raiseException">indicates whether an exception is to be thrown when the type can't
        /// be found. If this is <c>false</c>, an instance of <see cref="DefInternal"/> will be returned when
        /// the type couldn't be found.</param>
        /// <returns></returns>
        public virtual T DetermineType <T>(string name, bool raiseException = true) where T : AbstractTypeDefinition
        {
            if (name.StartsWith(this.MetaDef.NativeNamespace + "::"))
            {
                name = name.Substring(name.IndexOf("::") + 2);
                return(Namespace.DetermineType <T>(name, raiseException));
            }

            return((IsNested) ? SurroundingClass.DetermineType <T>(name, raiseException) : Namespace.DetermineType <T>(name, raiseException));
        }
        public override void PostProcessAttributes(AttributeSet holder)
        {
            ClassDefinition type = (ClassDefinition)holder;

            foreach (string[] names in _interfaceNames)
            {
                List <ClassDefinition> ifaces = new List <ClassDefinition>();
                foreach (string ifacename in names)
                {
                    ifaces.Add(type.DetermineType <ClassDefinition>(ifacename));
                }
                Interfaces.Add(ifaces.ToArray());
            }
        }