void Register(IEnumerable <Assembly> assemblies) { foreach (var each in assemblies.SelectMany(x => x.GetTypes().Where(IsActorGrain))) { var @interface = new ActorGrainInterface(each); interfaces.Add(each.FullName, @interface); } bool IsActorGrain(Type type) => type != typeof(IActorGrain) && type.IsInterface && typeof(IActorGrain).IsAssignableFrom(type); }
void Register(IEnumerable <Assembly> assemblies) { foreach (var each in assemblies.SelectMany(x => x.GetTypes().Where(IsActorGrain))) { var @interface = new ActorGrainInterface(each); interfaces.Add(each.FullName, @interface); } bool IsActorGrain(Type type) { return(type.IsInterface && typeof(IActorGrain).IsAssignableFrom(type) && type.GetCustomAttribute <ActorGrainMarkerInterfaceAttribute>() == null); } }
public static ActorPath For(Type interfaceOrClass, string id) { Requires.NotNull(interfaceOrClass, nameof(interfaceOrClass)); Requires.NotNull(id, nameof(id)); if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentException("An actor id cannot be empty or contain whitespace only", nameof(id)); } if (!typeof(IActorGrain).IsAssignableFrom(interfaceOrClass)) { throw new InvalidOperationException($"Type '{interfaceOrClass}' should be a type which implements IActorGrain interface"); } if (!interfaceOrClass.IsInterface) { interfaceOrClass = ActorGrainInterface.InterfaceOf(interfaceOrClass); } return(new ActorPath(interfaceOrClass.FullName, id)); }
/// <summary> /// Returns actual <see cref="IActorGrain"/> interface implemented by give actor class /// </summary> /// <param name="type">The actor class type</param> /// <returns>Type of the interface</returns> public static Type InterfaceOf(Type type) => ActorGrainInterface.InterfaceOf(type);