[fix]修正UdpServer在接收广播时连续启动接收的错误,在StarAgent中,此时可能收到广播包,SocketFlags是Broadcast,需要清空,否则报错“参考的对象类型不支持尝试的操作”; 无需设置SocketOptionName.PacketInformation,在ReceiveMessageFromAsync时会自动设置,并且支持ipv6;
石头 authored at 2024-10-10 00:36:00 石头 committed at 2024-10-10 00:45:43
1.73 KiB
X
<#@ template language="C#" hostSpecific="true" debug="true" #>
<#@ assembly name="$(SolutionDir)\DLL\NewLife.Core.dll" #>
<#@ assembly name="$(SolutionDir)\DLL\XCode.dll" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="XCode.Code" #>
<#@ import namespace="XCode.DataAccessLayer" #>
<#@ output extension=".log" #>
<#
    // XCode代码生成模板用法: https://www.yuque.com/smartstone/xcode/model

    // 设置当前工作目录
	PathHelper.BasePath = Host.ResolvePath(".");

    // 设置如何格式化字段名,默认去掉下划线并转驼峰命名
    //ModelResolver.Current = new ModelResolver { TrimUnderline = false, Camel = false };

    // 加载模型文件,得到数据表
    var option = new BuilderOption();
    var tables = ClassBuilder.LoadModels(null, option, out var atts);
    EntityBuilder.FixModelFile(null, option, atts, tables);

    // 生成实体类
    //option.BaseClass = "I{name}";
    //option.ModelNameForCopy = "I{name}";
    EntityBuilder.BuildTables(tables, option, chineseFileName: true);

    // 生成简易模型类
    option.Output = @"Output\EntityModels\";
    option.ClassNameTemplate = "{name}Model";
    option.ModelNameForCopy = "I{name}";
    //ClassBuilder.BuildModels(tables, option);

    // 生成简易接口
    option.BaseClass = null;
    option.ClassNameTemplate = null;
    option.Output = @"Output\EntityInterfaces\";
    //ClassBuilder.BuildInterfaces(tables, option);

    // 精确控制生成
    /*foreach (var item in tables)
    {
        var builder = new ClassBuilder
        {
            Table = item,
            Option = option.Clone(),
        };
        builder.Execute();
        builder.Save(null, true, false);
    }*/
#>