fork download
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using System.Xml.Serialization;
  5.  
  6. namespace Code.With.Ideone
  7. {
  8. [Serializable]
  9. public abstract class C1
  10. {
  11. [XmlIgnore]
  12. public abstract bool IsValid_C1 { get; set;}
  13. }
  14.  
  15. [Serializable]
  16. public class C2 : C1
  17. {
  18. public bool IsValid_C2 { get; set; }
  19.  
  20. private bool IsPrivate_C2 { get; set; }
  21.  
  22. public override bool IsValid_C1 { get; set;}
  23.  
  24. public C2()
  25. {
  26. IsValid_C1 = true;
  27. IsValid_C2 = false;
  28. IsPrivate_C2 = true;
  29. }
  30. }
  31.  
  32. public static class AbstractPropertiesAttributeTest
  33. {
  34. public static void Main(string[] args)
  35. {
  36. Type c2Type = typeof(C2);
  37. PropertyInfo[] allpi = c2Type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
  38. foreach(PropertyInfo pi in allpi)
  39. {
  40. Console.WriteLine(pi.Name);
  41. Console.WriteLine("=================================================");
  42. Attribute[] allatt = Attribute.GetCustomAttributes(pi);
  43. foreach(Attribute attr in allatt)
  44. {
  45. Console.WriteLine(attr.GetType().FullName);
  46. }
  47. Console.WriteLine("**********************************");
  48. }
  49. }
  50. }
  51. }
  52.  
Success #stdin #stdout 0.04s 33912KB
stdin
Standard input is empty
stdout
IsValid_C2
=================================================
**********************************
IsPrivate_C2
=================================================
**********************************
IsValid_C1
=================================================
System.Xml.Serialization.XmlIgnoreAttribute
**********************************