本文整理汇总了C#中MutableString.Append方法的典型用法代码示例。如果您正苦于以下问题:C# MutableString.Append方法的具体用法?C# MutableString.Append怎么用?C# MutableString.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableString
的用法示例。
在下文中一共展示了MutableString.Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Append
private static MutableString/*!*/ Append(RubyRegex/*!*/ self, MutableString/*!*/ result) {
Assert.NotNull(self, result);
result.Append("(?");
if (AppendOptionString(result, self.Options, true, false) < 3) {
result.Append('-');
}
AppendOptionString(result, self.Options, false, false);
result.Append(':');
AppendEscapeForwardSlash(result, self.GetPattern());
result.Append(')');
return result;
}
示例2: Replace
public static MutableString/*!*/ Replace(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ other) {
// Handle case where objects are the same identity
if (ReferenceEquals(self, other)) {
return self;
}
self.Clear();
self.Append(other);
return self.TaintBy(other);
}
示例3: Append
public static MutableString/*!*/ Append(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ other) {
return self.Append(other).TaintBy(other);
}
示例4: AppendReplacementExpression
private static void AppendReplacementExpression(MutableString input, GroupCollection/*!*/ groups, MutableString/*!*/ result, MutableString/*!*/ replacement) {
int backslashCount = 0;
for (int i = 0; i < replacement.Length; i++) {
char c = replacement.GetChar(i);
if (c == '\\')
backslashCount++;
else if (backslashCount == 0)
result.Append(c);
else {
AppendBackslashes(backslashCount, result, 0);
// Odd number of \'s + digit means insert replacement expression
if ((backslashCount & 1) == 1) {
if (Char.IsDigit(c)) {
AppendGroupByIndex(groups, c - '0', backslashCount, result);
} else if (c == '&') {
AppendGroupByIndex(groups, groups.Count - 1, backslashCount, result);
} else if (c == '`') {
// Replace with everything in the input string BEFORE the match
result.Append(input, 0, groups[0].Index);
} else if (c == '\'') {
// Replace with everything in the input string AFTER the match
int start = groups[0].Index + groups[0].Length;
result.Append(input, start, input.Length - start);
} else if (c == '+') {
// Replace last character in last successful match group
AppendLastCharOfLastMatchGroup(groups, result);
} else {
// unknown escaped replacement char, go ahead and replace untouched
result.Append('\\');
result.Append(c);
}
} else {
// Any other # of \'s or a non-digit character means insert literal \'s and character
AppendBackslashes(backslashCount, result, 1);
result.Append(c);
}
backslashCount = 0;
}
}
AppendBackslashes(backslashCount, result, 1);
}
示例5: AppendGroupByIndex
private static void AppendGroupByIndex(GroupCollection/*!*/ groups, int index, int backslashCount, MutableString/*!*/ result) {
if (groups[index].Success) {
result.Append(groups[index].Value);
}
}
示例6: Reinitialize
public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [NotNull]byte[] other) {
self.Clear();
self.Append(other);
return self;
}
示例7: BlockReplaceAll
// returns true if block jumped
// "result" will be null if there is no successful match
private static bool BlockReplaceAll(RubyScope/*!*/ scope, MutableString/*!*/ input, BlockParam/*!*/ block,
RubyRegex/*!*/ regex, out object blockResult, out MutableString result) {
var matchScope = scope.GetInnerMostClosureScope();
MatchCollection matches = regex.Matches(input);
if (matches.Count == 0) {
result = null;
blockResult = null;
matchScope.CurrentMatch = null;
return false;
}
// create an empty result:
result = input.CreateInstance().TaintBy(input);
int offset = 0;
foreach (Match match in matches) {
MatchData currentMatch = new MatchData(match, input);
matchScope.CurrentMatch = currentMatch;
uint version = input.Version;
if (block.Yield(MutableString.Create(match.Value), out blockResult)) {
return true;
}
if (input.Version != version) {
return false;
}
// resets the $~ scope variable to the last match (skipd if block jumped):
matchScope.CurrentMatch = currentMatch;
MutableString replacement = Protocols.ConvertToString(scope.RubyContext, blockResult);
result.TaintBy(replacement);
// prematch:
result.Append(input, offset, match.Index - offset);
// replacement (unlike ReplaceAll, don't interpolate special sequences like \1 in block return value):
result.Append(replacement);
offset = match.Index + match.Length;
}
// post-last-match:
result.Append(input, offset, input.Length - offset);
blockResult = null;
return false;
}
示例8: AppendReplacementExpression
private static void AppendReplacementExpression(ConversionStorage<MutableString> toS, BinaryOpStorage hashDefault,
MutableString/*!*/ input, MatchData/*!*/ match, MutableString/*!*/ result, Union<IDictionary<object, object>, MutableString>/*!*/ replacement) {
if (replacement.Second != null) {
AppendReplacementExpression(input, match, result, replacement.Second);
} else {
Debug.Assert(toS != null && hashDefault != null);
object replacementObj = HashOps.GetElement(hashDefault, replacement.First, match.GetValue());
if (replacementObj != null) {
var replacementStr = Protocols.ConvertToString(toS, replacementObj);
result.Append(replacementStr).TaintBy(replacementStr);
}
}
}
示例9: Reinitialize
public static MutableString/*!*/ Reinitialize(MutableString/*!*/ self, [DefaultProtocol, NotNull]MutableString other) {
if (ReferenceEquals(self, other)) {
return self;
}
self.Clear();
self.Append(other);
return self.TaintBy(other);
}
示例10: AppendRawBytes
private void AppendRawBytes(MutableString/*!*/ buffer, int count) {
Debug.Assert(count > 0);
if (_peekAhead != -1) {
buffer.Append((byte)_peekAhead);
_peekAhead = -1;
count--;
}
buffer.Append(_stream, count);
}
示例11: Read
public static MutableString/*!*/ Read(StringIO/*!*/ self, MutableString buffer, bool eofError) {
var content = self.GetReadableContent();
int start = self._position;
int length = content.GetByteCount();
if (buffer != null) {
buffer.Clear();
} else {
buffer = MutableString.CreateBinary();
}
if (start < length) {
self._position = length;
buffer.Append(content, start, length - start).TaintBy(content);
} else if (eofError) {
throw new EOFError("end of file reached");
}
return buffer;
}
示例12: AppendRawBytes
private void AppendRawBytes(MutableString/*!*/ buffer, int count) {
Debug.Assert(count > 0);
int remaining = count;
if (_bufferCount > 0) {
int c = Math.Min(_bufferCount, count);
buffer.Append(_buffer, _bufferStart, c);
ConsumeBuffered(c);
remaining -= c;
}
if (count == Int32.MaxValue) {
const int chunk = 1024;
int done = buffer.GetByteCount();
int bytesRead;
do {
buffer.Append(_stream, chunk);
bytesRead = buffer.GetByteCount() - done;
done += bytesRead;
} while (bytesRead == chunk);
} else {
buffer.Append(_stream, remaining);
}
}
示例13: AppendOptionString
private static int AppendOptionString(MutableString/*!*/ result, RubyRegexOptions options, bool enabled, bool includeEncoding) {
int count = 0;
if (((options & RubyRegexOptions.Multiline) != 0) == enabled) {
result.Append('m');
count++;
}
if (((options & RubyRegexOptions.IgnoreCase) != 0) == enabled) {
result.Append('i');
count++;
}
if (((options & RubyRegexOptions.Extended) != 0) == enabled) {
result.Append('x');
count++;
}
if (includeEncoding) {
switch (options & RubyRegexOptions.EncodingMask) {
case RubyRegexOptions.NONE: break;
case RubyRegexOptions.EUC: result.Append('e'); break;
case RubyRegexOptions.FIXED: result.Append('n'); break;
case RubyRegexOptions.UTF8: result.Append('u'); break;
case RubyRegexOptions.SJIS: result.Append('s'); break;
default: throw Assert.Unreachable;
}
}
return count;
}
示例14: AppendEscapeForwardSlash
internal static MutableString/*!*/ AppendEscapeForwardSlash(MutableString/*!*/ result, MutableString/*!*/ pattern) {
int first = 0;
int i = SkipToUnescapedForwardSlash(pattern, 0);
while (i >= 0) {
Debug.Assert(i < pattern.Length);
Debug.Assert(pattern.GetChar(i) == '/' && (i == 0 || pattern.GetChar(i - 1) != '\\'));
result.Append(pattern, first, i - first);
result.Append('\\');
first = i; // include forward slash in the next append
i = SkipToUnescapedForwardSlash(pattern, i + 1);
}
result.Append(pattern, first, pattern.Length - first);
return result;
}
示例15: AppendLastCharOfLastMatchGroup
private static void AppendLastCharOfLastMatchGroup(MatchData/*!*/ match, MutableString/*!*/ result) {
int i = match.GroupCount - 1;
// move to last successful match group
while (i > 0 && !match.GroupSuccess(i)) {
i--;
}
if (i > 0 && match.GroupSuccess(i)) {
int length = match.GetGroupLength(i);
if (length > 0) {
result.Append(match.OriginalString, match.GetGroupStart(i) + length - 1, 1);
}
}
}