Ejemplo n.º 1
0
        public static void FillGenericRestrictions(string lineOfCode, List <ParsedType> GenericTypes, List <ParsedField> ArgumentList)
        {
            // Vic says - this only handles one constraint on one generic type.
            // If it gets more complicated than that, this needs to be modified.

            if (GenericTypes.Count != 0 && lineOfCode.Contains("where "))
            {
                int m = 3;

                string constraintsString = lineOfCode.Substring(lineOfCode.IndexOf("where "));

                string constraint = constraintsString.Substring(constraintsString.IndexOf(": ") + 2);

                // Let's separate em and build em back because we gotta get rid of things like "new()"
                if (constraint.Contains(","))
                {
                    string[] splitConstraints = constraint.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);
                    constraintsToUse.Clear();

                    foreach (string individualConstraint in splitConstraints)
                    {
                        string trimmed = individualConstraint.Trim();

                        if (trimmed != "new()")
                        {
                            constraintsToUse.Add(trimmed);
                        }
                    }
                    constraint = "";
                    for (int i = 0; i < constraintsToUse.Count; i++)
                    {
                        if (i == constraintsToUse.Count - 1)
                        {
                            constraint += constraintsToUse[i];
                        }
                        else
                        {
                            constraint += constraintsToUse[i] + ", ";
                        }
                    }
                }

                GenericTypes[0].GenericRestrictions.Add(constraint);
            }

            for (int i = 0; i < GenericTypes.Count; i++)
            {
                ParsedType genericType = GenericTypes[i];
                foreach (ParsedField parsedField in ArgumentList)
                {
                    if (parsedField.Type.GenericType != null && parsedField.Type.GenericType.Name == genericType.Name)
                    {
                        parsedField.Type.GenericRestrictions.AddRange(genericType.GenericRestrictions);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static Type GetTypeInListFromParsedType(ParsedType parsedType)
        {
            string typeAsString = "";

            if (parsedType.GenericType != null)
            {
                typeAsString = parsedType.GenericType.Name;
            }
            else
            {
                // it's probably a [], so just use the type itself
                typeAsString = parsedType.Name;
            }

            return(GetTypeFromString(typeAsString));
        }
Ejemplo n.º 3
0
        public ParsedType Clone()
        {
            ParsedType typeToReturn = new ParsedType();

            typeToReturn.Name             = Name;
            typeToReturn.IsInterface      = IsInterface;
            typeToReturn.NumberOfElements = NumberOfElements;

            if (GenericType != null)
            {
                typeToReturn.GenericType = GenericType.Clone();
            }

            typeToReturn.GenericRestrictions = new List <string>();
            typeToReturn.GenericRestrictions.AddRange(GenericRestrictions);

            return(typeToReturn);
        }
Ejemplo n.º 4
0
        public static Type GetTypeFromParsedType(ParsedType parsedType)
        {
            if (parsedType.GenericType != null)
            {
                Type baseType = GetTypeFromString(parsedType.Name + "<>");

                if (baseType == null)
                {
                    baseType = GetTypeFromString(parsedType.Name);
                }
                if (baseType == null)
                {
                    baseType = GetTypeFromString(parsedType.NameWithGenericNotation);
                }

                if (baseType == null)
                {
                    int m = 3;
                    return null;
                }

                if (baseType.IsGenericTypeDefinition)
                {

                    return MakeGenericType(parsedType, baseType);
                }
                else
                {
                    return baseType;
                }

            }
            else if (parsedType.GenericRestrictions.Count != 0)
            {
                return GetTypeFromString(parsedType.GenericRestrictions[0]);
            }
            else
            {

                string typeAsString = parsedType.NameWithGenericNotation;

                return GetTypeFromString(typeAsString);
            }
        }
Ejemplo n.º 5
0
        public static Type GetTypeFromParsedType(ParsedType parsedType)
        {
            if (parsedType.GenericType != null)
            {
                Type baseType = GetTypeFromString(parsedType.Name + "<>");

                if (baseType == null)
                {
                    baseType = GetTypeFromString(parsedType.Name);
                }
                if (baseType == null)
                {
                    baseType = GetTypeFromString(parsedType.NameWithGenericNotation);
                }

                if (baseType == null)
                {
                    int m = 3;
                    return(null);
                }

                if (baseType.IsGenericTypeDefinition)
                {
                    return(MakeGenericType(parsedType, baseType));
                }
                else
                {
                    return(baseType);
                }
            }
            else if (parsedType.GenericRestrictions.Count != 0)
            {
                return(GetTypeFromString(parsedType.GenericRestrictions[0]));
            }
            else
            {
                string typeAsString = parsedType.NameWithGenericNotation;

                return(GetTypeFromString(typeAsString));
            }
        }
Ejemplo n.º 6
0
        public ParsedType(string entireString)
        {
            if (entireString == null)
            {
                return;
            }

            if (entireString.Contains("<") && entireString.Contains(">"))
            {
                int genericOpenIndex  = entireString.IndexOf('<');
                int genericCloseIndex = entireString.LastIndexOf('>');

                NumberOfElements = 1;

                Name = entireString.Substring(0, genericOpenIndex);
                string genericContents = entireString.Substring(genericOpenIndex + 1, genericCloseIndex - genericOpenIndex - 1);

                GenericType = new ParsedType(genericContents);
            }
            else
            {
                if (entireString.Contains(","))
                {
                    NumberOfElements = entireString.Split(',').Length;
                }
                else
                {
                    NumberOfElements = 1;
                }

                Name = entireString;
            }
            if (Name.StartsWith("I") && Name.Length > 1 && Char.IsUpper(Name[1]))
            {
                IsInterface = true;
            }
        }
Ejemplo n.º 7
0
        internal void FillHeaderInformation(string headerLine)
        {
            Scope      scope;
            ParsedType type;
            string     variableName;
            bool       isConst; // will always be false for properties
            string     valueToAssignTo;
            bool       isVirtual;
            bool       isOverride;
            bool       isStatic;
            bool       isNew;
            bool       isAsync;

            GetLineInformation(headerLine, out scope, out type, out variableName, out isConst, out isVirtual,
                               out isOverride, out isStatic, out isNew, out isAsync, out valueToAssignTo);

            Scope    = scope;
            Type     = type;
            Name     = variableName;
            IsStatic = isStatic;

            // Unqualify the type
            type.Unqualify();
        }
Ejemplo n.º 8
0
        private void ParseHeader(string classContents)
        {
            int lineIndex = 0;
            int wordIndex = 0;

            if (classContents.StartsWith("\r") || classContents.StartsWith("\t"))
            {
                classContents = classContents.TrimStart();
            }

            string line = GetLine(classContents, ref lineIndex);

            while (line.Trim().EndsWith(":"))
            {
                string additionalLine = GetLine(classContents, ref lineIndex);
                line = line.Trim() + " " + additionalLine.Trim();
            }

            string genericWord = "";

            bool isInsideGenericName          = false;
            bool isInsideGenericInheritedType = false;

            bool       justFoundWhere         = false;
            ParsedType genericTypeRestraining = null;

            mName = "";

            #region Loop through the words to get the header structure

            while (true)
            {
                string word = GetWord(line, ref wordIndex).Trim();

                if (word == "")
                {
                    break;
                }
                else if (word == "class" || word == "struct")
                {
                    IsInterface = false;
                }
                else if (word == "interface")
                {
                    IsInterface = true;
                }
                else if (word == "partial")
                {
                    IsPartial = true;
                }
                else if (justFoundWhere)
                {
                    for (int i = 0; i < mGenericTypes.Count; i++)
                    {
                        if (mGenericTypes[i].Name == word)
                        {
                            genericTypeRestraining = mGenericTypes[i];
                            break;
                        }
                    }
                    justFoundWhere = false;
                }
                else if (word == "where")
                {
                    genericTypeRestraining = null;
                    justFoundWhere         = true;
                }
                else if (word == "," && !isInsideGenericName && !isInsideGenericInheritedType)
                {
                    continue;
                }
                else if (string.IsNullOrEmpty(mName) || isInsideGenericName)
                {
                    mName += word;

                    if (word.Contains('<') && !word.Contains('>'))
                    {
                        isInsideGenericName = true;
                    }
                    else if (isInsideGenericName && word.Contains('>'))
                    {
                        isInsideGenericName = false;
                    }
                    else if (word.Contains('<') && word.Contains('>'))
                    {
                        int indexOfLessThan = word.IndexOf("<");

                        mName = word.Substring(0, indexOfLessThan);

                        string remainderOfStuff =
                            word.Substring(indexOfLessThan, word.Length - indexOfLessThan);

                        // get rid of < and >
                        remainderOfStuff = remainderOfStuff.Substring(1, remainderOfStuff.Length - 2);

                        string[] generics = remainderOfStuff.Split(',');

                        foreach (string generic in generics)
                        {
                            mGenericTypes.Add(new ParsedType(generic));
                            //GenericTypes.Add(new ParsedField(
                        }
                    }
                }
                else if (word == ":" || word == "{")
                {
                    // do nothing
                }
                else
                {
                    if (isInsideGenericInheritedType)
                    {
                        genericWord += word;
                    }

                    if (word.Contains('<') && !word.Contains('>'))
                    {
                        isInsideGenericInheritedType = true;
                        genericWord = word;
                    }
                    else if (isInsideGenericInheritedType && word.Contains('>'))
                    {
                        isInsideGenericInheritedType = false;
                        mParentClassesAndInterfaces.Add(new ParsedType(genericWord));
                    }
                    else if (genericTypeRestraining != null)
                    {
                        genericTypeRestraining.GenericRestrictions.Add(word);
                    }
                    else if (!isInsideGenericInheritedType)
                    {
                        mParentClassesAndInterfaces.Add(new ParsedType(word));
                    }
                }
            }

            #endregion


            //int firstOpenBracket = classContents.IndexOf('{');
            //int firstColon = classContents.IndexOf(':');

            //if (firstColon != -1 && firstColon < firstOpenBracket)
            //{
            //    int indexAt = 0;
            //    string interfaceToAdd = StringFunctions.GetWordAfter(": ", classContents, indexAt);



            //    while (true)
            //    {
            //        mParentClassesAndInterfaces.Add(interfaceToAdd);

            //        indexAt = classContents.IndexOf(interfaceToAdd, indexAt) + interfaceToAdd.Length;

            //        // Don't add one for the first one
            //        if (classContents[indexAt] == ' ')
            //        {
            //            interfaceToAdd = classContents[indexAt].ToString();
            //        }
            //        while (classContents[indexAt + 1] == ' ')
            //        {
            //            indexAt++;
            //            interfaceToAdd = classContents[indexAt].ToString();
            //        }


            //        interfaceToAdd = StringFunctions.GetWordAfter(interfaceToAdd, classContents, indexAt);



            //    }
            //}
        }
Ejemplo n.º 9
0
 public ParsedProperty(Scope scope, string type, string name)
 {
     Scope = scope;
     Type  = new ParsedType(type);
     Name  = name;
 }
Ejemplo n.º 10
0
 public ParsedField(Scope scope, string type, string name)
 {
     Scope = scope;
     Type  = new ParsedType(type);
     Name  = name;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="header">We ref this simply for performance reasons.</param>
        /// <param name="memberName"></param>
        /// <param name="type"></param>
        /// <param name="classType"></param>
        private static void GetTypeFromHeader(ref CsvHeader header, ref string memberName, out Type type, out string classType)
        {
            classType = "";

            if (memberName.Contains("("))
            {

                // The user is defining the type for this property
                classType = CsvHeader.GetClassNameFromHeader(header.Name);

                bool shouldBeNewed = false;

                if (classType.StartsWith("List<"))
                {
                    classType = "System.Collections.Generic." + classType;
                    shouldBeNewed = true;
                }

                if (string.IsNullOrEmpty(classType))
                {
                    // We can get here if the class is (required)
                    type = typeof(string);
                }
                else
                {
                    if (classType.Contains("<"))
                    {
                        ParsedType parsedType = new ParsedType(classType);
                        type = TypeManager.GetTypeFromParsedType(parsedType);
                    }
                    else
                    {
                        type = TypeManager.GetTypeFromString(classType);
                    }
                }

                memberName = StringFunctions.RemoveWhitespace(memberName);

                memberName = memberName.Substring(0, memberName.IndexOfAny(new char[] { '(' }));

                if (shouldBeNewed)
                {
                    // The user probably wants these new'ed:
                    memberName += " = new " + classType + "()";
                }
            }
            else
            {
                memberName = StringFunctions.RemoveWhitespace(memberName);
                type = typeof(string);
            }
        }
Ejemplo n.º 12
0
 public ParsedProperty(Scope scope, string type, string name)
 {
     Scope = scope;
     Type = new ParsedType(type);
     Name = name;
 }
Ejemplo n.º 13
0
        public static bool DoesListOfFieldsContainsField(List<ParsedField> parsedFields, string variableName, out ParsedType parsedType)
        {
            parsedType = null;
            if (parsedFields == null)
            {
                return false;
            }

            for (int i = 0; i < parsedFields.Count; i++)
            {
                if (parsedFields[i].Name == variableName)
                {
                    parsedType = parsedFields[i].Type;
                    return true;
                }
            }
            return false;
        }
Ejemplo n.º 14
0
        public static Type GetTypeInListFromParsedType(ParsedType parsedType)
        {
            string typeAsString = "";

            if (parsedType.GenericType != null)
            {
                typeAsString = parsedType.GenericType.Name;
            }
            else
            {
                // it's probably a [], so just use the type itself
                typeAsString = parsedType.Name;
            }

            return GetTypeFromString(typeAsString);
        }
Ejemplo n.º 15
0
        internal void FillHeaderInformation(string headerLine)
        {
            Scope scope;
            ParsedType type;
            string variableName;
            bool isConst; // will always be false for properties
            string valueToAssignTo;
            bool isVirtual;
            bool isOverride;
            bool isStatic;
            bool isNew;
            bool isAsync;

            GetLineInformation(headerLine, out scope, out type, out variableName, out isConst, out isVirtual,
                out isOverride, out isStatic, out isNew, out isAsync, out valueToAssignTo);

            Scope = scope;
            Type = type;
            Name = variableName;
            IsStatic = isStatic;

            // Unqualify the type
            type.Unqualify();


        }
Ejemplo n.º 16
0
        public static void GetLineInformation(
            string line,
            out Scope scope,
            out ParsedType type,
            out string variableName,
            out bool isConst,
            out bool isVirtual,
            out bool isOverride,
            out bool isStatic,
            out bool isNew,
            out bool isAsync,
            out string valueToAssignTo
            )
        {
            int index = 0;
            scope = Scope.Private;
            type = null;
            variableName = null;
            isConst = false;
            valueToAssignTo = null;
            isVirtual = false;
            isOverride = false;
            isStatic = false;
            isNew = false;
            isAsync = false;

            bool hasHadOpenParenthesis = false;
            bool hasHadOpenQuotes = false;
            bool hasEqualsBeenUsed = false;

            string currentType = "";

            while (true)
            {
                string word = ParsedClass.GetWord(line, ref index);

                const string public1 = " public ";
                //const string startWithPublic = "public ";

                if (string.IsNullOrEmpty(word))
                {
                    break;
                }
                else if (word == ";")
                {
                    continue;
                }
                else if (word == "const")
                {
                    isConst = true;
                }
                else if (word == "public")
                {
                    scope = Scope.Public;
                }
                else if (word == "private")
                {
                    scope = Scope.Private;
                }
                else if (word == "protected")
                {
                    scope = Scope.Protected;
                }
                else if (word == "internal")
                {
                    scope = Scope.Internal;
                }
                else if (word == "virtual")
                {
                    isVirtual = true;
                }
                else if (word == "override")
                {
                    isOverride = true;
                }
                else if (word == "static")
                {
                    isStatic = true;
                }
                else if (word == "new")
                {
                    isNew = true;
                }
                else if (word == "async")
                {
                    isAsync = true;
                }
                else if (type == null)
                {
                    if (word.Contains("<") && !word.Contains(">"))
                    {
                        currentType += word;
                    }
                    else if (currentType != "")
                    {
                        currentType += word;
                        if (word.Contains(">"))
                        {
                            type = new ParsedType(currentType);

                            currentType = "";
                        }
                    }
                    else
                    {

                        // check for []
                        int tempIndex = index;
                        string nextWord = ParsedClass.GetWord(line, ref tempIndex);
                        string wordAfterThat = ParsedClass.GetWord(line, ref tempIndex);

                        if (nextWord == "[" && wordAfterThat == "]")
                        {
                            type = new ParsedType(word + "[]");
                            index = tempIndex;
                        }
                        else
                        {
                            type = new ParsedType(word);
                        }
                    }
                }
                else if (!hasEqualsBeenUsed && word == "(")
                {
                    hasHadOpenParenthesis = true;
                }
                else if (variableName == null && !hasHadOpenParenthesis)
                {
                    if (word.EndsWith(";"))
                    {
                        variableName = word.Substring(0, word.Length - 1);
                    }
                    else
                    {
                        variableName = word;
                    }
                }
                else if (word == "=")
                {
                    hasEqualsBeenUsed = true;
                }
                else if (hasEqualsBeenUsed)
                {
                    if (valueToAssignTo == null)
                    {
                        valueToAssignTo = word;

                        if (valueToAssignTo.StartsWith("\"") && !hasHadOpenQuotes)
                        {
                            if (!valueToAssignTo.EndsWith("\""))
                            {
                                hasHadOpenQuotes = true;

                                int indexOfClosingQuotes = line.IndexOf("\"", index) + 1; // add 1 to capture the quote

                                string extraStuffToAdd = line.Substring(index, indexOfClosingQuotes - index);

                                valueToAssignTo += extraStuffToAdd;
                                index = indexOfClosingQuotes;
                            }
                        }
                    }
                    else
                    {

                        valueToAssignTo += " " + word;
                    }
                }

            }
        }
Ejemplo n.º 17
0
        private static Type MakeGenericType(ParsedType parsedType, Type baseType)
        {
            string genericString = parsedType.GenericType.Name;

            if (genericString.Contains(','))
            {
                string[] strings = genericString.Split(',');

                Type[] types = new Type[strings.Length];

                for (int i = 0; i < strings.Length; i++)
                {
                    types[i] = GetTypeFromString(strings[i]);
                }

                return(baseType.MakeGenericType(types));
            }
            else
            {
                if (genericString.Contains('.'))
                {
                    int lastDot = genericString.LastIndexOf('.');

                    genericString = genericString.Substring(lastDot + 1, genericString.Length - (lastDot + 1));
                }
                Type genericType = GetTypeFromString(genericString);

                if (genericType == null && parsedType.GenericType.Name == "T")
                {
                    if (parsedType.GenericRestrictions.Count != 0)
                    {
                        genericType = GetTypeFromString(parsedType.GenericRestrictions[0]);
                    }
                    else
                    {
                        genericType = typeof(object);
                    }
                }
                if (genericType == null)
                {
                    return(null);
                }
                else
                {
                    try
                    {
                        return(baseType.MakeGenericType(genericType));
                    }
                    catch (Exception exception)
                    {
#if GLUE
                        System.Windows.Forms.MessageBox.Show("Error making a generic type out of " + baseType.Name + "<" + genericType.Name + ">" +
                                                             "\n This is probably because your game hasn't been rebuilt since you've made a critical change");
                        return(null);
#else
                        throw exception;
#endif
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public static bool DoesListOfPropertiesContainProperty(List<ParsedProperty> parsedProperty, string variableName, out ParsedType parsedType)
        {

            for (int i = 0; i < parsedProperty.Count; i++)
            {
                if (parsedProperty[i].Name == variableName)
                {
                    parsedType = parsedProperty[i].Type;
                    return true;
                }
            }
            parsedType = null;
            return false;
        }
Ejemplo n.º 19
0
        private static Type MakeGenericType(ParsedType parsedType, Type baseType)
        {
            string genericString = parsedType.GenericType.Name;

            if (genericString.Contains(','))
            {
                string[] strings = genericString.Split(',');

                Type[] types = new Type[strings.Length];

                for (int i = 0; i < strings.Length; i++)
                {
                    types[i] = GetTypeFromString(strings[i]);
                }

                return baseType.MakeGenericType(types);
            }
            else
            {
                if (genericString.Contains('.'))
                {
                    int lastDot = genericString.LastIndexOf('.');

                    genericString = genericString.Substring(lastDot + 1, genericString.Length - (lastDot + 1));
                }
                Type genericType = GetTypeFromString(genericString);

                if (genericType == null && parsedType.GenericType.Name == "T")
                {
                    if (parsedType.GenericRestrictions.Count != 0)
                    {
                        genericType = GetTypeFromString(parsedType.GenericRestrictions[0]);
                    }
                    else
                    {
                        genericType = typeof(object);
                    }
                }
                if (genericType == null)
                {
                    return null;
                }
                else
                {
                    try
                    {
                        return baseType.MakeGenericType(genericType);
                    }
                    catch(Exception exception)
                    {
#if GLUE
                        System.Windows.Forms.MessageBox.Show("Error making a generic type out of " + baseType.Name + "<" + genericType.Name + ">" +
                            "\n This is probably because your game hasn't been rebuilt since you've made a critical change");
                        return null;
#else
                        throw exception;
#endif
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public static void GetLineInformation(
            string line,
            out Scope scope,
            out ParsedType type,
            out string variableName,
            out bool isConst,
            out bool isVirtual,
            out bool isOverride,
            out bool isStatic,
            out bool isNew,
            out bool isAsync,
            out string valueToAssignTo
            )
        {
            int index = 0;

            scope           = Scope.Private;
            type            = null;
            variableName    = null;
            isConst         = false;
            valueToAssignTo = null;
            isVirtual       = false;
            isOverride      = false;
            isStatic        = false;
            isNew           = false;
            isAsync         = false;

            bool hasHadOpenParenthesis = false;
            bool hasHadOpenQuotes      = false;
            bool hasEqualsBeenUsed     = false;

            string currentType = "";

            while (true)
            {
                string word = ParsedClass.GetWord(line, ref index);

                const string public1 = " public ";
                //const string startWithPublic = "public ";

                if (string.IsNullOrEmpty(word))
                {
                    break;
                }
                else if (word == ";")
                {
                    continue;
                }
                else if (word == "const")
                {
                    isConst = true;
                }
                else if (word == "public")
                {
                    scope = Scope.Public;
                }
                else if (word == "private")
                {
                    scope = Scope.Private;
                }
                else if (word == "protected")
                {
                    scope = Scope.Protected;
                }
                else if (word == "internal")
                {
                    scope = Scope.Internal;
                }
                else if (word == "virtual")
                {
                    isVirtual = true;
                }
                else if (word == "override")
                {
                    isOverride = true;
                }
                else if (word == "static")
                {
                    isStatic = true;
                }
                else if (word == "new")
                {
                    isNew = true;
                }
                else if (word == "async")
                {
                    isAsync = true;
                }
                else if (type == null)
                {
                    if (word.Contains("<") && !word.Contains(">"))
                    {
                        currentType += word;
                    }
                    else if (currentType != "")
                    {
                        currentType += word;
                        if (word.Contains(">"))
                        {
                            type = new ParsedType(currentType);

                            currentType = "";
                        }
                    }
                    else
                    {
                        // check for []
                        int    tempIndex     = index;
                        string nextWord      = ParsedClass.GetWord(line, ref tempIndex);
                        string wordAfterThat = ParsedClass.GetWord(line, ref tempIndex);

                        if (nextWord == "[" && wordAfterThat == "]")
                        {
                            type  = new ParsedType(word + "[]");
                            index = tempIndex;
                        }
                        else
                        {
                            type = new ParsedType(word);
                        }
                    }
                }
                else if (!hasEqualsBeenUsed && word == "(")
                {
                    hasHadOpenParenthesis = true;
                }
                else if (variableName == null && !hasHadOpenParenthesis)
                {
                    if (word.EndsWith(";"))
                    {
                        variableName = word.Substring(0, word.Length - 1);
                    }
                    else
                    {
                        variableName = word;
                    }
                }
                else if (word == "=")
                {
                    hasEqualsBeenUsed = true;
                }
                else if (hasEqualsBeenUsed)
                {
                    if (valueToAssignTo == null)
                    {
                        valueToAssignTo = word;

                        if (valueToAssignTo.StartsWith("\"") && !hasHadOpenQuotes)
                        {
                            if (!valueToAssignTo.EndsWith("\""))
                            {
                                hasHadOpenQuotes = true;

                                int indexOfClosingQuotes = line.IndexOf("\"", index) + 1; // add 1 to capture the quote

                                string extraStuffToAdd = line.Substring(index, indexOfClosingQuotes - index);

                                valueToAssignTo += extraStuffToAdd;
                                index            = indexOfClosingQuotes;
                            }
                        }
                    }
                    else
                    {
                        valueToAssignTo += " " + word;
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public ParsedType(string entireString)
        {
            if (entireString == null)
            {
                return;
            }

            if (entireString.Contains("<") && entireString.Contains(">"))
            {
                int genericOpenIndex = entireString.IndexOf('<');
                int genericCloseIndex = entireString.LastIndexOf('>');

                NumberOfElements = 1;

                Name = entireString.Substring(0, genericOpenIndex);
                string genericContents = entireString.Substring(genericOpenIndex + 1, genericCloseIndex - genericOpenIndex - 1);

                GenericType = new ParsedType(genericContents);
            }
            else
            {
                if (entireString.Contains(","))
                {
                    NumberOfElements = entireString.Split(',').Length;
                }
                else
                {
                    NumberOfElements = 1;
                }

                Name = entireString;
            }
            if (Name.StartsWith("I") && Name.Length > 1 && Char.IsUpper(Name[1]))
            {
                IsInterface = true;
            }        
        
        }
Ejemplo n.º 22
0
        public ParsedType Clone()
        {
            ParsedType typeToReturn = new ParsedType();
            typeToReturn.Name = Name;
            typeToReturn.IsInterface = IsInterface;
            typeToReturn.NumberOfElements = NumberOfElements;

            if (GenericType != null)
            {
                typeToReturn.GenericType = GenericType.Clone();
            }

            typeToReturn.GenericRestrictions = new List<string>();
            typeToReturn.GenericRestrictions.AddRange(GenericRestrictions);

            return typeToReturn;
        }
Ejemplo n.º 23
0
 public ParsedField(Scope scope, string type, string name)
 {
     Scope = scope;
     Type = new ParsedType(type);
     Name = name;
 }