diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..412eeda7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/c#/Book/PetrolPump/PetrolPump/PetrolPump/PetrolPump.csproj b/c#/Book/PetrolPump/PetrolPump/PetrolPump/PetrolPump.csproj index f2ba51a8..55f07527 100644 --- a/c#/Book/PetrolPump/PetrolPump/PetrolPump/PetrolPump.csproj +++ b/c#/Book/PetrolPump/PetrolPump/PetrolPump/PetrolPump.csproj @@ -70,6 +70,7 @@ + diff --git a/c#/Book/PetrolPump/PetrolPump/PetrolPump/Pump/FillState.cs b/c#/Book/PetrolPump/PetrolPump/PetrolPump/Pump/FillState.cs new file mode 100644 index 00000000..ba1f8d2d --- /dev/null +++ b/c#/Book/PetrolPump/PetrolPump/PetrolPump/Pump/FillState.cs @@ -0,0 +1,28 @@ +namespace PetrolPump.Pump +{ + public class FillState + { + public enum Type + { + IDLE, + FILLING, + SALE_COMPLETE + } + + public FillState(Type mode) + { + this.Mode = mode; + this.Sale = null; + } + + public FillState(Type mode, Sale sale) + { + this.Mode = mode; + this.Sale = sale; + } + + public readonly Type Mode; + public readonly Sale Sale; +} + +} diff --git a/c#/Sodium/Sodium.sln b/c#/Sodium/Sodium.sln index 1a4f23a8..b405ec95 100644 --- a/c#/Sodium/Sodium.sln +++ b/c#/Sodium/Sodium.sln @@ -1,43 +1,43 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sodium", "Sodium.csproj", "{D2080704-D359-4743-B568-5D976F9882A0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "..\Tests\Tests.csproj", "{3BD22EFF-873C-48CF-B8E6-075ACA62F48C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Release|Any CPU.Build.0 = Release|Any CPU - {D2080704-D359-4743-B568-5D976F9882A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2080704-D359-4743-B568-5D976F9882A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2080704-D359-4743-B568-5D976F9882A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2080704-D359-4743-B568-5D976F9882A0}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = Sodium.csproj - Policies = $0 - $0.TextStylePolicy = $1 - $1.FileWidth = 120 - $1.TabWidth = 4 - $1.IndentWidth = 2 - $1.inheritsSet = Mono - $1.inheritsScope = text/plain - $1.scope = text/x-csharp - $0.CSharpFormattingPolicy = $2 - $2.ElseIfNewLinePlacement = SameLine - $2.AfterDelegateDeclarationParameterComma = True - $2.inheritsSet = Mono - $2.inheritsScope = text/x-csharp - $2.scope = text/x-csharp - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sodium", "Sodium.csproj", "{D2080704-D359-4743-B568-5D976F9882A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "..\Tests\Tests.csproj", "{3BD22EFF-873C-48CF-B8E6-075ACA62F48C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BD22EFF-873C-48CF-B8E6-075ACA62F48C}.Release|Any CPU.Build.0 = Release|Any CPU + {D2080704-D359-4743-B568-5D976F9882A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2080704-D359-4743-B568-5D976F9882A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2080704-D359-4743-B568-5D976F9882A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2080704-D359-4743-B568-5D976F9882A0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = Sodium.csproj + Policies = $0 + $0.TextStylePolicy = $1 + $1.FileWidth = 120 + $1.TabWidth = 4 + $1.IndentWidth = 2 + $1.inheritsSet = Mono + $1.inheritsScope = text/plain + $1.scope = text/x-csharp + $0.CSharpFormattingPolicy = $2 + $2.ElseIfNewLinePlacement = SameLine + $2.AfterDelegateDeclarationParameterComma = True + $2.inheritsSet = Mono + $2.inheritsScope = text/x-csharp + $2.scope = text/x-csharp + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/c#/Sodium/src/Sodium/Extensions.cs b/c#/Sodium/src/Sodium/Extensions.cs index 0ae83e71..c536c596 100644 --- a/c#/Sodium/src/Sodium/Extensions.cs +++ b/c#/Sodium/src/Sodium/Extensions.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Xml.Schema; namespace Sodium { @@ -65,6 +66,14 @@ public override bool Equals(object obj) return false; } + public override int GetHashCode() + { + var hash = IsPresent.GetHashCode(); + if (value != null) + hash = (hash * 397) ^ value.GetHashCode(); + return hash; + } + public bool Equals(Optional other) { if (IsPresent && other.IsPresent) diff --git a/c#/Sodium/src/Sodium/PriorityQueue.cs b/c#/Sodium/src/Sodium/PriorityQueue.cs index 696cd4d4..f073bd2f 100644 --- a/c#/Sodium/src/Sodium/PriorityQueue.cs +++ b/c#/Sodium/src/Sodium/PriorityQueue.cs @@ -162,7 +162,7 @@ private void TrickleDown(int index, HeapEntry he) public IEnumerator GetEnumerator() { - return new PriorityQueueEnumerator(this); + return new PriorityQueueEnumerator(this); } #endregion @@ -202,7 +202,7 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex #region Priority Queue enumerator [Serializable] - private class PriorityQueueEnumerator : IEnumerator where TA : IComparable + private class PriorityQueueEnumerator : IEnumerator { private int index; private PriorityQueue pq;