public void StringFragment_OperatorNotEquals_4() { string original = "Hello, world"; StringFragment right = new StringFragment(original, 7, 5); Assert.IsFalse("world" != right); }
public void StringFragment_OperatorNotEquals_3() { string original = "Hello, world"; StringFragment left = new StringFragment(original, 7, 5); Assert.IsFalse(left != "world"); }
public void StringFragment_ToString_1() { string original = "Hello, world"; StringFragment fragment = new StringFragment(original, 7, 5); Assert.AreEqual("world", fragment.ToString()); }
public void StringFragment_OperatorNotEquals_2() { string original = "Hello, world"; StringFragment left = new StringFragment(original, 7, 5); StringFragment right = new StringFragment(original, 7, 3); Assert.IsTrue(left != right); }
public void StringFragment_Construction_1() { string original = "Hello, world"; StringFragment fragment = new StringFragment(original, 7, 5); Assert.AreSame(original, fragment.Original); Assert.AreEqual(7, fragment.Offset); Assert.AreEqual(5, fragment.Length); }
public void StringFragment_Equals_1() { string original = "Hello, world"; StringFragment left = new StringFragment(original, 7, 5); StringFragment right = new StringFragment(original, 7, 5); Assert.IsTrue(left.Equals(right)); right = new StringFragment(original, 7, 3); Assert.IsFalse(left.Equals(right)); Assert.IsFalse(left.Equals("world")); }
public ParsingState ExitRule() { var fragPos = this.CurrentNodes.First().Fragment.Position; var fragLen = this.CurrentNodes.Last().Fragment.Position + this.CurrentNodes.Last().Fragment.Length - fragPos; var fragment = new StringFragment(this.Text, fragPos, fragLen); // Console.WriteLine("exit " + this.CurrentRule.Name + " @" + this.Position); return(new ParsingState( this, this.Parent.CurrentRule, this.Parent.Parent, this.Position, this.Parent.Skipping, this.Parent.CurrentNodes.Concat(new[] { new StringTreeNode(fragment, this.CurrentRule, this.CurrentNodes.ToArray()) }) ) { Depth = this.Depth - 1 }); }
private static FieldFragment Create(CrudeProperty property) { if (property.Type != CrudePropertyType.Field) { throw new ArgumentException($"This method can not be called for {property.Type} fragments"); } var type = property.Info.PropertyType; var unwrappedType = type.UnwrapNullable(); FieldFragment?fragment = null; if (IsNumeric(unwrappedType)) { fragment = CreateGeneric(typeof(NumberFragment <>), type, property); } if (IsDate(unwrappedType)) { fragment = CreateGeneric(typeof(DateFragment <>), type, property); } if (unwrappedType == typeof(bool)) { fragment = new BooleanFragment(property); } if (unwrappedType == typeof(string)) { fragment = new StringFragment(property); } if (unwrappedType.IsEnum) { fragment = new EnumFragment(property); } return(fragment ??= new NotRenderedFragment(property)); }
public ParsingState MoveForward(int len) { var fragment = new StringFragment(this.Text, this.Position, len); this.Log.WriteLine("fwd@{0} {1}", this.Position, fragment); // Console.WriteLine("fwd in " + this.CurrentRule.Name + " @" + this.Position); return(new ParsingState( this, this.CurrentRule, this.Parent, this.Position + len, this.Skipping, this.CurrentNodes.Concat(new[] { new StringTreeNode(fragment, this.CurrentRule) }) ) { Depth = this.Depth }); }