Exemple #1
0
        private async Task <IList <Tuple <Entry, FhirResponse> > > HandleTransaction(
            IList <Entry> interactions,
            IInteractionHandler interactionHandler,
            Mapper <string, IKey> mapper)
        {
            var responses = new List <Tuple <Entry, FhirResponse> >();

            await _transfer.Internalize(interactions, mapper).ConfigureAwait(false);

            foreach (var interaction in interactions)
            {
                var response = await interactionHandler.HandleInteraction(interaction).ConfigureAwait(false);

                if (!response.IsValid)
                {
                    throw new Exception();
                }

                interaction.Resource = response.Resource;
                response.Resource    = null;

                responses.Add(
                    new Tuple <Entry, FhirResponse>(
                        interaction,
                        response)); //CCR: How to handle responses for transactions?
                //The specifications says only one response should be sent per EntryComponent,
                //but one EntryComponent might correspond to multiple atomic entries (Entry)
                //Example: conditional delete
            }

            _transfer.Externalize(interactions);
            return(responses);
        }
 internal InteractionOutput(IntPtr interactionContext, IInteractionHandler interactionHandler, SynchronizationContext syncContext)
 {
     _interactionContext = interactionContext;
     _interactionHandler = interactionHandler;
     _syncContext = syncContext;
     Alive = true;
 }
        public FhirResponse HandleOperation(ResourceManipulationOperation operation, IInteractionHandler interactionHandler, Mapper <string, IKey> mapper = null)
        {
            IList <Entry> interactions = operation.GetEntries().ToList();

            if (mapper != null)
            {
                transfer.Internalize(interactions, mapper);
            }

            FhirResponse response = null;

            foreach (Entry interaction in interactions)
            {
                response = MergeFhirResponse(response, interactionHandler.HandleInteraction(interaction));
                if (!response.IsValid)
                {
                    throw new Exception();
                }
                interaction.Resource = response.Resource;
            }

            transfer.Externalize(interactions);

            return(response);
        }
Exemple #4
0
 public DefaultPlayableSet(IControl player, IViewPort viewPort, IInteractionHandler interactionHandler, ICollection <IInstance> levelObjects)
 {
     _player             = player;
     _viewPort           = viewPort;
     _interactionHandler = interactionHandler;
     _levelInstances     = levelObjects;
 }
Exemple #5
0
 internal InteractionOutput(IntPtr interactionContext, IInteractionHandler interactionHandler, SynchronizationContext syncContext)
 {
     _interactionContext = interactionContext;
     _interactionHandler = interactionHandler;
     _syncContext        = syncContext;
     Alive = true;
 }
Exemple #6
0
        private async Task <FhirResponse> HandleOperation(
            ResourceManipulationOperation operation,
            IInteractionHandler interactionHandler,
            Mapper <string, IKey> mapper = null)
        {
            IList <Entry> interactions = operation.GetEntries().ToList();

            if (mapper != null)
            {
                await _transfer.Internalize(interactions, mapper).ConfigureAwait(false);
            }

            FhirResponse response = null;

            foreach (var interaction in interactions)
            {
                response = MergeFhirResponse(
                    response,
                    await interactionHandler.HandleInteraction(interaction).ConfigureAwait(false));
                if (!response.IsValid)
                {
                    throw new Exception();
                }

                interaction.Resource = response.Resource;
            }

            _transfer.Externalize(interactions);

            return(response);
        }
        public void Setup()
        {
            _gameState = new GameStateClass(
                new Map(
                    new HardCodedLayerGenerator(),
                    3,
                    new Player(new Position(), new Stats(1, 1, 1), "john", 10)));

            _sut = new InteractionHandler();
        }
Exemple #8
0
 public IInteractionHandler getInteractionHandler()
 {
     if (ctx == null)
     {
         throw new Exception("Tenes que llamar a la funcion setTenant despues de inicializar esta clase");
     }
     if (interactionHandler == null)
     {
         interactionHandler = new InteractionHandler(ctx);
     }
     return(interactionHandler);
 }
Exemple #9
0
 public ConcreteTurnExecutioner(
     IMoveValidator validator,
     ICharacterFormatter formatter,
     ITurnScheduler scheduler,
     IMoveExecutioner executioner,
     IInteractionHandler interactionHandler)
 {
     _validator          = validator;
     _formatter          = formatter;
     _turnScheduler      = scheduler;
     _moveExecutioner    = executioner;
     _interactionHandler = interactionHandler;
 }
Exemple #10
0
        internal static IntPtr CreateInteractionContext(IInteractionHandler interactionHandler, SynchronizationContext syncContext)
        {
            IntPtr ic;

            CreateInteractionContext(out ic);
            InteractionOutput io = new InteractionOutput(ic, interactionHandler, syncContext);

            lock (_lockObj)
            {
                _listeners.Add(ic.ToInt64(), io);
            }
            RegisterOutputCallbackInteractionContext(ic, Marshal.GetFunctionPointerForDelegate(_callback), ic);
            return(ic);
        }
        public void Setup()
        {
            _uut = new InteractionHandler();

            _state  = Substitute.For <IGameState>();
            _player = Substitute.For <IPlayer>();

            _player.Position.X.Returns(5);
            _player.Position.Y.Returns(5);

            _interactiveObjects = new IInteractiveObject[10, 10];

            _state.Player.Returns(_player);

            _state.Map.GetCurrentLayer().InteractiveObjects.Returns(_interactiveObjects);
        }
        public IList <Tuple <Entry, FhirResponse> > HandleTransaction(Bundle bundle, IInteractionHandler interactionHandler)
        {
            if (interactionHandler == null)
            {
                throw new InvalidOperationException("Unable to run transaction operation");
            }

            var entries = new List <Entry>();
            Mapper <string, IKey> mapper = new Mapper <string, IKey>();

            foreach (var operation in bundle.Entry.Select(e => ResourceManipulationOperationFactory.GetManipulationOperation(e, localhost, searchService)))
            {
                IList <Entry> atomicOperations = operation.GetEntries().ToList();
                AddMappingsForOperation(mapper, operation, atomicOperations);
                entries.AddRange(atomicOperations);
            }

            return(HandleTransaction(entries, interactionHandler, mapper));
        }
Exemple #13
0
        public async Task <IList <Tuple <Entry, FhirResponse> > > HandleTransaction(
            Bundle bundle,
            IInteractionHandler interactionHandler)
        {
            if (interactionHandler == null)
            {
                throw new InvalidOperationException("Unable to run transaction operation");
            }

            var entries = new List <Entry>();
            var mapper  = new Mapper <string, IKey>();

            foreach (var task in bundle.Entry.Select(
                         e => ResourceManipulationOperationFactory.GetManipulationOperation(e, _localhost, _searchService)))
            {
                var operation = await task.ConfigureAwait(false);

                IList <Entry> atomicOperations = operation.GetEntries().ToList();
                AddMappingsForOperation(mapper, operation, atomicOperations);
                entries.AddRange(atomicOperations);
            }

            return(await HandleTransaction(entries, interactionHandler, mapper).ConfigureAwait(false));
        }
        public IList <Tuple <Entry, FhirResponse> > HandleTransaction(IList <Entry> interactions, IInteractionHandler interactionHandler)
        {
            if (interactionHandler == null)
            {
                throw new InvalidOperationException("Unable to run transaction operation");
            }

            return(HandleTransaction(interactions, interactionHandler, null));
        }
 public FhirResponse HandleTransaction(ResourceManipulationOperation operation, IInteractionHandler interactionHandler)
 {
     return(HandleOperation(operation, interactionHandler));
 }
 internal static IntPtr CreateInteractionContext(IInteractionHandler interactionHandler, SynchronizationContext syncContext)
 {
     IntPtr ic;
     CreateInteractionContext(out ic);
     InteractionOutput io = new InteractionOutput(ic, interactionHandler, syncContext);
     lock (_lockObj)
     {
         _listeners.Add(ic.ToInt64(), io);
     }
     RegisterOutputCallbackInteractionContext(ic, Marshal.GetFunctionPointerForDelegate(_callback), ic);
     return ic;
 }
Exemple #17
0
 public async Task <IList <Tuple <Entry, FhirResponse> > > HandleTransaction(
     IList <Entry> interactions,
     IInteractionHandler interactionHandler) =>
 interactionHandler == null
         ? throw new InvalidOperationException("Unable to run transaction operation")
         : await HandleTransaction(interactions, interactionHandler, null).ConfigureAwait(false);
Exemple #18
0
 public Client(IInteractionHandler interactionHandler)
 {
     _interactionHandler = interactionHandler;
 }
Exemple #19
0
 protected ZApplicationBase(IInteractionHandler interactionHandler)
 {
     InteractionHandler = interactionHandler;
 }
Exemple #20
0
 public InteractionObject(IMapObject mapObject, Condition condition, IInteractionHandler handler)
 {
     this.mapObject = mapObject;
     this.handler   = handler;
     this.condition = condition;
 }
Exemple #21
0
 public Task <FhirResponse> HandleTransaction(
     ResourceManipulationOperation operation,
     IInteractionHandler interactionHandler) =>
 HandleOperation(operation, interactionHandler);
 void setInteractionHander(IInteractionHandler h)
 {
     handler = h;
 }
Exemple #23
0
 public InteractionObject(IMapObject mapObject, IInteractionHandler handler)
 {
     this.mapObject = mapObject;
     this.handler   = handler;
 }