コード例 #1
0
        static void Main(string[] args)
        {
            var mobilePhoneFactory = new MobilePhoneFactory();

            IMobilePhone mobilePhoneApple = mobilePhoneFactory.GetMobilePhone(MobilePhoneType.Apple);

            mobilePhoneApple.DisplayInfo();

            IMobilePhone mobilePhoneSamsung = mobilePhoneFactory.GetMobilePhone(MobilePhoneType.Samsung);

            mobilePhoneSamsung.DisplayInfo();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wincubate/agilent
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new AppleFactory(); // <-- Only(!) reference to vendor

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new SamsungFactory();

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
コード例 #4
0
        public IMobilePhone GetMobilePhone(MobilePhoneType type)
        {
            IMobilePhone mobilePhone = null;

            switch (type)
            {
            case MobilePhoneType.Apple:
                mobilePhone = new Apple();
                break;

            case MobilePhoneType.Samsung:
                mobilePhone = new Samsung();
                break;
            }
            return(mobilePhone);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Zgencheva/C--OOP
        static void Main(string[] args)
        {
            Console.WriteLine("Are you an apple fangirl?");
            var isFangirl = Console.ReadLine() == "yes" ? true : false;
            ITechnologyAbstractFactory techFactory = null;

            if (isFangirl)
            {
                techFactory = new AppleFactory();
            }
            else
            {
                techFactory = new SamsungFactory();
            }
            IMobilePhone myphone  = techFactory.CreatePhone();
            ITablet      mytablet = techFactory.CreateTablet();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: KamenYu/Csharp-Advanced
        static void Main(string[] args)
        {
            string techType = Console.ReadLine();

            ITechnologyAbstractFactory abstractFactory = null;

            if (techType.ToLower() == "samsung")
            {
                abstractFactory = new SamsungFactory();
            }
            else if (techType.ToLower() == "apple")
            {
                abstractFactory = new AppleFactory();
            }

            IMobilePhone mobilePhone = abstractFactory.CreatePhone();
            ITablet      tablet      = abstractFactory.CreateTablet();

            Console.WriteLine(mobilePhone.GetType().Name);
            Console.WriteLine(tablet.GetType().Name);
        }
コード例 #7
0
 public MobileClient(IMobilePhone mobilePhone)
 {
     _normalPhone = mobilePhone.GetNormalPhone();
     _smartPhone  = mobilePhone.GetSmartPhone();
 }
コード例 #8
0
ファイル: TMP.cs プロジェクト: shahedbd/DotNetCoreDI
 public Human(IMobilePhone mobilePhone)
 {
     _mobilePhone = mobilePhone;
 }
コード例 #9
0
 public MobileClient(IMobilePhone factory)
 {
     smartPhone  = factory.GetSmartPhone();
     normalPhone = factory.GetNormalPhone();
 }
コード例 #10
0
        public static void InterfaceTest()
        {
            A a = new A(); //class A
            B b = new B(); //class B

            a.aTest();
            a.DialNumber();
            a.ReceiveCall();
            a.EndCall();
            b.aTest();
            b.DialNumber();
            b.ReceiveCall();
            b.EndCall();

            IMobilePhone iA = (IMobilePhone)a; //interface

            iA.DialNumber();
            iA.ReceiveCall();
            iA.EndCall();
            IMobilePhone iB = (IMobilePhone)b;

            iB.DialNumber();
            iB.ReceiveCall();
            iB.EndCall();


            MyFather f = new MyFather();
            MyMother m = new MyMother();

            f.Name = "James";
            m.Name = "Jennifer";

            Console.WriteLine("My {0} is {1}", f.ParentTitle(), f.Name);
            Console.WriteLine("My {0} is {1}", m.ParentTitle(), m.Name);

            Childer c = new Childer();

            c.Name       = "Sophy";
            c.title      = "Father";
            c.parentName = "Jame";
            Console.WriteLine("{2}'s {0} is {1}", c.ParentTitle(), c.ParentName(), c.Name);


            iFive obj = new OddEven(); //iFive (small) OddEven (bigger)

            obj.One();
            obj.Three();
            obj.Five();

            iEven obj1 = new OddEven();

            obj1.Two();
            obj1.Four();

            ILog log  = new ConsoleLog();
            ILog log1 = new FileLog();

            log.Log("sending log to console");
            log1.Log("write log to log.txt");

            infDemo.infDemoTest(); //public static method
        }
コード例 #11
0
 public MobileAbstractFactory(IMobilePhone factory)
 {
     smartPhone  = factory.GetSmartPhone();
     normalPhone = factory.GetNormalPhone();
 }
コード例 #12
0
 public Person(IMobilePhone imobilephone)
 {
     _iMobilePhone = imobilephone;
 }
コード例 #13
0
 public Client(IMobilePhone factory)
 {
     _smartPhone = factory.GetSmartPhone();
     _oldPhone   = factory.GetOldPhone();
 }
コード例 #14
0
 internal CMobilePhone(CItem parent, IMedDataSource dataSource) : base(parent, dataSource)
 {
     this.MobilePhone = (IMobilePhone)dataSource;
 }