Skip to content

Instantly share code, notes, and snippets.

@brlinton
Created March 4, 2013 01:48
Show Gist options
  • Select an option

  • Save brlinton/5079358 to your computer and use it in GitHub Desktop.

Select an option

Save brlinton/5079358 to your computer and use it in GitHub Desktop.

Revisions

  1. brlinton created this gist Mar 4, 2013.
    384 changes: 384 additions & 0 deletions LogLevelStatsIL.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,384 @@
    using System;
    using System.ComponentModel;
    using System.Runtime.CompilerServices;
    using System.Threading;

    namespace WoodChipper.Models
    {
    public class LogLevelStats : INotifyPropertyChanged
    {
    public virtual int DebugLines
    {
    get
    {
    int u003cDebugLinesu003ek_BackingField = this.u003cDebugLinesu003ek__BackingField;
    return u003cDebugLinesu003ek_BackingField;
    }
    set
    {
    if (this.u003cDebugLinesu003ek__BackingField != value)
    {
    this.u003cDebugLinesu003ek__BackingField = value;
    this.OnPropertyChanged("TotalLines");
    this.OnPropertyChanged("DebugPercent");
    this.OnPropertyChanged("DebugString");
    this.OnPropertyChanged("InfoPercent");
    this.OnPropertyChanged("InfoString");
    this.OnPropertyChanged("WarnPercent");
    this.OnPropertyChanged("WarnString");
    this.OnPropertyChanged("ErrorPercent");
    this.OnPropertyChanged("ErrorString");
    this.OnPropertyChanged("FatalPercent");
    this.OnPropertyChanged("FatalString");
    this.OnPropertyChanged("DebugLines");
    return;
    }
    else
    {
    return;
    }
    }
    }

    private double DebugPercent
    {
    get
    {
    double percentOfTotal = this.GetPercentOfTotal(this.DebugLines);
    return percentOfTotal;
    }
    }

    public virtual string DebugString
    {
    get
    {
    string str;
    if (double.IsNaN(this.DebugPercent))
    {
    str = "0.0%";
    }
    else
    {
    double debugPercent = this.DebugPercent;
    str = debugPercent.ToString("P1");
    }
    string str1 = str;
    return str1;
    }
    }

    public virtual int ErrorLines
    {
    get
    {
    int u003cErrorLinesu003ek_BackingField = this.u003cErrorLinesu003ek__BackingField;
    return u003cErrorLinesu003ek_BackingField;
    }
    set
    {
    if (this.u003cErrorLinesu003ek__BackingField != value)
    {
    this.u003cErrorLinesu003ek__BackingField = value;
    this.OnPropertyChanged("TotalLines");
    this.OnPropertyChanged("DebugPercent");
    this.OnPropertyChanged("DebugString");
    this.OnPropertyChanged("InfoPercent");
    this.OnPropertyChanged("InfoString");
    this.OnPropertyChanged("WarnPercent");
    this.OnPropertyChanged("WarnString");
    this.OnPropertyChanged("ErrorPercent");
    this.OnPropertyChanged("ErrorString");
    this.OnPropertyChanged("FatalPercent");
    this.OnPropertyChanged("FatalString");
    this.OnPropertyChanged("ErrorLines");
    return;
    }
    else
    {
    return;
    }
    }
    }

    private double ErrorPercent
    {
    get
    {
    double percentOfTotal = this.GetPercentOfTotal(this.ErrorLines);
    return percentOfTotal;
    }
    }

    public virtual string ErrorString
    {
    get
    {
    string str;
    if (double.IsNaN(this.ErrorPercent))
    {
    str = "0.0%";
    }
    else
    {
    double errorPercent = this.ErrorPercent;
    str = errorPercent.ToString("P1");
    }
    string str1 = str;
    return str1;
    }
    }

    public virtual int FatalLines
    {
    get
    {
    int u003cFatalLinesu003ek_BackingField = this.u003cFatalLinesu003ek__BackingField;
    return u003cFatalLinesu003ek_BackingField;
    }
    set
    {
    if (this.u003cFatalLinesu003ek__BackingField != value)
    {
    this.u003cFatalLinesu003ek__BackingField = value;
    this.OnPropertyChanged("TotalLines");
    this.OnPropertyChanged("DebugPercent");
    this.OnPropertyChanged("DebugString");
    this.OnPropertyChanged("InfoPercent");
    this.OnPropertyChanged("InfoString");
    this.OnPropertyChanged("WarnPercent");
    this.OnPropertyChanged("WarnString");
    this.OnPropertyChanged("ErrorPercent");
    this.OnPropertyChanged("ErrorString");
    this.OnPropertyChanged("FatalPercent");
    this.OnPropertyChanged("FatalString");
    this.OnPropertyChanged("FatalLines");
    return;
    }
    else
    {
    return;
    }
    }
    }

    private double FatalPercent
    {
    get
    {
    double percentOfTotal = this.GetPercentOfTotal(this.FatalLines);
    return percentOfTotal;
    }
    }

    public virtual string FatalString
    {
    get
    {
    string str;
    if (double.IsNaN(this.FatalPercent))
    {
    str = "0.0%";
    }
    else
    {
    double fatalPercent = this.FatalPercent;
    str = fatalPercent.ToString("P1");
    }
    string str1 = str;
    return str1;
    }
    }

    public virtual int InfoLines
    {
    get
    {
    int u003cInfoLinesu003ek_BackingField = this.u003cInfoLinesu003ek__BackingField;
    return u003cInfoLinesu003ek_BackingField;
    }
    set
    {
    if (this.u003cInfoLinesu003ek__BackingField != value)
    {
    this.u003cInfoLinesu003ek__BackingField = value;
    this.OnPropertyChanged("TotalLines");
    this.OnPropertyChanged("DebugPercent");
    this.OnPropertyChanged("DebugString");
    this.OnPropertyChanged("InfoPercent");
    this.OnPropertyChanged("InfoString");
    this.OnPropertyChanged("WarnPercent");
    this.OnPropertyChanged("WarnString");
    this.OnPropertyChanged("ErrorPercent");
    this.OnPropertyChanged("ErrorString");
    this.OnPropertyChanged("FatalPercent");
    this.OnPropertyChanged("FatalString");
    this.OnPropertyChanged("InfoLines");
    return;
    }
    else
    {
    return;
    }
    }
    }

    private double InfoPercent
    {
    get
    {
    double percentOfTotal = this.GetPercentOfTotal(this.InfoLines);
    return percentOfTotal;
    }
    }

    public virtual string InfoString
    {
    get
    {
    string str;
    if (double.IsNaN(this.InfoPercent))
    {
    str = "0.0%";
    }
    else
    {
    double infoPercent = this.InfoPercent;
    str = infoPercent.ToString("P1");
    }
    string str1 = str;
    return str1;
    }
    }

    public virtual string[] LogContent
    {
    get
    {
    string[] u003cLogContentu003ek_BackingField = this.u003cLogContentu003ek__BackingField;
    return u003cLogContentu003ek_BackingField;
    }
    set
    {
    if (this.u003cLogContentu003ek__BackingField != value)
    {
    this.u003cLogContentu003ek__BackingField = value;
    this.OnPropertyChanged("LogContent");
    return;
    }
    else
    {
    return;
    }
    }
    }

    public virtual int TotalLines
    {
    get
    {
    int debugLines = this.DebugLines + this.InfoLines + this.WarnLines + this.ErrorLines + this.FatalLines;
    return debugLines;
    }
    }

    public virtual int WarnLines
    {
    get
    {
    int u003cWarnLinesu003ek_BackingField = this.u003cWarnLinesu003ek__BackingField;
    return u003cWarnLinesu003ek_BackingField;
    }
    set
    {
    if (this.u003cWarnLinesu003ek__BackingField != value)
    {
    this.u003cWarnLinesu003ek__BackingField = value;
    this.OnPropertyChanged("TotalLines");
    this.OnPropertyChanged("DebugPercent");
    this.OnPropertyChanged("DebugString");
    this.OnPropertyChanged("InfoPercent");
    this.OnPropertyChanged("InfoString");
    this.OnPropertyChanged("WarnPercent");
    this.OnPropertyChanged("WarnString");
    this.OnPropertyChanged("ErrorPercent");
    this.OnPropertyChanged("ErrorString");
    this.OnPropertyChanged("FatalPercent");
    this.OnPropertyChanged("FatalString");
    this.OnPropertyChanged("WarnLines");
    return;
    }
    else
    {
    return;
    }
    }
    }

    private double WarnPercent
    {
    get
    {
    double percentOfTotal = this.GetPercentOfTotal(this.WarnLines);
    return percentOfTotal;
    }
    }

    public virtual string WarnString
    {
    get
    {
    string str;
    if (double.IsNaN(this.WarnPercent))
    {
    str = "0.0%";
    }
    else
    {
    double warnPercent = this.WarnPercent;
    str = warnPercent.ToString("P1");
    }
    string str1 = str;
    return str1;
    }
    }

    public LogLevelStats()
    {
    }

    public virtual void ClearStats()
    {
    this.DebugLines = 0;
    this.InfoLines = 0;
    this.WarnLines = 0;
    this.ErrorLines = 0;
    this.FatalLines = 0;
    this.LogContent = new string[0];
    }

    private double GetPercentOfTotal(int property)
    {
    int denom = this.TotalLines;
    bool flag = denom != 0;
    if (!flag)
    {
    denom = 1;
    }
    double num = (double)property / (double)denom;
    return num;
    }

    public virtual void OnPropertyChanged(string propertyName)
    {
    PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
    bool flag = propertyChangedEventHandler == null;
    if (!flag)
    {
    propertyChangedEventHandler(this, new PropertyChangedEventArgs(propertyName));
    }
    }

    public virtual event PropertyChangedEventHandler PropertyChanged;
    }
    }