public static string GetCompositeElement(this TypedSegment typedSegment, params string[] components) { string result = string.Empty; if (components != null && components.Length > 0) { result = components.Aggregate((i, j) => i + typedSegment.Delimiters.SubElementSeparator + j); } return(result); }
public override TypedShakeCondition <string> AsTypedShakeCondition() { Regex currentRegex = new Regex(TargetWord); return(LexicalExtensions.GenerateTypedRegexCond <string>( (x, y, z) => { Match m = currentRegex.Match(x, y, z - y); TypedSegment output = m.Success ? new TypedSegment(m.Length, WordType, m.Index + y) : null; return new Tuple <bool, TypedSegment>(m.Success, output); })); }
public override TypedShakeCondition <string> AsTypedShakeCondition() { TypedShakeCondition <string> fn = null; if (RequiresEqualityCheck) { fn = LexicalExtensions.GenerateTypedCond <string>( (val, ind, len) => { bool condition = val.Equals(TargetWord); TypedSegment seg = new TypedSegment(TargetWord.Length, WordType, ind); return(new Tuple <bool, TypedSegment>(condition, seg)); }); } else { fn = LexicalExtensions.GenerateMultiCharacterTypedCond(TargetWord, TargetWord); } return((x) => { bool result = x.Value.Contains(TargetWord); return result ? fn(x) : null; }); }
public Tuple <bool, TypedSegment> GenerateSingularTypedDualMatch(string x, int start, int length) { TypedSegment result = (TypedSegment)GenerateSingularDualMatch0(x, start, length, true); return(new Tuple <bool, TypedSegment>(result != null, result)); }