示例#1
0
 /// <summary>
 /// 安装入口
 /// </summary>
 /// <param name="exportPathType">导出引导类型</param>
 /// <returns>是否安装成功</returns>
 public bool Run(Type exportPathType, string outputFileName)
 {
     fastCSharp.code.cSharp.webPath exportWebPath = exportPathType.customAttribute <fastCSharp.code.cSharp.webPath>(false);
     if (exportWebPath == null)
     {
         error.Message("没有找到 path 导出信息 " + exportPathType.fullName());
     }
     else if (exportWebPath.Flag == 0)
     {
         error.Message("缺少导出二进制位标识 " + exportPathType.fullName());
     }
     else
     {
         foreach (Type type in exportPathType.Assembly.GetTypes())
         {
             fastCSharp.code.cSharp.webPath webPath = type.customAttribute <fastCSharp.code.cSharp.webPath>(false);
             if (webPath != null && (webPath.Flag & exportWebPath.Flag) == exportWebPath.Flag)
             {
                 this.type = type;
                 Attribute = webPath;
                 nextCreate();
             }
         }
         this.outputFileName = outputFileName + outputFileExtensionName;
         onCreated();
         return(true);
     }
     return(false);
 }
示例#2
0
            /// <summary>
            /// 安装下一个类型
            /// </summary>
            protected override void nextCreate()
            {
                sqlStreamMember[] members = code.memberInfo.GetMembers(type, Attribute.MemberFilter)
                                            .getArray(value => new sqlStreamMember {
                    Member = value, Attribute = value.GetAttribute <fastCSharp.emit.dataMember>(Attribute.IsBaseTypeAttribute, Attribute.IsInheritAttribute)
                });
                WebPaths.Empty();
                list <webPathType> types;

                if (webPathTypes == null)
                {
                    webPathTypes = new Dictionary <Type, list <webPathType> >();
                    foreach (Type type in AutoParameter.Types)
                    {
                        fastCSharp.code.cSharp.webPath webPath = type.customAttribute <fastCSharp.code.cSharp.webPath>(false);
                        if (webPath != null && webPath.Type != null && webPath.MemberName != null)
                        {
                            FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
                            if (fields.Length != 0)
                            {
                                if (!webPathTypes.TryGetValue(webPath.Type, out types))
                                {
                                    webPathTypes.Add(webPath.Type, types = new list <webPathType>());
                                }
                                int memberIndex = fields.Length;
                                types.Add(new webPathType {
                                    MemberType = type, Attribute = webPath, Members = fields.getArray(value => new memberInfo(value, --memberIndex))
                                });
                            }
                        }
                    }
                }
                if (webPathTypes.TryGetValue(type, out types))
                {
                    foreach (webPathType webPath in types)
                    {
                        memberInfo[] fields = webPath.CheckMembers(members);
                        if (fields != null)
                        {
                            WebPaths.Add(new webPathType {
                                MemberType = webPath.MemberType, Attribute = webPath.Attribute, Members = fields
                            });
                        }
                    }
                }
                CounterMembers = members.getFindArray(value => value.Attribute != null && value.Attribute.CounterTimeout > 0 && value.Member.Type == typeof(int));
                if (Attribute.LogTcpCallService == null)
                {
                    SqlStreamMembers = null;
                }
                else
                {
                    SqlStreamMembers = members.getFindArray(value => value.Attribute != null && (value.Attribute.IsSqlStream || value.Attribute.SqlStreamCountType != null));
                    if (!Attribute.IsDefaultSerialize && Attribute.IsLogMemberMap)
                    {
                        fastCSharp.emit.dataSerialize dataSerialize = type.Type.customAttribute <fastCSharp.emit.dataSerialize>(true);
                        if (dataSerialize != null && !dataSerialize.IsMemberMap)
                        {
                            error.Message("数据库日志流处理类型 " + type.FullName + " 序列化不支持成员位图");
                        }
                    }
                }
                SqlStreamTypeCount = SqlStreamMembers.count(value => value.Attribute.SqlStreamCountType != null);
                subArray <sqlStreamMember> strings = members.getFind(value => value.Member.Type == typeof(string) && (value.Attribute == null || (value.Attribute.MaxStringLength == 0 && !value.Attribute.IsIgnoreMaxStringLength)));

                if (strings.Count != 0)
                {
                    error.Message(type.FullName + " 字符串字段缺少最大长度限制 " + strings.joinString(',', value => value.Member.MemberName));
                }
                IndexMembers   = members.getFind(value => value.Attribute != null && value.Attribute.IsMemberIndex).getArray(value => value.Member);
                NowTimeMembers = members.getFind(value => value.Member.MemberType.IsDateTime && value.Attribute != null && value.Attribute.IsNowTime).getArray(value => new nowTimeMember {
                    Member = value.Member
                });
                base.nextCreate();
            }