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


C# Location.Equals方法代码示例

本文整理汇总了C#中Location.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Location.Equals方法的具体用法?C# Location.Equals怎么用?C# Location.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: testEquals

        public void testEquals()
        {
            // Same UN locode - equal
            Assert.True(
                new Location(new UnLocode("ATEST"), "test-name", CET, CustomsZone.None).Equals(
                new Location(new UnLocode("ATEST"), "test-name", CET, CustomsZone.None)));

            // Different UN locodes - not equal
            Assert.False(
                new Location(new UnLocode("ATEST"), "test-name", CET, CustomsZone.None).Equals(
                new Location(new UnLocode("TESTB"), "test-name", CET, CustomsZone.None)));

            // Always equal to itself
            Location location = new Location(new UnLocode("ATEST"), "test-name", CET, CustomsZone.None);
            Assert.True(location.Equals(location));

            // Never equal to null
            Assert.False(location.Equals(null));

            // Special NONE location is equal to itself
            Assert.True(Location.None.Equals(Location.None));

            try
            {
                new Location(null, null, null, null);
                Assert.Fail("Should not allow any null constructor arguments");
            }
            catch(ArgumentException)
            {
            }
        }
开发者ID:awhatley,项目名称:dddsample.net,代码行数:31,代码来源:LocationTest.cs

示例2: check_that_the_Equals_method_works

        public void check_that_the_Equals_method_works()
        {
            Location loc1 = new Location(5, 6);
              Location loc2 = new Location(5, 6);
              Location loc3 = new Location(5, 5);
              Location loc4 = new Location(6, 5);

              Specify.That(loc1.Equals(loc2)).ShouldBeTrue();
              Specify.That(loc1.Equals(loc3)).ShouldBeFalse();
              Specify.That(loc1.Equals(loc4)).ShouldBeFalse();
              Specify.That(loc3.Equals(loc4)).ShouldBeFalse();
        }
开发者ID:iamjwc,项目名称:fightin-zigbees,代码行数:12,代码来源:location_test.cs

示例3: 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

示例4: CanCompareForEquality

		public void CanCompareForEquality()
		{
			Location loc1 = new Location(85.6789, 92.4517);
			Location loc2 = new Location(85.6789, 92.4517);

			Assert.True(loc1.Equals(loc2));
			Assert.Equal(loc1.GetHashCode(), loc2.GetHashCode());
		}
开发者ID:Virtualhurst,项目名称:Geocoding.net,代码行数:8,代码来源:LocationTest.cs

示例5: LocationEquals_CompareToNull_ReturnsFalse

        public void LocationEquals_CompareToNull_ReturnsFalse()
        {
            int x = 300;
            int y = 300;
            Location location1 = new Location(x, y);

            Assert.AreEqual(false, location1.Equals(null)); ;
        }
开发者ID:yurik256,项目名称:RobotCleaner,代码行数:8,代码来源:LocationTests.cs

示例6: LocationEquals_TwoObjectsDifferentCoordinates_ReturnsFalse

        public void LocationEquals_TwoObjectsDifferentCoordinates_ReturnsFalse()
        {
            int x = 300;
            int y = 300;
            Location location1 = new Location(x, y);
            Location location2 = new Location(x + 1, y);

            Assert.AreEqual(false, location1.Equals(location2)); ;
        }
开发者ID:yurik256,项目名称:RobotCleaner,代码行数:9,代码来源:LocationTests.cs

示例7: RouteSpecification

 public RouteSpecification(Location.Location origin, Location.Location destination, DateTime arrivalDeadline)
 {
     if (origin == null) throw new ArgumentNullException("origin");
     if (destination == null) throw new ArgumentNullException("destination");
     if (arrivalDeadline < DateTime.Now.AddDays(2)) throw new ArgumentException("arrivalDeadline should be greater than actual date by two days");
     if (origin.Equals(destination)) throw new ArgumentException("Origin and destination can't be the same: " + origin.Name);
     _origin = origin;
     _destination = destination;
     _arrivalDeadline = arrivalDeadline;
 }
开发者ID:midoI,项目名称:AutoMapperLib,代码行数:10,代码来源:RouteSpecification.cs

示例8: FindNextLocation

    public static Location FindNextLocation(Location start, Location dest, IGameState state)
    {
        if (start.Equals(dest) || !state.GetIsPassable(dest))
            return null;

        List<Location> list = FindPath(start, dest, state);
        if (list != null)
            return list[0];
        else
            return null;
    }
开发者ID:Lapixx,项目名称:CS-UU-KI2,代码行数:11,代码来源:Pathfinding.cs

示例9: FindNextLocation

    public static Location FindNextLocation(Location start, Location dest, IGameState state, List<Location> avoid, LayeredInfluenceMap heat)
    {
        if (start.Equals(dest) || !state.GetIsPassable(dest) || avoid.Contains(dest))
            return null;

        List<Location> list = FindPath(start, dest, state, avoid, heat);
        if (list != null)
            return list[0];
        else
            return null;
    }
开发者ID:Lapixx,项目名称:CS-UU-KI1,代码行数:11,代码来源:Pathfinding.cs

示例10: TestEquals

        public void TestEquals()
        {
            // Same UN locode - equal
            Assert.IsTrue(new Location(new UnLocode("ATEST"), "test-name").
                              Equals(new Location(new UnLocode("ATEST"), "test-name")));

            // Different UN locodes - not equal
            Assert.IsFalse(new Location(new UnLocode("ATEST"), "test-name").
                               Equals(new Location(new UnLocode("TESTB"), "test-name")));

            // Always equal to itself
            var location = new Location(new UnLocode("ATEST"), "test-name");
            Assert.IsTrue(location.Equals(location));

            // Never equal to null
            Assert.IsFalse(location.Equals(null));

            // Special UNKNOWN location is equal to itself
            Assert.IsTrue(Location.UNKNOWN.Equals(Location.UNKNOWN));

            new Location(null, null);
        }
开发者ID:chandmk,项目名称:esddd,代码行数:22,代码来源:LocationTest.cs

示例11: Program

        public Program()
        {
            State state = new State("map.txt"); // State
            Location start = new Location(1, 1);
            Location dest = new Location(3, 13);
            List<Location> avoid = new List<Location>();

            List<Location> closed, open;
            List<Location> path = Pathfinding.FindPath(start, dest, state, avoid, out closed, out open);
            //List<Location> path = Pathfinding.GetNeighbours(dest, state);

            if (path == null)
                path = new List<Location>();

            for (int y = 0; y < state.Height; y++)
            {
                for (int x = 0; x < state.Width; x++)
                {
                    if (start.Equals(new Location(y, x)))
                        Console.Write("S");
                    else if (dest.Equals(new Location(y, x)))
                        Console.Write("E");
                    else if (path.Contains(new Location(y, x)))
                        Console.Write("*");
                    else if (state.Map[y, x])
                        Console.Write("=");
                    else if (closed.Contains(new Location(y, x)))
                        Console.Write(" ");
                    else if (open.Contains(new Location(y, x)))
                        Console.Write("+");
                    else
                        Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.Write("Length = " + path.Count.ToString());
            Console.ReadLine();
        }
开发者ID:Lapixx,项目名称:CS-UU-KI1,代码行数:39,代码来源:Program.cs

示例12: checkPossibleWays

        private void checkPossibleWays(int movesLeft, Location position, Location previousPosition, List<Location> path)
        {
            path.Add(position);
            if (movesLeft == 0) {
                List<Location> onePath = createPath(path);
                endPositions.Add(onePath);
            } else {
                //To the right
                if (position.column + 1 != state.gridSize.Width && (
                    (state.types[position.row][position.column + 1] == (int)SquareType.Properties && state.values[position.row][position.column + 1] > 0) ||
                    (state.types[position.row][position.column + 1] != (int)SquareType.Properties)
                    )) {
                    Location p = new Location(position.column + 1, position.row);
                    //Makes sure to not add the square where it came from
                    if (previousPosition.Equals(p) == false) {
                        //In case it's a line.
                        if (state.types[position.row][position.column + 1] == (int)SquareType.Lines)
                            checkPossibleWays(movesLeft, p, position, path);
                        else
                            checkPossibleWays(movesLeft - 1, p, position, path);
                    }
                }

                //To the left
                if (position.column - 1 != -1 && (
                    (state.types[position.row][position.column - 1] == (int)SquareType.Properties && state.values[position.row][position.column - 1] > 0) ||
                    (state.types[position.row][position.column - 1] != (int)SquareType.Properties)
                    )) {
                    Location p = new Location(position.column - 1, position.row);
                    //Makes sure to not add the square where it came from
                    if (previousPosition.Equals(p) == false) {
                        //In case it's a line.
                        if (state.types[position.row][position.column - 1] == (int)SquareType.Lines)
                            checkPossibleWays(movesLeft, p, position, path);
                        else
                            checkPossibleWays(movesLeft - 1, p, position, path);
                    }
                }

                //Up
                if (position.row - 1 != -1 && (
                    (state.types[position.row - 1][position.column] == (int)SquareType.Properties && state.values[position.row - 1][position.column] > 0) ||
                    (state.types[position.row - 1][position.column] != (int)SquareType.Properties)
                    )) {

                    Location p = new Location(position.column, position.row - 1);
                    //Makes sure to not add the square where it came from
                    if (previousPosition.Equals(p) == false) {
                        //In case it's a line.
                        if (state.types[position.row - 1][position.column] == (int)SquareType.Lines)
                            checkPossibleWays(movesLeft, p, position, path);
                        else
                            checkPossibleWays(movesLeft - 1, p, position, path);
                    }
                }

                //Down
                if (position.row + 1 != state.gridSize.Height && (
                    (state.types[position.row + 1][position.column] == (int)SquareType.Properties && state.values[position.row + 1][position.column] > 0) ||
                    (state.types[position.row + 1][position.column] != (int)SquareType.Properties)
                    )) {

                    Location p = new Location(position.column, position.row + 1);
                    //Makes sure to not add the square where it came from
                    if (previousPosition.Equals(p) == false) {
                        //In case it's a line.
                        if (state.types[position.row + 1][position.column] == (int)SquareType.Lines)
                            checkPossibleWays(movesLeft, p, position, path);
                        else
                            checkPossibleWays(movesLeft - 1, p, position, path);
                    }
                }
            }
            path.RemoveAt(path.Count - 1);
        }
开发者ID:kelseyabreu,项目名称:CommandBoard,代码行数:75,代码来源:Form1.cs

示例13: FindPath

    // Returns a list of tiles that form the shortest path between start and dest
    public static List<Location> FindPath(Location start, Location dest, IGameState state, List<Location> avoid, LayeredInfluenceMap heat = null, int maxDepth = int.MaxValue)
    {
        if (start.Equals(dest) || !state.GetIsPassable(dest) || avoid.Contains(dest))
            return null;

        HashSet<string> closed = new HashSet<string>();
        Dictionary<string, PathfindNode> locToNode = new Dictionary<string, PathfindNode>();
        List<PathfindNode> open = new List<PathfindNode>();

        List<Location> reachable;

        PathfindNode first = new PathfindNode(start, null, dest, state, heat[start]);
        open.Add(first);
        locToNode.Add(MyBot.LocationToKey(first.Position), first);

        // Repeat until the destination node is reached
        PathfindNode last = null;
        while (open.Count > 0)
        {
            if (state.TimeRemaining < 10)
            {
                MyBot.LogShit("timeout.txt", "stop B - " + state.TimeRemaining);
                return null;
            }

            // Search the best available tile (lowest cost to reach from start, closest to dest)

            PathfindNode best = null;
            foreach (PathfindNode next in open)
            {
                if (best == null)
                    best = next;

                if (next.F < best.F)
                    best = next;
            }

            if (best.G > maxDepth)
                return null;

            //PathfindNode best = open.Min;

            // Move to closed list
            open.Remove(best);
            locToNode.Remove(MyBot.LocationToKey(best.Position));
            closed.Add(MyBot.LocationToKey(best.Position));

            if (best.Position.Equals(dest)) // Destination added to closed list - almost done!
            {
                last = best;
                break;
            }

            // Find tiles adjacent to this tile
            reachable = GetNeighbours(best.Position, state);
            string lid;
            PathfindNode pfn;
            foreach (Location next in reachable)
            {
                if (!state.GetIsPassable(next) || avoid.Contains(next)) // Check if tile is blocked
                    continue;

                lid = MyBot.LocationToKey(next);

                if (closed.Contains(lid))
                    continue;

                if(locToNode.ContainsKey(lid))
                {
                    pfn = locToNode[lid];
                    if (best.G + 1 < pfn.G)
                        pfn.Parent = best;
                }
                else{
                    pfn = new PathfindNode(next, best, dest, state, heat[next]);
                    open.Add(pfn);
                    locToNode.Add(lid, pfn);
                }
            }
        }

        if (last == null)
            return null;

        // Trace the route from destination to start (using each node's parent property)
        List<PathfindNode> route = new List<PathfindNode>();
        while (last != first && last != null)
        {
            route.Add(last);
            last = last.Parent;
        }

        // Reverse route and convert to Points
        List<Location> path = new List<Location>();
        for (int i = route.Count - 1; i >= 0; i--)
        {
            path.Add(route[i].Position);
        }

//.........这里部分代码省略.........
开发者ID:Lapixx,项目名称:CS-UU-KI1,代码行数:101,代码来源:Pathfinding.cs

示例14: OnViewportChanged

        protected override void OnViewportChanged()
        {
            var bounds = ParentMap.ViewportTransform.Inverse.TransformBounds(new Rect(new Point(), ParentMap.RenderSize));
            var start = ParentMap.MapTransform.Transform(new Point(bounds.X, bounds.Y));
            var end = ParentMap.MapTransform.Transform(new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height));
            var minSpacing = MinLineSpacing * 360d / (Math.Pow(2d, ParentMap.ZoomLevel) * 256d);
            var spacing = LineSpacings[LineSpacings.Length - 1];

            if (spacing >= minSpacing)
            {
                spacing = LineSpacings.FirstOrDefault(s => s >= minSpacing);
            }

            var labelStart = new Location(
                Math.Ceiling(start.Latitude / spacing) * spacing,
                Math.Ceiling(start.Longitude / spacing) * spacing);

            var labelEnd = new Location(
                Math.Floor(end.Latitude / spacing) * spacing,
                Math.Floor(end.Longitude / spacing) * spacing);

            var lineStart = new Location(
                Math.Min(Math.Max(labelStart.Latitude - spacing, -ParentMap.MapTransform.MaxLatitude), ParentMap.MapTransform.MaxLatitude),
                labelStart.Longitude - spacing);

            var lineEnd = new Location(
                Math.Min(Math.Max(labelEnd.Latitude + spacing, -ParentMap.MapTransform.MaxLatitude), ParentMap.MapTransform.MaxLatitude),
                labelEnd.Longitude + spacing);

            if (!lineStart.Equals(graticuleStart) || !lineEnd.Equals(graticuleEnd))
            {
                graticuleStart = lineStart;
                graticuleEnd = lineEnd;

                var geometry = (PathGeometry)path.Data;
                geometry.Figures.Clear();
                geometry.Transform = ParentMap.ViewportTransform;

                for (var lat = labelStart.Latitude; lat <= end.Latitude; lat += spacing)
                {
                    var figure = new PathFigure
                    {
                        StartPoint = ParentMap.MapTransform.Transform(new Location(lat, lineStart.Longitude)),
                        IsClosed = false,
                        IsFilled = false
                    };

                    figure.Segments.Add(new LineSegment
                    {
                        Point = ParentMap.MapTransform.Transform(new Location(lat, lineEnd.Longitude)),
                    });

                    geometry.Figures.Add(figure);
                }

                for (var lon = labelStart.Longitude; lon <= end.Longitude; lon += spacing)
                {
                    var figure = new PathFigure
                    {
                        StartPoint = ParentMap.MapTransform.Transform(new Location(lineStart.Latitude, lon)),
                        IsClosed = false,
                        IsFilled = false
                    };

                    figure.Segments.Add(new LineSegment
                    {
                        Point = ParentMap.MapTransform.Transform(new Location(lineEnd.Latitude, lon)),
                    });

                    geometry.Figures.Add(figure);
                }

                var childIndex = 1; // 0 for Path
                var format = spacing < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";

                for (var lat = labelStart.Latitude; lat <= end.Latitude; lat += spacing)
                {
                    for (var lon = labelStart.Longitude; lon <= end.Longitude; lon += spacing)
                    {
                        TextBlock label;

                        if (childIndex < Children.Count)
                        {
                            label = (TextBlock)Children[childIndex];
                        }
                        else
                        {
                            var renderTransform = new TransformGroup();
                            renderTransform.Children.Add(new TranslateTransform());
                            renderTransform.Children.Add(ParentMap.RotateTransform);
                            renderTransform.Children.Add(new TranslateTransform());

                            label = new TextBlock
                            {
                                RenderTransform = renderTransform
                            };

                            label.SetBinding(TextBlock.ForegroundProperty, new Binding
                            {
                                Source = this,
//.........这里部分代码省略.........
开发者ID:huoxudong125,项目名称:XamlMapControl,代码行数:101,代码来源:MapGraticule.Silverlight.WinRT.cs

示例15: IsAdjacentLocation

 /// <summary>
 /// Determines whether the specified location is adjacent to this instance.
 /// That is, whether it is located one point to the left, right, above, or below.
 /// </summary>
 /// <param name="location">The location.</param>
 /// <returns>
 /// 	<c>true</c> if the specified location is adjacent; otherwise, <c>false</c>.
 /// </returns>
 public bool IsAdjacentLocation(Location location)
 {
     return !location.Equals(this)
            && ((ColumnNumber == location.ColumnNumber
                 && RowNumber <= location.RowNumber + 1
                 && RowNumber >= location.RowNumber - 1)
                ||
                (RowNumber == location.RowNumber
                 && ColumnNumber <= location.ColumnNumber + 1
                 && ColumnNumber >= location.ColumnNumber - 1)
               );
 }
开发者ID:NCCUCS-Windows-Programming,项目名称:MikeWazowski-Comeback,代码行数:20,代码来源:Location.cs


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