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 ExFieldInfo SearchExField(string name) { var fieldArray = MType.GetFields(); foreach (FieldInfo field in fieldArray) { if (ReflectionUtil.IsDeclare(MType, field)) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr == null) { if (field.Name == name) { return(GclUtil.CreatExFieldInfo(field, ForType)); //return field; } } else { if (propertyAttr.Code == name) { return(GclUtil.CreatExFieldInfo(field, ForType)); //return field; } } } } if (ParentMapping != null) { return(ParentMapping.SearchExField(name)); } return(null); }
public TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = MType.GetMethods( ); foreach (var method in methodArray) { ZCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(ZCodeAttribute)) as ZCodeAttribute; if (procAttr == null) { ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(method, this.ForType); TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod); if (typeProcDesc.Eq(procDesc)) { return(typeProcDesc); } } else { ProcDescCodeParser parser = new ProcDescCodeParser(); parser.InitType(ForType, method); TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code); if (typeProcDesc.Eq(procDesc)) { ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(method, this.ForType); typeProcDesc.ExMethod = exMethod; return(typeProcDesc); } } } if (ParentMapping != null) { return(ParentMapping.SearchProc(procDesc)); } return(null); }
public ExPropertyInfo SearchExProperty(string name) { var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/); foreach (var property in propertyArray) { if (ReflectionUtil.IsDeclare(MType, property)) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr == null) { if (property.Name == name) { return(GclUtil.CreatExPropertyInfo(property, ForType)); //return property; } } else { if (propertyAttr.Code == name) { return(GclUtil.CreatExPropertyInfo(property, ForType)); //return property; } } } } if (ParentMapping != null) { return(ParentMapping.SearchExProperty(name)); } return(null); }
public ExFieldInfo SearchExField(string name) { if (this.ForType.IsEnum) { var fieldArray = this.ForType.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo field in fieldArray) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr == null) { if (field.Name == name) { return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType)); //return ForType.GetField(field.Name); } } else { if (propertyAttr.Code == name) { return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType)); //return ForType.GetField(field.Name); } } } return(null); } else { var fieldArray = MType.GetFields(); foreach (FieldInfo field in fieldArray) { if (ReflectionUtil.IsDeclare(MType, field)) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr == null) { if (field.Name == name) { return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType)); //return ForType.GetField(field.Name); } } else { if (propertyAttr.Code == name) { return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType)); //return ForType.GetField(field.Name); } } } } return(null); } }
public static string[] GetZNames(MemberInfo element) { Attribute[] attrs = Attribute.GetCustomAttributes(element); List <string> _znames = new List <string>(); foreach (var attr in attrs) { if (attr is ZCodeAttribute) { ZCodeAttribute zcodeAttr = (attr as ZCodeAttribute); _znames.Add(zcodeAttr.Code); } } return(_znames.ToArray()); }
public override ExPropertyInfo SearchExProperty(string name) { var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { if (!ReflectionUtil.IsDeclare(this.SharpType, property)) { continue; } ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; string zpropertyName = null; if (propertyAttr != null) { //zpropertyName = property.Name; zpropertyName = propertyAttr.Code; if (zpropertyName == name) { return(new ExPropertyInfo(property, true, name)); } } //else //{ // zpropertyName = property.Name; //} //if (zpropertyName == name) //{ // return new ExPropertyInfo(property, true, name); //} } //if (ParentMapping != null) //{ ExPropertyInfo epi = ParentMapping.SearchExProperty(name); if (epi != null) { epi.IsSelf = false; return(epi); } //} return(null); }
public List <SymbolEnumItem> SearchEnumItem(string name) { List <SymbolEnumItem> list = new List <SymbolEnumItem>(); foreach (var gcl in this.EnumTypes) { if (gcl is TktGcl) { var fields = gcl.ForType.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var fi in fields) { if (fi.Name == name) { object value = fi.GetValue(null); SymbolEnumItem symbol = new SymbolEnumItem(fi.Name, value); list.Add(symbol); } } } else { var fields = gcl.ForType.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (var fi in fields) { object value = fi.GetValue(null); string rname = fi.Name; var mapAttrObj = Attribute.GetCustomAttribute(fi, typeof(ZCodeAttribute)); if (mapAttrObj != null) { ZCodeAttribute mapAttr = mapAttrObj as ZCodeAttribute; rname = mapAttr.Code; } if (rname == name) { SymbolEnumItem symbol = new SymbolEnumItem(rname, value); list.Add(symbol); } } } } return(list); }
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); }
bool isExFieldInfoByAttr(string name, MemberInfo member) { Attribute[] attrs = Attribute.GetCustomAttributes(member, typeof(ZCodeAttribute)); if (attrs.Length == 0) { if (member.Name == name) { return(true);// return GclUtil.CreatExFieldInfo(ForType.GetField(member.Name), ForType); } } else { foreach (Attribute attr in attrs) { ZCodeAttribute zCodeAttribute = attr as ZCodeAttribute; if (zCodeAttribute.Code == name) { return(true);// return GclUtil.CreatExFieldInfo(ForType.GetField(member.Name), ForType); } } } return(false); // return null; }
public override ExPropertyInfo[] GetPropertyInfoes() { List <ExPropertyInfo> exList = new List <ExPropertyInfo>(); var propertyArray = this.SharpType.GetProperties(); foreach (var property in propertyArray) { ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute; if (propertyAttr != null) { var zpropertyName = propertyAttr.Code; ExPropertyInfo exPI = new ExPropertyInfo(property, ReflectionUtil.IsDeclare(this.SharpType, property), zpropertyName); exList.Add(exPI); } } ExPropertyInfo[] pArr = ParentMapping.GetPropertyInfoes(); foreach (ExPropertyInfo pitem in pArr) { pitem.IsSelf = false; } exList.AddRange(pArr); return(exList.ToArray()); }
public TKTProcDesc SearchProc(TKTProcDesc procDesc) { var methodArray = MType.GetMethods(); foreach (var method in methodArray) { if (ReflectionUtil.IsDeclare(MType, method)) { //ZCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(ZCodeAttribute)) as ZCodeAttribute; Attribute[] attrs = Attribute.GetCustomAttributes(method, typeof(ZCodeAttribute)); if (attrs.Length == 0) // if (procAttr == null) { ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(method, this.ForType); TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod); if (typeProcDesc.Eq(procDesc)) { MethodInfo rmethod = method; if (rmethod.IsAbstract) { rmethod = searchMethodByMethod(method); } if (rmethod == null) { return(null); } else { TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(exMethod); return(rdesc); } } } else { ParameterInfo[] paramArray = method.GetParameters(); parser.InitType(ForType, method); foreach (Attribute attr in attrs) { ZCodeAttribute zCodeAttribute = attr as ZCodeAttribute; TKTProcDesc typeProcDesc = parser.Parser(WordDict, zCodeAttribute.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) { return(null); } else { ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(rmethod, this.ForType); typeProcDesc.ExMethod = exMethod; return(typeProcDesc); } } } } } } if (isRootMapping()) { return(null); } else { return(ParentMapping.SearchProc(procDesc)); } }
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); }