示例#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 Word90Factory getInstance()
        {
            if (instances == null)
            {
                instances = new List <Word90Factory>();

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

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

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