public async Task VerifyBlueprintLifeCycle(Constants.UnitFlag flag, Constants.UnitStage stage, Constants.UnitType type) { IBlueprint createdBlueprint = new Blueprint(); createdBlueprint.Units.Add(new BaseBlueprintUnit() { UnitFlag = flag, UnitState = stage, UnitType = type }); Guid createdId = createdBlueprint.Id; Assert.NotEqual(Guid.Empty, createdId); createdBlueprint.Name = "Some fantastical name!"; string json = JsonConvert.SerializeObject(createdBlueprint); IBlueprint loadedBlueprint = JsonConvert.DeserializeObject <Blueprint>(json); Assert.Equal(createdId, loadedBlueprint.Id); Assert.Equal(createdBlueprint.Name, loadedBlueprint.Name); Assert.Equal(flag, loadedBlueprint.Units[0].UnitFlag); Assert.Equal(stage, loadedBlueprint.Units[0].UnitState); Assert.Equal(type, loadedBlueprint.Units[0].UnitType); Assert.False(await loadedBlueprint.Units[0].RunProcessor()); Assert.False(await loadedBlueprint.Units[0].RunValidator()); }
private void UpdatePipeLinks(IBlueprint blueprint, Coordinate position) { UpdatePipeLink(blueprint, position, Coordinates.Up); UpdatePipeLink(blueprint, position, Coordinates.Down); UpdatePipeLink(blueprint, position, Coordinates.Right); UpdatePipeLink(blueprint, position, Coordinates.Left); }
public void TestInitialize() { repository = new UserRepository(); repository.Clear(); blueprintPortfolio = new BlueprintRepository(); blueprintPortfolio.Clear(); conn = new SessionConnector(); Session session = conn.LogIn("admin", "admin", (IUserRepository)repository); administrator = new UserAdministrator(session, repository); user1 = new Client("client1N", "client1S", "client1UN", "client1P", "999000111", "dir", "55555555", DateTime.Now); user2 = new Client("client2N", "client2S", "client2UN", "client2P", "999000111", "dir", "55555556", DateTime.Now); user3 = new Designer("d1", "d1", "designer3", "12345", DateTime.Now); user4 = new Designer("designer2N", "designer2S", "designer2UN", "designer2P", DateTime.Now); architect = new Architect("Archi", "Tect", "architect", "architect", DateTime.Now); materials = new MaterialContainer(); blueprintTest = new Blueprint(12, 12, "Blueprint1", materials); blueprint2 = new Blueprint(10, 10, "Blueprint2"); blueprint3 = new Blueprint(11, 11, "Blueprint2"); blueprintTest.Owner = user1; blueprint2.Owner = user2; blueprint3.Owner = user1; administrator.Add(user1); administrator.Add(user2); administrator.Add(user3); administrator.Add(user4); administrator.Add(architect); }
private bool DoesBlueprintHaveBlocksOnLine(Coordinate position, IBlueprint blueprint) { int startColumn; int endColumn; switch (FacingDirection) { case EdgeType.LEFT: startColumn = 0; endColumn = position.X; break; case EdgeType.RIGHT: startColumn = position.X + 1; endColumn = blueprint.Dimensions.X; break; default: startColumn = 0; endColumn = 0; break; } for (int j = startColumn; j < endColumn; j++) { if (blueprint.HasBlock(new Coordinate(j, position.Y))) { return(true); } } return(false); }
private void AddDoorsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int doorsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.DOOR)); float doorsPrice = costsNPrices.GetPrice((int)ComponentType.DOOR); report.SetTotalPrice(ComponentType.DOOR, doorsCount * doorsPrice); }
public static void ApplyToAll(this IBlueprint blueprint, params IEntity[] entities) { foreach (var entity in entities) { blueprint.Apply(entity); } }
private void AddColumnsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int columnsCount = aBlueprint.GetColumns().Count; float columnPrice = costsNPrices.GetPrice((int)ComponentType.COLUMN); report.SetTotalPrice(ComponentType.COLUMN, columnsCount * columnPrice); }
public bool Craft(IBlueprint bp) { Dictionary <string, int> mats = bp.getMaterials(); List <ItemInfo> items = inventory.getItems(); foreach (string mat in mats.Keys) { ItemInfo inventoryItem = items.Find(x => x.itemName == mat); if (inventoryItem == null) { return(false); } int neededAmount; mats.TryGetValue(mat, out neededAmount); if (!enoughMats(inventoryItem.getAmount(), neededAmount)) { return(false); } inventory.decreaseItemCountInInventory(inventoryItem, neededAmount); } addCraftedToInventory(bp); return(true); }
private void AddWindowsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int windowsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.WINDOW)); float windowsPrice = costsNPrices.GetPrice((int)ComponentType.WINDOW); report.SetTotalPrice(ComponentType.WINDOW, windowsCount * windowsPrice); }
private bool DoesBlueprintHaveBlocksOnColumn(Coordinate position, IBlueprint blueprint) { int startLine; int endLine; switch (FacingDirection) { case EdgeType.DOWN: startLine = position.Y + 1; endLine = blueprint.Dimensions.Y; break; case EdgeType.UP: startLine = 0; endLine = position.Y; break; default: startLine = 0; endLine = 0; break; } for (int i = startLine; i < endLine; i++) { if (blueprint.HasBlock(new Coordinate(position.X, i))) { return(true); } } return(false); }
public void GetEnumeratorBlueprintTest() { portfolio.Add(blueprint1); IBlueprint blueprintGot = ((IRepository <IBlueprint>)portfolio).Get(blueprint1); Assert.AreEqual(blueprintGot, blueprint1); }
private void AddBeamsPrice(BlueprintPriceReport report, IBlueprint aBlueprint) { int beamsCount = aBlueprint.GetBeams().Count; float beamPrice = costsNPrices.GetPrice((int)ComponentType.BEAM); report.SetTotalPrice(ComponentType.BEAM, beamsCount * beamPrice); }
public static void ApplyToAll(this IBlueprint blueprint, params IEntity[] entities) { for (var i = 0; i < entities.Length; i++) { blueprint.Apply(entities[i]); } }
public static decimal ManufacturingTime(this IBlueprint bp, int industrySkill = 5, decimal implantModifier = 1, decimal productionSlotModifier = 1) { decimal productionTimeModifier = (1 - (0.04m * industrySkill)) * implantModifier * productionSlotModifier; decimal PEFactor = bp.ProdLevel < 0 ? (bp.ProdLevel - 1) : (bp.ProdLevel / (decimal)(1 + bp.ProdLevel)); return(bp.Details.productionTime * (1 - ((decimal)bp.Details.productivityModifier / (decimal)bp.Details.productionTime) * (PEFactor)) * productionTimeModifier); }
public BlueprintEditor(Session session, IBlueprint blueprint, IRepository <IBlueprint> aRepository, IRepository <Template> tempsRepository) { this.templates = tempsRepository; this.session = session; this.blueprint = blueprint; this.repository = aRepository; HasBeenModify = false; }
public void Remove(IBlueprint aBlueprint) { if (!Session.UserLogged.HasPermission(Permission.CREATE_BLUEPRINT)) { throw new NoPermissionsException(); } repository.Delete(aBlueprint); }
public bool Exist(IBlueprint aBlueprint) { if (!Session.UserLogged.HasPermission(Permission.READ_BLUEPRINT)) { throw new NoPermissionsException(); } return(repository.Exists(aBlueprint)); }
public static void SerializeToFile(IBlueprint blueprint, Image image, string path) { if (blueprint == null) throw new ArgumentNullException(nameof(blueprint)); if (image == null) throw new ArgumentNullException(nameof(image)); if (path == null) throw new ArgumentNullException(nameof(path)); using (var stream = File.OpenWrite(path)) SerializeToStream(blueprint, image, stream); }
private void editButton_Click(object sender, EventArgs e) { if (!(signedList.SelectedIndex == -1 && unSignedList.SelectedIndex == -1)) { IBlueprint selected = GetSelectedBlueprint(); parent.OpenBlueprintEditor((Blueprint)selected); } }
private void deleteButton_Click(object sender, EventArgs e) { if (!(signedList.SelectedIndex == -1 && unSignedList.SelectedIndex == -1)) { IBlueprint selected = GetSelectedBlueprint(); permissionController.Remove(selected); ShowUserBlueprints(); } }
internal static void LoadContainer(IBlueprint config) { // ReSharper disable once SuspiciousTypeConversion.Global lock (Triowing) { if (IocFactory != null) return; IocFactory = config as IContainerSetup ?? new StardustIocFactory(); } }
/// <summary> /// This method contains all binding configuration on one easy to use file. Add this statement to your applications startup code block (like Global.asax+Application_Start) /// </summary> /// <param name="config">an implementation of IModuleConfiguration that contains all bindings</param> public static void LoadModuleConfiguration(IBlueprint config) { HasExternalIoc = config is IContainerSetup; KernelFactory.LoadContainer(config); LoadKernel(); GetConfigurator().Bind <ILogging>().To(config.LoggingType).SetSingletonScope(); config.Bind(GetConfigurator()); LoggingExtentions.SetLogger(config.LoggingType); }
public void Sign(IBlueprint aBlueprint) { if (!Session.UserLogged.HasPermission(Permission.CAN_SIGN_BLUEPRINT)) { throw new NoPermissionsException(); } aBlueprint.Sign(Session.UserLogged); repository.Modify(aBlueprint); }
public BlueprintDump(IBlueprint blueprint) { if (blueprint == null) throw new ArgumentNullException(nameof(blueprint)); Header = blueprint.Header; if (Header.TrackedRideTypes == null) Header.TrackedRideTypes = Header.Types; Coaster = blueprint.Coasters.FirstOrDefault(); }
public void SignBlueprintNoPermissionTest() { initializerWithData(); Session session = conn.LogIn("designer1UN", "designer1P", (IUserRepository)repository); IRepository <IBlueprint> bpStorage = new BlueprintRepository(); BlueprintController controller = new BlueprintController(session, bpStorage); IBlueprint aBlueprint = controller.GetBlueprints().First(); controller.Sign(aBlueprint); }
private void deleteButton_Click(object sender, EventArgs e) { IBlueprint selected = (IBlueprint)blueprintList.SelectedItem; if (selected != null) { permissionController.Remove(selected); FillList(); } }
private void signedList_SelectedIndexChanged(object sender, EventArgs e) { unSignedList.ClearSelected(); if (signedList.SelectedIndex != -1) { signatureLists.Show(); IBlueprint selected = (IBlueprint)signedList.SelectedItem; signatureLists.DataSource = selected.GetSignatures(); } }
private void CreatePipeObject( IBlueprint blueprint, Coordinate position, EdgeType firstEdge, EdgeType secondEdge) { var curve = CreatePipeCurve(firstEdge, secondEdge); var pipeObject = pipeFactory.Create(curve); pipeObject.Position = objectTable.GetTile(position).Position; pipeObject.Scale = objectTable.GetTile(position).Scale; objectTable.SetPipe(position, firstEdge, secondEdge, pipeObject); }
public void ShipComponentAdded(IBlueprint blueprint, Coordinate position) { var shipComponent = blueprint.GetBlock(position).ShipComponent; objectTable.SetShipComponent(position, shipComponentFactory.Create(shipComponent)); objectTable.GetShipComponent(position).Position = objectTable.GetTile(position).Position; objectTable.GetShipComponent(position).Scale = objectTable.GetTile(position).Scale; controller.AssignShipComponentControl(objectTable.GetShipComponent(position), position); UpdateTiles(); }
public void WallsPersistenceCountTest() { blueprint1.InsertWall(new Point(2, 2), new Point(3, 2)); blueprint1.InsertWall(new Point(2, 2), new Point(2, 4)); portfolio.Add(blueprint1); IBlueprint retrieved = portfolio.Get(blueprint1.GetId()); int expectedResult = 2; int actualResult = retrieved.GetWalls().Count; Assert.AreEqual(expectedResult, actualResult); }
public BlueprintCostReport GenerateCostReport(IBlueprint aBlueprint) { BlueprintCostReport report = new BlueprintCostReport(); AddWallsCost(report, aBlueprint); AddBeamsCost(report, aBlueprint); AddColumnsCost(report, aBlueprint); AddWindowsCost(report, aBlueprint); AddDoorsCost(report, aBlueprint); return(report); }
public void ColumnsPersistenceCountTest() { blueprint1.InsertColumn(new Point(2, 3)); blueprint1.InsertColumn(new Point(1, 2)); portfolio.Add(blueprint1); IBlueprint retrieved = portfolio.Get(blueprint1.GetId()); int expectedResult = 2; int actualResult = retrieved.GetColumns().Count; Assert.AreEqual(expectedResult, actualResult); }
public BlueprintPriceReport GeneratePriceReport(IBlueprint aBlueprint) { BlueprintPriceReport report = new BlueprintPriceReport(); AddWallsPrice(report, aBlueprint); AddBeamsPrice(report, aBlueprint); AddColumnsPrice(report, aBlueprint); AddWindowsPrice(report, aBlueprint); AddDoorsPrice(report, aBlueprint); return(report); }
/// <summary> /// Writes the passed blueprint to the specified writer. /// </summary> /// <param name="writer">Writer to write the blueprint to.</param> /// <param name="blueprint">Blueprint to write.</param> public void Write(XmlWriter writer, IBlueprint blueprint) { writer.WriteStartElement(BlueprintElementName); { // Write blueprint id. writer.WriteAttributeString(BlueprintIdAttributeName, blueprint.Id); // Write property values. writer.WriteStartElement(PropertyValuesElementName); { foreach (var property in blueprint.PropertyValues) { var propertyType = property.Value.GetType(); writer.WriteStartElement(PropertyElementName); { writer.WriteAttributeString(PropertyKeyAttributeName, property.Key); writer.WriteAttributeString(PropertyTypeAttributeName, propertyType.FullName); new XmlSerializer(propertyType, new XmlRootAttribute(PropertyValueElementName)).Serialize( writer, property.Value); } writer.WriteEndElement(); } } writer.WriteEndElement(); // Write components. writer.WriteStartElement(ComponentsElementName); { foreach (var component in blueprint.ComponentTypes) { writer.WriteElementString(ComponentElementName, component); } } writer.WriteEndElement(); } writer.WriteEndElement(); }
public static string SerializeToString(IBlueprint blueprint) { if (blueprint == null) throw new ArgumentNullException(nameof(blueprint)); var settings = new JsonSerializerSettings { ContractResolver = new MiniJsonContractResolver(), Converters = new[] {new MiniJsonFloatConverter()} }; return string.Concat(blueprint.Data.Select(d => JsonConvert.SerializeObject((d as DataWrapper).Data, settings) + "\r\n")); }
public static void SerializeToStream(IBlueprint blueprint, Image image, Stream stream) { if (blueprint == null) throw new ArgumentNullException(nameof(blueprint)); if (image == null) throw new ArgumentNullException(nameof(image)); if (stream == null) throw new ArgumentNullException(nameof(stream)); using (var img = new Bitmap(image)) { WriteToImage(SerializeToString(blueprint), img); img.Save(stream, ImageFormat.Png); } }