Example #1
0
 public void ConvertToSerializationMetrics(bool convertBandToBandData)
 {
     foreach (LoadMetric loadMetric in this.Metrics)
     {
         long num;
         this.values.TryRemove(loadMetric, out num);
         Band       band = loadMetric as Band;
         LoadMetric metric;
         if (band != null)
         {
             if (convertBandToBandData)
             {
                 metric = new BandData(band)
                 {
                     TotalWeight = (int)num
                 };
             }
             else
             {
                 metric = band;
             }
         }
         else
         {
             metric = new LoadMetric(loadMetric.Name, loadMetric.IsSize);
         }
         this[metric] = num;
     }
 }
Example #2
0
        public long GetAggregateMaximumLoad(LoadMetric metric)
        {
            long num = this.MaximumLoad[metric];

            if (this.children.Count == 0)
            {
                return(num);
            }
            return(num + this.Children.OfType <LoadContainer>().Sum((LoadContainer child) => child.GetAggregateMaximumLoad(metric)));
        }
Example #3
0
        public override long GetAggregateConsumedLoad(LoadMetric metric)
        {
            long num = base.ConsumedLoad[metric];

            if (this.children.Count == 0)
            {
                return(num);
            }
            return(num + this.Children.Sum((LoadEntity child) => child.GetAggregateConsumedLoad(metric)));
        }
Example #4
0
        public ByteQuantifiedSize GetSizeMetric(LoadMetric sizeMetric)
        {
            long num;

            if (!this.values.TryGetValue(sizeMetric, out num) || num <= 0L)
            {
                return(ByteQuantifiedSize.Zero);
            }
            return(sizeMetric.ToByteQuantifiedSize(num));
        }
Example #5
0
        public override string ToString()
        {
            IEnumerable <string> enumerable = this.values.Select(delegate(KeyValuePair <LoadMetric, long> kvp)
            {
                LoadMetric key = kvp.Key;
                return(key.GetValueString(kvp.Value));
            });
            string arg = string.Join(",", enumerable);

            return(string.Format("{{{0}}}", arg));
        }
Example #6
0
        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(null, obj))
            {
                return(false);
            }
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            LoadMetric left = obj as LoadMetric;

            return(!(left == null) && this.Equals((LoadMetric)obj));
        }
Example #7
0
 public long this[LoadMetric metric]
 {
     get
     {
         long result;
         if (!this.values.TryGetValue(metric, out result))
         {
             result = 0L;
         }
         return(result);
     }
     set
     {
         this.values[metric] = value;
     }
 }
Example #8
0
 public bool SupportsAdditional(LoadMetricStorage incomingLoad, out LoadMetric exceededMetric, out long requestedUnits, out long availableUnits)
 {
     AnchorUtil.ThrowOnNullArgument(incomingLoad, "incomingLoad");
     exceededMetric = null;
     requestedUnits = 0L;
     availableUnits = 0L;
     foreach (LoadMetric loadMetric in this.values.Keys)
     {
         if (this[loadMetric] < incomingLoad[loadMetric] || this[loadMetric] == 0L)
         {
             exceededMetric = loadMetric;
             availableUnits = this[loadMetric];
             requestedUnits = incomingLoad[loadMetric];
             return(false);
         }
     }
     return(true);
 }
Example #9
0
 public virtual long GetAggregateConsumedLoad(LoadMetric metric)
 {
     return(this.ConsumedLoad[metric]);
 }
Example #10
0
 protected bool Equals(LoadMetric other)
 {
     return(string.Equals(this.name, other.name));
 }