Esempio n. 1
0
 public IHousewithFloorSpecification WithFloor(IBuildingSpecification <Floor> floor)
 {
     return(new HouseSpecification(this.address,
                                   floor,
                                   this.walls,
                                   this.roof));
 }
Esempio n. 2
0
 public IHousewithWallsSpecification WithWalls(IBuildingSpecification <Walls> walls)
 {
     return(new HouseSpecification(this.address,
                                   this.floor,
                                   walls,
                                   this.roof));
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // Cat cat = new Dog();
            // Cat cat = (Cat)new Dog();
            // Cat cat = new Dog().AsCat();
            Cat cat = new WrappedDog(new Dog());


            IExpectAlternateContact spec =
                UserSpecification
                .ForPerson()
                .WithName("Max")
                .WithSurname("Planck")
                .WithPrimaryContact(
                    ContactSpecification.ForEmailAddress("*****@*****.**"));

            IBuildingSpecification <EmailAddress> contact =
                ContactSpecification.ForEmailAddress("*****@*****.**");

            if (!spec.CanAdd(contact))
            {
                Console.WriteLine("Cannot add desired contact...");
            }
            else
            {
                spec = spec.WithAlternateContact(contact);
                IUser user = spec.AndNoMoreContacts().Build();
                Console.WriteLine(user);
            }

            Console.ReadLine();
        }
Esempio n. 4
0
 public IHouseWithRoofSpecification WithRoof(IBuildingSpecification <Roof> roof)
 {
     return(new HouseSpecification(this.address,
                                   this.floor,
                                   this.walls,
                                   roof));
 }
Esempio n. 5
0
 public HouseSpecification(string address, IBuildingSpecification <Floor> floor, IBuildingSpecification <Walls> walls, IBuildingSpecification <Roof> roof)
 {
     this.address = address;
     this.floor   = floor;
     this.walls   = walls;
     this.roof    = roof;
 }
 public ConvertingSpecification(IBuildingSpecification <TProduct> containedSpec)
 {
     if (containedSpec == null)
     {
         throw new ArgumentNullException();
     }
     this.ContainedSpec = containedSpec;
 }
        public bool Equals(IBuildingSpecification <TBase> other)
        {
            ConvertingSpecification <TBase, TProduct> convertingSpec =
                other as ConvertingSpecification <TBase, TProduct>;

            return
                (convertingSpec != null &&
                 this.ContainedSpec.Equals(convertingSpec.ContainedSpec));
        }
        public static bool SafeEquals <T>(this IBuildingSpecification <T> first,
                                          IBuildingSpecification <T> second)
        {
            bool firstNull  = object.ReferenceEquals(first, null);
            bool secondNull = object.ReferenceEquals(second, null);

            return
                ((firstNull && secondNull) ||
                 (!firstNull && first.Equals(second)));
        }
        public IExpectModel ProducedBy(IBuildingSpecification <Models.Producer> producerSpec)
        {
            if (producerSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new MachineSpecification()
            {
                ProducerSpec = producerSpec
            });
        }
        public IExpectPhoneNumber WithEmailAddress(IBuildingSpecification <Models.EmailAddress> emailSpec)
        {
            if (emailSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new LegalEntitySpecification()
            {
                CompanyName = this.CompanyName,
                EmailAddressSpec = emailSpec
            });
        }
        public IBuildingSpecification <Models.Machine> OwnedBy(IBuildingSpecification <Models.LegalEntity> ownerSpec)
        {
            if (ownerSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new MachineSpecification()
            {
                ProducerSpec = this.ProducerSpec,
                Model = this.Model,
                OwnerSpec = ownerSpec
            });
        }
        public IExpectOtherContact WithPhoneNumber(IBuildingSpecification <Models.PhoneNumber> phoneSpec)
        {
            if (phoneSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new LegalEntitySpecification()
            {
                CompanyName = this.CompanyName,
                EmailAddressSpec = this.EmailAddressSpec,
                PhoneNumberSpec = phoneSpec
            });
        }
        public IExpectAlternateContact WithPrimaryContact(IBuildingSpecification <IContactInfo> primaryContactSpec)
        {
            if (primaryContactSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new PersonSpecification()
            {
                Name = this.Name,
                Surname = this.Surname,
                ContactSpecs = new[] { primaryContactSpec },
                PrimaryContactSpec = primaryContactSpec
            });
        }
        public IExpectOtherContact WithOtherContact(IBuildingSpecification <IContactInfo> contactSpec)
        {
            if (contactSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new LegalEntitySpecification()
            {
                CompanyName = this.CompanyName,
                EmailAddressSpec = this.EmailAddressSpec,
                PhoneNumberSpec = this.PhoneNumberSpec,
                OtherContactSpecs = new List <IBuildingSpecification <IContactInfo> >(this.OtherContactSpecs)
                {
                    contactSpec
                }
            });
        }
        public IExpectAlternateContact WithAlternateContact(IBuildingSpecification <IContactInfo> contactSpec)
        {
            if (contactSpec == null)
            {
                throw new ArgumentNullException();
            }

            return(new PersonSpecification()
            {
                Name = this.Name,
                Surname = this.Surname,
                ContactSpecs = new List <IBuildingSpecification <IContactInfo> >(this.ContactSpecs)
                {
                    contactSpec
                },
                PrimaryContactSpec = this.PrimaryContactSpec
            });
        }
        public IExpectAlternateContact WithPrimaryContact <T>(IBuildingSpecification <T> primaryContactSpec) where T : IContactInfo
        {
            if (primaryContactSpec == null)
            {
                throw new ArgumentNullException();
            }

            ConvertingSpecification <IContactInfo, T> convertedSpec =
                new ConvertingSpecification <IContactInfo, T>(primaryContactSpec);

            return(new PersonSpecification()
            {
                Name = this.Name,
                Surname = this.Surname,
                ContactSpecs = new[] { convertedSpec },
                PrimaryContactSpec = convertedSpec
            });
        }
        public IExpectAlternateContact WithAlternateContact <T>(IBuildingSpecification <T> contactSpec) where T : IContactInfo
        {
            if (!this.CanAdd(contactSpec))
            {
                throw new ArgumentException();
            }

            ConvertingSpecification <IContactInfo, T> convertedSpec =
                new ConvertingSpecification <IContactInfo, T>(contactSpec);

            return(new PersonSpecification()
            {
                Name = this.Name,
                Surname = this.Surname,
                ContactSpecs = new List <IBuildingSpecification <IContactInfo> >(this.ContactSpecs)
                {
                    convertedSpec
                },
                PrimaryContactSpec = this.PrimaryContactSpec
            });
        }
 public static ConvertingSpecification <TBase, TProduct> From(IBuildingSpecification <TProduct> specification)
 {
     return(new ConvertingSpecification <TBase, TProduct>(specification));
 }
 public bool Equals(IBuildingSpecification <Models.PhoneNumber> other) =>
 this.Equals(other as PhoneNumberSpecification);
 public bool Equals(IBuildingSpecification <Models.Producer> other) =>
 this.Equals(other as ProducerSpecification);
Esempio n. 21
0
 public bool Equals(IBuildingSpecification <Models.Machine> other) =>
 this.Equals(other as MachineSpecification);
 public bool CanAdd <T>(IBuildingSpecification <T> contactSpec) where T : IContactInfo =>
 contactSpec != null &&
 CanAdd(new ConvertingSpecification <IContactInfo, T>(contactSpec));
 public bool Equals(IBuildingSpecification <Models.Person> other) =>
 this.Equals(other as PersonSpecification);
 private bool CanAdd(IBuildingSpecification <IContactInfo> contactSpec) =>
 !this.ContactSpecs.Any(spec => spec.Equals(contactSpec));
Esempio n. 25
0
 public bool Equals(IBuildingSpecification <Models.EmailAddress> other) =>
 this.Equals(other as EmailAddressSpecification);
Esempio n. 26
0
 public bool Equals(IBuildingSpecification <Models.LegalEntity> other) =>
 this.Equals(other as LegalEntitySpecification);