Ejemplo n.º 1
0
        public Assets.Exports.UObject?ConstructObject()
        {
            var type = ObjectTypeRegistry.Get(Name);

            if (type != null)
            {
                try
                {
                    var instance = Activator.CreateInstance(type);
                    if (instance is Assets.Exports.UObject obj)
                    {
                        return(obj);
                    }
                    else
                    {
                        Log.Warning("Class {Type} did have a valid constructor but does not inherit UObject", type);
                    }
                }
                catch (Exception e)
                {
                    Log.Warning(e, "Class {Type} could not be constructed", type);
                }
            }

            return(null);
        }
        public ObjectProcessTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("five-step-process-test");

            var queue = new AsyncMessageQueue(null);

            _exchange = new LocalExchange(queue);
            var adapter = new ProcessMessageTextAdapter();

            EntryAdapterProvider.Instance(_world).RegisterAdapter(adapter);

            var dispatcher  = new MockDispatcher();
            var objectStore = _world.ActorFor <IObjectStore>(() => new InMemoryObjectStoreActor <string>(dispatcher));

            var objectTypeRegistry = new ObjectTypeRegistry(_world);

            var stepCountStateInfo =
                new Info <StepCountObjectState>(
                    objectStore,
                    nameof(StepCountObjectState),
                    MapQueryExpression.Using <StepCountObjectState>("find", MapQueryExpression.Map("id", "id")),
                    StateObjectMapper.With <StepCountObjectState>(new object(), new object()));

            objectTypeRegistry.Register(stepCountStateInfo);

            _exchangeSender = new LocalExchangeSender(queue);

            var processTypeRegistry = new ProcessTypeRegistry(_world);

            processTypeRegistry.Register(new ObjectProcessInfo <FiveStepEmittingObjectProcess, StepCountObjectState>(nameof(FiveStepEmittingObjectProcess), _exchange, objectTypeRegistry));

            _exchangeReceivers = new ExchangeReceivers();

            RegisterExchangeCoveys();
        }
        public EmployeeEntityTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("test-object-entity");
            var objectStore = _world.ActorFor <IObjectStore>(typeof(InMemoryObjectStoreActor <string>), new MockDispatcher());

            var registry = new ObjectTypeRegistry(_world);

            // NOTE: The InMemoryObjectStoreActor implementation currently
            // does not use PersistentObjectMapper, and thus the no-op decl.
            var employeeInfo =
                new Info <EmployeeState>(
                    objectStore,
                    "HR-Database",
                    MapQueryExpression.Using <IEmployee>("find", MapQueryExpression.Map("number", "number")),
                    StateObjectMapper.With <IEmployee>(new object(), new object()));

            registry.Register(employeeInfo);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Construct my default state.
 /// </summary>
 /// <param name="processName">The name of the current process</param>
 /// <param name="exchange">The <see cref="IExchange"/></param>
 /// <param name="registry">The <see cref="ObjectTypeRegistry"/> used by the <see cref="ObjectProcess{T}"/></param>
 public ObjectProcessInfo(string processName, IExchange exchange, ObjectTypeRegistry registry) : base(typeof(TProcess), processName, exchange)
     => Registry = registry;