示例#1
0
            protected override MethodDispatcherBuildResult BuildMethodDispatcher(Type interfaceType)
            {
                var actorEventInterfaceDescription = ActorEventInterfaceDescription.CreateUsingCRCId(interfaceType);
                var res = this.methodDispatcherBuilder.Build(actorEventInterfaceDescription);

                InterfaceDetailsStore.UpdateKnownTypeDetail(actorEventInterfaceDescription);
                return(res);
            }
            protected override ProxyGeneratorBuildResult BuildProxyGenerator(Type interfaceType)
            {
                // get all event interfaces supported by this actorInterface and build method dispatchers for those
                var actorEventInterfaces = new [] { interfaceType };

                // create interface descriptions for all interfaces
                var actorEventInterfaceDescriptions = actorEventInterfaces.Select <Type, InterfaceDescription>(
                    t => ActorEventInterfaceDescription.Create(t));

                return(this.proxyGeneratorBuilder.Build(interfaceType, actorEventInterfaceDescriptions));
            }
        /// <summary>
        /// Creates <see cref="ActorTypeInformation"/> from actorType.
        /// </summary>
        /// <param name="actorType">Type of class implementing the actor to create ActorTypeInforamtion for.</param>
        /// <returns><see cref="ActorTypeInformation"/> created from actorType.</returns>
        /// <exception cref="System.ArgumentException">
        /// <para>When <see cref="System.Type.BaseType"/> for actorType is not of type <see cref="Actor"/>.</para>
        /// <para>When actorType does not implement an interface deriving from <see cref="IActor"/>
        /// and is not marked as abstract.</para>
        /// <para>When actorType implements more than one interface which derives from <see cref="IActor"/>
        /// but doesn't have <see cref="ActorServiceAttribute"/>.</para>
        /// </exception>
        public static ActorTypeInformation Get(Type actorType)
        {
            if (!actorType.IsActor())
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.ErrorNotAnActor,
                              actorType.FullName,
                              typeof(Actor).FullName),
                          "actorType");
            }

            string actorServiceName = null;
            var    actorServiceAttr = ActorServiceAttribute.Get(actorType);

            if (actorServiceAttr != null)
            {
                actorServiceName = actorServiceAttr.Name;
            }

            // get all actor interfaces
            var actorInterfaces = actorType.GetActorInterfaces();

            // ensure that the if the actor type is not abstract it implements at least one actor interface
            if ((actorInterfaces.Length == 0) && (!actorType.GetTypeInfo().IsAbstract))
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.ErrorNoActorInterfaceFound,
                              actorType.FullName,
                              typeof(IActor).FullName),
                          "actorType");
            }

            // ensure that all actor interfaces can be remoted
            foreach (var actorInterface in actorInterfaces)
            {
                ActorInterfaceDescription.Create(actorInterface);
            }

            // if the actor implements more than one actor interfaces make sure that it has actorServiceName
            if ((actorInterfaces.Length > 1) && string.IsNullOrEmpty(actorServiceName) && (!actorType.GetTypeInfo().IsAbstract))
            {
                throw new ArgumentException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.ErrorNoActorServiceNameMultipleInterfaces,
                              actorType.FullName,
                              typeof(ActorServiceAttribute).FullName),
                          "actorType");
            }

            // get actor event interfaces
            var eventInterfaces = actorType.GetActorEventInterfaces();

            // ensure that all of the event interfaces can be remoted
            if (eventInterfaces != null)
            {
                foreach (var eventInterface in eventInterfaces)
                {
                    ActorEventInterfaceDescription.Create(eventInterface);
                }
            }

            return(new ActorTypeInformation()
            {
                InterfaceTypes = actorInterfaces,
                ImplementationType = actorType,
                ServiceName = actorServiceName,
                IsAbstract = actorType.GetTypeInfo().IsAbstract,
                IsRemindable = actorType.IsRemindableActor(),
                EventInterfaceTypes = eventInterfaces,
                StatePersistence = StatePersistenceAttribute.Get(actorType).StatePersistence
            });
        }
示例#4
0
 // We need this to have ActorEventProxy invoking V1 Api for Compat Mode
 protected override MethodBodyTypesBuildResult BuildMethodBodyTypes(Type interfaceType)
 {
     return(this.methodBodyTypesBuilder.Build(ActorEventInterfaceDescription.Create(interfaceType)));
 }