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
文件: Plex.cs 项目: juanlurie/Tools
 public Plex(Command command)
 {
     this.command = command;
 }
示例#10
0
文件: Abort.cs 项目: juanlurie/Tools
 public Abort(Command command)
 {
     this.command = command;
     simpleJobBuilder = command.SimpleJobBuilder;
 }
示例#11
0
 public Utorrent(Command command)
 {
     this.command = command;
 }