Example #1
0
        public void EqualsOperatorReturnsFalseIfTuplesContainDifferentItem2()
        {
            var tuple1 = new Tuple<string, int>("this is a test", 42);
            var tuple2 = new Tuple<string, int>("this is a test", 9);

            Assert.IsFalse(tuple1.Equals(tuple2));
        }
Example #2
0
        public void EqualsOperatorReturnsTrueIfTuplesComposedOfSamePieces()
        {
            var tuple1 = new Tuple<string, int>("this is a test", 42);
            var tuple2 = new Tuple<string, int>("this is a test", 42);

            Assert.IsTrue(tuple1.Equals(tuple2));
        }
Example #3
0
 public void OneNullOneNotSameData()
 {
     var one = new Tuple<string, string>("Hi", null);
     var two = new Tuple<string, string>("Hi", null);
     var equalsOutput = one.Equals(two);
     var operatorOutput = one == two;
     Assert.True(equalsOutput, "Different tuples with same values should compare to true");
     Assert.True(operatorOutput, "Different tuples with same values should compare to true");
 }
Example #4
0
 public void OneNullOneNotDifferentData()
 {
     var one = new Tuple<string, string>("Hi", null);
     var two = new Tuple<string, string>("Hi", "Hi");
     var equalsOutput = one.Equals(two);
     var operatorOutput = one == two;
     Assert.False(equalsOutput, "Different tuples with different values should compare to false");
     Assert.False(operatorOutput, "Different tuples with different values should compare to false");
 }
Example #5
0
 public void DifferentTripleCompare()
 {
     var tripleOne = new Tuple<int, int, int>(5, 5, 5);
     var tripleTwo = new Tuple<int, int, int>(5, 1, 5);
     var equalsOutput = tripleOne.Equals(tripleTwo);
     var operatorOutput = tripleOne == tripleTwo;
     Assert.False(equalsOutput, "Different tuples with different values should compare to false");
     Assert.False(operatorOutput, "Different tuples with different values should compare to false");
 }
        public void Test()
        {
            BinarySerializer serializer = new BinarySerializer();

            var message = new Tuple<string, string>("Name", "Cool");
            string subject = serializer.GetObjectSubject(message);
            var array = serializer.Serialize(message);

            var messageDeserialized = serializer.Deserialize(subject, array.Array, array.Offset, array.Count);

            Assert.That(message.Equals(messageDeserialized));
        }
Example #7
0
 static void Main(string[] args)
 {
     // a set of generic classes for holding a set of differently typed elements
     var t1 = new Tuple<int, string>(123, "Hello");
     Tuple<int, string> t2 = Tuple.Create(123, "Hello");
     var t3 = Tuple.Create(123, "Hello");
     Console.WriteLine(t1.Item1 * 2);
     Console.WriteLine(t2.Item2.ToUpper());
     Console.WriteLine(t1 == t2);
     // False for reference types
     Console.WriteLine(t1.Equals(t2));
     // True
 }
Example #8
0
		public void Sample()
		{
			// Создание кортежа
			var tuple = new Tuple<int, string, bool>(42, "abc", true);

			// Доступ к компонентам кортежа:
			Assert.That(tuple.Item1, Is.EqualTo(42));
			Assert.That(tuple.Item2, Is.EqualTo("abc"));
			Assert.That(tuple.Item3, Is.EqualTo(true));

			//Переопределенный ToString 
			Assert.That(tuple.ToString(), Is.EqualTo("(42, abc, True)"));

			// Переопределенный Equals сравнивает значения компонент кортежа
			var otherTuple = new Tuple<int, string, bool>(42, "abc", true);
			Assert.IsTrue(tuple.Equals(otherTuple));
		}
		public void OutputAndDebugWriter ()
		{
			//Interesting fact... Debug.Write(""); produces log entry
			//but Console.Write(""); does not

			InitializeTest ();
			AddBreakpoint ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
			var errorsList = new List<string> ();
			errorsList.Add ("ErrorText");
			var outputList = new HashSet<string> ();
			outputList.Add ("NormalText");
			var debugList = new List<Tuple<int,string,string>> ();
			debugList.Add (new Tuple<int,string,string> (0, "", "DebugText"));
			debugList.Add (new Tuple<int, string, string> (3, "SomeCategory", "DebugText2"));

			var unexpectedOutput = new List<string> ();
			var unexpectedError = new List<string> ();
			var unexpectedDebug = new List<Tuple<int,string,string>> ();

			Session.DebugWriter = delegate(int level, string category, string message) {
				var entry = new Tuple<int,string,string> (level, category, message);
				if (entry.Equals (new Tuple<int,string,string> (0, "", "")))//Sdb is emitting some empty messages :S 
					return;
				if (debugList.Contains (entry)) {
					debugList.Remove (entry);
				} else {
					unexpectedDebug.Add (entry);
				}
			};
			Session.OutputWriter = delegate(bool isStderr, string text) {
				if (isStderr) {
					if (errorsList.Contains (text))
						errorsList.Remove (text);
					else
						unexpectedError.Add (text);
				} else {
					if (outputList.Contains (text))
						outputList.Remove (text);
					else
						unexpectedOutput.Add (text);
				}
			};
			StartTest ("OutputAndDebugWriter");
			CheckPosition ("5070ed1c-593d-4cbe-b4fa-b2b0c7b25289");
			if (outputList.Count > 0)
				Assert.Fail ("Output list still has following items:" + string.Join (",", outputList));
			if (errorsList.Count > 0)
				Assert.Fail ("Error list still has following items:" + string.Join (",", errorsList));
			if (debugList.Count > 0)
				Assert.Fail ("Debug list still has following items:" + string.Join (",", debugList));
			if (unexpectedOutput.Count > 0)
				Assert.Fail ("Unexcpected Output list has following items:" + string.Join (",", unexpectedOutput));
			if (unexpectedError.Count > 0)
				Assert.Fail ("Unexcpected Error list has following items:" + string.Join (",", unexpectedError));
			if (unexpectedDebug.Count > 0)
				Assert.Fail ("Unexcpected Debug list has following items:" + string.Join (",", unexpectedDebug));
		}
Example #10
0
 public void SameTripleCompare()
 {
     var tripleOne = new Tuple<int, int, int>(5, 5, 5);
     var equalsOutput = tripleOne.Equals(tripleOne);
     var operatorOutput = tripleOne == tripleOne;
     Assert.True(equalsOutput, "Same tuple should compare to true");
     Assert.True(operatorOutput, "Same tuple should compare to true");
 }
Example #11
0
        private HashSet<List<Tuple<long, long>>> CheckNextVerticesOfLeftSide(ref IVertex myCurrentVertexLeft, ref Node myCurrentNodeLeft)
        {
            //get all referenced ObjectUUIDs using the given Edge
            var leftVertices = myCurrentVertexLeft.GetOutgoingEdge(_AttributeDefinition.ID).GetTargetVertices();

            #region check left friends
            foreach (var nextLeftVertex in leftVertices)
            {
                Node nextLeftNode = null;
                Tuple<long, long> nextLeft = new Tuple<long, long>(nextLeftVertex.VertexTypeID, nextLeftVertex.VertexID);

                #region if the child is the _Target
                if (nextLeft.Equals(_Target.Key))
                {
                    if (TargetFoundCheckAbort(nextLeft, ref myCurrentNodeLeft, ref nextLeftNode, nextLeftVertex))
                        return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
                }
                #endregion
                #region already visited from right side
                else if (_VisitedNodesRight.ContainsKey(nextLeft))
                {
                    if (VisitedByRightSide(nextLeft, ref myCurrentNodeLeft))
                        return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
                }
                #endregion already visited from right side
                #region already visited
                else if (_VisitedNodesLeft.ContainsKey(nextLeft))
                {
                    UpdateVisitedLeft(nextLeft, ref myCurrentNodeLeft);
                }
                #endregion already visited
                #region set as visited
                else
                {
                    SetAsVisitedLeft(nextLeft, ref myCurrentNodeLeft, ref nextLeftNode, nextLeftVertex);
                }
                #endregion set as visited
            }
            #endregion check left friends

            return null;
        }
Example #12
0
        /// <summary>
        /// Please look at the class documentation for detailed description how this algorithm works.
        /// </summary>
        /// <param name="myTypeAttribute">The Attribute representing the edge to follow (p.e. "Friends")</param>
        /// <param name="myVertexType">The type of the start node.</param>
        /// <param name="myStart">The start node</param>
        /// <param name="myEnd">The end node</param>
        /// <param name="shortestOnly">true, if only shortest path shall be found</param>
        /// <param name="findAll">if true and shortestOnly is true, all shortest paths will be found. 
        /// If true, and shortest only is false, all paths will be searched</param>
        /// <param name="myMaxDepth">The maximum depth to search</param>
        /// <param name="myMaxPathLength">The maximum path length which shall be analyzed</param>
        /// <returns>A HashSet which contains all found paths. Every path is represented by a List of ObjectUUIDs</returns>m>
        public HashSet<List<Tuple<long, long>>> Find(IAttributeDefinition myTypeAttribute,
            IVertexType myVertexType,
            IVertex myStart,
            IVertex myEnd,
            bool shortestOnly,
            bool findAll,
            UInt64 myMaxDepth,
            UInt64 myMaxPathLength)
        {
            #region declarations

            //set current depth
            _DepthLeft = 1;
            _DepthRight = 1;

            //maximum depth
            _MaxDepthLeft = 0;
            _MaxDepthRight = 0;

            _MaxPathLength = myMaxPathLength;

            #region initialize maxDepths

            //if the maxDepth is greater then maxPathLength, then set maxDepth to maxPathLength
            if (myMaxDepth > _MaxPathLength)
                myMaxDepth = _MaxPathLength;
            else if (_MaxPathLength > myMaxDepth)
                _MaxPathLength = myMaxDepth;

            //set depth for left side
            _MaxDepthLeft = Convert.ToUInt64(myMaxDepth / 2 + 1);

            //if myMaxDepth is 1 _MaxDepthRight keeps 0, just one side is searching
            if (myMaxDepth > 1)
                //both sides have the same depth
                _MaxDepthRight = _MaxDepthLeft;

            //if myMaxDepth is even, one side has to search in a greater depth
            if ((myMaxDepth % 2) == 0)
                _MaxDepthRight = Convert.ToUInt64(_MaxDepthLeft - 1);

            #endregion

            //shortest path length
            _ShortestPathLength = 0;

            //_Target node, the _Target of the select
            _Target = new Node(myEnd.VertexTypeID, myEnd.VertexID);
            _Root = new Node(myStart.VertexTypeID, myStart.VertexID);

            //the attribute (edge) which is used for the search
            _AttributeDefinition = myTypeAttribute;

            //search the type on which the attribute is defined
            IVertexType current = myVertexType;
            List<IVertexType> tempList = new List<IVertexType>();
            tempList.Add(current);

            bool foundDefinedType = false;

            while (current.HasParentType && !foundDefinedType)
            {
                if (current.ParentVertexType.HasAttribute(_AttributeDefinition.Name))
                {
                    foundDefinedType = true;
                }

                current = current.ParentVertexType;
                tempList.Add(current);
            }

            if (foundDefinedType)
                _Types = tempList;
            else
                _Types.Add(myVertexType);

            //dummy node to check in which level the BFS is
            _DummyLeft = null;
            _DummyRight = null;

            _FindAll = findAll;
            _ShortestOnly = shortestOnly;

            #endregion

            #region BidirectionalBFS
            //check if the EdgeType is ASetReferenceEdgeType

            #region initialize variables

            //enqueue start node to start from left side
            _QueueLeft.Enqueue(myStart);
            //enqueue _DummyLeft to analyze the depth of the left side
            _QueueLeft.Enqueue(_DummyLeft);

            //enqueue _Target node to start from right side
            _QueueRight.Enqueue(myEnd);
            //enqueue _DummyRight to analyze the depth of the right side
            _QueueRight.Enqueue(_DummyRight);

            //add _Root and _Target to visitedNodes
            _VisitedNodesLeft.Add(_Root.Key, _Root);
            _VisitedNodesRight.Add(_Target.Key, _Target);

            #endregion

            #region check if start has outgoing and _Target has incoming edge

            //check that the start node has the outgoing edge and the target has incoming vertices
            if (!myStart.HasOutgoingEdge(_AttributeDefinition.ID) && !HasIncomingVertices(myEnd))
            {
                return null;
            }

            #endregion

            //if there is more than one object in the queue and the actual depth is less than MaxDepth
            while (((_QueueLeft.Count > 0) && (_QueueRight.Count > 0)) &&
                   ((_DepthLeft <= _MaxDepthLeft) || (_DepthRight <= _MaxDepthRight)))
            {
                #region both queues contain objects and both depths are not reached
                if (((_QueueLeft.Count > 0) && (_QueueRight.Count > 0)) &&
                    ((_DepthLeft <= _MaxDepthLeft) && (_DepthRight <= _MaxDepthRight)))
                {
                    #region check if a level is completely searched

                    if (LeftLevelCompleted())
                        continue;

                    if (RightLevelCompleted())
                        continue;

                    #endregion check if there is a dummyNode at the beginning of a queue

                    #region get first nodes of the queues

                    //hold the actual element of the queues
                    Node currentNodeLeft;
                    Node currentNodeRight;

                    IVertex currentVertexLeft;
                    IVertex currentVertexRight;

                    Tuple<long, long> currentLeft;
                    Tuple<long, long> currentRight;

                    //get the first Object of the queue
                    currentVertexLeft = _QueueLeft.Dequeue();
                    currentLeft = new Tuple<long, long>(currentVertexLeft.VertexTypeID,
                                                        currentVertexLeft.VertexID);

                    if (_VisitedNodesLeft.ContainsKey(currentLeft))
                        currentNodeLeft = _VisitedNodesLeft[currentLeft];
                    else
                        currentNodeLeft = new Node(currentLeft);

                    //get the first Object of the queue
                    currentVertexRight = _QueueRight.Dequeue();
                    currentRight = new Tuple<long, long>(currentVertexRight.VertexTypeID,
                                                            currentVertexRight.VertexID);

                    if (_VisitedNodesRight.ContainsKey(currentRight))
                        currentNodeRight = _VisitedNodesRight[currentRight];
                    else
                        currentNodeRight = new Node(currentRight);

                    #endregion

                    #region the edge and the backwardedge are existing
                    if (currentVertexLeft.HasOutgoingEdge(_AttributeDefinition.ID)
                        && HasIncomingVertices(currentVertexRight))
                    {
                        //get all referenced ObjectUUIDs using the given Edge
                        var leftVertices = currentVertexLeft.GetOutgoingEdge(_AttributeDefinition.ID).GetTargetVertices();

                        #region check left friends
                        foreach (var nextLeftVertex in leftVertices)
                        {
                            Node nextLeftNode = null;
                            Tuple<long, long> nextLeft = new Tuple<long, long>(nextLeftVertex.VertexTypeID, nextLeftVertex.VertexID);

                            #region if the child is the _Target
                            if (nextLeft.Equals(_Target.Key))
                            {
                                if (TargetFoundCheckAbort(nextLeft, ref currentNodeLeft, ref nextLeftNode, nextLeftVertex))
                                    return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
                            }
                            #endregion
                            #region already visited
                            else if (_VisitedNodesLeft.ContainsKey(nextLeft))
                            {
                                UpdateVisitedLeft(nextLeft, ref currentNodeLeft);
                            }
                            #endregion already visited
                            #region set as visited
                            else
                            {
                                SetAsVisitedLeft(nextLeft, ref currentNodeLeft, ref nextLeftNode, nextLeftVertex);
                            }
                            #endregion set as visited
                        }
                        #endregion check left friends

                        //get all referenced ObjectUUIDs using the given Edge
                        var rightVertices = GetIncomingVertices(currentVertexRight);

                        #region check right friends
                        foreach (var nextRightVertex in rightVertices)
                        {
                            Node nextRightNode = null;
                            Tuple<long, long> nextRight = new Tuple<long, long>(nextRightVertex.VertexTypeID, nextRightVertex.VertexID);

                            #region if the child is the _Target
                            if (_Root.Key.Equals(nextRight))
                            {
                                if (RootFoundCheckAbort(nextRight, ref currentNodeRight, ref nextRightNode, nextRightVertex))
                                    return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
                            }
                            #endregion if the child is the _Target
                            #region already visited
                            else if (_VisitedNodesRight.ContainsKey(nextRight))
                            {
                                UpdateVisitedRight(nextRight, ref currentNodeRight);
                            }
                            #endregion already visited
                            #region set as visited
                            else
                            {
                                SetAsVisitedRight(nextRight, ref currentNodeRight, ref nextRightNode, nextRightVertex);
                            }
                            #endregion set as visited
                        }
                        #endregion check right friends

                        #region build intersection of _VisitedNodesLeft and _VisitedNodesRight
                        //marks if intersection nodes are existing
                        bool foundIntersect = false;

                        foreach (var node in _VisitedNodesLeft)
                        {
                            if (_VisitedNodesRight.ContainsKey(node.Key))
                            {
                                //set nodes children and parents
                                node.Value.addChildren(_VisitedNodesRight[node.Key].Children);
                                node.Value.addParents(_VisitedNodesRight[node.Key].Parents);

                                //set nodes children and parents
                                _VisitedNodesRight[node.Key].addChildren(node.Value.Children);
                                _VisitedNodesRight[node.Key].addParents(node.Value.Parents);

                                _IntersectNodes.Add(_VisitedNodesRight[node.Key]);

                                foundIntersect = true;
                            }
                        }
                        #endregion build intersection of _VisitedNodesLeft and _VisitedNodesRight

                        #region analyze intersection
                        //if intersection nodes existing
                        if (foundIntersect)
                        {
                            //only shortest path
                            if (_ShortestOnly && !_FindAll)
                            {
                                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                                {
                                    _ShortestPathLength = _MaxPathLength;
                                }
                                else
                                {
                                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                                }

                                //return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
                                return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll)
                                            .GetShortestPath(_IntersectNodes);
                            }
                            //if find all shortest paths
                            else if (_ShortestOnly && _FindAll)
                            {
                                //set maxDepth to actual depth
                                _MaxDepthLeft = _DepthLeft;
                                _MaxDepthRight = _DepthRight;

                                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                                {
                                    _ShortestPathLength = _MaxPathLength;
                                }
                                else if (_ShortestPathLength == 0)
                                {
                                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                                }

                            }
                        }
                        #endregion analyze intersection
                    }
                    #endregion the edge and the backwardedge are existing
                    #region only the edge exists
                    else if (currentVertexLeft.HasOutgoingEdge(_AttributeDefinition.ID))
                    {
                        var result = CheckNextVerticesOfLeftSide(ref currentVertexLeft, ref currentNodeLeft);

                        if (result != null)
                            return result;
                    }
                    #endregion only the edge exists
                    #region only the backwardedge exists
                    else if (HasIncomingVertices(currentVertexRight))
                    {
                        var result = CheckNextVerticesOfRightSide(ref currentVertexRight, ref currentNodeRight);

                        if (result != null)
                            return result;
                    }
                    #endregion only the backwardedge exists
                }
                #endregion  both queues contain objects and both depths are not reached
                #region only left queue contain objects
                else if ((_QueueLeft.Count > 0) && (_DepthLeft <= _MaxDepthLeft))
                {
                    #region check if first element of queue is a dummy

                    if (LeftLevelCompleted())
                        continue;

                    #endregion check if first element of queue is a dummy

                    #region get first nodes of the queues

                    //hold the actual element of the queues
                    Node currentNodeLeft;
                    IVertex currentVertexLeft;

                    //get the first Object of the queue
                    currentVertexLeft = _QueueLeft.Dequeue();
                    Tuple<long, long> currentLeft = new Tuple<long, long>(currentVertexLeft.VertexTypeID, currentVertexLeft.VertexID);

                    if (_VisitedNodesLeft.ContainsKey(currentLeft))
                        continue;

                    if (_VisitedNodesLeft.ContainsKey(currentLeft))
                        currentNodeLeft = _VisitedNodesLeft[currentLeft];
                    else
                        currentNodeLeft = new Node(currentLeft);

                    #endregion

                    #region check next vertices

                    if (currentVertexLeft.HasOutgoingEdge(_AttributeDefinition.ID))
                    {
                        var result = CheckNextVerticesOfLeftSide(ref currentVertexLeft, ref currentNodeLeft);

                        if (result != null)
                            return result;
                    }

                    #endregion
                }
                #endregion only left queue contain objects
                #region only right queue contain objects
                else if ((_QueueRight.Count > 0) && (_DepthRight <= _MaxDepthRight))
                {
                    #region check if first element of the queue is a dummy

                    if (RightLevelCompleted())
                        continue;

                    #endregion check if first element of the queue is a dummy

                    #region get first nodes of the queues

                    //hold the actual element of the queues
                    Node currentNodeRight;
                    IVertex currentVertexRight;

                    //get the first Object of the queue
                    currentVertexRight = _QueueRight.Dequeue();
                    Tuple<long, long> currentRight = new Tuple<long, long>(currentVertexRight.VertexTypeID, currentVertexRight.VertexID);

                    if (_VisitedNodesRight.ContainsKey(currentRight))
                        continue;

                    if (_VisitedNodesRight.ContainsKey(currentRight))
                        currentNodeRight = _VisitedNodesRight[currentRight];
                    else
                        currentNodeRight = new Node(currentRight);

                    #endregion

                    #region check next vertices

                    if (HasIncomingVertices(currentVertexRight))
                    {
                        var result = CheckNextVerticesOfRightSide(ref currentVertexRight, ref currentNodeRight);

                        if (result != null)
                            return result;
                    }

                    #endregion
                }
                #endregion only right queue contain objects
                #region abort loop

                else
                    break;

                #endregion abort loop
            }

            #region nothing found
            if (_ShortestOnly && !_FindAll)
                return null;
            #endregion

            //get result paths
            #region start TargetAnalyzer
            if (_ShortestOnly && _FindAll)
            {
                if (_ShortestPathLength > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }

                return new TargetAnalyzer(_Root, _Target, _ShortestPathLength, _ShortestOnly, _FindAll).GetPaths();
            }
            else
            {
                return new TargetAnalyzer(_Root, _Target, _MaxPathLength, _ShortestOnly, _FindAll).GetPaths();
            }
            #endregion start TargetAnalyzer

            #endregion BidirectionalBFS
        }
Example #13
0
        public void TupleEqualsNullReturnsFalse()
        {
            var testTuple = new Tuple<string, int>("this is a test", 42);

            Assert.IsFalse(testTuple.Equals(null));
        }
Example #14
0
        public void TupleEqualsItselfReturnsTrue()
        {
            var testTuple = new Tuple<string, int>("this is a test", 42);

            Assert.IsTrue(testTuple.Equals(testTuple));
        }
        protected override Tuple CalculateMro(Tuple baseClasses)
        {
            // should always be the same for ReflectedTypes
            Debug.Assert(baseClasses.Equals(BaseClasses));

            if (effectivePythonType != null) {
                return effectivePythonType.MethodResolutionOrder;
            } else {
                return base.CalculateMro(baseClasses);
            }
        }
        private void AfterPreAppStartExecute(Tuple<long, long> currentHash, Tuple<long, long> cachedTopLevelFilesHash) {
            bool gotLock = false;
            try {
                // Grab the compilation mutex, since this method accesses the codegen files
                CompilationLock.GetLock(ref gotLock);

                // After pre app start methods have executed, the second hash value should match the current value in the hash code combiner.
                CheckCodeGenFiles(currentHash.Item2, cachedTopLevelFilesHash.Item2);

                if (!cachedTopLevelFilesHash.Equals(currentHash)) {
                    // Hash has changed. Persist it to disk
                    _codeGenCache.SavePreservedSpecialFilesCombinedHash(currentHash);
                }

                // VSWhidbey 537929 : Setup a filechange monitor for the web.hash file. If this file is modified,
                // we will need to shutdown the appdomain so we don't use the obsolete assemblies. The new appdomain
                // will use the up-to-date assemblies.
                HttpRuntime.FileChangesMonitor.StartMonitoringFile(_webHashFilePath,
                    new FileChangeEventHandler(this.OnWebHashFileChange));
                Debug.Assert(File.Exists(_webHashFilePath), _webHashFilePath);
            }
            finally {
                // Always release the mutex if we had taken it
                if (gotLock) {
                    CompilationLock.ReleaseLock();
                }
            }
        }
Example #17
0
        /// <summary>
        /// Checks if the search should be aborted.
        /// </summary>
        /// <param name="myTuple">the Tuple of the current Vertex.</param>
        /// <param name="myCurrentNode">The current Node.</param>
        /// <param name="myNextNode">The next Node.</param>
        /// <param name="myVertex">The actual Vertex.</param>
        /// <returns>True, if the target is found AND the BFS could be finished. False, if the BFS should be continued.</returns>
        private bool TargetFoundCheckAbort(Tuple<long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            if (myTuple.Equals(_Target.Key))
            {
                //set currentLeft as parent of _Target
                _Target.addParent(myCurrentNode);

                #region check if already visited
                if (_VisitedNodesLeft.ContainsKey(myTuple))
                {
                    //set currentLeft as parent
                    _VisitedNodesLeft[myTuple].addParent(myCurrentNode);

                    //set currentNodeLeft as child
                    myCurrentNode.addChild(_VisitedNodesLeft[myTuple]);
                }
                else
                {
                    //create a new node and set currentLeft = parent
                    myNextNode = new Node(myTuple, myCurrentNode);

                    //set currentNodeLeft as child of currentLeft
                    myCurrentNode.addChild(myNextNode);

                    //never seen before
                    //mark the node as visited
                    _VisitedNodesLeft.Add(myNextNode.Key, myNextNode);

                    //and put node into the queue
                    _QueueLeft.Enqueue(myVertex);
                }

                #endregion

                #region check how much parents are searched

                if (_ShortestOnly && !_FindAll)
                {
                    if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                    }

                    return true;
                }
                //if find all shortest paths
                else if (_ShortestOnly && _FindAll)
                {
                    //set maxDepth to actual depth
                    _MaxDepthLeft = _DepthLeft;
                    _MaxDepthRight = _DepthRight;

                    if ((_DepthLeft + _DepthRight) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight);
                    }
                }

                #endregion
            }

            return false;
        }