Advertisement
retesere20

itypedescriptror self declaration

Apr 25th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1.  
  2. public partial class modifiableInputsIndi : Strategy
  3. {
  4. protected override void Initialize(){ Name = ""; }
  5. public override string ToString() { if (isSameDefaultClass()) return "_"; else return this.Name; }
  6.  
  7. public bool isSameDefaultClass(){
  8. //string basenam = this.GetType().BaseType.Name; // DeclaringType // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name
  9. //return Name == basenam;
  10. return this.GetType().Name== MethodBase.GetCurrentMethod().DeclaringType.Name; // "ttDefaultStrategy" //
  11. }
  12. }
  13.  
  14.  
  15.  
  16.  
  17. namespace NinjaTrader.Strategy
  18. {
  19. #region modifiableInputsIndi
  20. public partial class modifiableInputsIndi : ICustomTypeDescriptor
  21. {
  22.  
  23.  
  24. // partial void ModifyProperties(PropertyDescriptorCollection col);
  25. // public virtual void ModifyProperties(PropertyDescriptorCollection col){}
  26.  
  27. // internal partial void ModifyProperties(PropertyDescriptorCollection col)
  28. // {
  29. // if (!ShowB) col.Remove(col.Find("InputB", true));
  30. // }
  31.  
  32.  
  33. #region ICustomTypeDescriptor Members
  34.  
  35. public AttributeCollection GetAttributes()
  36. {
  37. return TypeDescriptor.GetAttributes(GetType());
  38. }
  39.  
  40. public string GetClassName()
  41. {
  42. return TypeDescriptor.GetClassName(GetType());
  43. }
  44.  
  45. public string GetComponentName()
  46. {
  47. return TypeDescriptor.GetComponentName(GetType());
  48. }
  49.  
  50. public TypeConverter GetConverter()
  51. {
  52. return TypeDescriptor.GetConverter(GetType());
  53. }
  54.  
  55. public EventDescriptor GetDefaultEvent()
  56. {
  57. return TypeDescriptor.GetDefaultEvent(GetType());
  58. }
  59.  
  60. public PropertyDescriptor GetDefaultProperty()
  61. {
  62. return TypeDescriptor.GetDefaultProperty(GetType());
  63. }
  64.  
  65. public object GetEditor(Type editorBaseType)
  66. {
  67. return TypeDescriptor.GetEditor(GetType(), editorBaseType);
  68. }
  69.  
  70. public EventDescriptorCollection GetEvents(Attribute[] attributes)
  71. {
  72. return TypeDescriptor.GetEvents(GetType(), attributes);
  73. }
  74.  
  75. public EventDescriptorCollection GetEvents()
  76. {
  77. return TypeDescriptor.GetEvents(GetType());
  78. }
  79.  
  80. public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
  81. {
  82. PropertyDescriptorCollection orig = TypeDescriptor.GetProperties(GetType(), attributes);
  83. PropertyDescriptor[] arr = new PropertyDescriptor[orig.Count];
  84. orig.CopyTo(arr, 0);
  85. PropertyDescriptorCollection col = new PropertyDescriptorCollection(arr);
  86.  
  87. ModifyProperties(col);
  88. return col;
  89. }
  90.  
  91. public PropertyDescriptorCollection GetProperties()
  92. {
  93. return TypeDescriptor.GetProperties(GetType());
  94. }
  95.  
  96. public object GetPropertyOwner(PropertyDescriptor pd)
  97. {
  98. return this;
  99. }
  100.  
  101. #endregion
  102. }
  103. #endregion
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement