public void Resolve() { if (_self == null) { return; } idName = GetFullName(_self); var desc = ResolverHelper.GetMemberFromCache(_self.DeclaringType, t => { return(t.Name.StartsWith("M:" + idName)); }); var args = _self.GetParameters(); Args = new List <TypeModel>(); for (int i = 0; i < args.Length; i++) { var arg = args[i]; TypeModel argmodel = ModelFactory.CreateTypeModel(arg.ParameterType); Args.Add(argmodel); } Description = desc?.Summary?.Trim(); Name = _self.Name; TypeName = _self.DeclaringType.FullName; ReturnArg = ModelFactory.CreateTypeModel(_self.ReturnType); ReturnArg.Description = desc?.Returns?.Trim(); }
public static TypeModel CreateTypeModel(Type type) { if (type == null) { return(null); } var result = type.ToTypeModel(); if (!result.IsArray && result.IsClass) { var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public); if (properties != null) { foreach (var p in properties) { TypeModel model = p.PropertyType.ToTypeModel(); model.MemberName = p.Name; var desc = ResolverHelper.GetMemberFromCache(p.DeclaringType, t => { return(t.Name.StartsWith("P:" + p.DeclaringType.FullName + "." + p.Name)); }); model.Description = desc?.Summary?.Trim(); result.Properties.Add(model); } } } return(result); }
public static TypeModel ToTypeModel(this Type t) { if (t == null) { return(null); } TypeModel model = TypeModelCacheManager.Get(t.FullName); if (model != null) { return(model); } model = t.ToTypeModelWithoutProperties(); if (model.Properties.Count == 0) { var properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public); if (properties != null) { foreach (var p in properties) { TypeModel m = p.PropertyType.ToTypeModelWithoutProperties(); m.MemberName = p.Name; var desc = ResolverHelper.GetMemberFromCache(p.DeclaringType, x => { return(x.Name.StartsWith("P:" + p.DeclaringType.FullName + "." + p.Name)); }); m.Description = desc?.Summary?.Trim(); model.Properties.Add(m); } } } if (model.IsClass) { TypeModelCacheManager.Set(t.FullName, model); } return(model); }