Exemple #1
0
        public IActionResult Create(HodoorItem hodoorItem)
        {
            if (hodoorItem == null)
            {
                return(BadRequest());
            }

            _stubDebugWriter = new StubDebugWriter();

            _context.HodoorItems.Add(hodoorItem);
            _context.SaveChanges();

            _stubDebugWriter.Write(string.Format("Created HodoorItem with ID: {0}", hodoorItem.Id));

            try
            {
                _hub.Clients.All.InvokeAsync("UpdateSpecific", "Hodoor", hodoorItem.Command, hodoorItem);
            }
            catch (Exception e)
            {
                _stubDebugWriter.Write(e.Message);
            }

            return(CreatedAtRoute("GetHodoor", new { id = hodoorItem.Id }, hodoorItem));
        }
 /// <summary>
 /// Adds the specified writer to the dispatcher.
 /// </summary>
 /// <param name="workspaceId">The ID of the workspace to which the writer belongs.</param>
 /// <param name="writer">The writer to be added.</param>
 public void Add(Guid workspaceId, IDebugWriter writer)
 {
     if(writer == null || _shutdownRequested)
     {
         return;
     }
     _writers.TryAdd(workspaceId, writer);
 }
 /// <summary>
 /// Adds the specified writer to the dispatcher.
 /// </summary>
 /// <param name="workspaceId">The ID of the workspace to which the writer belongs.</param>
 /// <param name="writer">The writer to be added.</param>
 public void Add(Guid workspaceId, IDebugWriter writer)
 {
     if (writer == null || _shutdownRequested)
     {
         return;
     }
     _writers.TryAdd(workspaceId, writer);
 }
 /// <summary>
 ///     Constructs a virtual machine in debug mode. Initialises internal structures.
 /// </summary>
 /// <param name="memory">
 ///     The array of bytes containing the initial memory contents of the machine (i.e. the program that
 ///     the machine should execute).
 /// </param>
 /// <param name="debugWriter">
 ///     The IDebugWriter to handle the machine's debug output.
 /// </param>
 public Machine(byte[] memory, IDebugWriter debugWriter)
     : this(memory, true)
 {
     if (memory.Length < MemoryBytes) Array.Resize(ref memory, MemoryBytes);
     Memory = memory;
     DebugMode = true;
     DebugWriter = debugWriter;
     Initialise();
 }
 /// <summary>
 ///     Prints information about the instruction to the console.
 /// </summary>
 internal void Print(IDebugWriter debugWriter)
 {
     // TODO: String representation of the instruction's opcode
     debugWriter.WriteLine("Opcode: \t0x{0:x2}", Opcode);
     debugWriter.WriteLine("Operand 0: \t0x{0:x2}", Operand0);
     debugWriter.WriteLine("Operand 1: \t0x{0:x2}", Operand1);
     debugWriter.WriteLine("Operand 2: \t0x{0:x2}", Operand2);
 }