예제 #1
0
        public static object ReadFromArgumentRow(CardDataset.ArgumentRow ar)
        {
            Type type = Type.GetType(ar.Type);

            ConstructorInfo [] constructors =
                type.GetConstructors(
                    BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            // To build an instance of argument we favor parameterless constructors and
            // constructors that take a single character.  This could be modified if needed.
            foreach (ConstructorInfo c in constructors)
            {
                ParameterInfo [] parameters = c.GetParameters();
                switch (parameters.Length)
                {
                case 0:
                    return(c.Invoke(new object [0]));

                case 1:
                    if (parameters [0].ParameterType == typeof(char))
                    {
                        char ch = ar.Value [0];
                        return(c.Invoke(new object [1] {
                            ch
                        }));
                    }
                    break;

                default:
                    Trace.Assert(false);
                    return(null);
                }
            }
            Trace.Assert(false);
            return(null);
        }
예제 #2
0
 public void WriteToArgumentRow(CardDataset.ArgumentRow ar)
 {
     ar.Type  = this.GetType().ToString();
     ar.Value = PersistableText;
 }