public string BuildRdsn(Type service, QueryContext[] contexts) { //_stages = stages; _contexts = contexts; _appClassName = service.Name; //BuildInputOutputValueTypes(); BuildHeaderRdsn(service.Namespace); BuildRewrittenTypes(); _builder.AppendLine("public class " + _appClassName + "Server_impl :" + _appClassName + "Server"); _builder.BeginBlock(); BuildServiceClientsRdsn(); //thrift or protobuf BuildServiceCallsRdsn(_appClassName); foreach (var c in contexts) { //never change BuildQueryRdsn(c); } //always thrift BuildServer(_appClassName, ServiceContract.GetServiceCalls(service)); _builder.EndBlock(); BuildMain(); BuildFooter(); return(_builder.ToString()); }
public static ServicePlan Compile(Type serviceType) { var calls = new Dictionary <MethodInfo, MethodCallExpression>(); var ctor = serviceType.GetConstructor(new Type[] { }); Debug.Assert(ctor != null, "ctor != null"); var this_ = ctor.Invoke(new object[] { }); foreach (var m in ServiceContract.GetServiceCalls(serviceType)) { var constructorInfo = m.GetParameters()[0].ParameterType.GetConstructor(new[] { typeof(string) }); if (constructorInfo == null) { continue; } var req = constructorInfo.Invoke(new object[] { "request" }); var result = (ISymbol)m.Invoke(this_, new[] { req }); calls[m] = result.Expression as MethodCallExpression; } return(Compile(calls, this_)); }