本文整理汇总了C#中Location.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Location.Clone方法的具体用法?C# Location.Clone怎么用?C# Location.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: locationXYRegionHandle
public void locationXYRegionHandle()
{
Location TestLocation1 = new Location(256000,256000);
Location TestLocation2 = new Location(1099511628032000);
Assert.That(TestLocation1 == TestLocation2);
Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided");
Assert.That(TestLocation2.RegionHandle == 1099511628032000,
"Location RegionHandle Property didn't match regionhandle provided in constructor");
TestLocation1 = new Location(256001, 256001);
TestLocation2 = new Location(1099511628032000);
Assert.That(TestLocation1 != TestLocation2);
Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor");
Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode");
Location TestLocation3;
object cln = TestLocation2.Clone();
TestLocation3 = (Location) cln;
Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y,
"Cloned Location values do not match");
Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test");
}
示例2: ParseDirectiveLine
/// <summary>
/// Parses a line containing a directive reference.
/// </summary>
/// <param name="parser">The parser.</param>
/// <param name="nameExpression">The regular expression to match the name of the directive.</param>
/// <param name="line">The line containing the directive.</param>
/// <param name="location">The location of the directive.</param>
/// <returns>A <see cref="DirectiveInfo"/> instance containing information about the directive, or <c>null</c> if the directive does not match the expression.</returns>
private static DirectiveInfo ParseDirectiveLine(Parser parser, string nameExpression, string line, Location location)
{
Regex re = new Regex("^#(?<name>" + nameExpression + ")(\\s+(?<params>.*))?$", RegexOptions.ExplicitCapture);
var match = re.Match(line);
if(!match.Success) {
return null;
}
var name = match.Groups["name"].Value;
var parametersText = match.Groups["params"].Value;
var parametersLocation = location.Clone();
parametersLocation.AdvanceString(line.Substring(0, match.Groups["params"].Index));
var parametersReader = new LocatedTextReaderWrapper(parametersText, parametersLocation);
return new DirectiveInfo {
Parser = parser,
Location = location,
DirectiveName = name,
ParametersReader = parametersReader
};
}
示例3: KioskLocation
/// <summary>
/// Initializes a new instance of the <see cref="KioskLocation" /> class.
/// </summary>
/// <param name="location">The location.</param>
public KioskLocation( Location location )
: base()
{
Location = location.Clone( false );
KioskSchedules = new List<KioskSchedule>();
}
示例4: ParseDirectiveLine
/// <summary>
/// Parses a line containing a directive reference.
/// </summary>
/// <param name="nameExpression">The regular expression to match the name of the directive.</param>
/// <param name="line">The line containing the directive.</param>
/// <param name="location">The location of the directive.</param>
/// <param name="parameterReader">The reader of the parsed directive parameters.</param>
/// <param name="directiveName">The parsed name of the directive.</param>
/// <returns>True if the directive was successfully parsed; otherwise, false.</returns>
private static bool ParseDirectiveLine(string nameExpression, string line, Location location, out ITokenReader parameterReader, out string directiveName)
{
parameterReader = null;
directiveName = null;
Regex re = new Regex("^#(?<name>" + nameExpression + ")(\\s+(?<params>.*))?$", RegexOptions.ExplicitCapture);
var match = re.Match(line);
if(!match.Success) {
return false;
}
directiveName = match.Groups["name"].Value;
var parametersText = match.Groups["params"].Value;
var parametersLocation = location.Clone();
parametersLocation.AdvanceString(line.Substring(0, match.Groups["params"].Index));
var parametersReader = new LocatedTextReaderWrapper(parametersText, parametersLocation);
parameterReader = new TokenReader(parametersReader);
return true;
}