private static void HandleLink(SynchronizationTopology topology, SynchronizationTopologyNodeBase source, SynchronizationTopologyNodeBase target)
        {
            topology.Servers.Add(source.ServerUrl);
            topology.Servers.Add(target.ServerUrl);

            SynchronizationTopologyConnection connection = null;

            if (target is SynchronizationTopologyDestinationNode)
            {
                var destinationNode = (SynchronizationTopologyDestinationNode)target;
                // going to destination
                connection             = topology.GetConnection(source.ServerUrl, target.ServerUrl) ?? new SynchronizationTopologyConnection();
                connection.Source      = source.ServerUrl;
                connection.Destination = target.ServerUrl;
                connection.SourceToDestinationState = destinationNode.State;
                connection.SendServerId             = destinationNode.SendServerId;
                connection.Errors = destinationNode.Errors;
            }
            else if (target is SynchronizationTopologySourceNode)
            {
                // going to source
                var sourceNode = (SynchronizationTopologySourceNode)target;
                connection             = topology.GetConnection(target.ServerUrl, source.ServerUrl) ?? new SynchronizationTopologyConnection();
                connection.Source      = target.ServerUrl;
                connection.Destination = source.ServerUrl;
                connection.DestinationToSourceState = sourceNode.State;
                connection.StoredServerId           = sourceNode.StoredServerId;
                connection.LastSourceFileEtag       = sourceNode.LastSourceFileEtag;
            }

            topology.Connections.Add(connection);
        }
        private void HandleLink(SynchronizationTopology topology, SynchronizationTopologyNodeBase source, SynchronizationTopologyNodeBase target)
        {
            SynchronizationTopologyConnection connection = null;

            if (target is SynchronizationTopologyDestinationNode)
            {
                var destinationNode = (SynchronizationTopologyDestinationNode)target;
                // going to destination

                var sourceServerId = destinationNode.SendServerId;
                var sourceUrl      = AddToCache(sourceServerId, source.ServerUrl);

                var destinationId = GetResourceId(destinationNode.DestinationServerId, destinationNode.ServerUrl);
                var targetUrl     = AddToCache(destinationId, destinationNode.ServerUrl);

                connection = topology.GetConnection(sourceServerId, destinationId, sourceUrl, targetUrl);
                if (connection == null)
                {
                    connection = new SynchronizationTopologyConnection();
                    topology.Connections.Add(connection);
                }

                connection.SendServerId        = destinationNode.SendServerId;
                connection.DestinationServerId = destinationId;
                connection.SourceUrl.Add(source.ServerUrl);
                connection.DestinationUrl.Add(target.ServerUrl);
                connection.SourceToDestinationState = destinationNode.State;
                connection.Errors = destinationNode.Errors;

                //left for backward compatibility with v3.0
                connection.Source      = sourceUrl;
                connection.Destination = targetUrl;
            }
            else if (target is SynchronizationTopologySourceNode)
            {
                // going to source
                var sourceNode     = (SynchronizationTopologySourceNode)target;
                var sourceServerId = sourceNode.StoredServerId;
                var sourceUrl      = AddToCache(sourceServerId, target.ServerUrl);

                var destinationId = GetResourceId(sourceNode.DestinationServerId, source.ServerUrl);
                var targetUrl     = AddToCache(destinationId, source.ServerUrl);

                connection = topology.GetConnection(sourceServerId, destinationId, sourceUrl, targetUrl);
                if (connection == null)
                {
                    connection = new SynchronizationTopologyConnection();
                    topology.Connections.Add(connection);
                }

                connection.StoredServerId      = sourceServerId;
                connection.DestinationServerId = destinationId;
                connection.SourceUrl.Add(target.ServerUrl);
                connection.DestinationUrl.Add(source.ServerUrl);
                connection.DestinationToSourceState = sourceNode.State;
                connection.LastSourceFileEtag       = sourceNode.LastSourceFileEtag;

                //left for backward compatibility with v3.0
                connection.Source      = sourceUrl;
                connection.Destination = targetUrl;
            }

            topology.Connections.Add(connection);
        }