protected void EmitModifiers(InputElementList mods, int indent, string suffix) { Indent(indent); if (mods.Count > 0) { bool partial = false; int n = 0; foreach (InputElement e in mods) { if (e.str == "partial") { partial = true; } else { Write(n++ > 0 ? " {0}" : "{0}", e.str); } } if (partial) { Write(n++ > 0 ? " partial" : "partial"); } Write("{0}", suffix); } }
private InputLayout AddInputLayout(InputElementList elements) { var il = new InputLayout(Renderer.Instance.Device, InputSignature.Data, elements.InputElements.ToArray()); inputLayouts[elements.HashCode] = il; return(il); }
public void They_should_be_applied_to_all_checkboxes() { var list = new InputElementList<CheckBoxField>(new Hash(@class => "foo")) {new CheckBoxField(), new CheckBoxField()}; foreach(var field in list) { Assert.That(field.Class, Is.EqualTo("foo")); } }
public static bool IsPublic(InputElementList mods) { foreach (InputElement i in mods) { if (i.str == "public") { return(true); } } return(false); }
public void Then_ToString_should_produce_correct_html() { var field1 = new CheckBoxField(new Hash(name => "foo", value => "bar")); var field2 = new CheckBoxField(new Hash(name => "x", value => "y")); string expected = string.Concat(field1, field2); var list = new InputElementList<CheckBoxField>(Hash.Empty) {field1, field2}; string html = list.ToString(); Assert.That(html, Is.EqualTo(expected)); }
internal InputLayout GetInputLayout(InputElementList elements) { if (elements == null || elements.HashCode == 0) { return(null); } if (inputLayouts.ContainsKey(elements.HashCode)) { return(inputLayouts[elements.HashCode]); } return(AddInputLayout(elements)); }
protected void EmitModifiers(InputElementList mods, int indent, string suffix) { Indent(indent); if (mods.Count > 0) { Write("{0}", mods[0].str); for (int i = 1; i < mods.Count; i++) { Write(" {0}", 0, mods[i].str); } Write("{0}", suffix); } }
public void Enumerating_should_return_checkboxes() { var field1 = new CheckBoxField(new Hash(name => "foo", value => "bar")); var field2 = new CheckBoxField(new Hash(name => "x", value => "y")); var list = new InputElementList<CheckBoxField>(Hash.Empty) {field1, field2}; var boxes = new List<CheckBoxField>(); foreach(var field in list) { boxes.Add(field); } Assert.That(boxes.Count, Is.EqualTo(2)); Assert.That(boxes[0], Is.EqualTo(field1)); Assert.That(boxes[1], Is.EqualTo(field2)); }
public void Then_the_format_should_be_applied_to_each_checkbox() { var list = new InputElementList<CheckBoxField>(Hash.Empty) { new CheckBoxField(new Hash(name => "Test1")), new CheckBoxField(new Hash(name => "Test2")) }; string expected = "<input name=\"Test1\" type=\"checkbox\"/><br /><input name=\"Test2\" type=\"checkbox\"/><br />"; string output = list.ToFormattedString("{0}<br />"); Assert.That(output, Is.EqualTo(expected)); }
public void They_should_not_overwrite_existing_attributes() { var list = new InputElementList<CheckBoxField>(new Hash(@class => "foo")) {new CheckBoxField(new Hash(@class => "bar"))}; Assert.That(list.First().Class, Is.EqualTo("bar")); }