protected override ProxyGeneratorBuildResult BuildProxyGenerator(Type interfaceType) { // get all event interfaces supported by this actorInterface and build method dispatchers for those var actorEventInterfaces = interfaceType.GetActorEventInterfaces(); var actorEventDispatchers = actorEventInterfaces.Select( t => this.eventCodeBuilder.GetOrBuilderMethodDispatcher(t).MethodDispatcher); IEnumerable <ActorMethodDispatcherBase> actorMethodDispatcherBases = actorEventDispatchers.Cast <ActorMethodDispatcherBase>(); // register them with the event subscriber manager ActorEventSubscriberManager.Singleton.RegisterEventDispatchers(actorMethodDispatcherBases); // create all actor interfaces that this interface derives from var actorInterfaces = new List <Type>() { interfaceType }; actorInterfaces.AddRange(interfaceType.GetActorInterfaces()); // create interface descriptions for all interfaces var actorInterfaceDescriptions = actorInterfaces.Select <Type, InterfaceDescription>( t => ActorInterfaceDescription.CreateUsingCRCId(t)); var res = this.proxyGeneratorBuilder.Build(interfaceType, actorInterfaceDescriptions); InterfaceDetailsStore.UpdateKnownTypesDetails(actorInterfaceDescriptions); return(res); }
protected MethodDispatcherBuildResult BuildMethodDispatcher(Type interfaceType) { var actorInterfaceDescription = ActorInterfaceDescription.CreateUsingCRCId(interfaceType); var res = this.methodDispatcherBuilder.Build(actorInterfaceDescription); return(res); }
protected override MethodDispatcherBuildResult BuildMethodDispatcher(Type interfaceType) { var actorInterfaceDescription = ActorInterfaceDescription.CreateUsingCRCId(interfaceType); var res = this.methodDispatcherBuilder.Build(actorInterfaceDescription); InterfaceDetailsStore.UpdateKnownTypeDetail(actorInterfaceDescription); return(res); }
protected MethodBodyTypesBuildResult BuildMethodBodyTypes(Type interfaceType) { var actorInterfaceDescriptions = ActorInterfaceDescription.CreateUsingCRCId(interfaceType); var result = this.methodBodyTypesBuilder.Build(actorInterfaceDescriptions); InterfaceDetailsStore.UpdateKnownTypeDetail(actorInterfaceDescriptions, result); return(result); }
internal ActorMethodFriendlyNameBuilder(ActorTypeInformation actorTypeInformation) { this.actorMethodDescriptions = new Dictionary <Type, Tuple <int, MethodDescription[]> >(); foreach (var actorInterfaceType in actorTypeInformation.InterfaceTypes) { var actorInterfaceDescription = ActorInterfaceDescription.Create(actorInterfaceType); this.actorMethodDescriptions[actorInterfaceType] = new Tuple <int, MethodDescription[]>( actorInterfaceDescription.Id, actorInterfaceDescription.Methods); } }
internal ActorMethodFriendlyNameBuilder(ActorTypeInformation actorTypeInformation) { this.actorMethodDescriptions = new Dictionary <Type, ActorInterfaceDescription>(); this.actorMethodDescriptionsV2 = new Dictionary <Type, ActorInterfaceDescription>(); foreach (var actorInterfaceType in actorTypeInformation.InterfaceTypes) { var actorInterfaceDescription = ActorInterfaceDescription.Create(actorInterfaceType); this.actorMethodDescriptions[actorInterfaceType] = actorInterfaceDescription; var actorInterfaceDescriptionV2 = ActorInterfaceDescription.CreateUsingCRCId(actorInterfaceType); this.actorMethodDescriptionsV2[actorInterfaceType] = actorInterfaceDescriptionV2; } }
protected ActorProxyGeneratorBuildResult BuildProxyGenerator(Type interfaceType) { // create all actor interfaces that this interface derives from var actorInterfaces = new List <Type>() { interfaceType }; actorInterfaces.AddRange(interfaceType.GetActorInterfaces()); // create interface descriptions for all interfaces var actorInterfaceDescriptions = actorInterfaces.Select <Type, InterfaceDescription>( t => ActorInterfaceDescription.CreateUsingCRCId(t)); var res = this.proxyGeneratorBuilder.Build(interfaceType, actorInterfaceDescriptions); return(res); }
/// <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 }); }
protected override MethodBodyTypesBuildResult BuildMethodBodyTypes(Type interfaceType) { return(this.methodBodyTypesBuilder.Build(ActorInterfaceDescription.Create(interfaceType))); }