Example #1
0
 /// <summary>
 /// Creates a new array type
 /// </summary>
 /// <param name="elementType">The type of the element</param>
 public ArrayType(BaseType elementType)
     : base(TypeSystem.ArrayTypeName(elementType), true, true, false)
 {
     this.ElementType = elementType;
 }
Example #2
0
 /// <summary>
 /// Creates a new primitive type
 /// </summary>
 /// <param name="primitiveType">The primitive type</param>
 public PrimitiveType(PrimitiveTypes primitiveType)
     : base(TypeSystem.ToString(primitiveType), false, false, false)
 {
 }
Example #3
0
 /// <summary>
 /// Returns the given primitive type
 /// </summary>
 /// <param name="primitiveType">The primitive type</param>
 public BaseType FindPrimitiveType(PrimitiveTypes primitiveType)
 {
     return(this.FindType(TypeSystem.ToString(primitiveType)));
 }
Example #4
0
 /// <summary>
 /// Finds the array type for the given element type
 /// </summary>
 /// <param name="elementType">The element type</param>
 /// <param name="tryToConstruct">Indicates if to try to construct the type if does not exist.</param>
 /// <returns>The type or null</returns>
 public ArrayType FindArrayType(BaseType elementType, bool tryToConstruct = true)
 {
     return(this.FindType(TypeSystem.ArrayTypeName(elementType), tryToConstruct) as ArrayType);
 }
Example #5
0
        /// <summary>
        /// Tries to create a type of the given type
        /// </summary>
        /// <param name="name">The name of the type</param>
        private BaseType CreateType(string name)
        {
            //Split the type name
            var      typeParts = SplitTypeName(name);
            BaseType type      = null;

            if (TypeSystem.FromString(typeParts[0], out var primitiveType))
            {
                type = new PrimitiveType(primitiveType);
            }
            else if (typeParts[0] == "Ref")
            {
                if (ExtractElementType(typeParts[1], out var elementTypeName))
                {
                    var elementType = FindType(elementTypeName);

                    if (elementType != null)
                    {
                        type = new ArrayType(elementType);
                    }
                }
                else if (typeParts[1] == "Null")
                {
                    type = new NullType();
                }
                else
                {
                    if (typeParts.Count >= 2)
                    {
                        var  className = "";
                        bool isFirst   = true;

                        for (var i = 1; i < typeParts.Count; i++)
                        {
                            if (isFirst)
                            {
                                isFirst = false;
                            }
                            else
                            {
                                className += ".";
                            }

                            className += typeParts[i];
                        }

                        var classMetadata = this.classMetadataProvider.GetMetadata(className);
                        if (classMetadata != null)
                        {
                            type = new ClassType(classMetadata);
                        }
                    }
                }
            }

            if (type != null)
            {
                this.types.Add(name, type);
            }

            return(type);
        }