public override TKTProcDesc[] GetProces() { List <TKTProcDesc> list = new List <TKTProcDesc>(); var methodArray = this.SharpType.GetMethods(); foreach (var method in methodArray) { if (!ReflectionUtil.IsDeclare(SharpType, method)) { continue; } /* 编译器生成的类肯定有标注 */ ZCodeAttribute procAttr = AttributeUtil.GetAttribute <ZCodeAttribute>(method); ProcDescCodeParser parser = new ProcDescCodeParser(); parser.InitType(SharpType, method); TKTProcDesc typeProcDesc = parser.Parser(procAttr.Code); ExMethodInfo exMethod = ZTypeUtil.CreatExMethodInfo(method, this.SharpType); typeProcDesc.ExMethod = exMethod; list.Add(typeProcDesc); } if (ParentMapping != null) { TKTProcDesc[] epi = ParentMapping.GetProces(); foreach (var pitem in epi) { pitem.ExMethod.IsSelf = false; } list.AddRange(epi); } return(list.ToArray()); }
public override TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = this.SharpType.GetMethods( ); foreach (var method in methodArray) { if (!ReflectionUtil.IsDeclare(SharpType, method)) { continue; } /* 编译器生成的类肯定有标注 */ ZCodeAttribute procAttr = AttributeUtil.GetAttribute <ZCodeAttribute>(method);// Attribute.GetCustomAttribute(method, typeof(ZCodeAttribute)) as ZCodeAttribute; //if (procAttr == null) //{ // ExMethodInfo exMethod = ZTypeHelper.CreatExMethodInfo(method, this.SharpType); // TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod); // if (typeProcDesc.Eq(procDesc)) // { // return typeProcDesc; // } //} //else //{ ProcDescCodeParser parser = new ProcDescCodeParser(); parser.InitType(SharpType, method); TKTProcDesc typeProcDesc = parser.Parser(procAttr.Code); if (typeProcDesc.Eq(procDesc)) { ExMethodInfo exMethod = ZTypeUtil.CreatExMethodInfo(method, this.SharpType); typeProcDesc.ExMethod = exMethod; return(typeProcDesc); } //} } if (ParentMapping != null) { return(ParentMapping.SearchProc(procDesc)); } return(null); }
public override TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = this.SharpType.GetMethods(); foreach (var method in methodArray) { if (!ReflectionUtil.IsDeclare(SharpType, method)) { continue; } /* 映射类可能有多个同义的方法对应同一个实际方法 */ ZCodeAttribute[] attrs = AttributeUtil.GetAttributes <ZCodeAttribute>(method); /* 编译器生成的类可能没有标注,没有标注的方法必定在ZMappingType上 */ if (attrs.Length == 0) { ExMethodInfo exMethod = ZTypeUtil.CreatExMethodInfo(method, this.SharpType); TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod); if (typeProcDesc.Eq(procDesc)) { TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(exMethod); return(rdesc); } } else if (attrs.Length > 0) { ParameterInfo[] paramArray = method.GetParameters(); parser.InitType(SharpType, method); foreach (ZCodeAttribute attr in attrs) { ZCodeAttribute zCodeAttribute = attr as ZCodeAttribute; TKTProcDesc typeProcDesc = parser.Parser(zCodeAttribute.Code); if (method.IsStatic && !method.IsAbstract && typeProcDesc.HasSubject() && typeProcDesc.GetSubjectArg().ArgType == this.SharpType) { typeProcDesc = typeProcDesc.CreateTail(); } if (typeProcDesc.Eq(procDesc)) { ExMethodInfo exMethod = null;// getExMethod(method); /* 非 Abstract 的方法肯定从被映射的类中搜索 */ if (method.IsAbstract) { var method2 = searchMethodFromSharp(method); exMethod = ZTypeUtil.CreatExMethodInfo(method2, this.SharpType); //return exMethod; } else { exMethod = ZTypeUtil.CreatExMethodInfo(method, this.ZMappingType); //return exMethod; } typeProcDesc.ExMethod = exMethod; return(typeProcDesc); } } } } if (ParentMapping != null && !isRoot()) { var epi = ParentMapping.SearchProc(procDesc); if (epi != null) { //epi.IsSelf = false; return(epi); } } return(null); }