本文整理汇总了C#中StringSegment类的典型用法代码示例。如果您正苦于以下问题:C# StringSegment类的具体用法?C# StringSegment怎么用?C# StringSegment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringSegment类属于命名空间,在下文中一共展示了StringSegment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FormatFilter_ContextContainsFormat_DefaultFormat
public void FormatFilter_ContextContainsFormat_DefaultFormat(
string format,
FormatSource place,
string contentType)
{
// Arrange
var mediaType = new StringSegment("application/json");
var mockObjects = new MockObjects(format, place);
var resultExecutingContext = mockObjects.CreateResultExecutingContext();
var resourceExecutingContext = mockObjects.CreateResourceExecutingContext(new IFilterMetadata[] { });
var filter = new FormatFilter(mockObjects.OptionsManager);
// Act
filter.OnResourceExecuting(resourceExecutingContext);
// Assert
Assert.Null(resourceExecutingContext.Result);
// Act
filter.OnResultExecuting(resultExecutingContext);
// Assert
var objectResult = Assert.IsType<ObjectResult>(resultExecutingContext.Result);
Assert.Equal(1, objectResult.ContentTypes.Count);
MediaTypeAssert.Equal(mediaType, objectResult.ContentTypes[0]);
}
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:28,代码来源:FormatFilterTest.cs
示例2: StringSource
/// <summary>
/// Initializes a new instance of the <see cref="StringSource"/> structure.
/// </summary>
/// <param name="segment">The <see cref="StringSegment"/> that contains the string data.</param>
public StringSource(StringSegment segment)
{
this.str = segment.SourceString;
this.builder = segment.SourceStringBuilder;
this.Start = segment.Start;
this.Length = segment.Length;
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:11,代码来源:StringSource.cs
示例3: Null
public void Null()
{
var segment = new StringSegment(null);
Assert.Equal(0, segment.Length);
Assert.True(segment.IsEmpty);
Assert.True(segment.IsNull);
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:7,代码来源:StringSegmentFacts.cs
示例4: Empty
public void Empty()
{
var segment = new StringSegment("");
Assert.Equal(0, segment.Length);
Assert.True(segment.IsEmpty);
Assert.False(segment.IsNull);
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:7,代码来源:StringSegmentFacts.cs
示例5: StringSegment_IndexOfString_ReturnsNegativeOneForNonExistingCharacter
public void StringSegment_IndexOfString_ReturnsNegativeOneForNonExistingCharacter()
{
var segment = new StringSegment("Hello, world!");
var result = segment.IndexOf("zorld");
TheResultingValue(result).ShouldBe(-1);
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:7,代码来源:StringSegmentTest.cs
示例6: StringSegment_IndexOfString_ReturnsCorrectValueForExistingCharacter
public void StringSegment_IndexOfString_ReturnsCorrectValueForExistingCharacter()
{
var segment = new StringSegment("Hello, world!");
var result = segment.IndexOf("world");
TheResultingValue(result).ShouldBe(7);
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:7,代码来源:StringSegmentTest.cs
示例7: TryParseHexadecimalInt32
/// <summary>
/// Converts the hexadecimal text of the specified <see cref="StringSegment"/> to an
/// instance of <see cref="Int32"/> if possible.
/// </summary>
/// <param name="segment">The string segment to convert.</param>
/// <param name="result">The converted value.</param>
/// <returns><see langword="true"/> if the conversion succeeded; otherwise, <see langword="false"/>.</returns>
public static Boolean TryParseHexadecimalInt32(StringSegment segment, out Int32 result)
{
var spaceCountLeading = CountLeadingSpace(ref segment);
var spaceCountTrailing = CountTrailingSpace(ref segment);
var valueStart = spaceCountLeading;
var valueLength = segment.Length - (spaceCountLeading + spaceCountTrailing);
var magnitude = (Int64)Math.Pow(16, valueLength - 1);
var digit = 0;
var total = 0L;
for (int i = 0; i < valueLength; i++)
{
if (!ConvertHexadecimalDigit(segment[valueStart + i], out digit))
{
result = 0;
return false;
}
total += (magnitude * digit);
magnitude /= 16;
}
if (total > Int32.MaxValue)
throw new OverflowException();
result = (Int32)total;
return true;
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:36,代码来源:StringSegmentConversion.cs
示例8: CharReaderShouldReadToCharacter
public void CharReaderShouldReadToCharacter()
{
StringSegment source = new StringSegment("abc:123");
CharReader reader = new CharReader(source);
reader.ReadTo(':', false);
Assert.Equal(3, reader.Position);
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:7,代码来源:CharReaderFacts.cs
示例9: CharReaderFromSegment
public void CharReaderFromSegment()
{
var segment = new StringSegment(TestContent);
var reader = new CharReader(segment);
Assert.False(reader.IsDone);
Assert.Equal(-1, reader.Position);
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:7,代码来源:CharReaderFacts.cs
示例10: DefaultConstructor
public void DefaultConstructor()
{
var segment = new StringSegment();
Assert.Equal(0, segment.Length);
Assert.True(segment.IsEmpty);
Assert.True(segment.IsNull);
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:8,代码来源:StringSegmentFacts.cs
示例11: StringSegment_CanBeCreatedFromString
public void StringSegment_CanBeCreatedFromString()
{
var source = "Hello, world!";
var segment = new StringSegment(source, 2, 4);
TheResultingString(segment.ToString())
.ShouldBe("llo,");
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:8,代码来源:StringSegmentTest.cs
示例12: TextParserToken
/// <summary>
/// Initializes a new instance of the <see cref="TextParserToken"/> structure.
/// </summary>
/// <param name="tokenType">The token's type.</param>
/// <param name="text">The token's text.</param>
/// <param name="sourceOffset">The offset of the first character in the source text that produced this token.</param>
/// <param name="sourceLength">The number of characters in the source text that produced this token.</param>
/// <param name="isNonBreakingSpace">A value indicating whether this token represents a non-breaking space.</param>
internal TextParserToken(TextParserTokenType tokenType, StringSegment text, Int32 sourceOffset, Int32 sourceLength, Boolean isNonBreakingSpace = false)
{
this.tokenType = tokenType;
this.text = text;
this.sourceOffset = sourceOffset;
this.sourceLength = sourceLength;
this.isNonBreakingSpace = isNonBreakingSpace;
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:16,代码来源:TextParserToken.cs
示例13: StringFormatterCommandInfo
/// <summary>
/// Initializes a new instance of the <see cref="StringFormatterCommandInfo"/> structure.
/// </summary>
/// <param name="commandName">The name of the command being handled.</param>
/// <param name="commandArgs">The command's argument list.</param>
/// <param name="commandHandler">The command's handler.</param>
public StringFormatterCommandInfo(StringSegment commandName,
StringFormatterCommandArguments commandArgs,
StringFormatterCommandHandler commandHandler)
{
this.CommandName = commandName;
this.CommandArguments = commandArgs;
this.CommandHandler = commandHandler;
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:14,代码来源:StringFormatterCommandInfo.cs
示例14: NoRunFactories
public void NoRunFactories()
{
WikiRunParser parser = new WikiRunParser(Enumerable.Empty<WikiRunFactory>());
StringSegment text = new StringSegment("we're");
List<WikiRun> runs = parser.Parse(text).ToList();
Assert.AreEqual(1, runs.Count);
Assert.AreEqual("we're", ((TextWikiRun) runs[0]).Text);
}
开发者ID:ejball,项目名称:EdgeWiki,代码行数:8,代码来源:WikiRunParserTests.cs
示例15: ParseUInt32
public static UInt32 ParseUInt32(StringSegment segment)
{
UInt32 value;
if (!TryParseUInt32(segment, out value))
throw new FormatException();
return value;
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:StringSegmentConversion.cs
示例16: EqualMatchesEntireSubstring
public void EqualMatchesEntireSubstring()
{
var segment = new StringSegment("abcdefghij", 2, 6);
segment.Equals("cdefgh", StringComparison.Ordinal).ShouldBe(true);
segment.Equals("cdefg", StringComparison.Ordinal).ShouldBe(false);
segment.Equals("cdefghi", StringComparison.Ordinal).ShouldBe(false);
segment.Equals("cDefgh", StringComparison.Ordinal).ShouldBe(false);
segment.Equals("cDefgh", StringComparison.OrdinalIgnoreCase).ShouldBe(true);
}
开发者ID:owin,项目名称:museum-piece-owin-hosting,代码行数:9,代码来源:StringSegmentTests.cs
示例17: TextLayoutToken
/// <summary>
/// Initializes a new instance of the <see cref="TextLayoutToken"/> structure.
/// </summary>
/// <param name="text">The token's text.</param>
/// <param name="bounds">The token's bounds relative to its layout region.</param>
/// <param name="fontFace">The token's font face.</param>
/// <param name="icon">The token's icon.</param>
/// <param name="glyphShader">The token's glyph shader.</param>
/// <param name="color">The token's color.</param>
internal TextLayoutToken(StringSegment text, Rectangle bounds, SpriteFontFace fontFace, TextIconInfo? icon, GlyphShader glyphShader, Color? color)
{
this.text = text;
this.bounds = bounds;
this.fontFace = fontFace;
this.icon = icon;
this.glyphShader = glyphShader;
this.color = color;
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:18,代码来源:TextLayoutToken.cs
示例18: FindRunInText
private WikiRun FindRunInText(StringSegment text)
{
Match match = text.Match(m_regex);
for (int runFactoryIndex = 0; runFactoryIndex < m_runFactories.Count; runFactoryIndex++)
if (match.Groups["z" + runFactoryIndex].Success)
return m_runFactories[runFactoryIndex].Parse(text, match);
return null;
}
开发者ID:ejball,项目名称:EdgeWiki,代码行数:9,代码来源:WikiRunParser.cs
示例19: StringSegment_StringCtor_AllowsNullBuffers
public void StringSegment_StringCtor_AllowsNullBuffers()
{
// Arrange & Act
var segment = new StringSegment(null);
// Assert
Assert.False(segment.HasValue);
Assert.Equal(0, segment.Offset);
Assert.Equal(0, segment.Length);
}
开发者ID:leloulight,项目名称:Common,代码行数:10,代码来源:StringSegmentTest.cs
示例20: BodyFromStringSegmentShouldHaveMatchingText
public void BodyFromStringSegmentShouldHaveMatchingText()
{
string s = "abcHello, worlddef";
string bText = "Hello, world";
StringSegment ss = new StringSegment(s, 3, 14);
Body b = new Body(ss);
Assert.Equal(bText, b.Text);
Assert.Equal(bText, b.SourceText.ToString());
Assert.Equal(bText, b.ToString());
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:10,代码来源:BodyFacts.cs
注:本文中的StringSegment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论