Exemplo n.º 1
0
        public bool Equals(CosmosObject cosmosObject1, CosmosObject cosmosObject2)
        {
            if (cosmosObject1.Count != cosmosObject2.Count)
            {
                return(false);
            }

            bool deepEquals = true;

            foreach (KeyValuePair <string, CosmosElement> kvp in cosmosObject1)
            {
                string        name   = kvp.Key;
                CosmosElement value1 = kvp.Value;

                if (cosmosObject2.TryGetValue(name, out CosmosElement value2))
                {
                    deepEquals &= this.Equals(value1, value2);
                }
                else
                {
                    return(false);
                }
            }

            return(deepEquals);
        }
Exemplo n.º 2
0
        public bool Equals(CosmosObject cosmosObject)
        {
            if (this.Count != cosmosObject.Count)
            {
                return(false);
            }

            // Order of properties does not mattter
            foreach (KeyValuePair <string, CosmosElement> kvp in this)
            {
                string        propertyName  = kvp.Key;
                CosmosElement propertyValue = kvp.Value;

                if (!cosmosObject.TryGetValue(propertyName, out CosmosElement otherPropertyValue))
                {
                    return(false);
                }

                if (propertyValue != otherPropertyValue)
                {
                    return(false);
                }
            }

            return(true);
        }