예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="actorType">actor type</param>
        /// <param name="actorKey">actor key</param>
        /// <param name="instance">instance of the actor class</param>
        /// <param name="actorProxy">actor proxy</param>
        public ActorRegistration(Type actorType, ActorKey actorKey, IActorBase instance, IActor actorProxy)
        {
            actorType.Verify(nameof(actorType)).IsNotNull();
            actorKey.Verify(nameof(actorKey)).IsNotNull();
            instance.Verify(nameof(instance)).IsNotNull();
            actorProxy.Verify(nameof(actorProxy)).IsNotNull();

            ActorType   = actorType;
            ActorKey    = actorKey;
            _instance   = instance;
            _actorProxy = actorProxy;
        }
예제 #2
0
        /// <summary>
        /// Create transparent proxy for instance of actor class
        /// </summary>
        /// <param name="context">work context</param>
        /// <param name="instance">instance of actor class</param>
        /// <param name="manager">actor manager</param>
        /// <returns>proxy</returns>
        public static T Create(IWorkContext context, IActorBase instance, IActorManager manager)
        {
            context.Verify(nameof(context)).IsNotNull();
            instance.Verify(nameof(instance)).IsNotNull();
            manager.Verify(nameof(manager)).IsNotNull();

            object proxyObject = Create <T, ActorProxy <T> >();

            ActorProxy <T> proxy = (ActorProxy <T>)proxyObject;

            proxy._instance = instance;
            proxy._manager  = manager;

            proxy._workContext = new WorkContextBuilder(context)
                                 .Set(_tag)
                                 .Set(_cv)
                                 .Build();

            return((T)proxyObject);
        }