Пример #1
0
        ///// <summary>
        ///// 当前循环集合
        ///// </summary>
        //protected object _loopValues_;
        ///// <summary>
        ///// 当前循环值
        ///// </summary>
        //protected object _loopValue_;
        /// <summary>
        /// 输出类定义开始段代码
        /// </summary>
        /// <param name="language">代码生成语言</param>
        /// <param name="isOutDefinition">是否输出类定义</param>
        /// <returns>类定义</returns>
        protected bool outStart(fastCSharp.code.auto.language language, bool isOutDefinition)
        {
            _definition_ = null;
            _language_   = language;
            if (isOutDefinition)
            {
                _code_.Empty();
                if (fastCSharp.code.coder.Add(GetType(), type.Type))
                {
                    switch (_language_)
                    {
                    case auto.language.JavaScript:
                    case auto.language.TypeScript:
                        _definition_ = new definition.javaScript(type);
                        break;

                    default: _definition_ = new definition.cSharp(type, true, false); break;
                    }
                    _code_.Add(_definition_.Start);
                    return(true);
                }
                return(false);
            }
            return(true);
        }
Пример #2
0
            /// <summary>
            /// 安装完成处理
            /// </summary>
            protected override void onCreated()
            {
                string webPathCode = @"//本文件由程序自动生成,请不要自行修改
" + onCreatedCode;

                code.Empty();
                if (fastCSharp.code.coder.WriteFileSuffix(outputFileName, webPathCode))
                {
                    fastCSharp.code.error.Message(outputFileName + " 被修改");
                }
            }
Пример #3
0
 ///// <summary>
 ///// 当前循环集合
 ///// </summary>
 //protected object _loopValues_;
 ///// <summary>
 ///// 当前循环值
 ///// </summary>
 //protected object _loopValue_;
 /// <summary>
 /// 输出类定义开始段代码
 /// </summary>
 /// <returns>类定义</returns>
 protected definition outStart()
 {
     if (fastCSharp.setup.cSharp.coder.Add(GetType(), CodeType.Type, null))
     {
         definition definition = new definition(type, true, false);
         _code_.Empty();
         _code_.Add(definition.Start);
         return(definition);
     }
     return(null);
 }
Пример #4
0
 /// <summary>
 /// 添加代码
 /// </summary>
 /// <param name="code">代码,null表示截断字符串</param>
 protected virtual void pushCode(string code)
 {
     if (code != null)
     {
         pushCodes.Add(code);
     }
     else
     {
         code = pushCodes.ToString();
         if (code.Length != 0)
         {
             this.code.Append(@"
     _code_.Add(@""", code.Replace(@"""", @""""""), @""");");
         }
         pushCodes.Empty();
     }
 }
Пример #5
0
            /// <summary>
            /// 安装完成处理
            /// </summary>
            public void OnCreated()
            {
                string webViewCode = webView.ts.Code;

                if (code.Count != 0 || webViewCode != null)
                {
                    string apiCode = @"//本文件由程序自动生成,请不要自行修改
" + code.ToString() + (webViewCode == null ? null : @"
" + webViewCode);
                    code.Empty();
                    string fileName = AutoParameter.ProjectPath + @"viewJs\api.ts";
                    if (fastCSharp.code.coder.WriteFileSuffix(fileName, apiCode))
                    {
                        fastCSharp.code.error.Message(fileName + " 被修改");
                    }
                }
            }
Пример #6
0
            /// <summary>
            /// 安装完成处理
            /// </summary>
            protected unsafe override void onCreated()
            {
                stringBuilder      clientCallCode = new stringBuilder();
                list <methodIndex> methods        = new list <methodIndex>();

                methodIndex[] methodIndexs;
                foreach (server server in servers.Values)
                {
                    if (server.IsMethod)
                    {
                        IsAllType = false;
                        TcpServerAttributeType = server.AttributeType == null || server.AttributeType.Type == null ? null : server.AttributeType.FullName;
                        ServiceAttribute       = fastCSharp.config.pub.LoadConfig(server.TcpServer, server.TcpServer.ServiceName);
                        foreach (server.type serverType in server.Types)
                        {
                            methods.Add(serverType.Methods);
                        }
                        methodIndexs = methods.ToArray();
                        methods.Empty();
                        if (ServiceAttribute.IsIdentityCommand)
                        {
                            methodIndexs = methodIndex.CheckIdentity(methodIndexs, ServiceAttribute.IsRememberIdentityCommand ? getRememberIdentityName() : nullRememberIdentityName, method => method.Method.MethodKeyFullName);
                            if (methodIndexs == null)
                            {
                                return;
                            }
                        }
                        int index = 0;
                        foreach (methodIndex method in methodIndexs)
                        {
                            method.MethodIndex = index++;
                        }
                        foreach (server.type serverType in server.Types)
                        {
                            if (serverType.Methods.Count != 0)
                            {
                                type         = serverType.Type;
                                IsTimeVerify = type == server.AttributeType && server.IsTimeVerify;
                                Attribute    = serverType.Attribute ?? new code.cSharp.tcpCall();
                                MethodIndexs = serverType.Methods.ToArray();
                                definition.cSharp definition = new definition.cSharp(type, true, false);
                                _code_.Empty();
                                create(false);
                                fastCSharp.code.coder.Add(definition.Start + _partCodes_["SERVERCALL"] + definition.End);
                                if (ServiceAttribute.IsSegmentation)
                                {
                                    clientCallCode.Add(definition.Start + _partCodes_["CLIENTCALL"] + definition.End);
                                }
                                else
                                {
                                    fastCSharp.code.coder.Add(definition.Start + _partCodes_["CLIENTCALL"] + definition.End);
                                }
                            }
                        }
                        IsAllType    = true;
                        MethodIndexs = methodIndexs;
                        methodIndexs = methodIndexs.getFindArray(value => !value.IsNullMethod);
                        if (ServiceAttribute.IsHttpClient && !methodIndex.CheckHttpMethodName(methodIndexs))
                        {
                            return;
                        }
                        IsVerifyMethod = methodIndexs.any(value => value.IsVerifyMethod);
                        subArray <int> groupIds = methodIndexs.distinct(value => value.Attribute.GroupId);
                        groupIds.Remove(0);
                        MethodGroups = groupIds.GetArray(value => new methodGroup {
                            GroupId = value
                        });
                        MaxCommandLength = (ServiceAttribute.IsIdentityCommand ? sizeof(int) : methodIndexs.maxKey(value => (value.Method.MethodKeyFullName.Length + 3) & (int.MaxValue - 3), sizeof(int))) + sizeof(int) * 4 + sizeof(fastCSharp.net.tcp.commandServer.streamIdentity);
                        _code_.Empty();
                        create(false);
                        fastCSharp.code.coder.Add(@"
namespace " + AutoParameter.DefaultNamespace + "." + serverPart + @"
{
" + _partCodes_["SERVER"] + @"
}");
                        string clientCode = @"
namespace " + AutoParameter.DefaultNamespace + "." + clientPart + @"
{
" + _partCodes_["CLIENT"] + @"
}";
                        if (ServiceAttribute.IsIdentityCommand && ServiceAttribute.IsRememberIdentityCommand)
                        {
                            coder.AddRemember(@"
namespace " + AutoParameter.DefaultNamespace + @".tcpRemember
{
" + _partCodes_["REMEMBER"] + @"
}");
                        }
                        if (ServiceAttribute.IsSegmentation)
                        {
                            clientCallCode.Add(clientCode);
                            string fileName = AutoParameter.ProjectPath + "{" + AutoParameter.DefaultNamespace + "}.tcpCall." + ServiceAttribute.ServiceName + ".client.cs";
                            clientCode = fastCSharp.code.coder.WarningCode + clientCallCode.ToString() + fastCSharp.code.coder.FileEndCode;
                            if (fastCSharp.code.coder.WriteFile(fileName, clientCode))
                            {
                                if (ServiceAttribute.ClientSegmentationCopyPath != null)
                                {
                                    string copyFileName = ServiceAttribute.ClientSegmentationCopyPath + "{" + AutoParameter.DefaultNamespace + "}.tcpCall." + ServiceAttribute.ServiceName + ".client.cs";
                                    if (!fastCSharp.code.coder.WriteFile(copyFileName, clientCode))
                                    {
                                        fastCSharp.code.error.Add(copyFileName + " 写入失败");
                                    }
                                }
                                fastCSharp.code.error.Message(fileName + " 被修改");
                            }
                            clientCallCode.Empty();
                        }
                        else
                        {
                            fastCSharp.code.coder.Add(clientCode);
                        }
                    }
                }
            }