GetType() public static method

public static GetType ( Node node ) : IType
node Node
return IType
Example #1
0
 override public bool IsSubclassOf(IType type)
 {
     foreach (TypeReference baseTypeReference in _typeDefinition.BaseTypes)
     {
         IType baseType = TypeSystemServices.GetType(baseTypeReference);
         if (type == baseType || baseType.IsSubclassOf(type))
         {
             return(true);
         }
     }
     return(_typeSystemServices.IsSystemObject(type));
 }
Example #2
0
        public IType[] GetInterfaces()
        {
            List buffer = new List(_typeDefinition.BaseTypes.Count);

            foreach (TypeReference baseType in _typeDefinition.BaseTypes)
            {
                IType type = TypeSystemServices.GetType(baseType);
                if (type.IsInterface)
                {
                    buffer.AddUnique(type);
                }
            }
            return((IType[])buffer.ToArray(new IType[buffer.Count]));
        }
Example #3
0
        int GetMaxBaseInterfaceDepth()
        {
            int max = 0;

            foreach (TypeReference baseType in _typeDefinition.BaseTypes)
            {
                IType tag   = TypeSystemServices.GetType(baseType);
                int   depth = tag.GetTypeDepth();
                if (depth > max)
                {
                    max = depth;
                }
            }
            return(max);
        }
Example #4
0
        public IEntity GetDefaultMember()
        {
            IType defaultMemberAttribute = _typeSystemServices.Map(Types.DefaultMemberAttribute);

            foreach (Attribute attribute in _typeDefinition.Attributes)
            {
                IConstructor tag = TypeSystemServices.GetEntity(attribute) as IConstructor;
                if (null != tag)
                {
                    if (defaultMemberAttribute == tag.DeclaringType)
                    {
                        StringLiteralExpression memberName = attribute.Arguments[0] as StringLiteralExpression;
                        if (null != memberName)
                        {
                            List buffer = new List();
                            Resolve(buffer, memberName.Value, EntityType.Any);
                            return(NameResolutionService.GetEntityFromList(buffer));
                        }
                    }
                }
            }
            if (_typeDefinition.BaseTypes.Count > 0)
            {
                List buffer = new List();

                foreach (TypeReference baseType in _typeDefinition.BaseTypes)
                {
                    IType   tag           = TypeSystemServices.GetType(baseType);
                    IEntity defaultMember = tag.GetDefaultMember();
                    if (defaultMember != null)
                    {
                        if (tag.IsInterface)
                        {
                            buffer.AddUnique(defaultMember);
                        }
                        else                         //non-interface base class trumps interfaces
                        {
                            return(defaultMember);
                        }
                    }
                }
                return(NameResolutionService.GetEntityFromList(buffer));
            }
            return(null);
        }
Example #5
0
        public IType[] GetInterfaces()
        {
            if (null == _interfaces)
            {
                List buffer = new List();

                foreach (TypeReference baseType in _typeDefinition.BaseTypes)
                {
                    IType tag = TypeSystemServices.GetType(baseType);
                    if (tag.IsInterface)
                    {
                        buffer.AddUnique(tag);
                    }
                }

                _interfaces = (IType[])buffer.ToArray(typeof(IType));
            }
            return(_interfaces);
        }
Example #6
0
        public void ResolveArrayTypeReference(ArrayTypeReference node)
        {
            if (node.Entity != null)
            {
                return;
            }

            ResolveTypeReference(node.ElementType);

            IType elementType = TypeSystemServices.GetType(node.ElementType);

            if (TypeSystemServices.IsError(elementType))
            {
                node.Entity = TypeSystemServices.ErrorEntity;
            }
            else
            {
                int rank = null == node.Rank ? 1 : (int)node.Rank.Value;
                node.Entity = _context.TypeSystemServices.GetArrayType(elementType, rank);
            }
        }
Example #7
0
        override public bool Resolve(List targetList, string name, EntityType flags)
        {
            bool found = base.Resolve(targetList, name, flags);

            foreach (TypeReference baseType in _typeDefinition.BaseTypes)
            {
                if (TypeSystemServices.GetType(baseType).Resolve(targetList, name, flags))
                {
                    found = true;
                }
            }

            if (!found)
            {
                // also look in System.Object
                if (_typeSystemServices.ObjectType.Resolve(targetList, name, flags))
                {
                    found = true;
                }
            }
            return(found);
        }