/// <summary> /// Crot: /// </summary> /// <param name="MusicFileService">Instance of the MusicFileService</param> /// <param name="LastFMService">Instance of the LastFMService</param> /// <param name="AlbumRepository">Instance of the AlbumRepository</param> /// <param name="AlbumFactory">Instance of the AlbumFactory</param> /// <param name="TrackFactory">Instance of the TrackFactory</param> /// <param name="ArtistFactory">Instance of the ArtistFactory</param> /// <param name="GenreFactory">Instance of the GenreFactory</param> public MusicFileDataService(IMusicFileService MusicFileService, ILastFMService LastFMService, IAlbumRepository AlbumRepository, AbstractFactory<Album> AlbumFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Artist> ArtistFactory, AbstractFactory<Genre> GenreFactory) { if (MusicFileService == null) throw new ArgumentNullException("MusicFileService", "No valid MusicFile service supplied"); _musicFileService = MusicFileService; if (LastFMService == null) throw new ArgumentNullException("LastFMService", "No valid LastFM service supplied"); _lastFMService = LastFMService; if (AlbumRepository == null) throw new ArgumentNullException("AlbumRepository", "No valid Album Repository supplied"); _albumRepository = AlbumRepository; if (AlbumFactory == null) throw new ArgumentNullException("AlbumFactory", "No valid Album Factory supplied"); _albumFactory = AlbumFactory; if (TrackFactory == null) throw new ArgumentNullException("TrackFactory", "No valid Track Factory supplied"); _trackFactory = TrackFactory; if (ArtistFactory == null) throw new ArgumentNullException("ArtistFactory", "No valid Artist Factory supplied"); _artistFactory = ArtistFactory; if (GenreFactory == null) throw new ArgumentNullException("GenreFactory", "No valid Genre Factory supplied"); _genreFactory = GenreFactory; }
/// <summary> /// ctor; /// </summary> /// <param name="AlbumRepository">Instance of the AlbumRepository</param> /// <param name="AlbumFactory">Instance of the AlbumFactory</param> /// <param name="ImageFactory">Instance of the ImageFactore</param> /// <param name="TrackFactory">Instance of the TrackFactory</param> /// <param name="ArtistFactory">Instance of the ArtistFactory</param> /// <param name="GenreFactory">Instance of thenGenreFactory</param> /// <param name="WikiFactory">Instance of the WikiFactory</param> /// <param name="LastFMService">Instance of the LastFMService</param> public LastFMModelDataService(IAlbumRepository AlbumRepository, AbstractFactory<Album> AlbumFactory, AbstractFactory<Image> ImageFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Artist> ArtistFactory, AbstractFactory<Genre> GenreFactory, AbstractFactory<Wiki> WikiFactory, ILastFMService LastFMService) { if (AlbumRepository == null) throw new ArgumentNullException("AlbumRepository", "No valid Album Repository supplied"); _albumRepository = AlbumRepository; if (AlbumFactory == null) throw new ArgumentNullException("AlbumFactory", "No valid Album factory supplied"); _albumFactory = AlbumFactory; if (ImageFactory == null) throw new ArgumentNullException("ImageFactory", "No valid Image factory supplied"); _imageFactory = ImageFactory; if (TrackFactory == null) throw new ArgumentNullException("TrackFactory", "No valid Track factory supplied"); _trackFactory = TrackFactory; if (ImageFactory == null) throw new ArgumentNullException("ArtistFactory", "No valid Artist factory supplied"); _artistFactory = ArtistFactory; if (ImageFactory == null) throw new ArgumentNullException("GenreFactory", "No valid Genre factory supplied"); _genreFactory = GenreFactory; if (WikiFactory == null) throw new ArgumentNullException("WikiFactory", "No valid Wiki factory supplied"); _wikiFactory = WikiFactory; if (LastFMService == null) throw new ArgumentNullException("LastFMService", "No valid Service for LastFM supplied"); _lastFMService = LastFMService; }
static void Main() { FactoryMethod method = new FactoryMethod(); PC comp = (PC)method.CreateComputer(true, 2, 4, 1500); AbstractFactory<PC> factory = new AbstractFactory<PC>(); PC pc = factory.Create(1, 1, 250); AbstractFactory<Notebook> factory2 = new AbstractFactory<Notebook>(); Notebook notebook = factory2.Create(2, 3, 2000); }
public void GetEnumeratorTest() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); factory.Register(0, new CustomCreator()); foreach (int id in factory) { Assert.AreEqual(0, id); } }
public void CreateTest() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); factory.Register(0, new CustomCreator()); factory.Register(1, null); Stream newStream = factory.Create(0); Assert.AreNotEqual(newStream, null); Assert.AreEqual(newStream.GetType(), typeof(MemoryStream)); Assert.AreEqual(factory.Create(1), null); }
public DesignMusicCollection(AbstractFactory<Artist> ArtistFactory, AbstractFactory<Album> AlbumFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Image> ImageFactory, AbstractFactory<Genre> GenreFactory, AbstractFactory<PlayList> PlaylistFactory, AbstractFactory<Wiki> WikiFactory) { // Load the dependencies if (ArtistFactory == null) throw new ArgumentNullException("ArtistFactory", "No valid Factory supplied to create Artist class"); _artistFactory = ArtistFactory; if (AlbumFactory == null) throw new ArgumentNullException("AlbumFactory", "No valid Factory supplied to create Album class"); _albumFactory = AlbumFactory; if (TrackFactory == null) throw new ArgumentNullException("TrackFactory", "No valid Factory supplied to create Track class"); _trackFactory = TrackFactory; if (_imageFactory == null) throw new ArgumentNullException("ImageFactory", "No valid Factory supplied to create Image class"); _imageFactory = ImageFactory; if (GenreFactory == null) throw new ArgumentNullException("GenreFactory", "No valid Factory supplied to create Genre class"); _genreFactory = GenreFactory; if (PlaylistFactory == null) throw new ArgumentNullException("PlaylistFactory", "No valid Factory supplied to create Playlist class"); _playlistFactory = PlaylistFactory; if (WikiFactory == null) throw new ArgumentNullException("WikiFactory", "No valid Factory supplied to create Wiki class"); _wikiFactory = WikiFactory; // Initialise the properties / collection this.Albums = new List<Album>(); this.Tracks = new List<Track>(); this.Artists = new List<Artist>(); this.Genres = new List<Genre>(); this.PlayLists = new List<PlayList>(); //Task loadTheData = Task.Factory.StartNew(() => Load()); //loadTheData.Wait(); // Load the data // Load data into the application: TESTING ONLY Data.InitialiseMusicCollection.SeedData(this, _artistFactory, _albumFactory, _trackFactory, _imageFactory, _genreFactory, _playlistFactory, _wikiFactory); }
/// <summary> /// ctor: accepts the injected instance of the in-memory context /// </summary> /// <param name="UnitOfWork">The instance of the context</param> /// <param name="ArtistFactory">Instance of the ArtistFactory</param> /// <param name="AlbumFactory">Instance of the albumFactory</param> /// <param name="TrackFactory">Instance of the TrackFactory</param> /// <param name="ImageFactory">Instance of the ImageFactory</param> /// <param name="GenreFactory">Instance of the GenreFactory</param> /// <param name="PlaylistFactory">Instance of the PlaylistFactory</param> /// <param name="WikiFactory">Instance of the WikiFactory</param> public PersistenceRepository(IUnitOfWork UnitOfWork, AbstractFactory<Artist> ArtistFactory, AbstractFactory<Album> AlbumFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Image> ImageFactory, AbstractFactory<Genre> GenreFactory, AbstractFactory<PlayList> PlaylistFactory, AbstractFactory<Wiki> WikiFactory ) { if (UnitOfWork == null) throw new ArgumentNullException("UnitOfWork", "No valid Unit of Work supplied"); _unitOfWork = UnitOfWork; if (ArtistFactory == null) throw new ArgumentNullException("ArtistFactory", "No valid Factory supplied to create Artist class"); _artistFactory = ArtistFactory; if (AlbumFactory == null) throw new ArgumentNullException("AlbumFactory", "No valid Factory supplied to create Album class"); _albumFactory = AlbumFactory; if (TrackFactory == null) throw new ArgumentNullException("TrackFactory", "No valid Factory supplied to create Track class"); _trackFactory = TrackFactory; if (ImageFactory == null) throw new ArgumentNullException("ImageFactory", "No valid Factory supplied to create Image class"); _imageFactory = ImageFactory; if (GenreFactory == null) throw new ArgumentNullException("GenreFactory", "No valid Factory supplied to create Genre class"); _genreFactory = GenreFactory; if (PlaylistFactory == null) throw new ArgumentNullException("PlaylistFactory", "No valid Factory supplied to create Playlist class"); _playlistFactory = PlaylistFactory; if (WikiFactory == null) throw new ArgumentNullException("WikiFactory", "No valid Factory supplied to create Wiki class"); _wikiFactory = WikiFactory; // Create an instance of the Navigation Properties Builder, for the Load _navigationProperyBuilder = new BuildNavigationProperties(); }
static void Main(string[] args) { AbstractFactory factory = FactoryProducer.GetFactory("shape"); IShape shape = factory.GetShape("square"); shape.Draw(); shape = factory.GetShape("rectangle"); shape.Draw(); shape = factory.GetShape("circle"); shape.Draw(); Console.WriteLine(); factory = FactoryProducer.GetFactory("color"); IColor color = factory.GetColor("Red"); color.FillColor(); color = factory.GetColor("Green"); color.FillColor(); color = factory.GetColor("Blue"); color.FillColor(); Console.WriteLine(); }
public override void OnAuthorization(HttpActionContext actionContext) { var attributes = actionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>(); bool isAnonymous = attributes.Any(a => a is AllowAnonymousAttribute); if (isAnonymous) { base.OnAuthorization(actionContext); return; } IUserInfoService UserBLL = AbstractFactory.CreateUserInfoService(); int UserID = Function.GetRequestInt("UserID"); UserInfo CurrentUserInfo = UserBLL.GetList(p => p.ID == UserID).FirstOrDefault(); if (CurrentUserInfo == null) { HandleUnauthorizedRequest(actionContext); return; } }
/// <summary> /// 初始化界面 /// </summary> private void Init() { dataservice = AbstractFactory.ChooseFactory(index).CreateDataService(); //时间定时器 _timer = new System.Timers.Timer(1000); _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _timer.Interval = 1 * 1000; _timer.Enabled = true; _timer.AutoReset = true; //加载图片 pictureEdit1.Image = Image.FromFile("test.png"); //获取上下工差 GetTol(); //显示上下工差 SetTolToForm(); //数据操作定时器 maintimer = new System.Timers.Timer(200); maintimer.Elapsed += new ElapsedEventHandler(maintimer_Elapsed); maintimer.Interval = 1 * 200; maintimer.Enabled = true; maintimer.AutoReset = true; }
public void Run() { System.Console.WriteLine("I am Abstract Faction Pattern"); AbstractFactory shapeFactory = FactoryProducer.GetFactory("Shape"); IShape shape = shapeFactory.GetShape("Circle"); shape.Draw(); shape = shapeFactory.GetShape("Rectangle"); shape.Draw(); shape = shapeFactory.GetShape("Square"); shape.Draw(); AbstractFactory colorFactory = FactoryProducer.GetFactory("Color"); IColor color = colorFactory.GetColor("Red"); color.Fill(); color = colorFactory.GetColor("Green"); color.Fill(); color = colorFactory.GetColor("Blue"); color.Fill(); }
public void DoubleMaxSize_ShouldBeTwoPages() { var buffer = new BMSByte(); var destructor = AbstractFactory.Get <INetworkTypeFactory>().GetNew <IMessageDestructor>(); int headerLength = destructor.HeaderLength; buffer.AugmentSize(destructor.MaxPageLength * 2); buffer.PointToEnd(); for (int i = 0; i < buffer.Size; i++) { buffer[i] = (byte)(i % byte.MaxValue); } IPagenatedMessage pm = destructor.BreakdownMessage(buffer); Assert.AreEqual(2, pm.Pages.Count); Assert.AreEqual(buffer.Size, pm.TotalSize); Assert.AreEqual(buffer, pm.Buffer); Assert.AreEqual(0, pm.Pages[0].StartOffset); Assert.AreEqual(destructor.MaxPageLength + headerLength, pm.Pages[0].Length); Assert.AreEqual(destructor.MaxPageLength + headerLength, pm.Pages[1].StartOffset); Assert.AreEqual(destructor.MaxPageLength + headerLength, pm.Pages[1].Length); }
static void Main(string[] args) { AbstractFactory factory = null; Console.WriteLine("Hello. How many passengers do you need?"); int passengers = Convert.ToInt32(Console.ReadLine()); if (passengers > 15) { factory = new LargeGroupFactory(); } else { factory = new SmallGroupFactory(); } var landVehicle = factory.CreateLandVehicle(); var seaVehicle = factory.CreateSeaVehicle(); Console.WriteLine("Land Vehicle : " + landVehicle.GetData() + ". With capacity of: " + landVehicle.GetCapacity()); Console.WriteLine("Sea Vehicle : " + seaVehicle.GetData() + ". With capacity of: " + seaVehicle.GetCapacity()); }
public void EarNoseThroatSurgeryInvalidStatistic() { // Arrange IAbstractFactory abstractFactory = AbstractFactory.Create(); IDependenciesAbstractFactory dependenciesAbstractFactory = abstractFactory.CreateDependenciesAbstractFactory(); IPatientLengthOfStayInputContext patientLengthOfStayInputContext = abstractFactory.CreateContextsAbstractFactory().CreatePatientLengthOfStayInputContextFactory().Create( specialty: dependenciesAbstractFactory.CreateCodeableConceptFactory().CreateEarNoseThroatSurgery(), statistic: dependenciesAbstractFactory.CreateValueFactory().Create(skew)); IPatientLengthOfStayExport patientLengthOfStayExport = abstractFactory.CreateExportsAbstractFactory().CreatePatientLengthOfStayExportFactory().Create(); // Act IPatientLengthOfStayOutputContext patientLengthOfStayOutputContext = patientLengthOfStayExport.GetPatientLengthOfStay( abstractFactory, patientLengthOfStayInputContext); // Assert Assert.IsNull( patientLengthOfStayOutputContext.Duration); }
public void MessageSerialization_ShouldMatch() { var mediator = A.Fake <INetworkMediator>(); var receipt = AbstractFactory.Get <INetworkTypeFactory>().GetNew <IMessageReceiptSignature>(); receipt = null; var mock = new ForgeMessageMock(); mock.MockString = "This is a test message"; mock.Receipt = receipt; BMSByte bin = null; var receiver = A.Fake <ISocket>(); var sender = A.Fake <ISocket>(); A.CallTo(() => sender.Send(A <EndPoint> ._, A <BMSByte> ._)).Invokes((ctx) => { var b = (BMSByte)ctx.Arguments[1]; bin = new BMSByte(); bin.Clone(b); }); var bus = new ForgeMessageBus(); bus.SetMediator(mediator); bus.SendMessage(mock, sender, receiver.EndPoint); Assert.IsNotNull(bin); bus.ReceiveMessageBuffer(receiver, sender.EndPoint, bin); Assert.IsNull(interpretedMessage.Receipt); var res = (ForgeMessageMock)interpretedMessage; Assert.IsTrue(res.ItWorked); Assert.AreEqual(mock.MockString, res.MockString); Assert.AreNotEqual(mock.ItWorked, res.ItWorked); }
public static void Start() { int choice; do { Console.Clear(); Console.WriteLine("------Creational Pattern Demo-------"); Console.WriteLine("Enter Your Choice"); Console.WriteLine("1 To See Factory Design Pattern"); Console.WriteLine("2 To See Singleton Design Pattern"); Console.WriteLine("3 To See Abstract factory Design Pattern"); Console.WriteLine("0 To Go Back"); choice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("------------------------------------"); switch (choice) { case 1: FactoryDemo.Start(); break; case 2: SingletonPattern.Start(); break; case 3: AbstractFactory.Start(); break; case 4: break; default: Console.WriteLine("Please Enter Valid Choice"); break; } } while (choice != 0); }
public void SpawnVeggies(ProduceRequirements requirements) { factory = FactoryProducer.GetFactory(FactoryType.Veggie); if (requirements.green) // If it's a green vegetable, spawn Broccoli { GameObject produce = Instantiate(broccoliPrefab); m_Broccoli = factory.GetVeggie(VeggieType.Broccoli); m_Broccoli.Vegetate(); } else if (requirements.yellow) // If it's a yellow vegetable, spawn a Potato { GameObject produce = Instantiate(potatoPrefab); m_Potato = factory.GetVeggie(VeggieType.Potato); m_Potato.Vegetate(); } else if (requirements == null) // if no requirements are given, spawn all vegetables //This is the case for when the user presses the vegetable key { m_Carrot = factory.GetVeggie(VeggieType.Carrot); m_Broccoli = factory.GetVeggie(VeggieType.Broccoli); m_Potato = factory.GetVeggie(VeggieType.Potato); m_Carrot.Vegetate(); m_Broccoli.Vegetate(); m_Potato.Vegetate(); } else // Otherwise spawn a carrot { GameObject produce = Instantiate(carrotPrefab); m_Carrot = factory.GetVeggie(VeggieType.Carrot); m_Carrot.Vegetate(); } }
public void SpawnFruit(ProduceRequirements requirements) { factory = FactoryProducer.GetFactory(FactoryType.Fruit); if (requirements.green) // If it is a green fruit, spawn an avocado { GameObject produce = Instantiate(avocadoPrefab); m_Avocado = factory.GetFruit(FruitType.Avocado); m_Avocado.Fruitify(); } else if (requirements.yellow) // if it is a yellow fruit, spawn a banana { GameObject produce = Instantiate(bananaPrefab); m_Banana = factory.GetFruit(FruitType.Banana); m_Banana.Fruitify(); } else if (requirements == null) // if no requirements are given, spawn all fruits // This is for the case when the user presses the fruit key { m_Apple = factory.GetFruit(FruitType.Apple); m_Banana = factory.GetFruit(FruitType.Banana); m_Avocado = factory.GetFruit(FruitType.Avocado); m_Apple.Fruitify(); m_Banana.Fruitify(); m_Avocado.Fruitify(); } else // Otherwise spawn an apple { GameObject produce = Instantiate(applePrefab); m_Apple = factory.GetFruit(FruitType.Apple); m_Apple.Fruitify(); } }
public ActionResult AddBook(Book newbook) { try { if (ModelState.IsValid) { // BookValidation bookValidation = new BookValidation(); // validating whether the book already exists or not // Abstract Factory pattern AbstractFactory abstractfactory = FactoryProducer.GetFactory("IBookValidation"); IBookValidation bookValidation = abstractfactory.getbookvalidation("BookValidation"); if (bookValidation.ValidateBook(newbook)) { int id = newbook.BookID; BookTable booktable = new BookTable(db); newbook.Status = BookStatus.Available.ToString(); booktable.Insert(newbook); ModelState.Clear(); ViewBag.Message = newbook.Name + ProjectConstants.SuccessMsg; } else { ViewBag.Message = ProjectConstants.AddBookFailMsg; return(View(ProjectConstants.AddBook)); } return(View(ProjectConstants.AddBook)); } } catch (Exception) { log.Error("Error while adding book to the database"); throw; } return(View(ProjectConstants.AddBook)); }
public static void TestPrototype() { AbstractFactory abstractShapeFactory = FactoryProducer.GetFactory(true); BaseShape shape = abstractShapeFactory.CreateEntityShape(Shape.HealthCrystal, 2, 5); BaseShape shallow = shape.Clone(); // Shallow Copy BaseShape deep = shape.DeepCopy(); // Deep Copy ShapeBlock ba = shape.GetShapes().First(); ShapeBlock sh = shallow.GetShapes().First(); ShapeBlock de = deep.GetShapes().First(); Logging.Instance.Write("Before"); Logging.Instance.Write("Base: " + shape.GetShapes().GetHashCode().ToString() + "(OffsetX: " + ba.OffsetX + ")"); Logging.Instance.Write("Shallow: " + shallow.GetShapes().GetHashCode().ToString() + " (OffsetX: " + sh.OffsetX + ")"); Logging.Instance.Write("Deep: " + deep.GetShapes().GetHashCode().ToString() + " (OffsetX: " + de.OffsetX + ")"); ba.OffsetX = 10; Logging.Instance.Write("After"); Logging.Instance.Write("Base: " + shape.GetShapes().GetHashCode().ToString() + " (OffsetX: " + ba.OffsetX + ")"); Logging.Instance.Write("Shallow: " + shallow.GetShapes().GetHashCode().ToString() + " (OffsetX: " + sh.OffsetX + ")"); Logging.Instance.Write("Deep: " + deep.GetShapes().GetHashCode().ToString() + " (OffsetX: " + de.OffsetX + ")"); }
public void RemovingAPlayer_ShouldRemoveBufferedMessages() { var ep = A.Fake <EndPoint>(); var player = A.Fake <INetPlayer>(); A.CallTo(() => player.EndPoint).Returns(ep); var buffer = new BMSByte(); var destructor = AbstractFactory.Get <INetworkTypeFactory>().GetNew <IMessageDestructor>(); var bufferInterpreter = AbstractFactory.Get <INetworkTypeFactory>().GetNew <IMessageBufferInterpreter>(); buffer.AugmentSize(destructor.MaxPageLength + destructor.MaxPageLength / 2); buffer.PointToEnd(); for (int i = 0; i < buffer.Size; i++) { buffer[i] = (byte)(i % byte.MaxValue); } var beforeBuffer = new BMSByte(); beforeBuffer.Clone(buffer); IPagenatedMessage pm = destructor.BreakdownMessage(buffer); IMessageConstructor constructor = null; for (int i = 0; i < pm.Pages.Count - 1; i++) { BMSByte pageBuffer = GetPageSection(buffer, pm, i); constructor = bufferInterpreter.ReconstructPacketPage(pageBuffer, ep); } bufferInterpreter.ClearBufferFor(player); Assert.IsNotNull(constructor); Assert.IsFalse(constructor.MessageReconstructed); BMSByte pbuf = GetPageSection(buffer, pm, pm.Pages.Count - 1); constructor = bufferInterpreter.ReconstructPacketPage(pbuf, ep); Assert.IsFalse(constructor.MessageReconstructed); }
public void ConnectCycle() { var serverEngine = A.Fake <IEngineProxy>(); var clientEngine = A.Fake <IEngineProxy>(); var factory = AbstractFactory.Get <INetworkTypeFactory>(); var serverMediator = factory.GetNew <INetworkMediator>(); serverMediator.ChangeEngineProxy(serverEngine); var clientMediator = factory.GetNew <INetworkMediator>(); clientMediator.ChangeEngineProxy(clientEngine); serverMediator.StartServer(15937, 64); clientMediator.StartClient(CommonSocketBase.LOCAL_IPV4, 15937); bool done = false; A.CallTo(() => serverEngine.NetworkingEstablished()).MustHaveHappenedOnceExactly(); A.CallTo(() => clientEngine.NetworkingEstablished()).Invokes((ctx) => { done = true; }); Thread.Sleep(500); Assert.IsTrue(done); clientMediator.SocketFacade.ShutDown(); }
static void Main(string[] args) { //get normal shape factory AbstractFactory shapeFactory = FactoryProducer.GetFactory(false); Shape normalSquare = shapeFactory.GetShape(ShapeType.Square); normalSquare.Draw(); Shape normalRectangle = shapeFactory.GetShape(ShapeType.Rectangle); normalRectangle.Draw(); //get rounded shape factory AbstractFactory roundedShapeFactory = FactoryProducer.GetFactory(true); Shape roundedSquare = roundedShapeFactory.GetShape(ShapeType.Square); roundedSquare.Draw(); Shape roundedRectangle = roundedShapeFactory.GetShape(ShapeType.Rectangle); roundedRectangle.Draw(); }
public Manager(AbstractFactory <Notebook> factory, string[] param = null) { _notebook = factory.Create(param); }
public Manager(AbstractFactory <PC> factory, string[] param = null) { _pc = factory.Create(param); }
// Constructors public Environment(AbstractFactory factory) { AbstractProductB = factory.CreateProductB(); //child B AbstractProductA = factory.CreateProductA(); // child A }
public void ItemTest() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); factory.Register(0, new CustomCreator()); factory.Register(1, new CustomCreator()); CustomCreator creator = (CustomCreator)factory[0]; CustomCreator creator2 = (CustomCreator)factory[4]; Assert.AreNotEqual(creator, null); Assert.AreEqual(creator2, null); }
/// <summary> /// The constructor initialises the properties using methods defined on the factory /// class that is passed as a parameter to the constructor. /// </summary> /// <param name="factory">Controls the type of objects that will be created. This will be /// a concrete implementation of an abstract base class.</param> public BasicClient(AbstractFactory factory) { _productA = factory.CreateProductA(); _productB = factory.CreateProductB(); }
public void SpawnBBQChicken() { factory = FactoryProducer.GetFactory(FactoryType.Pizza); m_BBQChicken = factory.GetPizza(ToppingType.BbqChicken); Debug.Log("Price: " + m_BBQChicken.GetPrice()); }
public void SpawnPepperoni() { factory = FactoryProducer.GetFactory(FactoryType.Pizza); m_Pepperoni = factory.GetPizza(ToppingType.Pepperoni); Debug.Log("Price: " + m_Pepperoni.GetPrice()); }
public void Add(AbstractFactory.Element part) { ListOfElements.Add(part); }
public void UnregisterTest() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); factory.Register(0, new CustomCreator()); factory.Register(1, new CustomCreator()); factory.Unregister(0); factory.Unregister(1); factory.Unregister(3); Assert.AreEqual(factory.Create(0), null); Assert.AreEqual(factory.Create(1), null); }
public TestCloseBuilder(AbstractFactory abstractFactory, string strategy) { test.level = abstractFactory.GetLevel(); this.strategy = strategy; }
public AutoWorld(AbstractFactory factory) { Cycle = factory.CreateCycle(); Auto = factory.CreateAuto(); }
public Computer(AbstractFactory abstractFactory) => _abstractFactory = abstractFactory;
public void RegisterTest() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); factory.Register(0, new CustomCreator()); factory.Register(1, new CustomCreator()); factory.Register(2, null); Assert.AreEqual(typeof(MemoryStream), factory.Create(0).GetType()); Assert.AreEqual(typeof(MemoryStream), factory.Create(1).GetType()); }
/// <summary> /// Initialises the In-Memory context with initial data. /// </summary> /// <param name="UnitOfWork">Instance of the in-memory context.</param> /// <param name="ArtistFactory">Instance of the factory to create Artist classes.</param> /// <param name="AlbumFactory">Instance of the factory to create Album classes.</param> /// <param name="TrackFactory">Instance of the factory to create Track classes.</param> /// <param name="ImageFactory">Instance of the factory to create Image classes.</param> /// <param name="GenreFactory">Instance of the factory to create Genre classes.</param> /// <param name="PlaylistFactory">Instance of the factory to create Playlist classes.</param> /// <param name="WikiFactory">Instance of the factory to create Wiki classes.</param> public static void SeedData(IUnitOfWork UnitOfWork, AbstractFactory<Artist> ArtistFactory, AbstractFactory<Album> AlbumFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Image> ImageFactory, AbstractFactory<Genre> GenreFactory, AbstractFactory<PlayList> PlaylistFactory, AbstractFactory<Wiki> WikiFactory) { // ******************* Create the Artists *************************************** var pinkFloyd = ArtistFactory.Create(); // Create a new artist. //var pinkFloyd = new Artist(); // Create a new artist. pinkFloyd.Id = 1; pinkFloyd.Name = "Pink Floyd"; pinkFloyd.Albums = new List<Album>(); //pinkFloyd.Albums = new List<int>(); pinkFloyd.AlbumIds = new List<int>(); var Opeth = ArtistFactory.Create(); //var Opeth = new Artist(); Opeth.Id = 2; Opeth.Name = "Opeth"; Opeth.Albums = new List<Album>(); //Opeth.Albums = new List<int>(); Opeth.AlbumIds = new List<int>(); // ******************* Create the Playlists ************************************ var FloydFavourites = PlaylistFactory.Create(); //var FloydFavourites = new PlayList(); FloydFavourites.Id = 1; FloydFavourites.Name = "Pink Floyd Favourites"; FloydFavourites.Tracks = new List<Track>(); //FloydFavourites.Tracks = new List<int>(); FloydFavourites.TrackIds = new List<int>(); var OpethFavourites = PlaylistFactory.Create(); //var OpethFavourites = new PlayList(); OpethFavourites.Id = 2; OpethFavourites.Name = "Opeth Favourites"; OpethFavourites.Tracks = new List<Track>(); //OpethFavourites.Tracks = new List<int>(); OpethFavourites.TrackIds = new List<int>(); // ******************* Create the Albums *************************************** var DarkSideOfTheMoon = AlbumFactory.Create(); //var DarkSideOfTheMoon = new Album(); DarkSideOfTheMoon.Id = 1; DarkSideOfTheMoon.Title = "Dark Side of the Moon"; DarkSideOfTheMoon.Artist = pinkFloyd; DarkSideOfTheMoon.Released = new DateTime(1973, 06, 01); DarkSideOfTheMoon.Tracks = new List<Track>(); DarkSideOfTheMoon.Images = new List<Image>(); DarkSideOfTheMoon.Genres = new List<Genre>(); DarkSideOfTheMoon.Wiki = WikiFactory.Create(); //DarkSideOfTheMoon.Wiki = new Wiki(); var Damnation = AlbumFactory.Create(); //var Damnation = new Album(); Damnation.Id = 2; Damnation.Title = "Damnation"; Damnation.Artist = Opeth; Damnation.Released = new DateTime(2003, 01, 01); Damnation.Tracks = new List<Track>(); Damnation.Images = new List<Image>(); Damnation.Genres = new List<Genre>(); Damnation.Wiki = WikiFactory.Create(); //Damnation.Wiki = new Wiki(); var WishYouWereHere = AlbumFactory.Create(); //var WishYouWereHere = new Album(); WishYouWereHere.Id = 3; WishYouWereHere.Title = "Wish You Were Here"; WishYouWereHere.Artist = pinkFloyd; WishYouWereHere.Released = new DateTime(1975, 06, 30); WishYouWereHere.Tracks = new List<Track>(); WishYouWereHere.Images = new List<Image>(); WishYouWereHere.Genres = new List<Genre>(); WishYouWereHere.Wiki = WikiFactory.Create(); //WishYouWereHere.Wiki = new Wiki(); // ******************* Create the Wikis *************************************** var dsotmWiki = WikiFactory.Create(); //var dsotmWiki = new Wiki(); dsotmWiki.Id = 1; dsotmWiki.Summary = "Dark Side Wiki Summary"; dsotmWiki.Content = "Dark Side Wiki Content"; dsotmWiki.Published = new DateTime(1990, 01, 01); var damWiki = WikiFactory.Create(); //var damWiki = new Wiki(); damWiki.Id = 2; damWiki.Summary = "Damnation Wiki Summary"; damWiki.Content = "Damnation Wiki Content"; damWiki.Published = new DateTime(2004, 01, 01); var wywhWiki = WikiFactory.Create(); //var wywhWiki = new Wiki(); wywhWiki.Id = 3; wywhWiki.Summary = "Wish You Were Here Wiki Summary"; wywhWiki.Content = "Wish You Were Here Wiki Content"; wywhWiki.Published = new DateTime(1990, 06, 01); // Add wiki to albums DarkSideOfTheMoon.Wiki = dsotmWiki; Damnation.Wiki = damWiki; WishYouWereHere.Wiki = wywhWiki; // ******************* Create the Genres *************************************** var pop = GenreFactory.Create(); //var pop = new Genre(); pop.Id = 1; pop.Name = "Pop"; pop.Url = string.Empty; pop.Albums = new List<Album>(); //pop.Albums = new List<int>(); pop.AlbumIds = new List<int>(); var rock = GenreFactory.Create(); //var rock = new Genre(); rock.Id = 2; rock.Name = "Rock"; rock.Url = string.Empty; rock.Albums = new List<Album>(); //rock.Albums = new List<int>(); rock.AlbumIds = new List<int>(); var seventies = GenreFactory.Create(); //var seventies = new Genre(); seventies.Id = 3; seventies.Name = "70's"; seventies.Url = string.Empty; seventies.Albums = new List<Album>(); //seventies.Albums = new List<int>(); seventies.AlbumIds = new List<int>(); // ******************* Create the Tracks *************************************** var dsotmTrack1 = TrackFactory.Create(); //var dsotmTrack1 = new Track(); dsotmTrack1.Id = 1; dsotmTrack1.Title = "Speak to Me/Breathe"; dsotmTrack1.Number = 1; dsotmTrack1.Duration = TimeSpan.Parse("00:03:57"); dsotmTrack1.Album = DarkSideOfTheMoon; dsotmTrack1.Artist = pinkFloyd; dsotmTrack1.Playlists = new List<PlayList>(); dsotmTrack1.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack2 = TrackFactory.Create(); //var dsotmTrack2 = new Track(); dsotmTrack2.Id = 2; dsotmTrack2.Title = "On the Run"; dsotmTrack2.Number = 2; dsotmTrack2.Duration = TimeSpan.Parse("00:03:35"); dsotmTrack2.Album = DarkSideOfTheMoon; dsotmTrack2.Artist = pinkFloyd; dsotmTrack2.Playlists = new List<PlayList>(); dsotmTrack2.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack3 = TrackFactory.Create(); //var dsotmTrack3 = new Track(); dsotmTrack3.Id = 3; dsotmTrack3.Title = "Time"; dsotmTrack3.Number = 3; dsotmTrack3.Duration = TimeSpan.Parse("00:07:04"); dsotmTrack3.Album = DarkSideOfTheMoon; dsotmTrack3.Artist = pinkFloyd; dsotmTrack3.Playlists = new List<PlayList>(); dsotmTrack3.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack4 = TrackFactory.Create(); //var dsotmTrack4 = new Track(); dsotmTrack4.Id = 4; dsotmTrack4.Title = "The Great Gig in the Sky"; dsotmTrack4.Number = 4; dsotmTrack4.Duration = TimeSpan.Parse("00:04:47"); dsotmTrack4.Album = DarkSideOfTheMoon; dsotmTrack4.Artist = pinkFloyd; dsotmTrack4.Playlists = new List<PlayList>(); dsotmTrack4.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack5 = TrackFactory.Create(); //var dsotmTrack5 = new Track(); dsotmTrack5.Id = 5; dsotmTrack5.Title = "Money"; dsotmTrack5.Number = 5; dsotmTrack5.Duration = TimeSpan.Parse("00:06:22"); dsotmTrack5.Album = DarkSideOfTheMoon; dsotmTrack5.Artist = pinkFloyd; dsotmTrack5.Playlists = new List<PlayList>(); dsotmTrack5.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack6 = TrackFactory.Create(); //var dsotmTrack6 = new Track(); dsotmTrack6.Id = 6; dsotmTrack6.Title = "Us and Them"; dsotmTrack6.Number = 6; dsotmTrack6.Duration = TimeSpan.Parse("00:07:50"); dsotmTrack6.Album = DarkSideOfTheMoon; dsotmTrack6.Artist = pinkFloyd; dsotmTrack6.Playlists = new List<PlayList>(); dsotmTrack6.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack7 = TrackFactory.Create(); //var dsotmTrack7 = new Track(); dsotmTrack7.Id = 7; dsotmTrack7.Title = "Any Colour You Like"; dsotmTrack7.Number = 7; dsotmTrack7.Duration = TimeSpan.Parse("00:03:25"); dsotmTrack7.Album = DarkSideOfTheMoon; dsotmTrack7.Artist = pinkFloyd; dsotmTrack7.Playlists = new List<PlayList>(); dsotmTrack7.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack8 = TrackFactory.Create(); //var dsotmTrack8 = new Track(); dsotmTrack8.Id = 8; dsotmTrack8.Title = "Brain Damage"; dsotmTrack8.Number = 8; dsotmTrack8.Duration = TimeSpan.Parse("00:03:50"); dsotmTrack8.Album = DarkSideOfTheMoon; dsotmTrack8.Artist = pinkFloyd; dsotmTrack8.Playlists = new List<PlayList>(); dsotmTrack8.AlbumId = DarkSideOfTheMoon.Id; var dsotmTrack9 = TrackFactory.Create(); //var dsotmTrack9 = new Track(); dsotmTrack9.Id = 9; dsotmTrack9.Title = "Eclipse"; dsotmTrack9.Number = 9; dsotmTrack9.Duration = TimeSpan.Parse("00:02:01"); dsotmTrack9.Album = DarkSideOfTheMoon; dsotmTrack9.Artist = pinkFloyd; dsotmTrack9.Playlists = new List<PlayList>(); dsotmTrack9.AlbumId = DarkSideOfTheMoon.Id; var DamTrack1 = TrackFactory.Create(); //var DamTrack1 = new Track(); DamTrack1.Id = 10; DamTrack1.Title = "Windowpane"; DamTrack1.Number = 1; DamTrack1.Duration = TimeSpan.Parse("00:07:44"); DamTrack1.Album = Damnation; DamTrack1.Artist = Opeth; DamTrack1.Playlists = new List<PlayList>(); DamTrack1.AlbumId = Damnation.Id; var DamTrack2 = TrackFactory.Create(); //var DamTrack2 = new Track(); DamTrack2.Id = 11; DamTrack2.Title = "In My Time Of Need"; DamTrack2.Number = 2; DamTrack2.Duration = TimeSpan.Parse("00:05:49"); DamTrack2.Album = Damnation; DamTrack2.Artist = Opeth; DamTrack2.Playlists = new List<PlayList>(); DamTrack2.AlbumId = Damnation.Id; var DamTrack3 = TrackFactory.Create(); //var DamTrack3 = new Track(); DamTrack3.Id = 12; DamTrack3.Title = "Death Whispered A Lullaby"; DamTrack3.Number = 3; DamTrack3.Duration = TimeSpan.Parse("00:05:49"); DamTrack3.Album = Damnation; DamTrack3.Artist = Opeth; DamTrack3.Playlists = new List<PlayList>(); DamTrack3.AlbumId = Damnation.Id; var DamTrack4 = TrackFactory.Create(); //var DamTrack4 = new Track(); DamTrack4.Id = 13; DamTrack4.Title = "Closure"; DamTrack4.Number = 4; DamTrack4.Duration = TimeSpan.Parse("00:05:15"); DamTrack4.Album = Damnation; DamTrack4.Artist = Opeth; DamTrack4.Playlists = new List<PlayList>(); DamTrack4.AlbumId = Damnation.Id; var DamTrack5 = TrackFactory.Create(); //var DamTrack5 = new Track(); DamTrack5.Id = 14; DamTrack5.Title = "Hope Leaves"; DamTrack5.Number = 5; DamTrack5.Duration = TimeSpan.Parse("00:04:30"); DamTrack5.Album = Damnation; DamTrack5.Artist = Opeth; DamTrack5.Playlists = new List<PlayList>(); DamTrack5.AlbumId = Damnation.Id; var DamTrack6 = TrackFactory.Create(); //var DamTrack6 = new Track(); DamTrack6.Id = 15; DamTrack6.Title = "To Rid The Disease"; DamTrack6.Number = 6; DamTrack6.Duration = TimeSpan.Parse("00:06:21"); DamTrack6.Album = Damnation; DamTrack6.Artist = Opeth; DamTrack6.Playlists = new List<PlayList>(); DamTrack6.AlbumId = Damnation.Id; var DamTrack7 = TrackFactory.Create(); //var DamTrack7 = new Track(); DamTrack7.Id = 16; DamTrack7.Title = "Ending Credits"; DamTrack7.Number = 7; DamTrack7.Duration = TimeSpan.Parse("00:03:39"); DamTrack7.Album = Damnation; DamTrack7.Artist = Opeth; DamTrack7.Playlists = new List<PlayList>(); DamTrack7.AlbumId = Damnation.Id; var DamTrack8 = TrackFactory.Create(); //var DamTrack8 = new Track(); DamTrack8.Id = 17; DamTrack8.Title = "Weakness"; DamTrack8.Number = 8; DamTrack8.Duration = TimeSpan.Parse("00:04:08"); DamTrack8.Album = Damnation; DamTrack8.Artist = Opeth; DamTrack8.Playlists = new List<PlayList>(); DamTrack8.AlbumId = Damnation.Id; // Add tracks to the playlist FloydFavourites.Tracks.Add(dsotmTrack4); FloydFavourites.TrackIds.Add(dsotmTrack4.Id); FloydFavourites.Tracks.Add(dsotmTrack6); FloydFavourites.TrackIds.Add(dsotmTrack6.Id); OpethFavourites.Tracks.Add(DamTrack7); OpethFavourites.TrackIds.Add(DamTrack7.Id); // Add the playlist to the track dsotmTrack4.Playlists.Add(FloydFavourites); dsotmTrack6.Playlists.Add(FloydFavourites); DamTrack7.Playlists.Add(OpethFavourites); // Add the tracks to the Albums DarkSideOfTheMoon.Tracks.Add(dsotmTrack1); DarkSideOfTheMoon.Tracks.Add(dsotmTrack2); DarkSideOfTheMoon.Tracks.Add(dsotmTrack3); DarkSideOfTheMoon.Tracks.Add(dsotmTrack4); DarkSideOfTheMoon.Tracks.Add(dsotmTrack5); DarkSideOfTheMoon.Tracks.Add(dsotmTrack6); DarkSideOfTheMoon.Tracks.Add(dsotmTrack7); DarkSideOfTheMoon.Tracks.Add(dsotmTrack8); DarkSideOfTheMoon.Tracks.Add(dsotmTrack9); Damnation.Tracks.Add(DamTrack1); Damnation.Tracks.Add(DamTrack2); Damnation.Tracks.Add(DamTrack3); Damnation.Tracks.Add(DamTrack4); Damnation.Tracks.Add(DamTrack5); Damnation.Tracks.Add(DamTrack6); Damnation.Tracks.Add(DamTrack7); Damnation.Tracks.Add(DamTrack8); // Create Images var dsotmImageSmall = ImageFactory.Create(); //var dsotmImageSmall = new Image(); dsotmImageSmall.Id = 1; dsotmImageSmall.Size = ImageSizeEnum.small; dsotmImageSmall.Url = string.Empty; var dsotmImageMedium = ImageFactory.Create(); //var dsotmImageMedium = new Image(); dsotmImageMedium.Id = 2; dsotmImageMedium.Size = ImageSizeEnum.medium; //dsotmImageMedium.Url = @"http://userserve-ak.last.fm/serve/64s/69704236.png"; dsotmImageMedium.Url = @"Assets\DarkSideOfTheMoonMedium.png"; var dsotmImageLarge = ImageFactory.Create(); //var dsotmImageLarge = new Image(); dsotmImageLarge.Id = 3; dsotmImageLarge.Size = ImageSizeEnum.large; //dsotmImageLarge.Url = @"http://userserve-ak.last.fm/serve/174s/69704236.png"; dsotmImageLarge.Url = @"Assets\DarkSideOfTheMoonLarge.png"; var dsotmImageExtraLarge = ImageFactory.Create(); //var dsotmImageExtraLarge = new Image(); dsotmImageExtraLarge.Id = 4; dsotmImageExtraLarge.Size = ImageSizeEnum.extralarge; dsotmImageExtraLarge.Url = string.Empty; var dsotmImageMega = ImageFactory.Create(); //var dsotmImageMega = new Image(); dsotmImageMega.Id = 5; dsotmImageMega.Size = ImageSizeEnum.mega; dsotmImageMega.Url = string.Empty; var damImageSmall = ImageFactory.Create(); //var damImageSmall = new Image(); damImageSmall.Id = 6; damImageSmall.Size = ImageSizeEnum.small; damImageSmall.Url = string.Empty; var damImageMedium = ImageFactory.Create(); //var damImageMedium = new Image(); damImageMedium.Id = 7; damImageMedium.Size = ImageSizeEnum.medium; damImageMedium.Url = @"http://userserve-ak.last.fm/serve/64s/86402755.png"; //damImageMedium.Url = @"DamnationMedium.png"; var damImageLarge = ImageFactory.Create(); //var damImageLarge = new Image(); damImageLarge.Id = 8; damImageLarge.Size = ImageSizeEnum.large; damImageLarge.Url = @"http://userserve-ak.last.fm/serve/174s/86402755.png"; //damImageLarge.Url = @"DamnationLarge.png"; var damImageExtraLarge = ImageFactory.Create(); //var damImageExtraLarge = new Image(); damImageExtraLarge.Id = 9; damImageExtraLarge.Size = ImageSizeEnum.extralarge; damImageExtraLarge.Url = string.Empty; var damImageMega = ImageFactory.Create(); //var damImageMega = new Image(); damImageMega.Id = 10; damImageMega.Size = ImageSizeEnum.mega; damImageMega.Url = string.Empty; var wywhImageMedium = ImageFactory.Create(); //var damImageMedium = new Image(); wywhImageMedium.Id = 11; wywhImageMedium.Size = ImageSizeEnum.medium; //wywhImageMedium.Url = @"http://userserve-ak.last.fm/serve/64s/40625357.png"; wywhImageMedium.Url = @"Assets\wywhMedium.png"; var wywhImageLarge = ImageFactory.Create(); //var damImageLarge = new Image(); wywhImageLarge.Id = 12; wywhImageLarge.Size = ImageSizeEnum.large; //wywhImageLarge.Url = @"http://userserve-ak.last.fm/serve/174s/40625357.png"; wywhImageLarge.Url = @"Assets\wywhLarge.png"; // Add the images tot the albums DarkSideOfTheMoon.Images.Add(dsotmImageSmall); DarkSideOfTheMoon.Images.Add(dsotmImageMedium); DarkSideOfTheMoon.Images.Add(dsotmImageLarge); DarkSideOfTheMoon.Images.Add(dsotmImageExtraLarge); DarkSideOfTheMoon.Images.Add(dsotmImageMega); Damnation.Images.Add(damImageSmall); Damnation.Images.Add(damImageMedium); Damnation.Images.Add(damImageLarge); Damnation.Images.Add(damImageExtraLarge); Damnation.Images.Add(damImageMega); WishYouWereHere.Images.Add(wywhImageMedium); WishYouWereHere.Images.Add(wywhImageLarge); // Add the Genres to the Albums DarkSideOfTheMoon.Genres.Add(rock); DarkSideOfTheMoon.Genres.Add(seventies); Damnation.Genres.Add(rock); WishYouWereHere.Genres.Add(seventies); WishYouWereHere.Genres.Add(pop); // Add albums to the Genres rock.Albums.Add(DarkSideOfTheMoon); rock.AlbumIds.Add(DarkSideOfTheMoon.Id); rock.Albums.Add(Damnation); rock.AlbumIds.Add(Damnation.Id); seventies.Albums.Add(DarkSideOfTheMoon); seventies.AlbumIds.Add(DarkSideOfTheMoon.Id); seventies.Albums.Add(WishYouWereHere); seventies.AlbumIds.Add(WishYouWereHere.Id); pop.Albums.Add(WishYouWereHere); pop.AlbumIds.Add(WishYouWereHere.Id); // Add the albums to the Artists //pinkFloyd.Albums.Add(DarkSideOfTheMoon); //Opeth.Albums.Add(Damnation); pinkFloyd.Albums.Add(DarkSideOfTheMoon); pinkFloyd.AlbumIds.Add(DarkSideOfTheMoon.Id); Opeth.Albums.Add(Damnation); Opeth.AlbumIds.Add(Damnation.Id); pinkFloyd.Albums.Add(WishYouWereHere); pinkFloyd.AlbumIds.Add(WishYouWereHere.Id); // Now add them to the collections // Track UnitOfWork.Tracks.Add(dsotmTrack1); UnitOfWork.Tracks.Add(dsotmTrack2); UnitOfWork.Tracks.Add(dsotmTrack3); UnitOfWork.Tracks.Add(dsotmTrack4); UnitOfWork.Tracks.Add(dsotmTrack5); UnitOfWork.Tracks.Add(dsotmTrack6); UnitOfWork.Tracks.Add(dsotmTrack7); UnitOfWork.Tracks.Add(dsotmTrack8); UnitOfWork.Tracks.Add(dsotmTrack9); UnitOfWork.Tracks.Add(DamTrack1); UnitOfWork.Tracks.Add(DamTrack2); UnitOfWork.Tracks.Add(DamTrack3); UnitOfWork.Tracks.Add(DamTrack4); UnitOfWork.Tracks.Add(DamTrack5); UnitOfWork.Tracks.Add(DamTrack6); UnitOfWork.Tracks.Add(DamTrack7); UnitOfWork.Tracks.Add(DamTrack8); // Genres UnitOfWork.Genres.Add(rock); UnitOfWork.Genres.Add(pop); UnitOfWork.Genres.Add(seventies); // Album UnitOfWork.Albums.Add(DarkSideOfTheMoon); UnitOfWork.Albums.Add(Damnation); UnitOfWork.Albums.Add(WishYouWereHere); // Artist UnitOfWork.Artists.Add(pinkFloyd); UnitOfWork.Artists.Add(Opeth); // Playlists UnitOfWork.PlayLists.Add(FloydFavourites); UnitOfWork.PlayLists.Add(OpethFavourites); }
public DocumentField(int a_documentId, decimal a_value, string a_abstractSymbol) { m_abstract = AbstractFactory.GetAbstract(a_abstractSymbol); DocumentId = a_documentId; Value = a_value; }
public void SpawnCheesePizza() { factory = FactoryProducer.GetFactory(FactoryType.Pizza); m_Cheese = factory.GetPizza(ToppingType.Cheese); Debug.Log("Price: " + m_Cheese.GetPrice()); }
// Constructor public Client(AbstractFactory factory) { _abstractProductB = factory.CreateProductB(); _abstractProductA = factory.CreateProductA(); }
public void SpawnSupreme() { factory = FactoryProducer.GetFactory(FactoryType.Pizza); m_Supreme = factory.GetPizza(ToppingType.Supreme); Debug.Log("Price: " + m_Supreme.GetPrice()); }
public MusicCollection(AbstractFactory<Artist> ArtistFactory, AbstractFactory<Album> AlbumFactory, AbstractFactory<Track> TrackFactory, AbstractFactory<Image> ImageFactory, AbstractFactory<Genre> GenreFactory, AbstractFactory<PlayList> PlaylistFactory, AbstractFactory<Wiki> WikiFactory) { // Load the dependencies if (ArtistFactory == null) throw new ArgumentNullException("ArtistFactory", "No valid Factory supplied to create Artist class"); _artistFactory = ArtistFactory; if (AlbumFactory == null) throw new ArgumentNullException("AlbumFactory", "No valid Factory supplied to create Album class"); _albumFactory = AlbumFactory; if (TrackFactory == null) throw new ArgumentNullException("TrackFactory", "No valid Factory supplied to create Track class"); _trackFactory = TrackFactory; if (ImageFactory == null) throw new ArgumentNullException("ImageFactory", "No valid Factory supplied to create Image class"); _imageFactory = ImageFactory; if (GenreFactory == null) throw new ArgumentNullException("GenreFactory", "No valid Factory supplied to create Genre class"); _genreFactory = GenreFactory; if (PlaylistFactory == null) throw new ArgumentNullException("PlaylistFactory", "No valid Factory supplied to create Playlist class"); _playlistFactory = PlaylistFactory; if (WikiFactory == null) throw new ArgumentNullException("WikiFactory", "No valid Factory supplied to create Wiki class"); _wikiFactory = WikiFactory; // TODO: Refactor the factories to be injected directly into the InitialiseMusiccollection // Initialise the properties / collection this.Albums = new List<Album>(); this.Tracks = new List<Track>(); this.Artists = new List<Artist>(); this.Genres = new List<Genre>(); this.PlayLists = new List<PlayList>(); }
public void SpawnMargherita() { factory = FactoryProducer.GetFactory(FactoryType.Pizza); m_Margherita = factory.GetPizza(ToppingType.Margherita); Debug.Log("Price: " + m_Margherita.GetPrice()); }
//Construtor public Cliente(AbstractFactory abstractFactory) { _abstractProductA = abstractFactory.CriarProdutoA(); _abstractProductB = abstractFactory.CriarProdutoB(); }
// private Rectangle _rectangle; // private Triangle _triangle; // private Trapezoid _trapezoid; // private Polygon _polygon; public Application(AbstractFactory factory) { _factory = factory; }
public InfixToPostfix(AbstractFactory factory, Stack<Command> postfix, string infix) { _infix = infix.Split(' '); _cmd = null; Hashtable _command_set = new Hashtable(); _command_set.Add("+", new MethodChooser(factory.CreateAddCommand)); _command_set.Add("-", new MethodChooser(factory.CreateSubtractCommand)); _command_set.Add("/", new MethodChooser(factory.CreateDivideCommand)); _command_set.Add("*", new MethodChooser(factory.CreateMultiplyCommand)); _command_set.Add("%", new MethodChooser(factory.CreateModulusCommand)); foreach (string _input in _infix) { try { temp = Convert.ToInt32(_input); _cmd = factory.CreateNumberCommand(temp); } catch (FormatException) { if (_command_set.ContainsKey(_input)) { _cmd = ((MethodChooser)_command_set[_input])(); } // Only other input should be ')' and '(' which will roll down to shunting yard. } /************* Shunting Yard Algorithm****************/ switch (_input) { case "(": _temp_stack.Push(null); break; case ")": while (_temp_stack.Count > 0) { if (_temp_stack.Peek() != null) { postfix.Push(_temp_stack.Pop()); } else { _temp_stack.Pop(); } } break; case "+": case "-": if (_temp_stack.Count > 0 && _temp_stack.Peek() != null) { postfix.Push(_temp_stack.Pop()); _temp_stack.Push(_cmd); } else { _temp_stack.Push(_cmd); } break; case "*": case "/": case "%": _temp_stack.Push(_cmd); break; default: //a number, by elimination, if my input and parsing are correct. postfix.Push(_cmd); break; } } foreach (Command item in _temp_stack) { if (item != null) postfix.Push(item); } }
public abstract void BuildProject(AbstractFactory.Element element);
public override void BuildProject(AbstractFactory.Element element) { project.Add(element); }
public void Construct(Builder builder, AbstractFactory.Element element) { builder.BuildProject(element); }
public void UnregisterTest1() { AbstractFactory<int, Stream> factory = new AbstractFactory<int, Stream>(); CustomCreator creator = new CustomCreator(); factory.Register(0, creator ); factory.Unregister(creator); Assert.AreEqual(factory.Create(0), null); }