本文整理汇总了C#中StringSegment.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# StringSegment.Equals方法的具体用法?C# StringSegment.Equals怎么用?C# StringSegment.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSegment
的用法示例。
在下文中一共展示了StringSegment.Equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: HasPropertyRef
/// <summary>
/// Gets a value indicating whether the string has the specified property.
/// </summary>
/// <param name="prop">The name of the property to evaluate.</param>
/// <returns><c>true</c> if the string has the specified property; otherwise, <c>false</c>.</returns>
public Boolean HasPropertyRef(ref StringSegment prop)
{
foreach (var kvp in properties)
{
if (prop.Equals(kvp.Key))
{
return true;
}
}
return false;
}
示例3: MatchVariantInternal
/// <summary>
/// Matches a source string to a target variant according to the specified culture and rule.
/// </summary>
private static String MatchVariantInternal(String culture, LocalizedString source, LocalizedStringVariant target, StringSegment rule)
{
Dictionary<String, LocalizationMatchEvaluator> registry;
if (!registeredMatchEvaluators.TryGetValue(culture, out registry))
return null;
foreach (var kvp in registry)
{
if (rule.Equals(kvp.Key))
{
return (kvp.Value == null) ? null : kvp.Value(source, target);
}
}
return null;
}
示例4: StringSegment_EqualsStringSegment_Invalid
public void StringSegment_EqualsStringSegment_Invalid()
{
// Arrange
var segment = new StringSegment();
var candidate = new StringSegment("Hello, World!", 3, 2);
// Act
var result = segment.Equals(candidate, StringComparison.Ordinal);
// Assert
Assert.False(result);
}
示例5: StringSegment_Equals_String_Valid
public void StringSegment_Equals_String_Valid(StringSegment candidate, StringComparison comparison, bool expectedResult)
{
// Arrange
var segment = new StringSegment("Hello, World!", 1, 4);
// Act
var result = segment.Equals(candidate, comparison);
// Assert
Assert.Equal(expectedResult, result);
}
示例6: StringSegment_EqualsString_Invalid
public void StringSegment_EqualsString_Invalid()
{
// Arrange
var segment = new StringSegment();
// Act
var result = segment.Equals(string.Empty, StringComparison.Ordinal);
// Assert
Assert.False(result);
}
示例7: HasPropertyRef
/// <summary>
/// Gets a value indicating whether the string variant has the specified property.
/// </summary>
/// <param name="prop">The name of the property to evaluate.</param>
/// <returns><see langword="true"/> if the string variant has the specified property; otherwise, <see langword="false"/>.</returns>
public Boolean HasPropertyRef(ref StringSegment prop)
{
foreach (var property in properties)
{
if (prop.Equals(property))
return true;
}
return parent.HasPropertyRef(ref prop);
}
示例8: GetVariant
/// <summary>
/// Gets the specified string variant.
/// </summary>
/// <param name="group">The name of the variant group of the variant to retrieve.</param>
/// <returns>The specified string variant.</returns>
public LocalizedStringVariant GetVariant(ref StringSegment group)
{
foreach (var kvp in variants)
{
if (group.Equals(kvp.Key))
{
return kvp.Value;
}
}
return null;
}
示例9: EqualsString
public void EqualsString(string content, string content2, bool expected)
{
var segment = new StringSegment(content);
Assert.Equal(expected, segment.Equals(content2));
}
示例10: TestEquals
public void TestEquals(string content)
{
var segment = new StringSegment(content);
Assert.True(segment.Equals(segment));
}