Ejemplo n.º 1
0
        /// <summary>
        /// Output collected statistics.
        /// Side effects: Updates statistics. Writes objects to stream.
        /// </summary>
        protected override void EndProcessing()
        {
            // Fix for 917114: If Property is not set,
            // and we aren't passed any records at all,
            // output 0s to emulate wc behavior.
            if (_totalRecordCount == 0 && Property is null)
            {
                _statistics.EnsureEntry(thisObject);
            }

            foreach (string propertyName in _statistics.Keys)
            {
                Statistics stat = _statistics[propertyName];
                if (stat.count == 0 && Property != null)
                {
                    // Why are there two different ids for this error?
                    string errorId = (IsMeasuringGeneric) ? "GenericMeasurePropertyNotFound" : "TextMeasurePropertyNotFound";
                    WritePropertyNotFoundError(propertyName, errorId);
                    continue;
                }

                MeasureInfo mi = null;
                if (IsMeasuringGeneric)
                {
                    double temp;
                    if ((stat.min is null || LanguagePrimitives.TryConvertTo <double>(stat.min, out temp)) &&
                        (stat.max is null || LanguagePrimitives.TryConvertTo <double>(stat.max, out temp)))
                    {
                        mi = CreateGenericMeasureInfo(stat, true);
                    }
                    else
                    {
                        mi = CreateGenericMeasureInfo(stat, false);
                    }
                }
Ejemplo n.º 2
0
        /// <summary>
        /// Output collected statistics.
        /// Side effects: Updates statistics. Writes objects to stream.
        /// </summary>
        protected override void EndProcessing()
        {
            // Fix for 917114: If Property is not set,
            // and we aren't passed any records at all,
            // output 0s to emulate wc behavior.
            if (_totalRecordCount == 0 && Property == null)
            {
                _statistics.EnsureEntry(thisObject);
            }

            foreach (string propertyName in _statistics.Keys)
            {
                Statistics stat = _statistics[propertyName];
                if (stat.count == 0 && Property != null)
                {
                    if (Context.IsStrictVersion(2))
                    {
                        string errorId = (IsMeasuringGeneric) ? "GenericMeasurePropertyNotFound" : "TextMeasurePropertyNotFound";
                        WritePropertyNotFoundError(propertyName, errorId);
                    }

                    continue;
                }

                MeasureInfo mi = null;
                if (IsMeasuringGeneric)
                {
                    double temp;
                    if ((stat.min == null || LanguagePrimitives.TryConvertTo <double>(stat.min, out temp)) &&
                        (stat.max == null || LanguagePrimitives.TryConvertTo <double>(stat.max, out temp)))
                    {
                        mi = CreateGenericMeasureInfo(stat, true);
                    }
                    else
                    {
                        mi = CreateGenericMeasureInfo(stat, false);
                    }
                }
                else
                {
                    mi = CreateTextMeasureInfo(stat);
                }

                // Set common properties.
                if (Property != null)
                {
                    mi.Property = propertyName;
                }

                WriteObject(mi);
            }
        }
Ejemplo n.º 3
0
 protected override void EndProcessing()
 {
     if ((this.totalRecordCount == 0) && (this.Property == null))
     {
         this.statistics.EnsureEntry("$_");
     }
     foreach (string str in this.statistics.Keys)
     {
         Statistics stat = this.statistics[str];
         if ((stat.count == 0) && (this.Property != null))
         {
             string errorId = this.IsMeasuringGeneric ? "GenericMeasurePropertyNotFound" : "TextMeasurePropertyNotFound";
             this.WritePropertyNotFoundError(str, errorId);
         }
         else
         {
             MeasureInfo sendToPipeline = null;
             if (this.IsMeasuringGeneric)
             {
                 double num;
                 if (((stat.min == null) || LanguagePrimitives.TryConvertTo <double>(stat.min, out num)) && ((stat.max == null) || LanguagePrimitives.TryConvertTo <double>(stat.max, out num)))
                 {
                     sendToPipeline = this.CreateGenericMeasureInfo(stat, true);
                 }
                 else
                 {
                     sendToPipeline = this.CreateGenericMeasureInfo(stat, false);
                 }
             }
             else
             {
                 sendToPipeline = this.CreateTextMeasureInfo(stat);
             }
             if (this.Property != null)
             {
                 sendToPipeline.Property = str;
             }
             base.WriteObject(sendToPipeline);
         }
     }
 }