示例#1
0
        static void Main(string[] args)
        {
            String projDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
            String path    = projDir + "\\testing-config.txt";

            System.IO.StreamReader file = new System.IO.StreamReader(path);

            String        line;
            List <String> testingInputs = new List <String>();

            while ((line = file.ReadLine()) != null)
            {
                testingInputs.Add(line.Trim());
            }
            file.Close();

            foreach (String test in testingInputs)
            {
                IGUIfactory factory = null;

                switch (test)
                {
                case "Word00":
                    factory = Word00Factory.getInstance();
                    break;

                case "Word10":
                    factory = Word10Factory.getInstance();
                    break;

                case "Word18":
                    factory = Word18Factory.getInstance();
                    break;

                case "Word90":
                    factory = Word90Factory.getInstance();
                    break;

                default:
                    Console.WriteLine("line not recognized");
                    break;
                }

                if (factory != null)
                {
                    IButton  button  = factory.createButton();
                    IPanel   panel   = factory.createPanel();
                    ITextbox textbox = factory.createTextbox();

                    Console.WriteLine("Testing " + test + ":" + button.getDescription() + ", " + panel.getDescription() + ", " + textbox.getDescription());
                }
                else
                {
                }
            }


            // pause
            Console.ReadKey();
        }
示例#2
0
        public static Word00Factory getInstance()
        {
            if (instances == null)
            {
                instances = new List <Word00Factory>();

                Word00Factory instance1 = new Word00Factory();
                instances.Add(instance1);

                return(instance1);
            }
            else if (instances.Count < 2)
            {
                Word00Factory instance2 = new Word00Factory();
                instances.Add(instance2);

                return(instance2);
            }
            else
            {
                Console.WriteLine("Warning: Already two instances of Word00. Returning first instance.");
                return(instances[0]);
            }
        }