public PropertyInfo SearchProperty(string name) { var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/); foreach (var property in propertyArray) { if (ReflectionUtil.IsDeclare(MType, property)) { MappingCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(MappingCodeAttribute)) as MappingCodeAttribute; if (propertyAttr == null) { if (property.Name == name) { return(property); } } else { if (propertyAttr.Code == name) { return(property); } } } } return(null); }
public FieldInfo SearchField(string name) { var fieldArray = MType.GetFields(); foreach (FieldInfo field in fieldArray) { if (ReflectionUtil.IsDeclare(MType, field)) { MappingCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(MappingCodeAttribute)) as MappingCodeAttribute; if (propertyAttr == null) { if (field.Name == name) { return(field); } } else { if (propertyAttr.Code == name) { return(field); } } } } return(null); }
public TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = MType.GetMethods(/*BindingFlags.DeclaredOnly*/); foreach (var method in methodArray) { if (ReflectionUtil.IsDeclare(MType, method)) { MappingCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(MappingCodeAttribute)) as MappingCodeAttribute; if (procAttr == null) { TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(method); if (typeProcDesc.Eq(procDesc)) { return(typeProcDesc); } } else { ProcDescCodeParser parser = new ProcDescCodeParser(); ParameterInfo[] paramArray = method.GetParameters(); foreach (var param in paramArray) { parser.AddType(param.ParameterType); } TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code); if (typeProcDesc.Eq(procDesc)) { typeProcDesc.Method = method; return(typeProcDesc); } } } } return(null); }
public TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = MType.GetMethods(); foreach (var method in methodArray) { if (ReflectionUtil.IsDeclare(MType, method)) { MappingCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(MappingCodeAttribute)) as MappingCodeAttribute; if (procAttr == null) { TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(method); if (typeProcDesc.Eq(procDesc)) { MethodInfo rmethod = method; if (rmethod.IsAbstract) { rmethod = searchMethodByMethod(method); } if (rmethod == null) { throw new RTException("方法与被翻译类型的方法不一致"); } else { TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(rmethod); return(rdesc); } } } else { ParameterInfo[] paramArray = method.GetParameters(); foreach (var param in paramArray) { parser.AddType(param.ParameterType); } TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code); if (method.IsStatic && !method.IsAbstract && typeProcDesc.HasSubject() && typeProcDesc.GetSubjectArg().ArgType == this.ForType) { typeProcDesc = typeProcDesc.CreateTail(); } if (typeProcDesc.Eq(procDesc)) { MethodInfo rmethod = method; if (rmethod.IsAbstract) { rmethod = searchMethodByMethod(method); } if (rmethod == null) { throw new RTException("过程描述标注错误"); } else { typeProcDesc.Method = rmethod; return(typeProcDesc); } } } } } return(null); }