//Insert strings from list to combo box cells public void SetLoaded(List <string> templ) { foreach (string s in templ) { TemplateValue.Insert(new NSComboBoxCell(s), 0); } }
private void UpdateExcelData(List <TemplateStruct> list, Dictionary <string, List <TemplateValue> > dic, MSExcel.Workbook wbook) { for (int i = 0; i < list.Count; i++) { TemplateStruct ts = list[i]; List <TemplateValue> temp = dic[list[i].NodeName]; int start = ExcelDataStart; MSExcel.Worksheet ws = (MSExcel.Worksheet)wbook.Sheets[i + 1]; for (int j = 0; j < temp.Count; j++) { TemplateValue tv = temp[j]; for (int k = 0; k < ts.Attributes.Count; k++) { MSExcel.Range r = ws.get_Range(getCell(start, k + StructCol)); r.Value2 = tv.Props[ts.Attributes[k]]; } start++; } } }
//deletes selected template partial void btnDelete(NSButtonCell sender) { Database.Templates.Remove(TemplateValue.StringValue); TemplateValue.Remove(TemplateValue.SelectedValue); TemplateValue.StringValue = ""; Database.SaveData(); }
public ActionResult ShowTemplate(TemplateModel model) { TemplateVariable tVariable = new TemplateVariable(); TemplateValue tValue = new TemplateValue(); string Barcode = @"<svg id = 'barcode'></svg><script>JsBarcode('#barcode', '" + tValue.Barcode + "', {width: 2,height: 40});</script>"; // //format: "pharmacode", // //lineColor: "#0aa", //+ 'width: 2,' //+ 'height: 40,' // // displayValue: false //+ '});</script>'; string updateHtml = ""; if (model.TemplateHtml != null) { string html = model.TemplateHtml; updateHtml = html.Replace(tVariable.barcode, Barcode); updateHtml = updateHtml.Replace(tVariable.name, tValue.Name); updateHtml = updateHtml.Replace(tVariable.branchname, tValue.BranchName); updateHtml = updateHtml.Replace(tVariable.branchemail, tValue.BranchEmail); updateHtml = updateHtml.Replace(tVariable.productname, tValue.ProductName); updateHtml = updateHtml.Replace(tVariable.productid, tValue.ProductId); updateHtml = updateHtml.Replace(tVariable.unit, tValue.Unit); updateHtml = updateHtml.Replace(tVariable.quantity, tValue.Quantity); updateHtml = updateHtml.Replace(tVariable.discount, tValue.Discount); updateHtml = updateHtml.Replace(tVariable.price, tValue.Price); updateHtml = updateHtml.Replace(tVariable.priceafterdiscount, tValue.PriceAfterDiscount); updateHtml = updateHtml.Replace(tVariable.branchlogo, tValue.BranchLogo); } model.TemplateHtml = updateHtml; return(View(model)); }
public NotificationMessage AddSubstitution(TemplateValue value) { if (_template == null) throw new InvalidOperationException("This NotificationMessage has no template"); _template.Values.Add(value); return this; }
public void renders_the_template() { var theValue = TemplateValue.For("field", "FirstName"); var theTemplate = new Template(StringToken.FromKeyString("Test", "{field} is required"), theValue); theTemplate.Render().ShouldBe("FirstName is required"); }
private TemplateValue() { Type = TemplateValueType.TVT_Invalid; ReferencedType = null; KeyType = null; ValueType = null; }
private Dictionary <string, List <TemplateValue> > GetTemplateList(XmlNode root) { Dictionary <string, List <TemplateValue> > dic = new Dictionary <string, List <TemplateValue> >(); foreach (XmlNode node in root.ChildNodes) { foreach (XmlNode item in node.ChildNodes) { if (item.NodeType != XmlNodeType.Element) { continue; } if (!dic.ContainsKey(item.LocalName)) { dic[item.LocalName] = new List <TemplateValue>(); } TemplateValue tv = new TemplateValue(); dic[item.LocalName].Add(tv); tv.NodeName = item.LocalName; tv.Props = new Dictionary <string, string>(); foreach (XmlAttribute att in item.Attributes) { tv.Props[att.LocalName] = att.Value; } } } return(dic); }
public void Validate(Accessor accessor, ValidationContext context) { var enumerable = accessor.GetValue(context.Target) as System.Collections.IEnumerable; if (enumerable == null || enumerable.Count() != _length) { context.Notification.RegisterMessage(accessor, Token, TemplateValue.For(LENGTH, _length)); } }
public void Validate(Accessor accessor, ValidationContext context) { var rawValue = accessor.GetValue(context.Target); if (rawValue != null && rawValue.ToString().Length > Length) { context.Notification.RegisterMessage(accessor, Token, TemplateValue.For(LENGTH, _length)); } }
public void Validate(Accessor accessor, ValidationContext context) { var value = context.GetFieldValue <string>(accessor); if (value != null && value.Length < Length) { context.Notification.RegisterMessage(accessor, Token, TemplateValue.For(LENGTH, _length)); } }
public void Validate(Accessor accessor, ValidationContext context) { var value = accessor.GetValue(context.Target); if (_bounds.CompareTo(value) > 0) { context.Notification.RegisterMessage(accessor, Token, TemplateValue.For("bounds", _bounds)); } }
public void gets_the_values_from_the_static_builder() { var v1 = TemplateValue.For("FirstName", "Joel"); var v2 = TemplateValue.For("LastName", "Arnold"); var collection = TemplateValueCollection.For(v1, v2); collection.ShouldHaveTheSameElementsAs(v1, v2); }
public void builds_the_dictionary() { var v1 = TemplateValue.For("FirstName", "Joel"); var v2 = TemplateValue.For("LastName", "Arnold"); var values = TemplateValueCollection.For(v1, v2).ToDictionary(); values["FirstName"].ShouldBe("Joel"); values["LastName"].ShouldBe("Arnold"); }
public void equality_check_negative() { var v1 = TemplateValue.For("FirstName", "Joel"); var v2 = TemplateValue.For("LastName", "Arnold"); var collection1 = TemplateValueCollection.For(v1, v2); var collection2 = TemplateValueCollection.For(v1); collection1.ShouldNotBe(collection2); }
public async Task <Unit> Handle(CreateTemplateCommand request, CancellationToken cancellationToken) { var templateValue = new TemplateValue(request.descriptionValue); var template = new Template(request.description, templateValue); await _templateRepository.AddAsync(template); await _templateRepository.UnityOfWork.SaveChangesAsync(); return(await Unit.Task); }
public void Validate(Accessor accessor, ValidationContext context) { var username = context.GetFieldValue <string>(accessor); var service = context.Service <IUserService>(); if (service.UsernameExists(username)) { context.Notification.RegisterMessage(accessor, Token, TemplateValue.For("username", username)); } }
public void equality_check() { var theValue = TemplateValue.For("field", "FirstName"); var template1 = new Template(StringToken.FromKeyString("Test", "{field} is required"), theValue); var template2 = new Template(StringToken.FromKeyString("Test", "{field} is required")); template2.Values.Add(theValue); template1.ShouldBe(template2); }
public void equality_check_negative() { var token = StringToken.FromKeyString("Test", "1...2...3"); var v1 = TemplateValue.For("FirstName", "Joel"); var v2 = TemplateValue.For("LastName", "Arnold"); var message1 = new NotificationMessage(token, v1, v2); var message2 = new NotificationMessage(token, v1); message1.ShouldNotEqual(message2); }
public void only_adds_the_value_once() { var v1 = TemplateValue.For("FirstName", "Joel"); var collection = new TemplateValueCollection(); collection.Add(v1); collection.Add(v1); collection.ShouldHaveTheSameElementsAs(v1); }
public void Validate(FubuCore.Reflection.Accessor accessor, ValidationContext context) { var username = context.GetFieldValue <string>(accessor); var users = context.Service <IUserService>(); if (users.UsernameExists(username)) { context.Notification.RegisterMessage(accessor, StringToken.FromKeyString("Validation:Username", "Username '{username}' already exists"), TemplateValue.For("username", username)); } }
public void adds_the_value() { var v1 = TemplateValue.For("FirstName", "Joel"); var v2 = TemplateValue.For("LastName", "Arnold"); var collection = new TemplateValueCollection(); collection.Add(v1); collection.Add(v2); collection.ShouldHaveTheSameElementsAs(v1, v2); }
public void gets_the_values() { var values = new List <TemplateValue> { TemplateValue.For("FirstName", "Joel"), TemplateValue.For("LastName", "Arnold") }; var collection = new TemplateValueCollection(values); collection.ShouldHaveTheSameElementsAs(values); }
public void Validate(Accessor accessor, ValidationContext context) { var value = context.GetFieldValue <string>(accessor) ?? string.Empty; var length = value.Length; if (length < _min || length > _max) { var min = TemplateValue.For("min", _min); var max = TemplateValue.For("max", _max); context.Notification.RegisterMessage(accessor, Token, min, max); } }
public void equality_check_negative() { var theValue = TemplateValue.For("field", "FirstName"); var template1 = new Template(StringToken.FromKeyString("Test", "{field} is required"), theValue); var template2 = new Template(StringToken.FromKeyString("Test2", "{field} is invalid")); template2.Values.Add(theValue); template1.ShouldNotEqual(template2); var template3 = new Template(StringToken.FromKeyString("Test3", "{field} is required")); template1.ShouldNotEqual(template3); }
/// <summary> /// Creates a pattern like this one, but with the template value modified to use /// the specified calendar system. /// </summary> /// <remarks> /// <para> /// Care should be taken in two (relatively rare) scenarios. Although the default template value /// is supported by all Noda Time calendar systems, if a pattern is created with a different /// template value and then this method is called with a calendar system which doesn't support that /// date, an exception will be thrown. Additionally, if the pattern only specifies some date fields, /// it's possible that the new template value will not be suitable for all values. /// </para> /// </remarks> /// <param name="calendar">The calendar system to convert the template value into.</param> /// <returns>A new pattern with a template value in the specified calendar system.</returns> public LocalDateTimePattern WithCalendar([NotNull] CalendarSystem calendar) => WithTemplateValue(TemplateValue.WithCalendar(calendar));
/// <summary> /// Creates a pattern like this one, but with the template value modified to use /// the specified calendar system. /// </summary> /// <remarks> /// <para> /// Care should be taken in two (relatively rare) scenarios. Although the default template value /// is supported by all Noda Time calendar systems, if a pattern is created with a different /// template value and then this method is called with a calendar system which doesn't support that /// date, an exception will be thrown. Additionally, if the pattern only specifies some date fields, /// it's possible that the new template value will not be suitable for all values. /// </para> /// </remarks> /// <param name="calendar">The calendar system to convert the template value into.</param> /// <returns>A new pattern with a template value in the specified calendar system.</returns> public ZonedDateTimePattern WithCalendar(CalendarSystem calendar) => WithTemplateValue(TemplateValue.WithCalendar(calendar));
//adds to list of combobox cells, created template in body field and save it partial void btnAdd(NSObject sender) { TemplateValue.Insert(new NSComboBoxCell(fldBody.StringValue), 0); Database.Templates.Add(fldBody.StringValue); Database.SaveData(); }
public void equals_other_value() { var theTemplate = TemplateValue.For("Test", "123"); theTemplate.ShouldBe(TemplateValue.For("Test", "123")); }
public void does_not_equal_value() { var theTemplate = TemplateValue.For("Test", "123"); theTemplate.ShouldNotBe(TemplateValue.For("Test2", "1234")); }
public static TemplateValue MakeFromString(string input) { // string // float // int // bool // reference: basically just any plain old word // list(TemplateValueType) // map(TemplateValueType -> TemplateValueType) TemplateValueType type = TemplateValueType.TVT_Invalid; if (input == "string") { type = TemplateValueType.TVT_String; } else if (input == "float") { type = TemplateValueType.TVT_Float; } else if (input == "int") { type = TemplateValueType.TVT_Int; } else if (input == "bool") { type = TemplateValueType.TVT_Bool; } else if (ReferenceRegex.IsMatch(input)) { type = TemplateValueType.TVT_Reference; } else if (ListRegex.IsMatch(input)) { type = TemplateValueType.TVT_List; } else if (MapRegex.IsMatch(input)) { type = TemplateValueType.TVT_Map; } else { return(null); } string referencedType = null; TemplateValue keyType = null; TemplateValue valueType = null; switch (type) { case TemplateValueType.TVT_String: case TemplateValueType.TVT_Float: case TemplateValueType.TVT_Int: case TemplateValueType.TVT_Bool: break; case TemplateValueType.TVT_Reference: { referencedType = input; break; } case TemplateValueType.TVT_List: { int leftParenIndex = input.IndexOf('('); int rightParenIndex = input.LastIndexOf(')'); string rawListType = input.Substring(leftParenIndex, rightParenIndex - leftParenIndex); valueType = MakeFromString(rawListType); break; } case TemplateValueType.TVT_Map: { int leftParenIndex = input.IndexOf('('); int arrowIndex = input.IndexOf("->"); int rightParenIndex = input.LastIndexOf(')'); string rawMapKeyType = input.Substring(leftParenIndex, arrowIndex - leftParenIndex).Trim(); keyType = MakeFromString(rawMapKeyType); string rawMapValueType = input.Substring(arrowIndex + 2, rightParenIndex - (arrowIndex + 2)).Trim(); valueType = MakeFromString(rawMapValueType); break; } default: Debug.LogError("Invalid template value type."); return(null); } TemplateValue value = new TemplateValue(); value.Type = type; value.ReferencedType = referencedType; value.KeyType = keyType; value.ValueType = valueType; return(value); }
public NotificationMessage AddSubstitution(TemplateValue value) { _template.Values.Add(value); return this; }