コード例 #1
0
 public static string MakeArgNotNullCode(string argName)
 {
     TemplateResolver rsv = new TemplateResolver(GetTemplate(@"TauCode.Wagen.Client.Resources.ArgNull.txt"));
     rsv.Map("arg", argName);
     string res = rsv.Resolve();
     return res;
 }
コード例 #2
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        private string MakeServiceNewRegion()
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.HandleServiceNewRegion.txt"));

            rsv.Map("serviceName", this.ServiceInterfaceTypeName);

            string res = "{0}{1}".FormatWith(
                Environment.NewLine + Environment.NewLine,
                rsv.Resolve());

            return res;
        }
コード例 #3
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        private string GenerateServiceProxyMethod(MethodInfo methodInfo, Type returnType, ParamRec[] before)
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.ServiceProxyMethod.txt"));

            Type actualReturnType = returnType ?? methodInfo.ReturnType;
            string type = CodeGeneratorHelper.TypeToString(actualReturnType);
            string name = methodInfo.Name;

            rsv.Map("returnType", type);

            rsv.Map("methodName", name);
            rsv.Map("argsDefinition", CodeGeneratorHelper.MakeMethodArgsDefinitionCode(
                methodInfo,
                before));

            string[] beforeArgValues = _isAccountHandle ? new[] { "sessionId" } : null;

            rsv.Map("args", CodeGeneratorHelper.MakeMethodArgsCode(methodInfo, beforeArgValues, true));

            // return
            string resTypeCasting;
            string ret;

            if (actualReturnType == typeof(void))
            {
                resTypeCasting = string.Empty;
                ret = "// no return from void";
            }
            else
            {
                resTypeCasting = "{0} res = ({0})".FormatWith(type);
                ret = "return res;";
            }

            rsv.Map("result-type-casting", resTypeCasting);
            rsv.Map("return", ret);

            return rsv.Resolve();
        }
コード例 #4
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        private string GenerateNormalMethodCode(MethodInfo mi)
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.HandleMethodNormal.txt"));

            rsv.Map("returnType", CodeGeneratorHelper.TypeToString(mi.ReturnType));
            rsv.Map("methodName", mi.Name);

            string handleMethodArgDefs = CodeGeneratorHelper.MakeMethodArgsDefinitionCode(mi, null);
            rsv.Map("handleMethodArgDefs", handleMethodArgDefs);

            string ret = mi.ReturnType == typeof(void) ? string.Empty : "return ";
            rsv.Map("return", ret);

            string thisServiceProxyInstance = this.GenerateServiceProxyInstanceCode();
            rsv.Map("thisServiceProxyInstance", thisServiceProxyInstance);

            string serviceMethodArgs = this.GenerateServiceMethodArgsCode(mi);
            rsv.Map("serviceMethodArgs", serviceMethodArgs);

            string res = rsv.Resolve();
            return res;
        }
コード例 #5
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        private string GenerateAccountRestoreMethod(MethodInfo mi)
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.HandleMethodAccountRestore.txt"));

            CodeGeneratorEntry retEntry = this.CodeGenerator.GetEntry(mi.ReturnType);

            string sessionIdVarName = "sessionId";

            string createdHandleClass = retEntry.HandleClassTypeName;

            string createdHandleClassCtorArgs = retEntry.GenerateCtorArgsCode(sessionIdVarName);

            rsv.Map("createdHandleInterface", retEntry.HandleInterfaceType.Name);
            rsv.Map("methodName", mi.Name);
            rsv.Map("sessionIdVarName", sessionIdVarName);
            rsv.Map("createdHandleClass", createdHandleClass);
            rsv.Map("createdHandleClassCtorArgs", createdHandleClassCtorArgs);

            string res = rsv.Resolve();
            return res;
        }
コード例 #6
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        private string GenerateAccountAuthMethod(MethodInfo mi)
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.HandleMethodAccountAuth.txt"));

            CodeGeneratorEntry retEntry = this.CodeGenerator.GetEntry(mi.ReturnType);
            string thisHandleMethodArgDefs = CodeGeneratorHelper.MakeMethodArgsDefinitionCode(mi, null);
            string thisServiceProxyInstance = this.GenerateServiceProxyInstanceCode();
            string thisServiceMethodArgs = this.GenerateServiceMethodArgsCode(mi);
            string createdHandleClass = retEntry.HandleClassTypeName;
            string createdHandleClassCtorArgs = retEntry.GenerateCtorArgsCode(retEntry._sessionIdVariableName);
            rsv.Map("createdHandleInterface", retEntry.HandleInterfaceType.Name);
            rsv.Map("methodName", mi.Name);
            rsv.Map("thisHandleMethodArgDefs", thisHandleMethodArgDefs);
            rsv.Map("sessionIdVarName", retEntry._sessionIdVariableName);
            rsv.Map("thisServiceProxyInstance", thisServiceProxyInstance);
            rsv.Map("thisServiceMethodArgs", thisServiceMethodArgs);
            rsv.Map("createdHandleClass", createdHandleClass);
            rsv.Map("createdHandleClassCtorArgs", createdHandleClassCtorArgs);

            string res = rsv.Resolve();
            return res;
        }
コード例 #7
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        public string GenerateServiceProxyClassTypeCode()
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.ServiceProxy.txt"));

            //CodeGeneratorDomainEntry entry = this.Domain.GetEntry(handleInterfaceType);
            List<Type> usedTypes = new List<Type>(CodeGeneratorHelper.GetTypesReferencedByInterfaceMethods(this.HandleInterfaceType));

            usedTypes.AddRange(
                new[]
                {
                    typeof(IRequester),
                    typeof(ServiceProxyBase),
                });

            rsv.Map("usings", CodeGeneratorHelper.MakeUsings(usedTypes, new[] { this.HandleInterfaceType.Namespace }));
            rsv.Map("namespace", this.HandleInterfaceType.Namespace);
            rsv.Map("serviceName", this.ServiceInterfaceTypeName);
            rsv.Map("serviceProxyName", this.ServiceProxyClassTypeName);
            rsv.Map("baseClass", _isAccountHandle ? "AccountServiceProxyBase" : "ServiceProxyBase");

            string methods = this.GenerateServiceMethods(this.GenerateServiceProxyMethod);
            methods += Environment.NewLine;

            rsv.Map("methods", methods);

            //string template = this.GetType().Assembly.GetAssemblyResourceText();
            string res = rsv.Resolve();
            return res;
        }
コード例 #8
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        public string GenerateServiceInterfaceTypeCode()
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.ServiceInterface.txt"));

            List<Type> usedTypes = new List<Type>(CodeGeneratorHelper.GetTypesReferencedByInterfaceMethods(this.HandleInterfaceType));
            if (_isAccountHandle)
            {
                usedTypes.Add(typeof(IAccountHandle));
            }

            string serviceInheritance = string.Empty;

            if (_isAccountHandle)
            {
                serviceInheritance = " : IAccountService";
            }

            string methods = this.GenerateServiceMethods(this.GenerateServiceInterfaceMethod);

            rsv.Map("usings", CodeGeneratorHelper.MakeUsings(usedTypes, new[] { this.HandleInterfaceType.Namespace }));
            rsv.Map("namespace", this.HandleInterfaceType.Namespace);
            rsv.Map("serviceName", this.ServiceInterfaceTypeName);
            rsv.Map("serviceInheritance", serviceInheritance);
            rsv.Map("methods", methods);

            string res = rsv.Resolve();
            return res;
        }
コード例 #9
0
ファイル: CodeGeneratorEntry.cs プロジェクト: taucode/taucode
        public string GenerateHandleClassTypeCode()
        {
            TemplateResolver rsv = new TemplateResolver(CodeGeneratorHelper.GetTemplate(@"TauCode.Wagen.Client.Resources.Handle.txt"));

            List<Type> usedTypes = new List<Type>(CodeGeneratorHelper.GetTypesReferencedByInterfaceMethods(this.HandleInterfaceType));
            if (_isAccountHandle)
            {
                usedTypes.Add(typeof(AccountHandle));
            }

            string baseClassInheritance;
            if (_isAccountHandle)
            {
                baseClassInheritance = " AccountHandle,";
            }
            else
            {
                baseClassInheritance = string.Empty;
            }

            string ctorArgDefs = this.GenerateCtorArgDefsCode();

            string baseCtorCall;
            if (_isAccountHandle)
            {
                baseCtorCall = "{0}: base({1}, {2})".FormatWith(
                    Environment.NewLine + "            ",
                    this.ServiceProxyInstanceVariableName,
                    _sessionIdVariableName);
            }
            else
            {
                baseCtorCall = string.Empty;
            }

            string ctorCode = this.GenerateCtorBodyCode();

            string newServiceForAccountHandle;
            if (_isAccountHandle)
            {
                newServiceForAccountHandle = this.MakeServiceNewRegion();
            }
            else
            {
                newServiceForAccountHandle = string.Empty;
            }

            string handleMethods = this.GenerateHandleMethods();

            rsv.Map("usings", CodeGeneratorHelper.MakeUsings(usedTypes, new[] { this.HandleInterfaceType.Namespace }));
            rsv.Map("namespace", this.HandleInterfaceType.Namespace);
            rsv.Map("handleClassName", this.HandleClassTypeName);
            rsv.Map("baseClassInheritance", baseClassInheritance);
            rsv.Map("handleInterfaceName", this.HandleInterfaceType.Name);
            rsv.Map("fields", this.GenerateFieldsCode());
            rsv.Map("ctorArgDefs", ctorArgDefs);
            rsv.Map("baseCtorCall", baseCtorCall);
            rsv.Map("ctorCode", ctorCode);
            rsv.Map("newServiceForAccountHandle", newServiceForAccountHandle);
            rsv.Map("handleMethods", handleMethods);

            string res = rsv.Resolve();
            return res;
        }