Example #1
0
        private void ServerDescriptionChanged(object sender, ServerDescriptionChangedEventArgs args)
        {
            var oldClusterDescription = Description;
            ClusterDescription newClusterDescription = oldClusterDescription;

            var newServerDescription = args.NewServerDescription;

            if (newServerDescription.State == ServerState.Disconnected)
            {
                newClusterDescription = Description
                                        .WithServerDescription(newServerDescription);
            }
            else
            {
                var determinedClusterType = DetermineClusterType(newServerDescription);
                if (oldClusterDescription.Type == ClusterType.Unknown)
                {
                    newClusterDescription = newClusterDescription
                                            .WithType(determinedClusterType)
                                            .WithServerDescription(newServerDescription);
                }
                else if (determinedClusterType != oldClusterDescription.Type)
                {
                    newClusterDescription = newClusterDescription
                                            .WithoutServerDescription(newServerDescription.EndPoint);
                }
                else
                {
                    newClusterDescription = newClusterDescription
                                            .WithServerDescription(newServerDescription);
                }
            }

            UpdateClusterDescription(newClusterDescription);
        }