diff MetroWpf/Stocks.Common/Models/Price.cs @ 21:dfc81f8bb838

working version for sttocks except ui within metrowpf
author adminsh@apollo
date Tue, 20 Mar 2012 15:07:31 +0000
parents 6109bc268b90
children
line wrap: on
line diff
--- a/MetroWpf/Stocks.Common/Models/Price.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Common/Models/Price.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -5,125 +5,131 @@
 
 namespace Stocks.Common.Models
 {
-  public class Price : IEquatable<Price>, IComparable<Price>, IComparable
-  {
-    public string Symbol { get; set; }
-    public decimal CurrentPrice { get; set; }
-    public decimal PreviousPrice { get; set; }
-
-    public Price()
-    {
-    }
-
-    public Price(string symbol, decimal currentPrice, decimal previousPrice)
-      : this()
+    public class Price : IEquatable<Price>, IComparable<Price>, IComparable
     {
-      Symbol = symbol;
-      CurrentPrice = currentPrice;
-      PreviousPrice = previousPrice;
-    }
+        public string CompanyName { get; set; }
+        public string Symbol { get; set; }
+        public decimal CurrentPrice { get; set; }
+        public decimal PreviousPrice { get; set; }
+
+        public Price()
+        {
+        }
+
+        public Price(
+            string company, 
+            string symbol, 
+            decimal currentPrice, 
+            decimal previousPrice) : this()
+        {
+            CompanyName = company;
+            Symbol = symbol;
+            CurrentPrice = currentPrice;
+            PreviousPrice = previousPrice;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (obj is Price)
+                return Equals(obj as Price);
+            else
+                return false;
+        }
 
-    public override bool Equals(object obj)
-    {
-      if (obj is Price)
-        return Equals(obj as Price);
-      else
-        return false;
-    }
+        public bool Equals(Price other)
+        {
+            return (CompanyName == other.CompanyName
+                && Symbol == other.Symbol
+              && CurrentPrice == other.CurrentPrice
+              && PreviousPrice == other.PreviousPrice);
+        }
+
+        public int CompareTo(Price other)
+        {
+            return Symbol.CompareTo(other.Symbol);
+        }
+
+        public int CompareTo(Price other, PriceComparisonType comparisonType)
+        {
+            switch (comparisonType)
+            {
+                case PriceComparisonType.NotSet:
+                case PriceComparisonType.Symbol:
+                    return Symbol.CompareTo(other.Symbol);
+                case PriceComparisonType.CurrentPrice:
+                    return CurrentPrice.CompareTo(other.CurrentPrice);
+                case PriceComparisonType.PreviousPrice:
+                    return PreviousPrice.CompareTo(other.PreviousPrice);
+                default:
+                    throw new Exception("Unknown comparison type");
+            }
+        }
 
-    public bool Equals(Price other)
-    {
-      return (Symbol == other.Symbol
-        && CurrentPrice == other.CurrentPrice
-        && PreviousPrice == other.PreviousPrice);
-    }
+        public int CompareTo(object obj)
+        {
+            Price other;
+            if (obj is Price)
+                other = obj as Price;
+            else
+                throw new ArgumentException("obj is not a Price");
 
-    public int CompareTo(Price other)
-    {
-      return Symbol.CompareTo(other.Symbol);
-    }
+            return CompareTo(other);
+        }
+        public override int GetHashCode()
+        {
+            int hash = 13;
+            hash = (hash * 7) + Symbol.GetHashCode();
+            hash = (hash * 7) + CurrentPrice.GetHashCode();
+            hash = (hash * 7) + PreviousPrice.GetHashCode();
+            return hash;
+        }
+
+        public static bool operator ==(Price lhs, Price rhs)
+        {
+            if (System.Object.ReferenceEquals(lhs, rhs))
+                return true;
+
+            if (((object)lhs == null) || ((object)rhs == null))
+                return false;
+
+            return lhs.Symbol == rhs.Symbol
+              && lhs.CurrentPrice == rhs.CurrentPrice
+              && lhs.PreviousPrice == rhs.PreviousPrice;
+        }
 
-    public int CompareTo(Price other, PriceComparisonType comparisonType)
-    {
-      switch (comparisonType)
-      {
-        case PriceComparisonType.NotSet:
-        case PriceComparisonType.Symbol:
-          return Symbol.CompareTo(other.Symbol);
-        case PriceComparisonType.CurrentPrice:
-          return CurrentPrice.CompareTo(other.CurrentPrice);
-        case PriceComparisonType.PreviousPrice:
-          return PreviousPrice.CompareTo(other.PreviousPrice);
-        default:
-          throw new Exception("Unknown comparison type");
-      }
+        public static bool operator !=(Price lhs, Price rhs)
+        {
+            return !(lhs == rhs);
+        }
+
+
+        public class PriceComparer : IComparer<Price>, IComparer
+        {
+            public PriceComparisonType ComparisonMethod { get; set; }
+
+            public int Compare(Price x, Price y)
+            {
+                return x.CompareTo(y, ComparisonMethod);
+            }
+
+            public int Compare(object x, object y)
+            {
+                Price lhs, rhs;
+
+                if (x is Price)
+                    lhs = x as Price;
+                else
+                    throw new ArgumentException("x is not a Price");
+
+                if (y is Price)
+                    rhs = y as Price;
+                else
+                    throw new ArgumentException("y is not a Price");
+
+                return lhs.CompareTo(rhs, ComparisonMethod);
+            }
+        }
     }
 
-    public int CompareTo(object obj)
-    {
-      Price other;
-      if (obj is Price)
-        other = obj as Price;
-      else
-        throw new ArgumentException("obj is not a Price");
-
-      return CompareTo(other);
-    }
-    public override int GetHashCode()
-    {
-      int hash = 13;
-      hash = (hash * 7) + Symbol.GetHashCode();
-      hash = (hash * 7) + CurrentPrice.GetHashCode();
-      hash = (hash * 7) + PreviousPrice.GetHashCode();
-      return hash;
-    }
-
-    public static bool operator ==(Price lhs, Price rhs)
-    {
-      if (System.Object.ReferenceEquals(lhs, rhs))
-        return true;
-
-      if (((object)lhs == null) || ((object)rhs == null))
-        return false;
-
-      return lhs.Symbol == rhs.Symbol
-        && lhs.CurrentPrice == rhs.CurrentPrice
-        && lhs.PreviousPrice == rhs.PreviousPrice;
-    }
-
-    public static bool operator !=(Price lhs, Price rhs)
-    {
-      return !(lhs == rhs);
-    }
-
-
-    public class PriceComparer : IComparer<Price>, IComparer
-    {
-      public PriceComparisonType ComparisonMethod { get; set; }
-
-      public int Compare(Price x, Price y)
-      {
-        return x.CompareTo(y, ComparisonMethod);
-      }
-
-      public int Compare(object x, object y)
-      {
-        Price lhs, rhs;
-
-        if (x is Price)
-          lhs = x as Price;
-        else
-          throw new ArgumentException("x is not a Price");
-
-        if (y is Price)
-          rhs = y as Price;
-        else
-          throw new ArgumentException("y is not a Price");
-
-        return lhs.CompareTo(rhs, ComparisonMethod);
-      }
-    }
-  }
-
-  public enum PriceComparisonType { NotSet = 0, Symbol, CurrentPrice, PreviousPrice }
-}
+    public enum PriceComparisonType { NotSet = 0, Symbol, CurrentPrice, PreviousPrice }
+}
\ No newline at end of file