GetPrimaryAndSecondaries() public method

Gets a list of primary and secondary instances.
public GetPrimaryAndSecondaries ( ) : List
return List
        // protected methods
        protected override MongoServerInstance ChooseServerInstance(ConnectedInstanceCollection connectedInstances, ReadPreference readPreference)
        {
            var secondaryAcceptableLatency = Server.Settings.SecondaryAcceptableLatency;

            switch (readPreference.ReadPreferenceMode)
            {
            case ReadPreferenceMode.Primary:
                return(connectedInstances.GetPrimary());

            case ReadPreferenceMode.PrimaryPreferred:
                var primary = connectedInstances.GetPrimary();
                if (primary != null)
                {
                    return(primary);
                }
                else
                {
                    return(GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency));
                }

            case ReadPreferenceMode.Secondary:
                return(GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency));

            case ReadPreferenceMode.SecondaryPreferred:
                var secondary = GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency);
                if (secondary != null)
                {
                    return(secondary);
                }
                else
                {
                    return(connectedInstances.GetPrimary());
                }

            case ReadPreferenceMode.Nearest:
                return(GetMatchingInstance(connectedInstances.GetPrimaryAndSecondaries(), readPreference, secondaryAcceptableLatency));

            default:
                throw new MongoInternalException("Invalid ReadPreferenceMode.");
            }
        }
        // protected methods
        protected override MongoServerInstance ChooseServerInstance(ConnectedInstanceCollection connectedInstances, ReadPreference readPreference)
        {
            var secondaryAcceptableLatency = Settings.SecondaryAcceptableLatency;

            switch (readPreference.ReadPreferenceMode)
            {
                case ReadPreferenceMode.Primary:
                    return connectedInstances.GetPrimary();

                case ReadPreferenceMode.PrimaryPreferred:
                    var primary = connectedInstances.GetPrimary();
                    if (primary != null)
                    {
                        return primary;
                    }
                    else
                    {
                        return GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency);
                    }

                case ReadPreferenceMode.Secondary:
                    return GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency);

                case ReadPreferenceMode.SecondaryPreferred:
                    var secondary = GetMatchingInstance(connectedInstances.GetSecondaries(), readPreference, secondaryAcceptableLatency);
                    if (secondary != null)
                    {
                        return secondary;
                    }
                    else
                    {
                        return connectedInstances.GetPrimary();
                    }

                case ReadPreferenceMode.Nearest:
                    return GetMatchingInstance(connectedInstances.GetPrimaryAndSecondaries(), readPreference, secondaryAcceptableLatency);

                default:
                    throw new MongoInternalException("Invalid ReadPreferenceMode.");
            }
        }