Exemple #1
0
        public void RaiseEvent(PMachine source, Event ev, object payload = null)
        {
            Assert(!(ev is Default), "Monitor cannot raise a null event");
            var oneArgConstructor = ev.GetType().GetConstructors().First(x => x.GetParameters().Length > 0);
            var @event            = (Event)oneArgConstructor.Invoke(new[] { payload });

            Raise(@event);
            throw new PNonStandardReturnException {
                      ReturnKind = NonStandardReturn.Raise
            };
        }
Exemple #2
0
        public PMachineValue CreateInterface <T>(PMachine creator, IPrtValue payload = null)
            where T : PMachineValue
        {
            var createdInterface = PModule.linkMap[creator.interfaceName][typeof(T).Name];

            Assert(creates.Contains(createdInterface),
                   $"Machine {GetType().Name} cannot create interface {createdInterface}, not in its creates set");
            var createMachine = PModule.interfaceDefinitionMap[createdInterface];
            var machineId     = CreateMachine(createMachine, createdInterface.Substring(2),
                                              new InitializeParametersEvent(new InitializeParameters(createdInterface, payload)));

            return(new PMachineValue(machineId, PInterfaces.GetPermissions(createdInterface)));
        }