Exemplo n.º 1
0
 // public static methods
 /// <summary>
 /// Determines whether two specified ReplicaSetTagSet objects have the same value.
 /// </summary>
 /// <param name="lhs">The first value to compare, or null.</param>
 /// <param name="rhs">The second value to compare, or null.</param>
 /// <returns>True if the value of lhs is the same as the value of rhs; otherwise, false.</returns>
 public static bool Equals(ReplicaSetTagSet lhs, ReplicaSetTagSet rhs)
 {
     if ((object)lhs == null)
     {
         return((object)rhs == null);
     }
     return(lhs.Equals(rhs));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Determines whether this instance and another specified ReplicaSetTagSet object have the same value.
 /// </summary>
 /// <param name="rhs">The ReplicaSetTagSet object to compare to this instance.</param>
 /// <returns>True if the value of the rhs parameter is the same as this instance; otherwise, false.</returns>
 public bool Equals(ReplicaSetTagSet rhs)
 {
     if ((object)rhs == null || GetType() != rhs.GetType())
     {
         return(false);
     }
     if ((object)this == (object)rhs)
     {
         return(true);
     }
     return(_tags.SequenceEqual(rhs._tags));
 }
 // public methods
 /// <summary>
 /// Add a new tag set to the existing tag sets.
 /// </summary>
 /// <param name="tagSet">The new tag set.</param>
 /// <returns>The ReadPreference so calls to AddTagSet can be chained.</returns>
 public ReadPreference AddTagSet(ReplicaSetTagSet tagSet)
 {
     if (_isFrozen)
     {
         ThrowFrozenException();
     }
     if (_tagSets == null)
     {
         _tagSets         = new List <ReplicaSetTagSet>();
         _tagSetsReadOnly = _tagSets.AsReadOnly();
     }
     _tagSets.Add(tagSet);
     return(this);
 }
Exemplo n.º 4
0
        internal static ReplicaSetTagSet ParseReplicaSetTagSet(string name, string s)
        {
            var tagSet = new ReplicaSetTagSet();

            foreach (var tagString in s.Split(','))
            {
                var parts = tagString.Split(':');
                if (parts.Length != 2)
                {
                    throw new FormatException(FormatMessage(name, s));
                }
                var tag = new ReplicaSetTag(parts[0].Trim(), parts[1].Trim());
                tagSet.Add(tag);
            }
            return(tagSet);
        }
Exemplo n.º 5
0
        private IEnumerable <ReplicaSetTagSet> ParseReplicaSetTagSets(string value)
        {
            var tagSets = new List <ReplicaSetTagSet>();

            foreach (var tagSetString in value.Split('|'))
            {
                var tagSet = new ReplicaSetTagSet();
                foreach (var tagString in tagSetString.Split(','))
                {
                    var parts = tagString.Split(':');
                    if (parts.Length != 2)
                    {
                        var message = string.Format("Invalid tag: {0}.", tagString);
                    }
                    var tag = new ReplicaSetTag(parts[0], parts[1]);
                    tagSet.Add(tag);
                }
                tagSets.Add(tagSet);
            }
            return(tagSets);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Determines whether two specified ReplicaSetTagSet objects have the same value.
 /// </summary>
 /// <param name="lhs">The first value to compare, or null.</param>
 /// <param name="rhs">The second value to compare, or null.</param>
 /// <returns>True if the value of lhs is the same as the value of rhs; otherwise, false.</returns>
 public static bool operator ==(ReplicaSetTagSet lhs, ReplicaSetTagSet rhs)
 {
     return(ReplicaSetTagSet.Equals(lhs, rhs));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the ReplicaSetTagSet class.
 /// </summary>
 /// <param name="other">The other ReplicaSetTagSet.</param>
 public ReplicaSetTagSet(ReplicaSetTagSet other)
 {
     _tags         = new List <ReplicaSetTag>(other._tags);
     _tagsReadOnly = _tags.AsReadOnly();
 }