public static void Reset() { ResetThis(); ActorInterface.Reset(); ActorPrototype.Reset(); ActorEndpointFactory.Reset(); StreamProvider.Reset(); Ref.Reset(); }
static void Register(Type actor) { var type = RegisterThis(actor); ActorInterface.Register(type); ActorPrototype.Register(type); ActorEndpointFactory.Register(type); StreamProvider.Register(type); Ref.Register(type); }
public static void Reset() { ResetThis(); ActorInterface.Reset(); ActorPrototype.Reset(); ActorEndpointFactory.Reset(); Ref.Reset(); StreamSubscriptionMatcher.Reset(); }
static void Register(Type actor) { var type = RegisterThis(actor); ActorInterface.Register(type); ActorPrototype.Register(type); ActorEndpointFactory.Register(type); Ref.Register(type); StreamSubscriptionMatcher.Register(type); }
ActorTypeDeclaration(Type actor) { this.actor = actor; var typeName = ActorTypeName.Of(actor); @interface = ActorInterface.Of(typeName); var path = typeName.Split(separator, StringSplitOptions.RemoveEmptyEntries); clazz = path.Last(); namespaces = path.TakeWhile(x => x != clazz).ToList(); namespaces.Insert(0, "Fun"); }
internal ActorType(Type @class, ActorInterface @interface, Type grain, string[] conventions) { Class = @class; Interface = @interface; Grain = grain; TypeCode = grain.TypeCode(); Sticky = StickyAttribute.IsApplied(@class); keepAliveTimeout = Sticky ? TimeSpan.FromDays(365 * 10) : KeepAliveAttribute.Timeout(@class); interleavePredicate = InterleaveAttribute.MayInterleavePredicate(@class); invoker = InvokerAttribute.From(@class); dispatcher = new Dispatcher(@class, conventions); dispatchers.Add(@class, dispatcher); Init(grain); }
public static IEnumerable <ActorType> Generate(Assembly[] assemblies) { var declarations = assemblies .SelectMany(x => x.ActorTypes()) .Select(x => new ActorTypeDeclaration(x)) .ToArray(); var dir = Path.Combine(Path.GetTempPath(), "Orleankka.Auto.Implementations"); Directory.CreateDirectory(dir); var binary = Path.Combine(dir, Guid.NewGuid().ToString("N") + ".dll"); var generated = Generate(assemblies, declarations); var syntaxTree = CSharpSyntaxTree.ParseText(generated.Source); var references = AppDomain.CurrentDomain.GetAssemblies() .Concat(generated.References) .Concat(ActorInterface.Registered().Select(x => x.GrainAssembly())) .Distinct() .Select(ToMetadataReference) .Where(x => x != null) .ToArray(); var compilation = CSharpCompilation.Create("Orleankka.Auto.Implementations", syntaxTrees: new[] { syntaxTree }, references: references, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var result = compilation.Emit(binary); if (!result.Success) { var failures = result.Diagnostics.Where(diagnostic => diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error); throw new Exception("Bad type.\n\n" + string.Join("\n", failures)); } var assemblyName = AssemblyName.GetAssemblyName(binary); var assembly = AppDomain.CurrentDomain.Load(assemblyName); return(declarations.Select(x => x.From(assembly))); }