Esempio n. 1
0
        public static AddressViewModel Create(IAddressObject o)
        {
            switch (o)
            {
            case WebAddressObject web:
                return(create(web));

            case EmailAddressObject email:
                return(create(email));

            case TelecomAddressObject device:
                return(create(device));
            }

            return(create(o as GeographicAddressObject));
        }
Esempio n. 2
0
 public async Task AddObject(IAddressObject o)
 {
     if (o is WebAddressObject web)
     {
         dbSet.Add(web.DbRecord);
     }
     if (o is EmailAddressObject email)
     {
         dbSet.Add(email.DbRecord);
     }
     if (o is GeographicAddressObject adr)
     {
         dbSet.Add(adr.DbRecord);
     }
     if (o is TelecomAddressObject tel)
     {
         dbSet.Add(tel.DbRecord);
     }
     await db.SaveChangesAsync();
 }
Esempio n. 3
0
 //4-Service Locator
 public Company()
 {
     this._address = ServiceLocator.getAddress();
 }                                                                //Static Class Service Locator is used to search for objects
Esempio n. 4
0
 //3-Interface Implementation
 public void setAddress(IAddressObject obj)
 {
     _address = obj;
 }
Esempio n. 5
0
        /*Applying Dependency Injection in 4 ways*/

        //1-Contructor
        public Company(IAddressObject obj)
        {
            _address = obj;
        }