Files
mROA/mROA.Codegen/RemoteTypeBinder.cstmpl
T

53 lines
2.1 KiB
Plaintext

// <auto-generated/>
using System.Collections.Generic;
using System.Reflection;
using System;
using mROA.Abstract;
using mROA.Implementation.Backend;
using mROA.Implementation;
namespace mROA.Codegen
{
public sealed class RemoteTypeBinder
{
static RemoteTypeBinder(){
RemoteInstanceRepository.RemoteTypeFactories = new Dictionary<Type, Func<int, IRepresentationModule, IEndPointContext, RemoteObjectBase>> {
<!I remoteTypePair r sep typesSep><!D typesSep>,
<!D>
};
InstanceRepository.EventBinders = new object[] {
<!I eventBinder r sep typesSep>
<!T objectBinderTemplate>
new EventBinder<<!L type>>
{
BindAction = (instance, context, representationProducer, index) =>
{
var ownerId = context.OwnerId;
var module = representationProducer.Produce(ownerId);
<!I eventBinder r sep typesSep><!D typesSep>
<!D>
<!T eventBinderTemplate>
(instance as <!L type>).<!L eventName> += (<!L parametersDeclaration>) =>
{
Console.WriteLine($"Try to send to {ownerId} with hash code {context.GetHashCode()}");
<!I callFilter>
Console.WriteLine("Sending event...");
var request = new DefaultCallRequest
{
CommandId = <!L commandId>,
ObjectId = new ComplexObjectIdentifier(index, ownerId),
Parameters = new object[] { <!L transferParameters> }
};
module.PostCallMessageAsync(request.Id, EMessageType.EventRequest, request, context);
};
<!T>
}
}
<!T>
};
}
}
}