public static ActorTypeInformation Get(Type actorType) { Debug.Assert(actorType != null); Debug.Assert(actorType.BaseType == typeof(Actor), "Actor must inherit from Actor class."); Debug.Assert(actorType.GetInterfaces().Contains(typeof(IActor))); IEnumerable <ApplicationManifestAttribute> manifests = actorType.GetCustomAttributes <ApplicationManifestAttribute>(); Debug.Assert(manifests.Count() > 0, "Actor must possess one or more ApplicationManifestAttributes."); foreach (ApplicationManifestAttribute manifest in manifests) { Debug.Assert(ActorNaming.ValidateActorNames(actorType.Name, manifest.ServiceName), "All actor service names must end with 'ActorService'."); } StatePersistenceAttribute persistenceAttribute = actorType.GetCustomAttributes(typeof(StatePersistenceAttribute), false).SingleOrDefault() as StatePersistenceAttribute; Debug.Assert(persistenceAttribute != null, "Actor must possess a StatePersistenceAttribute."); return(new ActorTypeInformation { ImplementationType = actorType, InterfaceTypes = actorType.GetInterfaces().Where(type => type.Equals(typeof(IActor)) == false).ToArray(), IsAbstract = actorType.IsAbstract, ServiceName = ActorNaming.BuildActorServiceName(actorType.Name), StatePersistence = persistenceAttribute.StatePersistence }); }
public static Uri Node <I>(Actor caller, string actorName) where I : IActor { Debug.Assert(typeof(I).IsInterface); Debug.Assert(caller != null); string[] namespaceSegments = caller.ServiceUri.Segments; Uri serviceUri = new Uri("fabric:/" + namespaceSegments[1] + ActorNaming.BuildActorServiceName(actorName)); return(serviceUri); }
public static Uri Accessor <I>(string actorName) where I : IActor { Debug.Assert(typeof(I).IsInterface); string[] namespaceSegments = typeof(I).Namespace.Split('.'); Uri serviceUri = new Uri("fabric:/" + Naming.Resource <I>() + "/" + ActorNaming.BuildActorServiceName(actorName)); return(serviceUri); }