Server/FormEditObject.cs
author Stephane Lenclud
Thu, 18 Aug 2016 20:14:30 +0200
changeset 242 0a956121c273
parent 238 c92587ddabcd
child 243 cc2251d065db
permissions -rw-r--r--
Weird signing crap.
StephaneLenclud@231
     1
using System;
StephaneLenclud@231
     2
using System.Collections.Generic;
StephaneLenclud@231
     3
using System.ComponentModel;
StephaneLenclud@231
     4
using System.Data;
StephaneLenclud@231
     5
using System.Diagnostics;
StephaneLenclud@231
     6
using System.Drawing;
StephaneLenclud@231
     7
using System.Linq;
StephaneLenclud@231
     8
using System.Text;
StephaneLenclud@231
     9
using System.Threading.Tasks;
StephaneLenclud@231
    10
using System.Windows.Forms;
StephaneLenclud@231
    11
using SharpLib.Display;
StephaneLenclud@231
    12
using SharpLib.Ear;
StephaneLenclud@231
    13
using System.Reflection;
StephaneLenclud@231
    14
using Microsoft.VisualBasic.CompilerServices;
StephaneLenclud@231
    15
using SharpLib.Utils;
StephaneLenclud@238
    16
using CodeProject.Dialog;
StephaneLenclud@239
    17
using System.IO;
StephaneLenclud@231
    18
StephaneLenclud@231
    19
namespace SharpDisplayManager
StephaneLenclud@231
    20
{
StephaneLenclud@231
    21
    /// <summary>
StephaneLenclud@231
    22
    /// Object edit dialog form.
StephaneLenclud@231
    23
    /// </summary>
StephaneLenclud@239
    24
    public partial class FormEditObject<T> : Form where T: SharpLib.Ear.Object
StephaneLenclud@231
    25
    {
StephaneLenclud@231
    26
        public T Object = null;
StephaneLenclud@231
    27
StephaneLenclud@231
    28
        public FormEditObject()
StephaneLenclud@231
    29
        {
StephaneLenclud@231
    30
            InitializeComponent();
StephaneLenclud@231
    31
        }
StephaneLenclud@231
    32
StephaneLenclud@231
    33
        /// <summary>
StephaneLenclud@231
    34
        /// 
StephaneLenclud@231
    35
        /// </summary>
StephaneLenclud@231
    36
        /// <param name="sender"></param>
StephaneLenclud@231
    37
        /// <param name="e"></param>
StephaneLenclud@231
    38
        private void FormEditAction_Load(object sender, EventArgs e)
StephaneLenclud@231
    39
        {
StephaneLenclud@236
    40
            // Populate registered object types
StephaneLenclud@231
    41
            IEnumerable < Type > types = Reflection.GetConcreteClassesDerivedFrom<T>();
StephaneLenclud@231
    42
            foreach (Type type in types)
StephaneLenclud@231
    43
            {
StephaneLenclud@231
    44
                ItemObjectType item = new ItemObjectType(type);
StephaneLenclud@231
    45
                comboBoxActionType.Items.Add(item);
StephaneLenclud@231
    46
            }
StephaneLenclud@231
    47
StephaneLenclud@231
    48
            if (Object == null)
StephaneLenclud@231
    49
            {
StephaneLenclud@231
    50
                // Creating new issue, select our first item
StephaneLenclud@231
    51
                comboBoxActionType.SelectedIndex = 0;
StephaneLenclud@231
    52
            }
StephaneLenclud@231
    53
            else
StephaneLenclud@231
    54
            {
StephaneLenclud@231
    55
                // Editing existing object
StephaneLenclud@239
    56
                // Look up our item in our combobox
StephaneLenclud@231
    57
                foreach (ItemObjectType item in comboBoxActionType.Items)
StephaneLenclud@231
    58
                {
StephaneLenclud@231
    59
                    if (item.Type == Object.GetType())
StephaneLenclud@231
    60
                    {
StephaneLenclud@231
    61
                        comboBoxActionType.SelectedItem = item;
StephaneLenclud@231
    62
                    }
StephaneLenclud@231
    63
                }
StephaneLenclud@239
    64
            }
StephaneLenclud@231
    65
        }
StephaneLenclud@231
    66
StephaneLenclud@231
    67
        private void buttonOk_Click(object sender, EventArgs e)
StephaneLenclud@231
    68
        {
StephaneLenclud@231
    69
            FetchPropertiesValue(Object);
StephaneLenclud@239
    70
            if (!Object.IsValid())
StephaneLenclud@239
    71
            {
StephaneLenclud@239
    72
                // Tell for closing event to abort
StephaneLenclud@239
    73
                DialogResult = DialogResult.None;
StephaneLenclud@239
    74
            }
StephaneLenclud@231
    75
        }
StephaneLenclud@231
    76
StephaneLenclud@239
    77
StephaneLenclud@239
    78
        private void FormEditObject_FormClosing(object sender, FormClosingEventArgs e)
StephaneLenclud@231
    79
        {
StephaneLenclud@239
    80
            e.Cancel = DialogResult == DialogResult.None;
StephaneLenclud@231
    81
        }
StephaneLenclud@231
    82
StephaneLenclud@231
    83
        private void comboBoxActionType_SelectedIndexChanged(object sender, EventArgs e)
StephaneLenclud@231
    84
        {
StephaneLenclud@231
    85
            //Instantiate an action corresponding to our type
StephaneLenclud@231
    86
            Type actionType = ((ItemObjectType) comboBoxActionType.SelectedItem).Type;
StephaneLenclud@231
    87
            //Create another type of action only if needed
StephaneLenclud@231
    88
            if (Object == null || Object.GetType() != actionType)
StephaneLenclud@231
    89
            {
StephaneLenclud@231
    90
                Object = (T)Activator.CreateInstance(actionType);
StephaneLenclud@231
    91
            }
StephaneLenclud@239
    92
StephaneLenclud@239
    93
            //Disable ok button if our object is not valid
StephaneLenclud@239
    94
            buttonOk.Enabled = Object.IsValid();
StephaneLenclud@239
    95
StephaneLenclud@231
    96
            //Create input fields
StephaneLenclud@231
    97
            UpdateTableLayoutPanel(Object);
StephaneLenclud@231
    98
        }
StephaneLenclud@231
    99
StephaneLenclud@231
   100
StephaneLenclud@231
   101
        /// <summary>
StephaneLenclud@231
   102
        /// Get properties values from our generated input fields
StephaneLenclud@231
   103
        /// </summary>
StephaneLenclud@236
   104
        private void FetchPropertiesValue(T aObject)
StephaneLenclud@231
   105
        {
StephaneLenclud@231
   106
            int ctrlIndex = 0;
StephaneLenclud@236
   107
            foreach (PropertyInfo pi in aObject.GetType().GetProperties())
StephaneLenclud@231
   108
            {
StephaneLenclud@231
   109
                AttributeObjectProperty[] attributes =
StephaneLenclud@231
   110
                    ((AttributeObjectProperty[]) pi.GetCustomAttributes(typeof(AttributeObjectProperty), true));
StephaneLenclud@231
   111
                if (attributes.Length != 1)
StephaneLenclud@231
   112
                {
StephaneLenclud@231
   113
                    continue;
StephaneLenclud@231
   114
                }
StephaneLenclud@231
   115
StephaneLenclud@231
   116
                AttributeObjectProperty attribute = attributes[0];
StephaneLenclud@231
   117
StephaneLenclud@231
   118
                if (!IsPropertyTypeSupported(pi))
StephaneLenclud@231
   119
                {
StephaneLenclud@231
   120
                    continue;
StephaneLenclud@231
   121
                }
StephaneLenclud@231
   122
StephaneLenclud@236
   123
                GetPropertyValueFromControl(iTableLayoutPanel.Controls[ctrlIndex+1], pi, aObject); //+1 otherwise we get the label
StephaneLenclud@231
   124
StephaneLenclud@231
   125
                ctrlIndex+=2; //Jump over the label too
StephaneLenclud@231
   126
            }
StephaneLenclud@231
   127
        }
StephaneLenclud@231
   128
StephaneLenclud@231
   129
        /// <summary>
StephaneLenclud@231
   130
        /// Extend this function to support reading new types of properties.
StephaneLenclud@231
   131
        /// </summary>
StephaneLenclud@236
   132
        /// <param name="aObject"></param>
StephaneLenclud@236
   133
        private void GetPropertyValueFromControl(Control aControl, PropertyInfo aInfo, T aObject)
StephaneLenclud@231
   134
        {
StephaneLenclud@231
   135
            if (aInfo.PropertyType == typeof(int))
StephaneLenclud@231
   136
            {
StephaneLenclud@231
   137
                NumericUpDown ctrl=(NumericUpDown)aControl;
StephaneLenclud@236
   138
                aInfo.SetValue(aObject,(int)ctrl.Value);
StephaneLenclud@231
   139
            }
StephaneLenclud@231
   140
            else if (aInfo.PropertyType.IsEnum)
StephaneLenclud@231
   141
            {
StephaneLenclud@231
   142
                // Instantiate our enum
StephaneLenclud@231
   143
                object enumValue= Activator.CreateInstance(aInfo.PropertyType);
StephaneLenclud@231
   144
                // Parse our enum from combo box
StephaneLenclud@231
   145
                enumValue = Enum.Parse(aInfo.PropertyType,((ComboBox)aControl).SelectedItem.ToString());
StephaneLenclud@231
   146
                //enumValue = ((ComboBox)aControl).SelectedValue;
StephaneLenclud@231
   147
                // Set enum value
StephaneLenclud@236
   148
                aInfo.SetValue(aObject, enumValue);
StephaneLenclud@231
   149
            }
StephaneLenclud@231
   150
            else if (aInfo.PropertyType == typeof(bool))
StephaneLenclud@231
   151
            {
StephaneLenclud@231
   152
                CheckBox ctrl = (CheckBox)aControl;
StephaneLenclud@236
   153
                aInfo.SetValue(aObject, ctrl.Checked);
StephaneLenclud@231
   154
            }
StephaneLenclud@231
   155
            else if (aInfo.PropertyType == typeof(string))
StephaneLenclud@231
   156
            {
StephaneLenclud@231
   157
                TextBox ctrl = (TextBox)aControl;
StephaneLenclud@236
   158
                aInfo.SetValue(aObject, ctrl.Text);
StephaneLenclud@231
   159
            }
StephaneLenclud@238
   160
            else if (aInfo.PropertyType == typeof(PropertyFile))
StephaneLenclud@238
   161
            {
StephaneLenclud@238
   162
                Button ctrl = (Button)aControl;
StephaneLenclud@238
   163
                PropertyFile value = new PropertyFile {FullPath=ctrl.Text};
StephaneLenclud@238
   164
                aInfo.SetValue(aObject, value);
StephaneLenclud@238
   165
            }
StephaneLenclud@231
   166
            //TODO: add support for other types here
StephaneLenclud@231
   167
        }
StephaneLenclud@231
   168
StephaneLenclud@236
   169
StephaneLenclud@231
   170
        /// <summary>
StephaneLenclud@236
   171
        /// Create a control for the given property.
StephaneLenclud@231
   172
        /// </summary>
StephaneLenclud@231
   173
        /// <param name="aInfo"></param>
StephaneLenclud@236
   174
        /// <param name="aAttribute"></param>
StephaneLenclud@236
   175
        /// <param name="aObject"></param>
StephaneLenclud@236
   176
        /// <returns></returns>
StephaneLenclud@236
   177
        private Control CreateControlForProperty(PropertyInfo aInfo, AttributeObjectProperty aAttribute, T aObject)
StephaneLenclud@231
   178
        {
StephaneLenclud@231
   179
            if (aInfo.PropertyType == typeof(int))
StephaneLenclud@231
   180
            {
StephaneLenclud@231
   181
                //Integer properties are using numeric editor
StephaneLenclud@231
   182
                NumericUpDown ctrl = new NumericUpDown();
StephaneLenclud@231
   183
                ctrl.AutoSize = true;
StephaneLenclud@231
   184
                ctrl.Minimum = Int32.Parse(aAttribute.Minimum);
StephaneLenclud@231
   185
                ctrl.Maximum = Int32.Parse(aAttribute.Maximum);
StephaneLenclud@231
   186
                ctrl.Increment = Int32.Parse(aAttribute.Increment);
StephaneLenclud@236
   187
                ctrl.Value = (int)aInfo.GetValue(aObject);
StephaneLenclud@231
   188
                return ctrl;
StephaneLenclud@231
   189
            }
StephaneLenclud@231
   190
            else if (aInfo.PropertyType.IsEnum)
StephaneLenclud@231
   191
            {
StephaneLenclud@231
   192
                //Enum properties are using combo box
StephaneLenclud@231
   193
                ComboBox ctrl = new ComboBox();
StephaneLenclud@231
   194
                ctrl.AutoSize = true;                
StephaneLenclud@231
   195
                ctrl.Sorted = true;                
StephaneLenclud@231
   196
                ctrl.DropDownStyle = ComboBoxStyle.DropDownList;
StephaneLenclud@231
   197
                //Data source is fine but it gives us duplicate entries for duplicated enum values
StephaneLenclud@231
   198
                //ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
StephaneLenclud@231
   199
StephaneLenclud@231
   200
                //Therefore we need to explicitly create our items
StephaneLenclud@231
   201
                Size cbSize = new Size(0,0);
StephaneLenclud@231
   202
                foreach (string name in aInfo.PropertyType.GetEnumNames())
StephaneLenclud@231
   203
                {
StephaneLenclud@231
   204
                    ctrl.Items.Add(name.ToString());
StephaneLenclud@231
   205
                    Graphics g = this.CreateGraphics();
StephaneLenclud@231
   206
                    //Since combobox autosize would not work we need to get measure text ourselves
StephaneLenclud@231
   207
                    SizeF size=g.MeasureString(name.ToString(), ctrl.Font);
StephaneLenclud@231
   208
                    cbSize.Width = Math.Max(cbSize.Width,(int)size.Width);
StephaneLenclud@231
   209
                    cbSize.Height = Math.Max(cbSize.Height, (int)size.Height);
StephaneLenclud@231
   210
                }
StephaneLenclud@231
   211
StephaneLenclud@231
   212
                //Make sure our combobox is large enough
StephaneLenclud@231
   213
                ctrl.MinimumSize = cbSize;
StephaneLenclud@231
   214
StephaneLenclud@231
   215
                // Instantiate our enum
StephaneLenclud@231
   216
                object enumValue = Activator.CreateInstance(aInfo.PropertyType);
StephaneLenclud@236
   217
                enumValue = aInfo.GetValue(aObject);
StephaneLenclud@231
   218
                //Set the current item
StephaneLenclud@231
   219
                ctrl.SelectedItem = enumValue.ToString();
StephaneLenclud@231
   220
StephaneLenclud@231
   221
                return ctrl;
StephaneLenclud@231
   222
            }
StephaneLenclud@231
   223
            else if (aInfo.PropertyType == typeof(bool))
StephaneLenclud@231
   224
            {
StephaneLenclud@231
   225
                CheckBox ctrl = new CheckBox();
StephaneLenclud@231
   226
                ctrl.AutoSize = true;
StephaneLenclud@231
   227
                ctrl.Text = aAttribute.Description;
StephaneLenclud@236
   228
                ctrl.Checked = (bool)aInfo.GetValue(aObject);                
StephaneLenclud@231
   229
                return ctrl;
StephaneLenclud@231
   230
            }
StephaneLenclud@231
   231
            else if (aInfo.PropertyType == typeof(string))
StephaneLenclud@231
   232
            {
StephaneLenclud@231
   233
                TextBox ctrl = new TextBox();
StephaneLenclud@231
   234
                ctrl.AutoSize = true;
StephaneLenclud@236
   235
                ctrl.Text = (string)aInfo.GetValue(aObject);
StephaneLenclud@231
   236
                return ctrl;
StephaneLenclud@231
   237
            }
StephaneLenclud@238
   238
            else if (aInfo.PropertyType == typeof(PropertyFile))
StephaneLenclud@238
   239
            {
StephaneLenclud@238
   240
                // We have a file property
StephaneLenclud@238
   241
                // Create a button that will trigger the open file dialog to select our file.
StephaneLenclud@238
   242
                Button ctrl = new Button();
StephaneLenclud@238
   243
                ctrl.AutoSize = true;
StephaneLenclud@238
   244
                ctrl.Text = ((PropertyFile)aInfo.GetValue(aObject)).FullPath;
StephaneLenclud@239
   245
StephaneLenclud@238
   246
                // Add lambda expression to Click event
StephaneLenclud@238
   247
                ctrl.Click += (sender, e) =>
StephaneLenclud@238
   248
                {
StephaneLenclud@238
   249
                    // Create open file dialog
StephaneLenclud@238
   250
                    OpenFileDialog ofd = new OpenFileDialog();
StephaneLenclud@238
   251
                    ofd.RestoreDirectory = true;
StephaneLenclud@238
   252
                    // Use file filter specified by our property
StephaneLenclud@238
   253
                    ofd.Filter = aAttribute.Filter;
StephaneLenclud@238
   254
                    // Show our dialog
StephaneLenclud@238
   255
                    if (DlgBox.ShowDialog(ofd) == DialogResult.OK)
StephaneLenclud@238
   256
                    {
StephaneLenclud@238
   257
                        // Fetch selected file name
StephaneLenclud@238
   258
                        ctrl.Text = ofd.FileName;
StephaneLenclud@239
   259
                        //Enable Ok button then
StephaneLenclud@239
   260
                        buttonOk.Enabled = Object.IsValid();
StephaneLenclud@238
   261
                    }
StephaneLenclud@238
   262
                };
StephaneLenclud@238
   263
StephaneLenclud@238
   264
                return ctrl;
StephaneLenclud@238
   265
            }
StephaneLenclud@231
   266
            //TODO: add support for other control type here
StephaneLenclud@231
   267
StephaneLenclud@231
   268
            return null;
StephaneLenclud@231
   269
        }
StephaneLenclud@231
   270
StephaneLenclud@231
   271
        /// <summary>
StephaneLenclud@231
   272
        /// Don't forget to extend that one and adding types
StephaneLenclud@231
   273
        /// </summary>
StephaneLenclud@231
   274
        /// <returns></returns>
StephaneLenclud@231
   275
        private bool IsPropertyTypeSupported(PropertyInfo aInfo)
StephaneLenclud@231
   276
        {
StephaneLenclud@231
   277
            if (aInfo.PropertyType == typeof(int))
StephaneLenclud@231
   278
            {
StephaneLenclud@231
   279
                return true;
StephaneLenclud@231
   280
            }
StephaneLenclud@231
   281
            else if (aInfo.PropertyType.IsEnum)
StephaneLenclud@231
   282
            {
StephaneLenclud@231
   283
                return true;
StephaneLenclud@231
   284
            }
StephaneLenclud@231
   285
            else if (aInfo.PropertyType == typeof(bool))
StephaneLenclud@231
   286
            {
StephaneLenclud@231
   287
                return true;
StephaneLenclud@231
   288
            }
StephaneLenclud@231
   289
            else if (aInfo.PropertyType == typeof(string))
StephaneLenclud@231
   290
            {
StephaneLenclud@231
   291
                return true;
StephaneLenclud@231
   292
            }
StephaneLenclud@238
   293
            else if (aInfo.PropertyType == typeof(PropertyFile))
StephaneLenclud@238
   294
            {
StephaneLenclud@238
   295
                return true;
StephaneLenclud@238
   296
            }
StephaneLenclud@231
   297
            //TODO: add support for other type here
StephaneLenclud@231
   298
StephaneLenclud@231
   299
            return false;
StephaneLenclud@231
   300
        }
StephaneLenclud@231
   301
StephaneLenclud@231
   302
        /// <summary>
StephaneLenclud@231
   303
        /// Update our table layout.
StephaneLenclud@231
   304
        /// Will instantiated every field control as defined by our action.
StephaneLenclud@231
   305
        /// Fields must be specified by rows from the left.
StephaneLenclud@231
   306
        /// </summary>
StephaneLenclud@231
   307
        /// <param name="aLayout"></param>
StephaneLenclud@236
   308
        private void UpdateTableLayoutPanel(T aObject)
StephaneLenclud@231
   309
        {
StephaneLenclud@231
   310
            toolTip.RemoveAll();
StephaneLenclud@231
   311
            //Debug.Print("UpdateTableLayoutPanel")
StephaneLenclud@231
   312
            //First clean our current panel
StephaneLenclud@231
   313
            iTableLayoutPanel.Controls.Clear();
StephaneLenclud@231
   314
            iTableLayoutPanel.RowStyles.Clear();
StephaneLenclud@231
   315
            iTableLayoutPanel.ColumnStyles.Clear();
StephaneLenclud@231
   316
            iTableLayoutPanel.RowCount = 0;
StephaneLenclud@231
   317
StephaneLenclud@231
   318
            //We always want two columns: one for label and one for the field
StephaneLenclud@231
   319
            iTableLayoutPanel.ColumnCount = 2;
StephaneLenclud@231
   320
            iTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
StephaneLenclud@231
   321
            iTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
StephaneLenclud@231
   322
StephaneLenclud@231
   323
StephaneLenclud@236
   324
            if (aObject == null)
StephaneLenclud@231
   325
            {
StephaneLenclud@231
   326
                //Just drop it
StephaneLenclud@231
   327
                return;
StephaneLenclud@231
   328
            }
StephaneLenclud@231
   329
            
StephaneLenclud@236
   330
            //IEnumerable<PropertyInfo> properties = aObject.GetType().GetProperties().Where(
StephaneLenclud@231
   331
            //    prop => Attribute.IsDefined(prop, typeof(AttributeObjectProperty)));
StephaneLenclud@231
   332
StephaneLenclud@231
   333
StephaneLenclud@236
   334
            foreach (PropertyInfo pi in aObject.GetType().GetProperties())
StephaneLenclud@231
   335
            {
StephaneLenclud@231
   336
                AttributeObjectProperty[] attributes = ((AttributeObjectProperty[])pi.GetCustomAttributes(typeof(AttributeObjectProperty), true));
StephaneLenclud@231
   337
                if (attributes.Length != 1)
StephaneLenclud@231
   338
                {
StephaneLenclud@231
   339
                    continue;
StephaneLenclud@231
   340
                }
StephaneLenclud@231
   341
StephaneLenclud@231
   342
                AttributeObjectProperty attribute = attributes[0];
StephaneLenclud@231
   343
StephaneLenclud@231
   344
                //Before anything we need to check if that kind of property is supported by our UI
StephaneLenclud@231
   345
                //Create the editor
StephaneLenclud@236
   346
                Control ctrl = CreateControlForProperty(pi, attribute, aObject);
StephaneLenclud@231
   347
                if (ctrl == null)
StephaneLenclud@231
   348
                {
StephaneLenclud@231
   349
                    //Property type not supported
StephaneLenclud@231
   350
                    continue;
StephaneLenclud@231
   351
                }
StephaneLenclud@231
   352
StephaneLenclud@231
   353
                //Add a new row
StephaneLenclud@231
   354
                iTableLayoutPanel.RowCount++;
StephaneLenclud@231
   355
                iTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
StephaneLenclud@231
   356
                //Create the label
StephaneLenclud@231
   357
                Label label = new Label();
StephaneLenclud@231
   358
                label.AutoSize = true;
StephaneLenclud@231
   359
                label.Dock = DockStyle.Fill;
StephaneLenclud@231
   360
                label.TextAlign = ContentAlignment.MiddleCenter;
StephaneLenclud@231
   361
                label.Text = attribute.Name;
StephaneLenclud@231
   362
                toolTip.SetToolTip(label, attribute.Description);
StephaneLenclud@231
   363
                iTableLayoutPanel.Controls.Add(label, 0, iTableLayoutPanel.RowCount-1);
StephaneLenclud@231
   364
StephaneLenclud@231
   365
                //Add our editor to our form
StephaneLenclud@231
   366
                iTableLayoutPanel.Controls.Add(ctrl, 1, iTableLayoutPanel.RowCount - 1);
StephaneLenclud@231
   367
                //Add tooltip to editor too
StephaneLenclud@231
   368
                toolTip.SetToolTip(ctrl, attribute.Description);
StephaneLenclud@231
   369
StephaneLenclud@231
   370
            }        
StephaneLenclud@231
   371
StephaneLenclud@231
   372
        }
StephaneLenclud@231
   373
StephaneLenclud@231
   374
        private void buttonTest_Click(object sender, EventArgs e)
StephaneLenclud@231
   375
        {
StephaneLenclud@231
   376
            FetchPropertiesValue(Object);
StephaneLenclud@231
   377
StephaneLenclud@231
   378
            //If our object has a test method with no parameters just run it then
StephaneLenclud@231
   379
            MethodInfo info = Object.GetType().GetMethod("Test");
StephaneLenclud@231
   380
            if ( info != null && info.GetParameters().Length==0)
StephaneLenclud@231
   381
            {
StephaneLenclud@231
   382
                info.Invoke(Object,null);
StephaneLenclud@231
   383
            }
StephaneLenclud@231
   384
StephaneLenclud@231
   385
        }
StephaneLenclud@231
   386
    }
StephaneLenclud@231
   387
}