static ProxyTestHelper()
 {
     _person = new Person(PersonId);
     _business = new Business(BusinessId);
     _location = new Location(LocationId);
     _phone = new Phone(PhoneId);
 }
 public PhoneWrapItem(IPhone phone, IEmployee employee = null)
 {
     if (phone == null)
         throw new ArgumentException("Phone is null!");
     this.PhoneItem = phone;
     this.EmployeeItem = employee;
 }
Example #3
0
        public AdvancedViewModel(ISettingsService settingsService, IFileSystemOperations fileSystemOperations,
                                 UIServices uiServices, IProviderBasedWindowsDeployer deployer,
                                 IDiskLayoutPreparer preparer,
                                 IWindowsOptionsProvider optionsProvider, IDeviceProvider deviceProvider, IDownloadProgress progress, StatusViewModel statusViewModel, IPhone phone)
        {
            StatusViewModel      = statusViewModel;
            this.settingsService = settingsService;
            this.uiServices      = uiServices;
            this.deployer        = deployer;
            this.preparer        = preparer;
            this.optionsProvider = optionsProvider;
            this.deviceProvider  = deviceProvider;
            this.progress        = progress;
            this.phone           = phone;

            sizeReservedForWindows =
                this.WhenAnyValue(x => x.GbsReservedForWindows, ByteSize.FromGigaBytes)
                .ToProperty(this, x => x.SizeReservedForWindows);

            DeleteDownloadedWrapper = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(() => DeleteDownloaded(fileSystemOperations)), uiServices.Dialog);
            ForceDualBootWrapper    = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(ForceDualBoot), uiServices.Dialog);

            BackupCommandWrapper  = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(Backup), uiServices.Dialog);
            RestoreCommandWrapper = new CommandWrapper <Unit, Unit>(this, ReactiveCommand.CreateFromTask(Restore), uiServices.Dialog);

            IsBusyObservable = Observable.Merge(new []
            {
                DeleteDownloadedWrapper.Command.IsExecuting,
                BackupCommandWrapper.Command.IsExecuting,
                RestoreCommandWrapper.Command.IsExecuting,
                ForceDualBootWrapper.Command.IsExecuting,
            });
        }
Example #4
0
 public InstallDevMenu(string rootFilesPath, IPhone phone, IBcdInvokerFactory bcdInvokerFactory, IFileSystemOperations fileSystemOperations, IDialog dialog)
 {
     this.rootFilesPath        = rootFilesPath;
     this.phone                = phone;
     this.bcdInvokerFactory    = bcdInvokerFactory;
     this.fileSystemOperations = fileSystemOperations;
     this.dialog               = dialog;
 }
Example #5
0
        static void Main(string[] args)
        {
            IPhone phone      = new Samsung(10);
            IPhone clonePhone = phone.Clone();

            phone.PrintModelInfo();
            clonePhone.PrintModelInfo();
        }
Example #6
0
 public InstallDevMenu(string rootFilesPath, IPhone phone, IBcdInvokerFactory bcdInvokerFactory, IFileSystemOperations fileSystemOperations, IPrompt prompt)
 {
     this.rootFilesPath        = rootFilesPath;
     this.phone                = phone;
     this.bcdInvokerFactory    = bcdInvokerFactory;
     this.fileSystemOperations = fileSystemOperations;
     this.prompt               = prompt;
 }
 public static void SetUp(TestContext context)
 {
     var helper = new ResponseDecoderHelper();
     _response = helper.PhoneResponse;
     _response3 = helper.PhoneResponse3;
     _phone = _response.Results.First();
     _phone3 = _response3.Results.First();
 }
Example #8
0
        public static void CommonMethod(IPhone phone)
        {
            phone.VideoCall();
            phone.Call();
            string mes = phone.Message("I'm a Robert Kocharian!!!");

            Console.WriteLine(mes);
        }
Example #9
0
 public void Update(int phoneId, IPhone phone)
 {
     Console.WriteLine("[" + this.GetType().ToString() + "]" + " Updating phone");
     if (storage.ContainsKey(phoneId))
     {
         storage[phoneId] = phone;
     }
 }
Example #10
0
        public int Save(IPhone phone)
        {
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving phone");
            int newId = ++id;

            storage[newId] = phone;
            return(newId);
        }
Example #11
0
 public Phone(IPhone phone)
 {
     if (phone == null)
     {
         throw new ArgumentNullException(nameof(phone));
     }
     PhoneString = phone.PhoneString;
 }
Example #12
0
 public void DeleteIPhone(IPhone iPhone)
 {
     if (iPhone != null)
     {
         _db.IPhones.Remove(iPhone);
     }
     _db.SaveChanges();
 }
Example #13
0
 public int GetPhoneQuantity(IPhone phone)
 {
     if (IsPhoneStored(phone))
     {
         return(_phoneStorage[phone]);
     }
     return(0);
 }
Example #14
0
        void B()
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterType <IPhone, ApplePhone>();
            container.RegisterType <IHeadphone, Headphone>();
            container.RegisterType <IPower, Power>();
            IPhone phone = container.Resolve <IPhone>();
        }
Example #15
0
        void A()
        {
            IUnityContainer container = new UnityContainer(); //定义一个容器

            container.RegisterType <IPhone, AndroidPhone>();  //注册类型,表示遇到IPhone类型,创建AndroidPhone的实例
            IPhone phone = container.Resolve <IPhone>();      //创建实例

            phone.Call();                                     //调用实例方法
        }
Example #16
0
        public static void SetUp(TestContext context)
        {
            var helper = new ResponseDecoderHelper();

            _response  = helper.PhoneResponse;
            _response3 = helper.PhoneResponse3;
            _phone     = _response.Results.First();
            _phone3    = _response3.Results.First();
        }
 public WindowsDeployer(IWindowsOptionsProvider optionsProvider, IPhone phone, IWindowsImageService imageService, IBootCreator bootCreator, IEnumerable <ISpaceAllocator> spaceAllocators, IObserver <double> progressObserver)
 {
     this.optionsProvider  = optionsProvider;
     this.phone            = phone;
     this.imageService     = imageService;
     this.bootCreator      = bootCreator;
     this.spaceAllocators  = spaceAllocators;
     this.progressObserver = progressObserver;
 }
 public LumiaDiskLayoutPreparer(IWindowsOptionsProvider optionsProvider, IFileSystemOperations fileOperations,
                                IEnumerable <ISpaceAllocator <IPhone> > spaceAllocators, IPartitionCleaner cleaner, IPhone phone)
 {
     this.optionsProvider = optionsProvider;
     this.fileOperations  = fileOperations;
     this.spaceAllocators = spaceAllocators;
     this.cleaner         = cleaner;
     this.phone           = phone;
 }
Example #19
0
        public static void Run()
        {
            //概念
            //IOC 是控制反转,即将创建对象的工作交给容器,是目标
            //DI 是依赖注入,是我们实现控制反转的手段

            //只有抽象,没有细节,好处是扩展
            IPhone phone = ObjectFactory.CreatePhone();
        }
Example #20
0
        public void IsGetPhoneDetailsPrintRigthResult()
        {
            var expected = "Model: IPhone 8; display: 4,7; platform: IOS;" +
                           $"camera: 12 MP; color: gray; price: 700$";
            var phone  = new IPhone("8", 4.7, "IOS", 12, "gray", 700);
            var actual = phone.GetPhoneDetails();

            Assert.AreEqual(expected, actual);
        }
Example #21
0
 public PhoneProxy(IPhone p, IContext ctx) : base()
 {
     context          = ctx;
     base.areacode    = p.areacode;
     base.code        = p.code;
     base.description = p.description;
     base.number      = p.number;
     base.clientPhone = null;
 }
Example #22
0
File: Program.cs Project: Fixu/IOC
        static void Main(string[] args)
        {
            //{
            //    Console.WriteLine("**********简单使用************");
            //    IUnityContainer container = new UnityContainer();
            //    container.RegisterType<IHead, Head>();
            //    container.RegisterType<IMicro, Micro>();
            //    container.RegisterType<IPower, Power>();
            //    container.RegisterType<IPhone, IosPhone>();

            //    IPhone phone = container.Resolve<IPhone>();

            //    phone.Show();

            //    Console.WriteLine($"phene.Micro is null=={phone.Micro==null}");
            //    Console.WriteLine($"phene.Head is null=={phone.Head==null}");
            //    Console.WriteLine($"phene.Power is null=={phone.Power==null}");
            //}
            //{
            //    Console.WriteLine("**********依赖注入************");

            //    IUnityContainer container = new UnityContainer();
            //    container.RegisterType<IHead, Head>();
            //    container.RegisterType<IPower, Power>();
            //    container.RegisterType<IMicro, Micro>();
            //    container.RegisterType<IPhone, IosPhone>();

            //    IPhone phone = container.Resolve<IPhone>();

            //    phone.Show();
            //    Console.WriteLine($"phene.Micro is null=={phone.Micro == null}");
            //    Console.WriteLine($"phene.Head is null=={phone.Head == null}");
            //    Console.WriteLine($"phene.Power is null=={phone.Power == null}");
            //}
            {
                Console.WriteLine("**********通过配置文件************");

                ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap
                {
                    ExeConfigFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"UnityXml\UnityConfig.xml")
                };
                Configuration             configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
                UnityConfigurationSection section       = (UnityConfigurationSection)configuration.GetSection(UnityConfigurationSection.SectionName);

                IUnityContainer container = new UnityContainer();
                section.Configure(container, "unityContainer");

                IPhone phone = container.Resolve <IPhone>();

                phone.Show();
                Console.WriteLine($"phene.Micro is null=={phone.Micro == null}");
                Console.WriteLine($"phene.Head is null=={phone.Head == null}");
                Console.WriteLine($"phene.Power is null=={phone.Power == null}");
            }
            Console.ReadLine();
        }
Example #23
0
        static void Main(string[] args)
        {
            //iPhone phone = new iPhone();
            //HTC htc = new HTC();
            //{
            //    Console.WriteLine("**************************");
            //    StudentService studentService = new StudentService();
            //    studentService.Study();
            //    studentService.PlayPhone(phone);
            //    studentService.PlayPhone(htc);
            //}
            //{
            //    Console.WriteLine("************DIP**************");
            //    IStudentService studentService = new StudentService();
            //    studentService.Study();//1 查看定义不方便
            //    studentService.PlayPhone(phone);//2 编译器的限制,不能访问接口美誉的声明的方法,每次增加方法,还得去抽象里面去添加才能使用
            //    studentService.PlayPhone(htc);
            //}

            //{
            //    Console.WriteLine("**************SimpleIOC************");
            //    IStudentService studentService = SimpleFactory.CreateStudentServer();
            //    studentService.Study();
            //    //依赖抽象,更加稳定,支持扩展
            //    //每个类型实例都需要去单独写方法
            //    {
            //        AbstractPhone abstractPhone = SimpleFactory.CreateAbstractPhone();
            //        studentService.PlayPhone(abstractPhone);
            //    }
            //}

            //{
            //    //IOC容器就出现了,其实是依赖倒置原则的封装实现,本质就是一个工厂,来创建对象的
            //    //nuget添加Unity引用
            //    IUnityContainer container = new UnityContainer(); // 1.实例化容器
            //    container.RegisterType<IStudentService, StudentService>(); //2.容器注册
            //    container.RegisterType<AbstractPhone, iPhone>();
            //    IStudentService service = container.Resolve<IStudentService>(); //3.获取实例
            //    AbstractPhone phone = container.Resolve<AbstractPhone>();
            //    service.Study();
            //    service.PlayPhone(phone);
            //}

            {
                //构造A对象时,但是A依赖于B对象,希望能自动的初始化B对象
                IUnityContainer container = new UnityContainer(); // 1.实例化容器
                container.RegisterType <IPhone, ApplePhone>();    //2.容器注册
                container.RegisterType <IMicrophone, Microphone>();
                container.RegisterType <IHeadphone, Headphone>();
                container.RegisterType <IPower, Power>();
                IPhone phone = container.Resolve <IPhone>(); //3.获取实例
                //构造A对象时,能自动把依赖的B/C/D对象初始化并传入进去
            }

            Console.ReadLine();
        }
Example #24
0
        public void EditIPhone(IPhone iPhone, Action <IPhone> editAction)
        {
            var iph = GetPhoneByProp(x => x.Id == iPhone.Id);

            if (iph != null)
            {
                editAction(iph);
            }
            _db.SaveChanges();
        }
Example #25
0
        public void SupplyPhonesToWarehouse(IPhone phone, IWarehouse warehouse)
        {
            warehouse.StorePhone(phone, 10);

            if (null != phonesSuppliedListener)
            {
                phonesSuppliedListener.OnPhonesSupplied("10 demo phones: " + phone.PhoneName +
                                                        " was stored in warehouse at: " + warehouse.Location);
            }
        }
Example #26
0
        /// <summary>
        /// Method that lists the steps in a phone's repair
        /// Any phone model that IMPLEMENTS all the methods of the interface IPhone can be INSERTED AS DEPENDENCIES to this method.
        /// This would be the common set of steps in the repair
        /// </summary>
        /// <param name="phone">Any class that implements the IPhone interface</param>
        public void RepairSteps(IPhone phone)
        {
            string part1 = phone.GetPhonePart1();

            Console.WriteLine(string.Format("{0} repaired", part1));

            double partCost = phone.GetPart1Cost();

            Console.WriteLine(string.Format("Repair cost {0}", partCost * 0.5));
        }
 public override void Load()
 {
     if (!IsLoaded)
     {
         var response = this.Client.FindPhones(new PhoneQuery(this.Id));
         var results  = response.Results;
         _phone        = ((results == null || !results.Any()) ? null : results.First());
         this.IsLoaded = true;
     }
 }
Example #28
0
        public static void Show()
        {
            Console.WriteLine("=====Basic Usage of Unity=========");
            IUnityContainer container = new UnityContainer(); //1. Declare a container

            container.RegisterType <IPhone, AndriodPhone>();  //2. Initiate the container, register the type
            IPhone phone = container.Resolve <IPhone>();      //3. Create an object by reflection

            phone.Call();
        }
Example #29
0
        public void Call()
        {
            if (_phone == null)
            {
                Console.WriteLine("Creating phone!");
                _phone = new Phone();
            }

            _phone.Call();
        }
Example #30
0
        public T CreatePhone <T>(IPhone source)
            where T : IPhone, new()
        {
            var target = CreateAddressInfo <T>(source);

            target.PhoneNumber = source.PhoneNumber;
            target.PhoneType   = source.PhoneType;

            return(target);
        }
        ///<summary>
        ///Method that list the steps in phone repair
        ///Any phone model that IMPLEMENTS all the methods of tyhe interfaces IPhone can be inserted as dependencies to this method.
        ///This would be the common set of steps in the repair.
        ///</summary>
        ///<param name="phone">Any class that implements the IPhone interfaces</param>
        public void RepairSteps(IPhone phone)
        {
            string part1 = phone.GetPhonePart1();

            Console.WriteLine($"{part1} repaired");

            double partCost = phone.GetPart1Cost();

            Console.WriteLine($"Repair Cost: {partCost * 0.5}");
        }
Example #32
0
 public PhoneBase(IPhone phone)
 {
     if (phone == null) return;
     PhoneId = phone.PhoneId;
     CountryCode = phone.CountryCode;
     PhoneNumber = phone.PhoneNumber;
     PhoneExtension = phone.PhoneExtension;
     IsPrimary = phone.IsPrimary;
     PhoneUsageEnum = phone.PhoneUsageEnum;
 }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            #region Sample1

            BaseNoteBook macBook = new MacBook();

            BaseNoteBook micsoroftBook = new MicrosoftBook();


            #endregion Sample1

            Console.Clear();

            #region Sample2

            BasePhone android = new Android();
            BasePhone iphone  = new IPhone();


            #endregion Sample2

            Console.Clear();

            #region Sample3

            //LogBase sqlLog1 = new SqlLog();
            //sqlLog1.WriteLog();

            var logType = LogType.Sql; // Configden okundu..


            LoggerFactory factory     = new LoggerFactory();
            var           logInstance = factory.CreateLogger(logType);


            logInstance.WriteLog();

            #endregion  Sample3


            #region Interface

            ICreateLoggerFactory lFactory = new CreateLoggerFactory(LogType.Sql);
            ILog logItem = lFactory.CreateLogger();

            logItem.ReadLog();
            logItem.WriteErrorLog();


            #endregion Interface

            Console.ReadLine();
        }
 public virtual void TryRepair(ref IPhone phone)
 {
     if (phone.Brand == AuthorizedBrand)
     {
         Repair(ref phone);
     }
     else
     {
         Successor?.TryRepair(ref phone);
     }
 }
Example #35
0
 public bool UpdatePhone(IPhone phone)
 {
     var repPhone = _repository.GetPhoneById(phone.Id);
     if (repPhone != null)
     {
         repPhone.PhoneNumber = phone.Number;
         repPhone.DepartmentId = phone.DepartmentId;
         repPhone.EmployeeId = phone.EmployeeId;
         return _repository.UpdatePhone(repPhone);
     }
     else
     {
         return false;
     }
 }
        public static void DumpPhone(IPhone phone, int depth, int indent = 0)
        {
            PrintName(phone, indent);
            WriteLine(indent, "Carrier:                     {0}", String.IsNullOrWhiteSpace(phone.Carrier) ? "null" : phone.Carrier);
            WriteLine(indent, "Country Calling Code:        {0}", phone.CountryCallingCode);
            WriteLine(indent, "Do Not Call:                 {0}", phone.DoNotCall.HasValue ? phone.DoNotCall.Value.ToString() : "null");
            WriteLine(indent, "Extension:                   {0}", phone.Extension ?? "null");
            WriteLine(indent, "LineType:                    {0}", phone.LineType);
            WriteLine(indent, "PhoneNumber:                 {0}", phone.PhoneNumber);
            WriteLine(indent, "Is Prepaid:                  {0}", phone.IsPrepaid.HasValue ? phone.IsPrepaid.Value.ToString() : "null");
            WriteLine(indent, "Reputation:                  {0}", GetSpamScore(phone));
            WriteLine(indent, "Is Valid:                    {0}", phone.IsValid);
            WriteLine(indent, "Is Connected:				{0}", phone.IsConnected);

            DumpBaseEntity(phone, depth, indent);
        }
Example #37
0
 public WindowsPhoneDevice()
 {
     this.phone = new WindowsPhone();
     this.bluetoothHub = new BluetoothHub();
     this.screen = new Screen();
 }
 private static int? GetSpamScore(IPhone phone)
 {
     return Phone.GetSpamScore(phone.Reputation);
 }
 public override void Load()
 {
     if (!IsLoaded)
     {
         var response = this.Client.FindPhones(new PhoneQuery(this.Id));
         var results = response.Results;
         _phone = ((results == null || !results.Any()) ? null : results.First());
         this.IsLoaded = true;
     }
 }
 public ClientUseBridgePattern()
 {
     this.userPhone =  new MobilePhone(new GenericPhone(), new GenericSMS());
 }
Example #41
0
 public DesktopController(IPhone phone, OsInterface os)
 {
     this.phone = phone;
     this.os = os;
     this.RegisterEvents();
 }
 public void Add(IPhone phone)
 {
     _phoneDictionary.Add(phone.Id, phone);
 }
Example #43
0
 public PhoneApdapter(IPhone phone)
 {
     this._phone = phone;
 }