Example #1
0
        /// <summary>
        /// Iterate over all the members that are of the StringPathContainer
        /// and return an array of path strings
        ///
        /// TODO: What if there are no string in the array?
        /// </summary>
        /// <returns>Array of path strings</returns>
        static void GetAllPaths()
        {
            //PathStringCollection p = new PathStringCollection();

            Type t = typeof(StandardTestPaths);

            FieldInfo[] _attrib = t.GetFields();
            //object[] _attrib = theObjInf.GetCustomAttributes();
            TestPathType tt = new TestPathType();

            // List<string> StringLstType;
            // StringLstType strLst;
            List <string> strLst = new List <string>();

            foreach (FieldInfo n in _attrib)
            {
                try {
                    if (n.FieldType == typeof(TestPathType))
                    {
                        // Console.WriteLine("The method name is {0} of type {1}", n.Name, n.FieldType);

                        // Boxing...
                        object obj; // = newT;
                        obj = n.GetValue((object)(new StandardTestPaths()));
                        TestPathType newT = (TestPathType)obj;

                        // Console.WriteLine("The path {0}", newT.path);
                        strLst.Add(newT.Path);
                    }
                } catch (Exception e) {
                    Console.WriteLine("The error was {0}", e.ToString());
                }
            }
            _paths = strLst.ToArray();
        }
Example #2
0
        /// <summary>
        /// Iterate over all the members that are of the StringPathContainer
        /// and return an array of path strings
        /// 
        /// TODO: What if there are no string in the array?
        /// </summary>
        /// <returns>Array of path strings</returns>
        static void GetAllPaths()
        {
            //PathStringCollection p = new PathStringCollection();

            Type t = typeof(StandardTestPaths);

            FieldInfo[] _attrib = t.GetFields();
            //object[] _attrib = theObjInf.GetCustomAttributes();
            TestPathType tt = new TestPathType();

            // List<string> StringLstType;
            // StringLstType strLst;
            List<string> strLst = new List<string>();

            foreach (FieldInfo n in _attrib) {
                try {
                    if (n.FieldType == typeof(TestPathType)) {
                        // Console.WriteLine("The method name is {0} of type {1}", n.Name, n.FieldType);

                        // Boxing...
                        object obj; // = newT;
                        obj = n.GetValue((object)(new StandardTestPaths()));
                        TestPathType newT = (TestPathType)obj;

                        // Console.WriteLine("The path {0}", newT.path);
                        strLst.Add(newT.Path);

                    }

                } catch (Exception e) {
                    Console.WriteLine("The error was {0}", e.ToString());
                }
            }
            _paths = strLst.ToArray();
        }