private ILabelService CreateServiceWithLabels() { var valuesToReturn = new List <Label>(); var danish = new Language("Danish", "da-DK"); typeof(Entity).GetProperty(nameof(Entity.Id)).SetValue(danish, 1); var english = new Language("English", "en-GB"); typeof(Entity).GetProperty(nameof(Entity.Id)).SetValue(english, 2); for (int i = 0; i < 100; i++) { var label = new Label($"Label Number: {i}"); var danishValue = new LabelValue($"Værdi for {i} på dansk", danish); var englishValue = new LabelValue($"Value for {i} in english", english); label.AddLabelValue(danishValue); label.AddLabelValue(englishValue); valuesToReturn.Add(label); } var mock = new Mock <ILabelService>(); mock.Setup(x => x.Get()).ReturnsAsync(valuesToReturn); return(mock.Object); }
private void branchCondition(ExprNode cond, StatementNode trueBranch, StatementNode falseBranch, List <LinearRepresentation> addBeforeEndLabel = null) { cond.AcceptVisit(this); LabelValue trueCond = new LabelValue(LABEL_PREFIX + labelCounter++); LabelValue endCond = new LabelValue(LABEL_PREFIX + labelCounter++); LinearRepresentation gotoCond = new LinearRepresentation(Operation.CondGoto, trueCond, idOrNum); evaluatedExpression.Add(gotoCond); moveExpressionToCode(); if (falseBranch != null) { falseBranch.AcceptVisit(this); } evaluatedExpression.Add(new LinearRepresentation(Operation.Goto, endCond)); evaluatedExpression.Add(new LinearRepresentation(trueCond, Operation.NoOperation)); moveExpressionToCode(); trueBranch.AcceptVisit(this); if (addBeforeEndLabel != null) { evaluatedExpression.AddRange(addBeforeEndLabel); } evaluatedExpression.Add(new LinearRepresentation(endCond, Operation.NoOperation)); moveExpressionToCode(); }
public LabelWasAssigned( PublicServiceId publicServiceId, LabelType labelType, LabelValue labelValue) { PublicServiceId = publicServiceId; LabelType = labelType; LabelValue = labelValue; }
public void VisitWhile(WhileNode n) { var beginLabel = new LabelValue(LABEL_PREFIX + labelCounter++); code.Add(new LinearRepresentation(beginLabel, Operation.NoOperation)); var beforeEnd = new List <LinearRepresentation>(); beforeEnd.Add(new LinearRepresentation(Operation.Goto, beginLabel)); branchCondition(n.Cond, (BlockNode)n.Child, null, beforeEnd); }
public static LabelValueDto TranslateValue(this LabelValue labelValue) { return(new LabelValueDto() { Id = labelValue.Id, IsoCode = labelValue.Language.IsoCode, Language = labelValue.Language.LanguageName, Value = labelValue.Value }); }
///<para>Change the opacity level of our test form.</para> private void Track_ValueChanged(object sender, EventArgs e) { byte opacity = (byte)Track.Value; LabelValue.Text = opacity.ToString(); LabelValue.Refresh(); // We need this because on slow computers (mine!) the windows takes some time to update our label. if (bitmap != null) { TestForm.SetBitmap(bitmap, opacity); } }
public LinearRepresentation(LabelValue label, Operation operation, StringValue destination = null, IValue leftOperand = null, IValue rightOperand = null) { Operation = operation; Destination = destination; LeftOperand = leftOperand; RightOperand = rightOperand; Label = label; }
public LinearRepresentation(Operation operation, StringValue destination = null, IValue leftOperand = null, IValue rightOperand = null) { var label = new LabelValue($"%ulabel{gen.GetNext()}"); Operation = operation; Destination = destination; LeftOperand = leftOperand; RightOperand = rightOperand; Label = label; }
public void WithAValidLabel( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LabelType labelType, LabelValue labelValue) { Assert( new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered)) .When(new UpdateLabels(publicServiceId, new Dictionary <LabelType, LabelValue> { { labelType, labelValue } })) .Then(publicServiceId, new LabelWasAssigned(publicServiceId, labelType, labelValue))); }
public void CannotUpdateLabelsOnRemovedPublicService( PublicServiceId publicServiceId, PublicServiceName publicServiceName, ReasonForRemoval reasonForRemoval, LabelType labelType, LabelValue labelValue) { Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new PublicServiceWasRemoved(publicServiceId, reasonForRemoval)) .When(new UpdateLabels(publicServiceId, new Dictionary <LabelType, LabelValue> { { labelType, labelValue } })) .Throws(new CannotPerformActionOnRemovedPublicService())); }
protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context) { var form = context.PeekNearest <IFormContext>(); var tb = context.CreateTagBuilder("div"); tb.AddCssClass("form-group"); if (ControlContextValue != null) { if (ControlContextValue.HasErrors) { tb.AddCssClass("has-error"); } else if (ControlContextValue.HasWarning) { tb.AddCssClass("has-warning"); } } ApplyCss(tb); ApplyAttributes(tb); tb.WriteStartTag(writer); context.Push(this); if (LabelValue != null) { LabelValue.WriteTo(writer, context); } if (ControlValue != null) { using (context.CreateWriter <FormGroupControls, AnyContent>().WithoutLabel(LabelValue == null).BeginContent(writer)) { ControlValue.WriteTo(writer, context); } } if (form != null && form.TypeValue == FormType.Inline) { return("</div> "); // trailing space is important for inline forms! Bootstrap does not provide spacing between groups in css! } return("</div>"); }
public void WithLabelValueThatIsUpdatedToEmpty( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LabelType labelType, LabelValue labelValue) { var emptyLabelValue = new LabelValue(string.Empty); Assert( new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new LabelWasAssigned(publicServiceId, labelType, labelValue)) .When(new UpdateLabels(publicServiceId, new Dictionary <LabelType, LabelValue> { { labelType, emptyLabelValue } })) .Then(publicServiceId, new LabelWasAssigned(publicServiceId, labelType, emptyLabelValue))); }
public void VisitFor(ForNode n) { var beginLabel = new LabelValue(LABEL_PREFIX + labelCounter++); var beforeEnd = new List <LinearRepresentation>(); n.ForVar.AcceptVisit(this); var iterVar = (IdentificatorValue)idOrNum; n.Beg.AcceptVisit(this); code.Add(new LinearRepresentation(Operation.Assign, iterVar, idOrNum)); // beforeEnd.Add(new LinearRepresentation(Operation.Assign, (IdentificatorValue)idOrNum, n.Beg)); beforeEnd.Add(new LinearRepresentation(Operation.Plus, (IdentificatorValue)iterVar, iterVar, new NumericValue(1))); beforeEnd.Add(new LinearRepresentation(Operation.Goto, beginLabel)); n.Beg.AcceptVisit(this); code.Add(new LinearRepresentation(beginLabel, Operation.NoOperation)); ExprNode condition = new BinOp(n.ForVar, n.End, Operator.Le); branchCondition(condition, n.St, null, beforeEnd); }
public List <LabelValue> GetLabelValues() { var result = new List <LabelValue>(); var labels = GetLabels(); foreach (var value in GetValues()) { var label = labels.FirstOrDefault(x => x.ItemId == value.Attachments.First()); if (label == null) { continue; } var labelValue = new LabelValue { LabelId = label.ItemId, LabelText = label.Title, ValueId = value.ItemId, ValueText = value.Title }; result.Add(labelValue); } return(result.OrderBy(x => x.LabelText).ThenBy(x => x.ValueText).ToList()); }
/// <summary> /// Generates a Loyalty Object /// </summary> /// <param name="issuerId"> </param> /// <param name="classId"> </param> /// <param name="objectId"> </param> /// <returns> loyaltyObject </returns> public static LoyaltyObject generateLoyaltyObject(string issuerId, string classId, string objectId) { // Define Barcode Barcode barcode = new Barcode() { Type = "qrCode", Value = "28343E3", AlternateText = "12345" }; // Define Points LoyaltyPoints points = new LoyaltyPoints() { Label = "Points", PointsType = "points", Balance = new LoyaltyPointsBalance() { String = "500" } }; // Define Text Module Data IList <TextModuleData> textModulesData = new List <TextModuleData>(); TextModuleData textModuleData = new TextModuleData() { Header = "Jane's Baconrista Rewards", Body = "Save more at your local Mountain View store Jane. " + "You get 1 bacon fat latte for every 5 coffees purchased. " + "Also just for you, 10% off all pastries in the Mountain View store." }; textModulesData.Add(textModuleData); // Define Links Module Data IList <Uri> uris = new List <Uri>(); Uri uri1 = new Uri() { Description = "My Baconrista Account", UriValue = "http://www.baconrista.com/myaccount?id=1234567890" }; uris.Add(uri1); LinksModuleData linksModuleData = new LinksModuleData() { Uris = uris }; // Define Info Module IList <LabelValue> row0cols = new List <LabelValue>(); LabelValue row0col0 = new LabelValue() { Label = "Next Reward in", Value = "2 coffees" }; LabelValue row0col1 = new LabelValue() { Label = "Member Since", Value = "01/15/2013" }; row0cols.Add(row0col0); row0cols.Add(row0col1); IList <LabelValue> row1cols = new List <LabelValue>(); LabelValue row1col0 = new LabelValue() { Label = "Local Store", Value = "Mountain View" }; row1cols.Add(row1col0); IList <LabelValueRow> rows = new List <LabelValueRow>(); LabelValueRow row0 = new LabelValueRow() { Columns = row0cols }; LabelValueRow row1 = new LabelValueRow() { Columns = row1cols }; rows.Add(row0); rows.Add(row1); InfoModuleData infoModuleData = new InfoModuleData() { ShowLastUpdateTime = true, LabelValueRows = rows }; // Define general messages IList <WalletObjectMessage> messages = new List <WalletObjectMessage>(); WalletObjectMessage message = new WalletObjectMessage() { Header = "Hi Jane!", Body = "Thanks for joining our program. Show this message to " + "our barista for your first free coffee on us!", ActionUri = new Uri() { UriValue = "http://baconrista.com" } }; messages.Add(message); // Define Wallet Instance LoyaltyObject loyaltyObj = new LoyaltyObject() { ClassId = issuerId + "." + classId, Id = issuerId + "." + objectId, Version = 1, State = "active", Barcode = barcode, AccountName = "Jane Doe", AccountId = "1234567890", LoyaltyPoints = points, Messages = messages, InfoModuleData = infoModuleData, TextModulesData = textModulesData, LinksModuleData = linksModuleData }; return(loyaltyObj); }
protected bool Equals(LabelValue other) { return(Label == other.Label && Value == other.Value); }
// Pass in a function that is used to fill the text of the label public LabelData(Rect r, LabelValue l) { Rect = r; labelValue = l; }
private void When(LabelWasAssigned @event) { var labelType = LabelType.Parse(@event.LabelType); _labels[labelType] = new LabelValue(@event.LabelValue); }
/// <summary> /// Generates a Loyalty Object /// </summary> /// <param name="issuerId"> </param> /// <param name="classId"> </param> /// <param name="objectId"> </param> /// <returns> loyaltyObject </returns> public static LoyaltyObject generateLoyaltyObject(string issuerId, string classId, string objectId) { // Define Barcode Barcode barcode = new Barcode() { Type = "qrCode", Value = "28343E3" }; // Define Points LoyaltyPoints points = new LoyaltyPoints() { Label = "Points", Balance = new LoyaltyPointsBalance() { String = "500" } }; // Define Text Module Data IList<TextModuleData> textModulesData = new List<TextModuleData>(); TextModuleData textModuleData = new TextModuleData() { Header = "Jane's Baconrista Rewards", Body = "You are 5 coffees away from receiving a free bacon fat latte" }; textModulesData.Add(textModuleData); // Define Uris IList<Uri> uris = new List<Uri>(); Uri uri1 = new Uri() { Description = "My Baconrista Account", UriValue = "http://www.baconrista.com/myaccount?id=1234567890" }; Uri uri2 = new Uri() { Description = "uri 2 description", UriValue = "http://www.google.com" }; uris.Add(uri1); uris.Add(uri2); LinksModuleData linksModuleData = new LinksModuleData() { Uris = uris }; // Define Info Module IList<LabelValue> row0cols = new List<LabelValue>(); LabelValue row0col0 = new LabelValue() { Label = "Member Name", Value = "Jane Doe" }; LabelValue row0col1 = new LabelValue() { Label = "Membership #", Value = "1234567890" }; row0cols.Add(row0col0); row0cols.Add(row0col1); IList<LabelValue> row1cols = new List<LabelValue>(); LabelValue row1col0 = new LabelValue() { Label = "Next Reward in", Value = "2 coffees" }; LabelValue row1col1 = new LabelValue() { Label = "Member Since", Value = "01/15/2013" }; row1cols.Add(row1col0); row1cols.Add(row1col1); IList<LabelValueRow> rows = new List<LabelValueRow>(); LabelValueRow row0 = new LabelValueRow() { HexBackgroundColor = "#BBCCFC", Columns = row0cols }; LabelValueRow row1 = new LabelValueRow() { HexBackgroundColor = "#FFFB00", Columns = row1cols }; rows.Add(row0); rows.Add(row1); InfoModuleData infoModuleData = new InfoModuleData() { HexFontColor = "#FFFFFF", HexBackgroundColor = "#FC058C", ShowLastUpdateTime = true, LabelValueRows = rows }; // Define Wallet Instance LoyaltyObject loyaltyObj = new LoyaltyObject() { ClassId = issuerId + "." + classId, Id = issuerId + "." + objectId, Version = "1", State = "active", Barcode = barcode, AccountName = "Jane Doe", AccountId = "1234567890", LoyaltyPoints = points, InfoModuleData = infoModuleData, TextModulesData = textModulesData, LinksModuleData = linksModuleData }; return loyaltyObj; }
/// <summary> /// Generates a Loyalty Object /// </summary> /// <param name="issuerId"> </param> /// <param name="classId"> </param> /// <param name="objectId"> </param> /// <returns> loyaltyObject </returns> public static LoyaltyObject generateLoyaltyObject(string issuerId, string classId, string objectId) { // Define Barcode Barcode barcode = new Barcode() { Type = "qrCode", Value = "28343E3", AlternateText = "12345" }; // Define Points LoyaltyPoints points = new LoyaltyPoints() { Label = "Points", PointsType = "points", Balance = new LoyaltyPointsBalance() { String = "500" } }; // Define Text Module Data IList<TextModuleData> textModulesData = new List<TextModuleData>(); TextModuleData textModuleData = new TextModuleData() { Header = "Jane's Baconrista Rewards", Body = "Save more at your local Mountain View store Jane. " + "You get 1 bacon fat latte for every 5 coffees purchased. " + "Also just for you, 10% off all pastries in the Mountain View store." }; textModulesData.Add(textModuleData); // Define Links Module Data IList<Uri> uris = new List<Uri>(); Uri uri1 = new Uri() { Description = "My Baconrista Account", UriValue = "http://www.baconrista.com/myaccount?id=1234567890" }; uris.Add(uri1); LinksModuleData linksModuleData = new LinksModuleData() { Uris = uris }; // Define Info Module IList<LabelValue> row0cols = new List<LabelValue>(); LabelValue row0col0 = new LabelValue() { Label = "Next Reward in", Value = "2 coffees" }; LabelValue row0col1 = new LabelValue() { Label = "Member Since", Value = "01/15/2013" }; row0cols.Add(row0col0); row0cols.Add(row0col1); IList<LabelValue> row1cols = new List<LabelValue>(); LabelValue row1col0 = new LabelValue() { Label = "Local Store", Value = "Mountain View" }; row1cols.Add(row1col0); IList<LabelValueRow> rows = new List<LabelValueRow>(); LabelValueRow row0 = new LabelValueRow() { Columns = row0cols }; LabelValueRow row1 = new LabelValueRow() { Columns = row1cols }; rows.Add(row0); rows.Add(row1); InfoModuleData infoModuleData = new InfoModuleData() { ShowLastUpdateTime = true, LabelValueRows = rows }; // Define general messages IList<WalletObjectMessage> messages = new List<WalletObjectMessage>(); WalletObjectMessage message = new WalletObjectMessage() { Header = "Hi Jane!", Body = "Thanks for joining our program. Show this message to " + "our barista for your first free coffee on us!", ActionUri = new Uri() { UriValue = "http://baconrista.com" } }; messages.Add(message); // Define Wallet Instance LoyaltyObject loyaltyObj = new LoyaltyObject() { ClassId = issuerId + "." + classId, Id = issuerId + "." + objectId, Version = 1, State = "active", Barcode = barcode, AccountName = "Jane Doe", AccountId = "1234567890", LoyaltyPoints = points, Messages = messages, InfoModuleData = infoModuleData, TextModulesData = textModulesData, LinksModuleData = linksModuleData }; return loyaltyObj; }
public string GenerateCode() { StringBuilder sb = new StringBuilder(); //if(csharps.Count<=0) // return ""; if (label.Length > 0) { sb.Append(label); if (sb.Length < 20) { sb.Append(IndentString.GetSpace(20 - sb.Length)); } foreach (DAGNode node in csharps) { List <string> exps = new List <string>(); string s = node.Generate(exps); if (node.IsComment) { sb.Append("/*"); } sb.Append(string.Join("", exps.ToArray())); if (node.IsStatement && node.Identifier.Length <= 0) { sb.Append(s + node.StatementSemicolon); } if (node.IsComment) { sb.Append("*/"); } } if (sb.Length < 80) { sb.Append(IndentString.GetSpace(80 - sb.Length)); } sb.Append("//"); sb.Append(opcode); if (operand.Value.Length > 0) { sb.Append("\t\t\t\t" + operand.Value); } } else if (csharps.Count > 0) { if (opcode == ".try") { sb.Append("IL_" + LabelValue.ToString("X6") + ":"); if (sb.Length < 20) { sb.Append(IndentString.GetSpace(20 - sb.Length)); } } else { sb.Append(IndentString.GetSpace(20)); } if (csharps.Count > 0) { foreach (DAGNode node in csharps) { List <string> exps = new List <string>(); string s = node.Generate(exps); sb.Append(string.Join("", exps.ToArray())); if (node.IsStatement && node.Identifier.Length <= 0) { sb.Append(s + node.StatementSemicolon); } } } } else { sb.Append(IndentString.GetSpace(80) + "//" + opcode); } return(sb.ToString()); }
// Functionless information readout. Does nothing but report information to the player. private void createHUD() { //create the layer itself GuiLayer hud = View.GetMainView().AddLayer("HUD", new Rectangle(-100, -100, 146, 100)); LabelValue currency = new LabelValue(hud, "Bacon", playerCurrency.ToString()); currency.SetPosition(0, 0); LabelValue health = new LabelValue(hud, "Karma", playerHealth.ToString()); health.SetPosition(0, 20); }
private void createTopBar() { GuiLayer topBar = View.GetMainView().AddLayer("TopBar", new Rectangle(0, 0, 200, 40)); //topBar.SetPosition(Game.GetRenderer().GetSize().width / 2 - 100, Game.GetRenderer().GetSize().height - topBar.GetSize().height); topBar.SetPosition(Game.GetRenderer().GetSize().width / 2 - 100, 0); // Wave GUI // The current wave we're on. LabelValue currentWave = new LabelValue(topBar, "Wave", "0"); currentWave.SetPosition(0, 0); // The total number of entities in the wave. LabelValue totalWaves = new LabelValue(topBar, "/", "0"); totalWaves.SetPosition(60, 0); // Which number in the wave is currently spawning. LabelValue wavePosition = new LabelValue(topBar, "Enemy", "0"); wavePosition.SetPosition(100, 0); // The number of entities in the wave. LabelValue waveCount = new LabelValue(topBar, "/", "0"); waveCount.SetPosition(160, 0); }