Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BaseDto
- {
- public int ID{ get; set; }
- }
- public class Client: BaseDto
- {
- public string Surname { get; set; }
- public string FirstName{ get; set; }
- public string email{ get; set; }
- }
- PropertyInfo[] props = typeof(Client).GetProperties();
- Type type = typeof(Client);
- List<Type> types = new List<Type>();
- do
- {
- types.Insert(0, type);
- type = type.BaseType;
- } while (type.BaseType!=null);
- PropertyInfo[] props = typeof(Client).GetProperties()
- .OrderBy(x => types.IndexOf(x.DeclaringType))
- .ToArray();
- typeof(Client).BaseType
- BindingFlags.DeclaredOnly
- var baseProps = typeof(BaseDto).GetProperties();
- var props = typeof(Client).GetProperties();
- var allProps = baseProps
- .Concat(props.Where(p => baseProps
- .Select(b => b.Name)
- .Contains(p.Name) == false));
- Dictionary<string, PropertyInfo> _PropertyIndex = new Dictionary<string, PropertyInfo>();
- Type thisType = typeof(Client);
- foreach (PropertyInfo pi in thisType.BaseType.GetProperties())
- _PropertyIndex.Add(pi.Name.ToUpper(), pi);
- foreach (PropertyInfo pi in thisType.GetProperties())
- if( !_PropertyIndex.ContainsKey(pi.Name.ToUpper()))
- _PropertyIndex.Add(pi.Name.ToUpper(), pi);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement