Exemple #1
0
        private static object GetState(string input, IParameter parameter)
        {
            var commandText = GetInput(input);

            switch (commandText[0])
            {
            case "contacts":
                return(null);

            case "connections":
                if (Contacts == null || Contacts.Count == 0)
                {
                    var               _parameter       = parameter as ConnectionsParameter;
                    string[]          args             = { "contacts", _parameter.NumberOfContacts.ToString() };
                    ContactsParameter contactParameter = new ContactsParameter(args);
                    var               command          = new ContactsCommand();
                    command.SetParameters(contactParameter);
                    var response = command.Run();
                    DisplayOutput(response);
                    SavePayload(string.Join(" ", args), response);
                }
                return(Contacts);

            case "search":
                if (Connections == null || Connections.Count == 0)
                {
                    throw new Exception("You need to run the \"connections <connections_frequency> [<number_of_contacts>]\" command before you can search");
                }
                return(new Dictionary <string, object>
                {
                    { "contacts", Contacts },
                    { "connections", Connections }
                });

            case "list":
                if (Contacts == null || Contacts.Count == 0)
                {
                    throw new Exception("You need to run the \"contacts <number_of_contacts>\" command before you can list");
                }
                return(Contacts);

            default:
                return(null);
            }
        }
 public void SetParameters(IParameter parameter)
 {
     this.parameter = parameter as ContactsParameter;
 }