当前位置: 首页>>代码示例>>C#>>正文


C# Location.Clone方法代码示例

本文整理汇总了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");

        }
开发者ID:justasabc,项目名称:opensim75,代码行数:29,代码来源:LocationTest.cs

示例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
            };
        }
开发者ID:peppy,项目名称:osq2osb,代码行数:33,代码来源:DirectiveNode.cs

示例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>();
 }
开发者ID:tcavaletto,项目名称:Rock-CentralAZ,代码行数:10,代码来源:KioskLocation.cs

示例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;
        }
开发者ID:strager,项目名称:osq2osb,代码行数:33,代码来源:DirectiveNode.cs


注:本文中的Location.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。