Ejemplo n.º 1
0
    public static ImmediateWindow.Result RunCommand(string command, out string result)
    {
        result = string.Empty;
        while (command.Contains("  "))
        {
            command = command.Replace("  ", " ");
        }
        if (command.StartsWith(" "))
        {
            command = command.Substring(1);
        }
        if (command.EndsWith(" "))
        {
            command = command.Substring(0, command.Length - 1);
        }
        string[] array = command.Split(new char[]
        {
            ' '
        });
        if (array.Length == 0)
        {
            return(ImmediateWindow.Result.NoInput);
        }
        List <Type> list = new List <Type>();

        string[] array2 = array[0].Split(new char[]
        {
            '.'
        });
        string text = string.Empty;

        for (int i = 0; i < array2.Length; i++)
        {
            if (!text.Empty())
            {
                text += ".";
            }
            text += array2[i];
            List <Type> types = ImmediateWindow.GetTypes(text);
            if (types.Count != 1)
            {
                list = list.Concat(types).ToList <Type>();
                break;
            }
            list = types;
        }
        if (list.Count == 0)
        {
            return(ImmediateWindow.Result.InvalidType);
        }
        if (list.Count > 1)
        {
            result = string.Join <Type>(" ", list);
            return(ImmediateWindow.Result.IncompleteType);
        }
        if (array.Length < 2)
        {
            return(ImmediateWindow.Result.InvalidMember);
        }
        string[] members = array[1].Split(new char[]
        {
            '.'
        });
        string[] parameters = array.Skip(2).ToArray <string>();
        return(ImmediateWindow.Execute(list[0], members, parameters, ref result));
    }