public static void TestFlyweight() { Console.WriteLine("----------------------Flyweight----------------------"); BoxFactory boxFactory = new BoxFactory(); Box blackRectangularBox = boxFactory.CreateBox("rectangular"); blackRectangularBox.Display("Black"); Box blackRoundBox = boxFactory.CreateBox("round"); blackRoundBox.Display("Black"); Box redRoundBox = boxFactory.CreateBox("round"); redRoundBox.Display("Red"); Box unsharedBox = new UnsharedBox(10, 20, 15); unsharedBox.Display("Green"); Console.WriteLine("Changing boxes width to be 100:"); blackRectangularBox.Width = 100; blackRoundBox.Width = 100; blackRectangularBox.Display("Black"); blackRoundBox.Display("Black"); redRoundBox.Display("Red"); unsharedBox.Display("Green"); Console.WriteLine("---------------------------------------------------\n"); }
public ConfigurationInterceptor(Type interfaceType, IoHandler ioHandler, string prefix = null) { _boxes = BoxFactory.Discover(interfaceType, ioHandler.ValueHandler); _interfaceType = interfaceType; _ioHandler = ioHandler; _prefix = prefix; }
private static void FlyWeight() { BoxFactory boxFactory = new BoxFactory(); Box blackBox1 = boxFactory.Get(BoxColor.Black); Box blackBox2 = boxFactory.Get(BoxColor.Black); }
public IEnumerable <Box> AddFromJsonString(string definitionJson) { var jboxes = JArray.Parse(definitionJson); BoxFactory.AddFromJson(this.rootBox, jboxes); return(this.rootBox.Children.Values); }
public InterfaceInterceptor(Type interfaceType, IoHandler ioHandler, string prefix = null) { _boxes = BoxFactory.Discover(interfaceType, ioHandler.ValueHandler, prefix); _ioHandler = ioHandler; _prefix = prefix; _reader = new DynamicReader(prefix, ioHandler); _writer = new DynamicWriter(prefix, ioHandler); }
public InterfaceInterceptor(Type interfaceType, IoHandler ioHandler, string prefix = null) { _boxes = BoxFactory.Discover(interfaceType, ioHandler.ValueHandler, prefix); _ioHandler = ioHandler; _prefix = prefix; _reader = new DynamicReader(prefix, ioHandler); _writer = new DynamicWriter(prefix, ioHandler); _isInpc = interfaceType.GetInterface(nameof(INotifyPropertyChanged)) != null; }
public void BoxFactoryShouldDeliverFiveBoxes() { // Arrange var boxFactory = new BoxFactory(); // Act var numberOfContainingBoxes = boxFactory.CreateBoxWithContainingBoxes(5); // Assert Assert.AreEqual(5, numberOfContainingBoxes.GetNumberOfContaintingBoxes); }
public IEnumerable <Box> AddFromXmlString(string definitionXml) { var setting = new XmlReaderSettings(); setting.IgnoreComments = true; setting.IgnoreWhitespace = true; using (var sr = new StringReader(definitionXml)) using (var xr = XmlReader.Create(sr, setting)) { BoxFactory.AddFromXml(this.rootBox, xr); } return(this.rootBox.Children.Values); }
private void CreateUnits() { var boxFactory = new BoxFactory(); var columnFactory = new ColumnFactory(); var rowFactory = new RowFactory(); for (int i = 0; i < 9; i++) { _boxes[i] = boxFactory.Factory(_cells, i); _columns[i] = columnFactory.Factory(_cells, i); _rows[i] = rowFactory.Factory(_cells, i); } }
/// <summary> /// 抽象工厂类 /// </summary> public void CreateBinFile() { // box 找码逻辑 AbstractFactory boxfactory = new BoxFactory(); BInFile boxbinFile = boxfactory.CreateBinFile(); boxbinFile.CreateBinFile(); // os 找码逻辑 AbstractFactory osfactory = new OsFactory(); BInFile osbinFile = osfactory.CreateBinFile(); osbinFile.CreateBinFile(); }
// Get an exact same object as this one. public override Component Clone() { BoxDescription boxDescription = BoxFactory.GetBoxDescription(Description.BackImage, Description.Size); HiddenObject hiddenObject = new HiddenObject { Image = HiddenObject.Image }; BoxState boxState = new BoxState { State = State.State }; ImageBinder imageBinder = new ImageBinder(); BoxFactory boxFactory = BoxFactory.GetInstance(); string image = (string)CurrentImage.Clone(); return(new Box { Description = boxDescription, HiddenObject = hiddenObject, State = boxState, ImageBinder = imageBinder, BoxFactory = boxFactory, CurrentImage = image, Position = this.Position, IsEnabled = this.IsEnabled }); }
// Initialize a new game environment public void NewGame() { Time = TimeSpan.Zero; HighScore = 0; Player = new Player { Name = "Player 1", Score = 0 }; ProjetPictue.Program.GeneratePhotos(); GameController = GameController.GetInstance(); Box box = new Box { Position = 1, CurrentImage = "", State = new BoxState(), IsEnabled = true, ImageBinder = new ImageBinder(), Description = BoxFactory.GetInstance().GetBoxDescription("images/card2.png", new System.Drawing.Size(79, 66)), HiddenObject = new HiddenObject(), BoxFactory = BoxFactory.GetInstance() }; GameController.Grid.Add(box); for (int i = 1; i < 5 * 8; i++) { Box box2 = (Box)box.Clone(); box2.Position = i + 1; GameController.Grid.Add(box2); } GameController.Grid.Draw(); ShowImages(null, null); timer = new System.Timers.Timer(); timer.Interval = 5000; timer.Elapsed += ShowImages; timer.Start(); }
// Start is called before the first frame update void Start() { boxFactory = new SampleBoxFactory(); }
public OpenCommand(Context context) { this.context = context; this.Box = BoxFactory.Create(); }
public void Return_Not_Null_When_Provider_Exist() { IBoxProvider box = new BoxFactory().GetBoxProvider(Store.PizzeriaA); Assert.IsNotNull(box); }