public void Run()
        {
            while (true)
            {
                string line = this.userInterface.ReadLine();
                if (string.IsNullOrWhiteSpace(line))
                {
                    break;
                }

                line = line.Trim();
                try
                {
                    this.Command = new Command(line);
                    this.airConditioner.ExecuteCommands();
                }
                catch (InvalidOperationException ex)
                {
                    this.userInterface.WriteLine(ex.Message);
                }
            }
        }
Пример #2
0
        public virtual void Apply(Command command)
        {
            AggregateInfo aggregateInfo;
            try
            {
                aggregateInfo = applyTo(command).Single();
            }
            catch (InvalidOperationException e)
            {
                throw new InvalidOperationException("A command must apply to a single aggregate instance", e);
            }

            //If it's not tracked, then select it from the domain.
            if (aggregateInfo.Lifestate == AggregateLifestate.Untracked)
                selectAggregate(aggregateInfo);

            try
            {
                //If we haven't found it in the domain, then create it, otherwise apply the command.
                if (aggregateInfo.Lifestate == AggregateLifestate.Untracked)
                    AggregateFactory.Create(aggregateInfo, command);
                else
                    aggregateInfo.Instance.AsDynamic().Apply(command);
            }
            catch (ApplicationException e)
            {
                if (e.Source == "ReflectionMagic")
                    throw new MissingMethodException(
                        aggregateInfo.Type.FullName,
                        string.Format(
                            "{0}({1})",
                            aggregateInfo.Lifestate == AggregateLifestate.Untracked ? "_ctor" : "Accept",
                            command.GetType()));

                throw;
            }
        }
Пример #3
0
 public Shutdown(Command command)
 {
     this.command = command;
     simpleJobBuilder = command.SimpleJobBuilder;
 }
Пример #4
0
 public UtorrentCommandTask(Command command, string json)
 {
     utorrentCommand = JsonConvert.DeserializeObject<UtorrentCommand>(json);
     this.command = command;
 }
Пример #5
0
 public RefreshUtorrent(Command command)
 {
     this.command = command;
 }
Пример #6
0
 public PlexConnect(Command command)
 {
     this.command = command;
 }
Пример #7
0
 public PlexHomeTheatre(Command command)
 {
     this.command = command;
 }
Пример #8
0
 public SickBeardCommand(Command command)
 {
     this.command = command;
 }
Пример #9
0
 public Plex(Command command)
 {
     this.command = command;
 }
Пример #10
0
 public Abort(Command command)
 {
     this.command = command;
     simpleJobBuilder = command.SimpleJobBuilder;
 }
Пример #11
0
 public Utorrent(Command command)
 {
     this.command = command;
 }