/// <summary>
        ///     Convenience method for dispatching the supplied op to the
        ///     appropriate method in the entity pipeline block.
        /// </summary>
        /// <exception cref="ArgumentException">
        ///     Thrown when op object is of an unrecognised type.
        /// </exception>
        public static void DispatchOp(this IEntityPipelineBlock block, IEntityPipelineOp pipelineOp)
        {
            switch (pipelineOp.PipelineOpType)
            {
            case PipelineOpType.AddEntity:
                block.AddEntity((AddEntityPipelineOp)pipelineOp);
                break;

            case PipelineOpType.RemoveEntity:
                block.RemoveEntity((RemoveEntityPipelineOp)pipelineOp);
                break;

            case PipelineOpType.CriticalSection:
                block.CriticalSection((CriticalSectionPipelineOp)pipelineOp);
                break;

            case PipelineOpType.AddComponent:
                block.AddComponent((AddComponentPipelineOp)pipelineOp);
                break;

            case PipelineOpType.RemoveComponent:
                block.RemoveComponent((RemoveComponentPipelineOp)pipelineOp);
                break;

            case PipelineOpType.ChangeAuthority:
                block.ChangeAuthority((ChangeAuthorityPipelineOp)pipelineOp);
                break;

            case PipelineOpType.UpdateComponent:
                block.UpdateComponent((UpdateComponentPipelineOp)pipelineOp);
                break;

            default:
                throw new ArgumentException(string.Format("Unknown op type {0}, cannot dispatch.", pipelineOp.GetType().Name), "op");
            }
        }
 private void RegisterDispatcherCallbacks()
 {
     registeredDispatcherCallbacks.Add(spatialCommunicator.RegisterAddEntity(addEntityOp => firstBlock.AddEntity(new AddEntityPipelineOp {
         DispatcherOp = addEntityOp
     })));
     registeredDispatcherCallbacks.Add(spatialCommunicator.RegisterRemoveEntity(removeEntityOp => firstBlock.RemoveEntity(new RemoveEntityPipelineOp {
         DispatcherOp = removeEntityOp
     })));
     registeredDispatcherCallbacks.Add(spatialCommunicator.RegisterCriticalSection(criticalSectionOp => firstBlock.CriticalSection(new CriticalSectionPipelineOp {
         DispatcherOp = criticalSectionOp
     })));
 }