Example #1
0
        public bool Add(ControllerClass @class)
        {
            ControllerClass.Merge.Instance hashCode = new ControllerClass.Merge.Instance();
            if (!@class)
            {
                return(false);
            }
            hashCode.hash   = @class.GetHashCode();
            hashCode.@value = @class;
            if (this.length == 1)
            {
                if (this.hash == hashCode.hash && object.ReferenceEquals(this.first.@value, hashCode.@value))
                {
                    return(false);
                }
            }
            else if (this.length > 1 && (this.hash & hashCode.hash) == hashCode.hash)
            {
                for (int i = 0; i < this.length; i++)
                {
                    if (this.classes[i].hash == this.hash && object.ReferenceEquals(this.classes[i].@value, hashCode.@value))
                    {
                        return(false);
                    }
                }
            }
            ControllerClass.Merge merge = this;
            merge.hash = merge.hash | hashCode.hash;
            ControllerClass.Merge merge1 = this;
            int num  = merge1.length;
            int num1 = num;

            merge1.length = num + 1;
            int num2 = num1;

            if (num2 == 0)
            {
                this.first = hashCode;
            }
            else if (num2 != 1)
            {
                Array.Resize <ControllerClass.Merge.Instance>(ref this.classes, this.length);
                this.classes[num2] = hashCode;
            }
            else
            {
                this.classes      = new ControllerClass.Merge.Instance[] { this.first, hashCode };
                this.first.hash   = 0;
                this.first.@value = null;
            }
            return(true);
        }
Example #2
0
        public bool Add(ControllerClass @class)
        {
            Instance instance;

            if (@class == null)
            {
                return(false);
            }
            instance.hash  = @class.GetHashCode();
            instance.value = @class;
            if (this.length == 1)
            {
                if ((this.hash == instance.hash) && object.ReferenceEquals(this.first.value, instance.value))
                {
                    return(false);
                }
            }
            else if ((this.length > 1) && ((this.hash & instance.hash) == instance.hash))
            {
                for (int i = 0; i < this.length; i++)
                {
                    if ((this.classes[i].hash == this.hash) && object.ReferenceEquals(this.classes[i].value, instance.value))
                    {
                        return(false);
                    }
                }
            }
            this.hash |= instance.hash;
            int index = this.length++;

            switch (index)
            {
            case 0:
                this.first = instance;
                break;

            case 1:
                this.classes     = new Instance[] { this.first, instance };
                this.first.hash  = 0;
                this.first.value = null;
                break;

            default:
                Array.Resize <Instance>(ref this.classes, this.length);
                this.classes[index] = instance;
                break;
            }
            return(true);
        }
Example #3
0
 public bool Add(ControllerClass @class)
 {
     ControllerClass.Merge.Instance hashCode = new ControllerClass.Merge.Instance();
     if (!@class)
     {
         return false;
     }
     hashCode.hash = @class.GetHashCode();
     hashCode.@value = @class;
     if (this.length == 1)
     {
         if (this.hash == hashCode.hash && object.ReferenceEquals(this.first.@value, hashCode.@value))
         {
             return false;
         }
     }
     else if (this.length > 1 && (this.hash & hashCode.hash) == hashCode.hash)
     {
         for (int i = 0; i < this.length; i++)
         {
             if (this.classes[i].hash == this.hash && object.ReferenceEquals(this.classes[i].@value, hashCode.@value))
             {
                 return false;
             }
         }
     }
     ControllerClass.Merge merge = this;
     merge.hash = merge.hash | hashCode.hash;
     ControllerClass.Merge merge1 = this;
     int num = merge1.length;
     int num1 = num;
     merge1.length = num + 1;
     int num2 = num1;
     if (num2 == 0)
     {
         this.first = hashCode;
     }
     else if (num2 != 1)
     {
         Array.Resize<ControllerClass.Merge.Instance>(ref this.classes, this.length);
         this.classes[num2] = hashCode;
     }
     else
     {
         this.classes = new ControllerClass.Merge.Instance[] { this.first, hashCode };
         this.first.hash = 0;
         this.first.@value = null;
     }
     return true;
 }