Ejemplo n.º 1
0
        public bool Equals(ImmutableVariableStorage other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            var dictionaryComparer = new ImmutableDictionaryComparer <string, Variable>();

            return(dictionaryComparer.Equals(SuperGlobals, other.SuperGlobals) &&
                   dictionaryComparer.Equals(Globals, other.Globals) &&
                   dictionaryComparer.Equals(Locals, other.Locals) &&
                   dictionaryComparer.Equals(ClassVariables, other.ClassVariables) &&
                   dictionaryComparer.Equals(LocalAccessibleGlobals, other.LocalAccessibleGlobals));

            return(SuperGlobals.OrderBy(x => x.Key).SequenceEqual(other.SuperGlobals.OrderBy(x => x.Key)) &&
                   Globals.OrderBy(x => x.Key).SequenceEqual(other.Globals.OrderBy(x => x.Key)) &&
                   Locals.OrderBy(x => x.Key).SequenceEqual(other.Locals.OrderBy(x => x.Key)) &&
                   ClassVariables.OrderBy(x => x.Key).SequenceEqual(other.ClassVariables.OrderBy(x => x.Key)) &&
                   LocalAccessibleGlobals.OrderBy(x => x.Key).SequenceEqual(other.LocalAccessibleGlobals.OrderBy(x => x.Key)));

            return(SuperGlobals.SequenceEqual(other.SuperGlobals) &&
                   Globals.SequenceEqual(other.Globals) &&
                   Locals.SequenceEqual(other.Locals) &&
                   ClassVariables.SequenceEqual(other.ClassVariables) &&
                   LocalAccessibleGlobals.SequenceEqual(other.LocalAccessibleGlobals));
        }
Ejemplo n.º 2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = SuperGlobals.GetHashCode();
         hashCode = (hashCode * 397) ^ Globals.GetHashCode();
         hashCode = (hashCode * 397) ^ Locals.GetHashCode();
         hashCode = (hashCode * 397) ^ ClassVariables.GetHashCode();
         hashCode = (hashCode * 397) ^ LocalAccessibleGlobals.GetHashCode();
         return(hashCode);
     }
 }