コード例 #1
0
ファイル: Program.cs プロジェクト: cemergen/Builder
        static void Main(string[] args)
        {
            Manufacturer  newManufacturer = new Manufacturer();
            IPhoneBuilder phoneBuilder, phoneBuilder2 = null;

            phoneBuilder  = new AndroidPhoneBuilder();
            phoneBuilder2 = new WindowsPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            newManufacturer.Construct(phoneBuilder2);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder2.Phone.ToString());
        }
コード例 #2
0
        private static void BuilderPattern()
        {
            Manufacturer manufacturer = new Manufacturer();

            IPhoneBuilder phoneBuilder = null;

            phoneBuilder = new AndroidPhoneBuilder();
            manufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());

            phoneBuilder = new WindowsPhoneBuilder();
            manufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());
        }
コード例 #3
0
        public void MobilePhone_Android_BuilderPattern_Test()
        {
            // Arrange
            Manufacturer  newManufacturer = new Manufacturer();
            IPhoneBuilder phoneBuilder    = null; // Lets have the Builder class ready

            // Creating an Android phone
            phoneBuilder = new AndroidPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Debug.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());

            // Now let us create a Windows Phone
            phoneBuilder = new WindowsPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Debug.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());
        }
コード例 #4
0
        public static void Perform()
        {
            Manufacturer  manufacturer = new Manufacturer();
            IPhoneBuilder phoneBuilder = null;

            phoneBuilder = new AndriodPhoneBuilder();
            manufacturer.Construct(phoneBuilder);
            Console.WriteLine("\n\nNew phone build : \n" + phoneBuilder.Phone.ToString());
            phoneBuilder = new WindowsPhoneBuilder();
            manufacturer.Construct(phoneBuilder);
            Console.WriteLine("\n\nNew phone build : \n" + phoneBuilder.Phone.ToString());
            phoneBuilder = new SymbionPhoneBuilder();
            manufacturer.Construct(phoneBuilder);
            Console.WriteLine("\n\nNew phone build : \n" + phoneBuilder.Phone.ToString());
            Console.WriteLine("");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            // Lets create the Director first
            Manufacturer newManufacturer = new Manufacturer();
            // Lets have the Builder class ready
            IPhoneBuilder phoneBuilder = null;

            // Now let us create an android phone
            phoneBuilder = new AndroidPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());

            // Now let us create a Windows Phone
            phoneBuilder = new WindowsPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("\nA new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());
        }
コード例 #6
0
        // GET: Build
        public ActionResult Index()
        {
            // create manufacturer
            Manufacturer manufacturer = new Manufacturer();

            // create builder
            ScooterBuilder scb = new ScooterBuilder();

            // creating bike by passing reference of scooter builder
            manufacturer.Construct(scb);

            // Geting the instance of bike, created by Construct method of manufacturer object.
            var b = scb.GetBike();

            return(View());
        }
コード例 #7
0
        public void Init()
        {
            Manufacturer manufacturer = new Manufacturer();

            manufacturer.Construct(mobileBuilder);
        }