public static ActorTypeInformation Get()

in src/Microsoft.ServiceFabric.Actors/Runtime/ActorTypeInformation.cs [114:203]


        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);
                }
            }

            var types = new List<Type> { actorType };
            types.AddRange(actorInterfaces);
#if !DotNetCoreClr
            var remotingserver = Services.Remoting.RemotingListenerVersion.V1;
#else
            var remotingserver = Services.Remoting.RemotingListenerVersion.V2;
#endif
            var remotingserverAttribuite = ActorRemotingProviderAttribute.GetProvider(types);
            if (remotingserverAttribuite != null)
            {
                remotingserver = remotingserverAttribuite.RemotingListenerVersion;
            }

            return new ActorTypeInformation()
            {
                InterfaceTypes = actorInterfaces,
                ImplementationType = actorType,
                ServiceName = actorServiceName,
                IsAbstract = actorType.GetTypeInfo().IsAbstract,
                IsRemindable = actorType.IsRemindableActor(),
                EventInterfaceTypes = eventInterfaces,
                StatePersistence = StatePersistenceAttribute.Get(actorType).StatePersistence,
                RemotingListenerVersion = remotingserver,
            };
        }