Browse Source

Initial Commit for Codeplex

Gareth O'Brien 11 years ago
commit
a719bff178
61 changed files with 7726 additions and 0 deletions
  1. 31 0
      .gitignore
  2. 22 0
      Foghorn.Core/App.Config
  3. 119 0
      Foghorn.Core/Foghorn.Core.csproj
  4. 33 0
      Foghorn.Core/FoghornModel.Context.cs
  5. 735 0
      Foghorn.Core/FoghornModel.Context.tt
  6. 4 0
      Foghorn.Core/FoghornModel.Designer.cs
  7. 9 0
      Foghorn.Core/FoghornModel.cs
  8. 374 0
      Foghorn.Core/FoghornModel.edmx
  9. 19 0
      Foghorn.Core/FoghornModel.edmx.diagram
  10. 213 0
      Foghorn.Core/FoghornModel.edmx.sql
  11. 845 0
      Foghorn.Core/FoghornModel.tt
  12. 30 0
      Foghorn.Core/ModelAssemblerExtensions.cs
  13. 362 0
      Foghorn.Core/ModelAssemblers.cs
  14. 28 0
      Foghorn.Core/ModelDtoExtensions.cs
  15. 163 0
      Foghorn.Core/ModelDtos.cs
  16. 34 0
      Foghorn.Core/Notification.cs
  17. 24 0
      Foghorn.Core/NotificationType.cs
  18. 57 0
      Foghorn.Core/Properties/AssemblyInfo.cs
  19. 30 0
      Foghorn.Core/SendingApplication.cs
  20. 31 0
      Foghorn.Core/Subscriber.cs
  21. 5 0
      Foghorn.Core/packages.config
  22. 9 0
      Foghorn.Test/App.config
  23. 94 0
      Foghorn.Test/Foghorn.Test.csproj
  24. 176 0
      Foghorn.Test/FoghornServiceTests.cs
  25. BIN
      Foghorn.Test/NotificationIcons/Error.png
  26. BIN
      Foghorn.Test/NotificationIcons/GreenCheck.png
  27. BIN
      Foghorn.Test/NotificationIcons/Icon.png
  28. BIN
      Foghorn.Test/NotificationIcons/OrderPlaced.png
  29. BIN
      Foghorn.Test/NotificationIcons/OrderShipped.png
  30. BIN
      Foghorn.Test/NotificationIcons/TestNotification0.png
  31. BIN
      Foghorn.Test/NotificationIcons/TestNotification1.png
  32. BIN
      Foghorn.Test/NotificationIcons/TestNotification2.png
  33. BIN
      Foghorn.Test/NotificationIcons/Warning.png
  34. BIN
      Foghorn.Test/NotificationTypes.xlsx
  35. 57 0
      Foghorn.Test/Properties/AssemblyInfo.cs
  36. 155 0
      Foghorn.Test/WcfTests.cs
  37. 5 0
      Foghorn.Test/packages.config
  38. 74 0
      Foghorn.WcfService/App.config
  39. 113 0
      Foghorn.WcfService/Foghorn.WcfService.csproj
  40. 175 0
      Foghorn.WcfService/FoghornService.cs
  41. 54 0
      Foghorn.WcfService/IFoghornService.cs
  42. 29 0
      Foghorn.WcfService/NLog.config
  43. 2704 0
      Foghorn.WcfService/NLog.xsd
  44. 90 0
      Foghorn.WcfService/Notifier.cs
  45. 57 0
      Foghorn.WcfService/Properties/AssemblyInfo.cs
  46. 35 0
      Foghorn.WcfService/Properties/Settings.Designer.cs
  47. 11 0
      Foghorn.WcfService/Properties/Settings.settings
  48. 25 0
      Foghorn.WcfService/license.txt
  49. 7 0
      Foghorn.WcfService/packages.config
  50. 78 0
      Foghorn.WindowsService/App.config
  51. 89 0
      Foghorn.WindowsService/Foghorn.WindowsService.csproj
  52. 37 0
      Foghorn.WindowsService/FoghornWindowsService.Designer.cs
  53. 46 0
      Foghorn.WindowsService/FoghornWindowsService.cs
  54. 36 0
      Foghorn.WindowsService/FoghornWindowsServiceInstaller.Designer.cs
  55. 24 0
      Foghorn.WindowsService/FoghornWindowsServiceInstaller.cs
  56. 34 0
      Foghorn.WindowsService/Program.cs
  57. 60 0
      Foghorn.WindowsService/ProjectInstaller.Designer.cs
  58. 32 0
      Foghorn.WindowsService/ProjectInstaller.cs
  59. 129 0
      Foghorn.WindowsService/ProjectInstaller.resx
  60. 57 0
      Foghorn.WindowsService/Properties/AssemblyInfo.cs
  61. 66 0
      Foghorn.sln

+ 31 - 0
.gitignore

@@ -0,0 +1,31 @@
+
+#ignore thumbnails created by windows
+Thumbs.db
+#Ignore files build by Visual Studio
+*.obj
+*.exe
+*.pdb
+*.user
+*.aps
+*.pch
+*.vspscc
+*_i.c
+*_p.c
+*.ncb
+*.suo
+*.tlb
+*.tlh
+*.bak
+*.cache
+*.ilk
+*.log
+[Bb]in
+[Dd]ebug*/
+*.lib
+*.sbr
+obj/
+[Rr]elease*/
+_ReSharper*/
+[Tt]est[Rr]esult*
+packages/
+Foghorn-cache/

+ 22 - 0
Foghorn.Core/App.Config

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+  <configSections>
+    <section name="entityFramework"
+             type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+             requirePermission="false" />
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+  </configSections>
+  <connectionStrings>
+    <add name="FoghornEntities"
+         connectionString="metadata=res://*/FoghornModel.csdl|res://*/FoghornModel.ssdl|res://*/FoghornModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=Foghorn;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
+         providerName="System.Data.EntityClient" />
+  </connectionStrings>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+      <parameters>
+        <parameter value="v11.0" />
+      </parameters>
+    </defaultConnectionFactory>
+  </entityFramework>
+</configuration>

+ 119 - 0
Foghorn.Core/Foghorn.Core.csproj

@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Foghorn.Core</RootNamespace>
+    <AssemblyName>Foghorn.Core</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework">
+      <HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data.Entity" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Security" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ModelAssemblerExtensions.cs" />
+    <Compile Include="ModelAssemblers.cs" />
+    <Compile Include="ModelDtoExtensions.cs" />
+    <Compile Include="ModelDtos.cs" />
+    <Compile Include="FoghornModel.Context.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>FoghornModel.Context.tt</DependentUpon>
+    </Compile>
+    <Compile Include="FoghornModel.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>FoghornModel.tt</DependentUpon>
+    </Compile>
+    <Compile Include="FoghornModel.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>FoghornModel.edmx</DependentUpon>
+    </Compile>
+    <Compile Include="Notification.cs">
+      <DependentUpon>FoghornModel.tt</DependentUpon>
+    </Compile>
+    <Compile Include="NotificationType.cs">
+      <DependentUpon>FoghornModel.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SendingApplication.cs">
+      <DependentUpon>FoghornModel.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Subscriber.cs">
+      <DependentUpon>FoghornModel.tt</DependentUpon>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <EntityDeploy Include="FoghornModel.edmx">
+      <Generator>EntityModelCodeGenerator</Generator>
+      <LastGenOutput>FoghornModel.Designer.cs</LastGenOutput>
+    </EntityDeploy>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.Config" />
+    <None Include="FoghornModel.Context.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <DependentUpon>FoghornModel.edmx</DependentUpon>
+      <LastGenOutput>FoghornModel.Context.cs</LastGenOutput>
+    </None>
+    <None Include="FoghornModel.edmx.diagram">
+      <DependentUpon>FoghornModel.edmx</DependentUpon>
+    </None>
+    <None Include="FoghornModel.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <DependentUpon>FoghornModel.edmx</DependentUpon>
+      <LastGenOutput>FoghornModel.cs</LastGenOutput>
+    </None>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="FoghornModel.edmx.sql" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 33 - 0
Foghorn.Core/FoghornModel.Context.cs

@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.Core
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Infrastructure;
+    
+    public partial class FoghornEntities : DbContext
+    {
+        public FoghornEntities()
+            : base("name=FoghornEntities")
+        {
+        }
+    
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            throw new UnintentionalCodeFirstException();
+        }
+    
+        public DbSet<Subscriber> Subscribers { get; set; }
+        public DbSet<Notification> Notifications { get; set; }
+        public DbSet<SendingApplication> SendingApplications { get; set; }
+        public DbSet<NotificationType> NotificationTypes { get; set; }
+    }
+}

+ 735 - 0
Foghorn.Core/FoghornModel.Context.tt

@@ -0,0 +1,735 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+const string inputFile = @"FoghornModel.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
+var itemCollection = loader.CreateEdmItemCollection(inputFile);
+var modelNamespace = loader.GetModelNamespace(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
+if (container == null)
+{
+    return string.Empty;
+}
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+// <#=GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=GetResourceString("Template_GeneratedCodeCommentLine3")#>
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+<#
+
+var codeNamespace = code.VsNamespaceSuggestion();
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#
+    PushIndent("    ");
+}
+
+#>
+using System;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+<#
+if (container.FunctionImports.Any())
+{
+#>
+using System.Data.Objects;
+using System.Data.Objects.DataClasses;
+using System.Linq;
+<#
+}
+#>
+
+<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
+{
+    public <#=code.Escape(container)#>()
+        : base("name=<#=container.Name#>")
+    {
+<#
+if (!loader.IsLazyLoadingEnabled(container))
+{
+#>
+        this.Configuration.LazyLoadingEnabled = false;
+<#
+}
+#>
+    }
+
+    protected override void OnModelCreating(DbModelBuilder modelBuilder)
+    {
+        throw new UnintentionalCodeFirstException();
+    }
+
+<#
+    foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
+    {
+#>
+    <#=codeStringGenerator.DbSet(entitySet)#>
+<#
+    }
+
+    foreach (var edmFunction in container.FunctionImports)
+    {
+        WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
+    }
+#>
+}
+<#
+
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+    PopIndent();
+#>
+}
+<#
+}
+#>
+<#+
+
+private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+{
+    if (typeMapper.IsComposable(edmFunction))
+    {
+#>
+
+    [EdmFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
+    <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
+    {
+<#+
+        codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+        <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
+    }
+<#+
+    }
+    else
+    {
+#>
+
+    <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
+    {
+<#+
+        codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+        <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
+    }
+<#+
+        if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
+        {
+            WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
+        }
+    }
+}
+
+public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
+{
+#>
+        var <#=name#> = <#=isNotNull#> ?
+            <#=notNullInit#> :
+            <#=nullInit#>;
+
+<#+
+}
+
+public const string TemplateId = "CSharp_DbContext_Context_EF5";
+
+public class CodeStringGenerator
+{
+    private readonly CodeGenerationTools _code;
+    private readonly TypeMapper _typeMapper;
+    private readonly MetadataTools _ef;
+
+    public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(typeMapper, "typeMapper");
+        ArgumentNotNull(ef, "ef");
+
+        _code = code;
+        _typeMapper = typeMapper;
+        _ef = ef;
+    }
+
+    public string Property(EdmProperty edmProperty)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            Accessibility.ForProperty(edmProperty),
+            _typeMapper.GetTypeName(edmProperty.TypeUsage),
+            _code.Escape(edmProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+
+    public string NavigationProperty(NavigationProperty navigationProperty)
+    {
+        var endType = _typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType());
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            AccessibilityAndVirtual(Accessibility.ForProperty(navigationProperty)),
+            navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+            _code.Escape(navigationProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(navigationProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(navigationProperty)));
+    }
+    
+    public string AccessibilityAndVirtual(string accessibility)
+    {
+        return accessibility + (accessibility != "private" ? " virtual" : "");
+    }
+    
+    public string EntityClassOpening(EntityType entity)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1}partial class {2}{3}",
+            Accessibility.ForType(entity),
+            _code.SpaceAfter(_code.AbstractOption(entity)),
+            _code.Escape(entity),
+            _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+    }
+    
+    public string EnumOpening(SimpleType enumType)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} enum {1} : {2}",
+            Accessibility.ForType(enumType),
+            _code.Escape(enumType),
+            _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+        }
+    
+    public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
+    {
+        var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+        foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+        {
+            var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+            var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+            var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + parameter.RawClrTypeName + "))";
+            writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+        }
+    }
+    
+    public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} IQueryable<{1}> {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            _code.Escape(edmFunction),
+            string.Join(", ", parameters.Select(p => p.FunctionParameterType + " " + p.FunctionParameterName).ToArray()));
+    }
+    
+    public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            edmFunction.NamespaceName,
+            edmFunction.Name,
+            string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+            _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+    }
+    
+    public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var paramList = String.Join(", ", parameters.Select(p => p.FunctionParameterType + " " + p.FunctionParameterName).ToArray());
+        if (includeMergeOption)
+        {
+            paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+        }
+
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            _code.Escape(edmFunction),
+            paramList);
+    }
+    
+    public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+        if (includeMergeOption)
+        {
+            callParams = ", mergeOption" + callParams;
+        }
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+            returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            edmFunction.Name,
+            callParams);
+    }
+    
+    public string DbSet(EntitySet entitySet)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} DbSet<{1}> {2} {{ get; set; }}",
+            Accessibility.ForReadOnlyProperty(entitySet),
+            _typeMapper.GetTypeName(entitySet.ElementType),
+            _code.Escape(entitySet));
+    }
+
+    public string UsingDirectives(bool inHeader, bool includeCollections = true)
+    {
+        return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+            ? string.Format(
+                CultureInfo.InvariantCulture,
+                "{0}using System;{1}" +
+                "{2}",
+                inHeader ? Environment.NewLine : "",
+                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+                inHeader ? "" : Environment.NewLine)
+            : "";
+    }
+}
+
+public class TypeMapper
+{
+    private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+    private readonly System.Collections.IList _errors;
+    private readonly CodeGenerationTools _code;
+    private readonly MetadataTools _ef;
+
+    public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(ef, "ef");
+        ArgumentNotNull(errors, "errors");
+
+        _code = code;
+        _ef = ef;
+        _errors = errors;
+    }
+
+    public string GetTypeName(TypeUsage typeUsage)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+    }
+
+    public string GetTypeName(EdmType edmType)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+    }
+
+    public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, string modelNamespace)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+    {
+        if (edmType == null)
+        {
+            return null;
+        }
+
+        var collectionType = edmType as CollectionType;
+        if (collectionType != null)
+        {
+            return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+        }
+
+        var typeName = _code.Escape(edmType.MetadataProperties
+                                .Where(p => p.Name == ExternalTypeNameAttributeName)
+                                .Select(p => (string)p.Value)
+                                .FirstOrDefault())
+            ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+                _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+                _code.Escape(edmType));
+
+        if (edmType is StructuralType)
+        {
+            return typeName;
+        }
+
+        if (edmType is SimpleType)
+        {
+            var clrType = UnderlyingClrType(edmType);
+            if (!IsEnumType(edmType))
+            {
+                typeName = _code.Escape(clrType);
+            }
+
+            return clrType.IsValueType && isNullable == true ?
+                String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+                typeName;
+        }
+
+        throw new ArgumentException("edmType");
+    }
+    
+    public Type UnderlyingClrType(EdmType edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        var primitiveType = edmType as PrimitiveType;
+        if (primitiveType != null)
+        {
+            return primitiveType.ClrEquivalentType;
+        }
+
+        if (IsEnumType(edmType))
+        {
+            return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+        }
+
+        return typeof(object);
+    }
+    
+    public object GetEnumMemberValue(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var valueProperty = enumMember.GetType().GetProperty("Value");
+        return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+    }
+    
+    public string GetEnumMemberName(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var nameProperty = enumMember.GetType().GetProperty("Name");
+        return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+    }
+
+    public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        var membersProperty = enumType.GetType().GetProperty("Members");
+        return membersProperty != null 
+            ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+            : Enumerable.Empty<MetadataItem>();
+    }
+    
+    public bool EnumIsFlags(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+        
+        var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+        return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+    }
+
+    public bool IsEnumType(GlobalItem edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        return edmType.GetType().Name == "EnumType";
+    }
+
+    public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+    }
+
+    public string CreateLiteral(object value)
+    {
+        if (value == null || value.GetType() != typeof(TimeSpan))
+        {
+            return _code.CreateLiteral(value);
+        }
+
+        return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+    }
+    
+    public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
+    {
+        ArgumentNotNull(types, "types");
+        ArgumentNotNull(sourceFile, "sourceFile");
+        
+        var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+        if (types.Any(item => !hash.Add(item)))
+        {
+            _errors.Add(
+                new CompilerError(sourceFile, -1, -1, "6023",
+                    String.Format(CultureInfo.CurrentCulture, GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+            return false;
+        }
+        return true;
+    }
+    
+    public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
+    {
+        return GetItemsToGenerate<SimpleType>(itemCollection)
+            .Where(e => IsEnumType(e));
+    }
+    
+    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
+    {
+        return itemCollection
+            .OfType<T>()
+            .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+            .OrderBy(i => i.Name);
+    }
+
+    public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
+    {
+        return itemCollection
+            .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+            .Select(g => GetGlobalItemName(g));
+    }
+
+    public string GetGlobalItemName(GlobalItem item)
+    {
+        if (item is EdmType)
+        {
+            return ((EdmType)item).Name;
+        }
+        else
+        {
+            return ((EntityContainer)item).Name;
+        }
+    }
+
+    public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+    
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+
+    public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type);
+    }
+    
+    public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    }
+    
+    public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+        return returnParamsProperty == null
+            ? edmFunction.ReturnParameter
+            : ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+    }
+
+    public bool IsComposable(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+        return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+    }
+
+    public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
+    {
+        return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+    }
+
+    public TypeUsage GetReturnType(EdmFunction edmFunction)
+    {
+        var returnParam = GetReturnParameter(edmFunction);
+        return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+    }
+    
+    public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+    {
+        var returnType = GetReturnType(edmFunction);
+        return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+    }
+}
+
+public class EdmMetadataLoader
+{
+    private readonly IDynamicHost _host;
+    private readonly System.Collections.IList _errors;
+
+    public EdmMetadataLoader(IDynamicHost host, System.Collections.IList errors)
+    {
+        ArgumentNotNull(host, "host");
+        ArgumentNotNull(errors, "errors");
+
+        _host = host;
+        _errors = errors;
+    }
+
+    public IEnumerable<GlobalItem> CreateEdmItemCollection(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        if (!ValidateInputPath(sourcePath))
+        {
+            return new EdmItemCollection();
+        }
+
+        var schemaElement = LoadRootElement(_host.ResolvePath(sourcePath));
+        if (schemaElement != null)
+        {
+            using (var reader = schemaElement.CreateReader())
+            {
+                IList<EdmSchemaError> errors;
+                var itemCollection = MetadataItemCollectionFactory.CreateEdmItemCollection(new[] { reader }, out errors);
+
+                ProcessErrors(errors, sourcePath);
+
+                return itemCollection;
+            }
+        }
+        return new EdmItemCollection();
+    }
+
+    public string GetModelNamespace(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        if (!ValidateInputPath(sourcePath))
+        {
+            return string.Empty;
+        }
+
+        var model = LoadRootElement(_host.ResolvePath(sourcePath));
+        if (model == null)
+        {
+            return string.Empty;
+        }
+
+        var attribute = model.Attribute("Namespace");
+        return attribute != null ? attribute.Value : "";
+    }
+
+    private bool ValidateInputPath(string sourcePath)
+    {
+        if (sourcePath == "$" + "edmxInputFile" + "$")
+        {
+            _errors.Add(
+                new CompilerError(_host.TemplateFile ?? sourcePath, 0, 0, string.Empty,
+                    GetResourceString("Template_ReplaceVsItemTemplateToken")));
+            return false;
+        }
+
+        return true;
+    }
+
+    public XElement LoadRootElement(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        var root = XElement.Load(sourcePath, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);
+        return root.Elements()
+            .Where(e => e.Name.LocalName == "Runtime")
+            .Elements()
+            .Where(e => e.Name.LocalName == "ConceptualModels")
+            .Elements()
+            .Where(e => e.Name.LocalName == "Schema")
+            .FirstOrDefault()
+                ?? root;
+    }
+
+    private void ProcessErrors(IEnumerable<EdmSchemaError> errors, string sourceFilePath)
+    {
+        foreach (var error in errors)
+        {
+            _errors.Add(
+                new CompilerError(
+                    error.SchemaLocation ?? sourceFilePath,
+                    error.Line,
+                    error.Column,
+                    error.ErrorCode.ToString(CultureInfo.InvariantCulture),
+                    error.Message)
+                {
+                    IsWarning = error.Severity == EdmSchemaErrorSeverity.Warning
+                });
+        }
+    }
+    
+    public bool IsLazyLoadingEnabled(EntityContainer container)
+    {
+        string lazyLoadingAttributeValue;
+        var lazyLoadingAttributeName = MetadataConstants.EDM_ANNOTATION_09_02 + ":LazyLoadingEnabled";
+        bool isLazyLoading;
+        return !MetadataTools.TryGetStringMetadataPropertySetting(container, lazyLoadingAttributeName, out lazyLoadingAttributeValue)
+            || !bool.TryParse(lazyLoadingAttributeValue, out isLazyLoading)
+            || isLazyLoading;
+    }
+}
+
+public static void ArgumentNotNull<T>(T arg, string name) where T : class
+{
+    if (arg == null)
+    {
+        throw new ArgumentNullException(name);
+    }
+}
+    
+private static readonly Lazy<System.Resources.ResourceManager> ResourceManager =
+    new Lazy<System.Resources.ResourceManager>(
+        () => new System.Resources.ResourceManager("System.Data.Entity.Design", typeof(MetadataItemCollectionFactory).Assembly), isThreadSafe: true);
+
+public static string GetResourceString(string resourceName)
+{
+    ArgumentNotNull(resourceName, "resourceName");
+
+    return ResourceManager.Value.GetString(resourceName, null);
+}
+
+#>

+ 4 - 0
Foghorn.Core/FoghornModel.Designer.cs

@@ -0,0 +1,4 @@
+// Default code generation is disabled for model 'C:\Development\Foghorn\Foghorn.Core\FoghornModel.edmx'. 
+// To enable default code generation, change the value of the 'Code Generation Strategy' designer
+// property to an alternate value. This property is available in the Properties Window when the model is
+// open in the designer.

+ 9 - 0
Foghorn.Core/FoghornModel.cs

@@ -0,0 +1,9 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+

+ 374 - 0
Foghorn.Core/FoghornModel.edmx

@@ -0,0 +1,374 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
+  <!-- EF Runtime content -->
+  <edmx:Runtime>
+    <!-- SSDL content -->
+    <edmx:StorageModels>
+      <Schema Namespace="FoghornModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008"
+              xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator"
+              xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+        <EntityContainer Name="FoghornModelStoreContainer">
+          <EntitySet Name="Subscribers" EntityType="FoghornModel.Store.Subscribers" store:Type="Tables" Schema="dbo" />
+          <EntitySet Name="Notifications" EntityType="FoghornModel.Store.Notifications" store:Type="Tables"
+                     Schema="dbo" />
+          <EntitySet Name="SendingApplications" EntityType="FoghornModel.Store.SendingApplications" store:Type="Tables"
+                     Schema="dbo" />
+          <EntitySet Name="NotificationTypes" EntityType="FoghornModel.Store.NotificationTypes" store:Type="Tables"
+                     Schema="dbo" />
+          <EntitySet Name="SubscriberNotification" EntityType="FoghornModel.Store.SubscriberNotification"
+                     store:Type="Tables" Schema="dbo" />
+          <AssociationSet Name="FK_SubscriberNotification_Subscriber"
+                          Association="FoghornModel.Store.FK_SubscriberNotification_Subscriber">
+            <End Role="Subscriber" EntitySet="Subscribers" />
+            <End Role="SubscriberNotification" EntitySet="SubscriberNotification" />
+          </AssociationSet>
+          <AssociationSet Name="FK_SubscriberNotification_Notification"
+                          Association="FoghornModel.Store.FK_SubscriberNotification_Notification">
+            <End Role="Notification" EntitySet="Notifications" />
+            <End Role="SubscriberNotification" EntitySet="SubscriberNotification" />
+          </AssociationSet>
+          <AssociationSet Name="SendingApplicationSubscriber"
+                          Association="FoghornModel.Store.SendingApplicationSubscriber">
+            <End Role="SendingApplication" EntitySet="SendingApplications" />
+            <End Role="Subscriber" EntitySet="Subscribers" />
+          </AssociationSet>
+          <AssociationSet Name="NotificationNotificationType"
+                          Association="FoghornModel.Store.NotificationNotificationType">
+            <End Role="Notification" EntitySet="Notifications" />
+            <End Role="NotificationType" EntitySet="NotificationTypes" />
+          </AssociationSet>
+          <AssociationSet Name="SendingApplicationNotificationType"
+                          Association="FoghornModel.Store.SendingApplicationNotificationType">
+            <End Role="SendingApplication" EntitySet="SendingApplications" />
+            <End Role="NotificationType" EntitySet="NotificationTypes" />
+          </AssociationSet>
+        </EntityContainer>
+        <EntityType Name="Subscribers">
+          <Key>
+            <PropertyRef Name="SubscriberId" />
+          </Key>
+          <Property Name="SubscriberId" Type="uniqueidentifier" Nullable="false" />
+          <Property Name="SubscriberName" Type="nvarchar" Nullable="false" MaxLength="255" />
+          <Property Name="Port" Type="int" Nullable="true" />
+          <Property Name="HostName" Type="nvarchar" Nullable="false" MaxLength="255" />
+          <Property Name="Password" Type="nvarchar" Nullable="false" MaxLength="20" />
+          <Property Name="SendingApplication_SendingApplicationId" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Notifications">
+          <Key>
+            <PropertyRef Name="NotificationId" />
+          </Key>
+          <Property Name="NotificationId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="NotificationTitle" Type="nvarchar(max)" Nullable="false" />
+          <Property Name="NotificationMessage" Type="nvarchar(max)" Nullable="false" />
+          <Property Name="SentDateTime" Type="datetime" Nullable="false" />
+          <Property Name="Priority" Type="int" Nullable="false" DefaultValue="0" />
+          <Property Name="Sticky" Type="bit" Nullable="false" DefaultValue="false" />
+          <Property Name="NotificationType_NotificationTypeId" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="SendingApplications">
+          <Key>
+            <PropertyRef Name="SendingApplicationId" />
+          </Key>
+          <Property Name="SendingApplicationId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="SendingApplicationName" Type="nvarchar" Nullable="false" MaxLength="255" />
+          <Property Name="SendingApplicationIcon" Type="varbinary(max)" Nullable="true" />
+        </EntityType>
+        <EntityType Name="NotificationTypes">
+          <Key>
+            <PropertyRef Name="NotificationTypeId" />
+          </Key>
+          <Property Name="NotificationTypeId" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="NotificationTypeName" Type="nvarchar" Nullable="false" MaxLength="32" />
+          <Property Name="NotificationTypeDisplayName" Type="nvarchar" Nullable="false" MaxLength="255" />
+          <Property Name="NotificationTypeIcon" Type="varbinary(max)" Nullable="true" />
+          <Property Name="SendingApplication_SendingApplicationId" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="SubscriberNotification">
+          <Key>
+            <PropertyRef Name="SentToSubscribers_SubscriberId" />
+            <PropertyRef Name="NotificationsSent_NotificationId" />
+          </Key>
+          <Property Name="SentToSubscribers_SubscriberId" Type="uniqueidentifier" Nullable="false" />
+          <Property Name="NotificationsSent_NotificationId" Type="int" Nullable="false" />
+        </EntityType>
+        <Association Name="SendingApplicationSubscriber">
+          <End Role="SendingApplication" Type="FoghornModel.Store.SendingApplications" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Role="Subscriber" Type="FoghornModel.Store.Subscribers" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="SendingApplication">
+              <PropertyRef Name="SendingApplicationId" />
+            </Principal>
+            <Dependent Role="Subscriber">
+              <PropertyRef Name="SendingApplication_SendingApplicationId" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="NotificationNotificationType">
+          <End Role="Notification" Type="FoghornModel.Store.Notifications" Multiplicity="*" />
+          <End Role="NotificationType" Type="FoghornModel.Store.NotificationTypes" Multiplicity="1" />
+          <ReferentialConstraint>
+            <Principal Role="NotificationType">
+              <PropertyRef Name="NotificationTypeId" />
+            </Principal>
+            <Dependent Role="Notification">
+              <PropertyRef Name="NotificationType_NotificationTypeId" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="SendingApplicationNotificationType">
+          <End Role="SendingApplication" Type="FoghornModel.Store.SendingApplications" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Role="NotificationType" Type="FoghornModel.Store.NotificationTypes" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="SendingApplication">
+              <PropertyRef Name="SendingApplicationId" />
+            </Principal>
+            <Dependent Role="NotificationType">
+              <PropertyRef Name="SendingApplication_SendingApplicationId" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_SubscriberNotification_Subscriber">
+          <End Role="Subscriber" Type="FoghornModel.Store.Subscribers" Multiplicity="1" />
+          <End Role="SubscriberNotification" Type="FoghornModel.Store.SubscriberNotification" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Subscriber">
+              <PropertyRef Name="SubscriberId" />
+            </Principal>
+            <Dependent Role="SubscriberNotification">
+              <PropertyRef Name="SentToSubscribers_SubscriberId" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_SubscriberNotification_Notification">
+          <End Role="SubscriberNotification" Type="FoghornModel.Store.SubscriberNotification" Multiplicity="*" />
+          <End Role="Notification" Type="FoghornModel.Store.Notifications" Multiplicity="1" />
+          <ReferentialConstraint>
+            <Principal Role="Notification">
+              <PropertyRef Name="NotificationId" />
+            </Principal>
+            <Dependent Role="SubscriberNotification">
+              <PropertyRef Name="NotificationsSent_NotificationId" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+      </Schema>
+    </edmx:StorageModels>
+    <!-- CSDL content -->
+    <edmx:ConceptualModels>
+      <Schema Namespace="FoghornModel" Alias="Self" p1:UseStrongSpatialTypes="false"
+              xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
+              xmlns:p1="http://schemas.microsoft.com/ado/2009/02/edm/annotation"
+              xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
+        <EntityContainer Name="FoghornEntities" p1:LazyLoadingEnabled="true">
+          <EntitySet Name="Subscribers" EntityType="FoghornModel.Subscriber" />
+          <EntitySet Name="Notifications" EntityType="FoghornModel.Notification" />
+          <AssociationSet Name="SubscriberNotification" Association="FoghornModel.SubscriberNotification">
+            <End Role="Subscriber" EntitySet="Subscribers" />
+            <End Role="Notification" EntitySet="Notifications" />
+          </AssociationSet>
+          <EntitySet Name="SendingApplications" EntityType="FoghornModel.SendingApplication" />
+          <AssociationSet Name="SendingApplicationSubscriber" Association="FoghornModel.SendingApplicationSubscriber">
+            <End Role="SendingApplication" EntitySet="SendingApplications" />
+            <End Role="Subscriber" EntitySet="Subscribers" />
+          </AssociationSet>
+          <EntitySet Name="NotificationTypes" EntityType="FoghornModel.NotificationType" />
+          <AssociationSet Name="NotificationNotificationType" Association="FoghornModel.NotificationNotificationType">
+            <End Role="Notification" EntitySet="Notifications" />
+            <End Role="NotificationType" EntitySet="NotificationTypes" />
+          </AssociationSet>
+          <AssociationSet Name="SendingApplicationNotificationType"
+                          Association="FoghornModel.SendingApplicationNotificationType">
+            <End Role="SendingApplication" EntitySet="SendingApplications" />
+            <End Role="NotificationType" EntitySet="NotificationTypes" />
+          </AssociationSet>
+        </EntityContainer>
+        <EntityType Name="Subscriber">
+          <Key>
+            <PropertyRef Name="SubscriberId" />
+          </Key>
+          <Property Type="Guid" Name="SubscriberId" Nullable="false" annotation:StoreGeneratedPattern="None" />
+          <Property Type="String" Name="SubscriberName" Nullable="false" MaxLength="255" />
+          <Property Type="Int32" Name="Port" Nullable="true" />
+          <NavigationProperty Name="NotificationsSent" Relationship="FoghornModel.SubscriberNotification"
+                              FromRole="Subscriber" ToRole="Notification" />
+          <NavigationProperty Name="SendingApplication" Relationship="FoghornModel.SendingApplicationSubscriber"
+                              FromRole="Subscriber" ToRole="SendingApplication" />
+          <Property Type="String" Name="HostName" Nullable="false" MaxLength="255" />
+          <Property Type="String" Name="Password" Nullable="false" MaxLength="20" />
+        </EntityType>
+        <EntityType Name="Notification">
+          <Key>
+            <PropertyRef Name="NotificationId" />
+          </Key>
+          <Property Type="Int32" Name="NotificationId" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <NavigationProperty Name="SentToSubscribers" Relationship="FoghornModel.SubscriberNotification"
+                              FromRole="Notification" ToRole="Subscriber" />
+          <Property Type="String" Name="NotificationTitle" Nullable="false" />
+          <Property Type="String" Name="NotificationMessage" Nullable="false" />
+          <NavigationProperty Name="NotificationType" Relationship="FoghornModel.NotificationNotificationType"
+                              FromRole="Notification" ToRole="NotificationType" />
+          <Property Type="DateTime" Name="SentDateTime" Nullable="false" annotation:StoreGeneratedPattern="None" />
+          <Property Type="Int32" Name="Priority" Nullable="false" DefaultValue="0" />
+          <Property Type="Boolean" Name="Sticky" Nullable="false" DefaultValue="False" />
+        </EntityType>
+        <Association Name="SubscriberNotification">
+          <End Type="FoghornModel.Subscriber" Role="Subscriber" Multiplicity="*" />
+          <End Type="FoghornModel.Notification" Role="Notification" Multiplicity="*">
+          </End>
+        </Association>
+        <EntityType Name="SendingApplication">
+          <Key>
+            <PropertyRef Name="SendingApplicationId" />
+          </Key>
+          <Property Type="Int32" Name="SendingApplicationId" Nullable="false"
+                    annotation:StoreGeneratedPattern="Identity" />
+          <Property Type="String" Name="SendingApplicationName" Nullable="false" MaxLength="255" />
+          <NavigationProperty Name="Subscribers" Relationship="FoghornModel.SendingApplicationSubscriber"
+                              FromRole="SendingApplication" ToRole="Subscriber" />
+          <NavigationProperty Name="NotificationTypes" Relationship="FoghornModel.SendingApplicationNotificationType"
+                              FromRole="SendingApplication" ToRole="NotificationType" />
+          <Property Type="Binary" Name="SendingApplicationIcon" Nullable="true" />
+        </EntityType>
+        <Association Name="SendingApplicationSubscriber">
+          <End Type="FoghornModel.SendingApplication" Role="SendingApplication" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Type="FoghornModel.Subscriber" Role="Subscriber" Multiplicity="*" />
+        </Association>
+        <EntityType Name="NotificationType">
+          <Key>
+            <PropertyRef Name="NotificationTypeId" />
+          </Key>
+          <Property Type="Int32" Name="NotificationTypeId" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Type="String" Name="NotificationTypeName" Nullable="false" MaxLength="32" />
+          <Property Type="String" Name="NotificationTypeDisplayName" Nullable="false" MaxLength="255" />
+          <NavigationProperty Name="SendingApplication" Relationship="FoghornModel.SendingApplicationNotificationType"
+                              FromRole="NotificationType" ToRole="SendingApplication" />
+          <Property Type="Binary" Name="NotificationTypeIcon" Nullable="true" />
+        </EntityType>
+        <Association Name="NotificationNotificationType">
+          <End Type="FoghornModel.Notification" Role="Notification" Multiplicity="*" />
+          <End Type="FoghornModel.NotificationType" Role="NotificationType" Multiplicity="1" />
+        </Association>
+        <Association Name="SendingApplicationNotificationType">
+          <End Type="FoghornModel.SendingApplication" Role="SendingApplication" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Type="FoghornModel.NotificationType" Role="NotificationType" Multiplicity="*">
+          </End>
+        </Association>
+      </Schema>
+    </edmx:ConceptualModels>
+    <!-- C-S mapping content -->
+    <edmx:Mappings>
+      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
+        <EntityContainerMapping StorageEntityContainer="FoghornModelStoreContainer"
+                                CdmEntityContainer="FoghornEntities">
+          <EntitySetMapping Name="Subscribers">
+            <EntityTypeMapping TypeName="IsTypeOf(FoghornModel.Subscriber)">
+              <MappingFragment StoreEntitySet="Subscribers">
+                <ScalarProperty Name="SubscriberId" ColumnName="SubscriberId" />
+                <ScalarProperty Name="SubscriberName" ColumnName="SubscriberName" />
+                <ScalarProperty Name="Port" ColumnName="Port" />
+                <ScalarProperty Name="HostName" ColumnName="HostName" />
+                <ScalarProperty Name="Password" ColumnName="Password" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Notifications">
+            <EntityTypeMapping TypeName="IsTypeOf(FoghornModel.Notification)">
+              <MappingFragment StoreEntitySet="Notifications">
+                <ScalarProperty Name="NotificationId" ColumnName="NotificationId" />
+                <ScalarProperty Name="NotificationTitle" ColumnName="NotificationTitle" />
+                <ScalarProperty Name="NotificationMessage" ColumnName="NotificationMessage" />
+                <ScalarProperty Name="SentDateTime" ColumnName="SentDateTime" />
+                <ScalarProperty Name="Priority" ColumnName="Priority" />
+                <ScalarProperty Name="Sticky" ColumnName="Sticky" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="SendingApplications">
+            <EntityTypeMapping TypeName="IsTypeOf(FoghornModel.SendingApplication)">
+              <MappingFragment StoreEntitySet="SendingApplications">
+                <ScalarProperty Name="SendingApplicationId" ColumnName="SendingApplicationId" />
+                <ScalarProperty Name="SendingApplicationName" ColumnName="SendingApplicationName" />
+                <ScalarProperty Name="SendingApplicationIcon" ColumnName="SendingApplicationIcon" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="NotificationTypes">
+            <EntityTypeMapping TypeName="IsTypeOf(FoghornModel.NotificationType)">
+              <MappingFragment StoreEntitySet="NotificationTypes">
+                <ScalarProperty Name="NotificationTypeId" ColumnName="NotificationTypeId" />
+                <ScalarProperty Name="NotificationTypeName" ColumnName="NotificationTypeName" />
+                <ScalarProperty Name="NotificationTypeDisplayName" ColumnName="NotificationTypeDisplayName" />
+                <ScalarProperty Name="NotificationTypeIcon" ColumnName="NotificationTypeIcon" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <AssociationSetMapping Name="SubscriberNotification" TypeName="FoghornModel.SubscriberNotification"
+                                 StoreEntitySet="SubscriberNotification">
+            <EndProperty Name="Subscriber">
+              <ScalarProperty Name="SubscriberId" ColumnName="SentToSubscribers_SubscriberId" />
+            </EndProperty>
+            <EndProperty Name="Notification">
+              <ScalarProperty Name="NotificationId" ColumnName="NotificationsSent_NotificationId" />
+            </EndProperty>
+          </AssociationSetMapping>
+          <AssociationSetMapping Name="SendingApplicationSubscriber"
+                                 TypeName="FoghornModel.SendingApplicationSubscriber" StoreEntitySet="Subscribers">
+            <EndProperty Name="SendingApplication">
+              <ScalarProperty Name="SendingApplicationId" ColumnName="SendingApplication_SendingApplicationId" />
+            </EndProperty>
+            <EndProperty Name="Subscriber">
+              <ScalarProperty Name="SubscriberId" ColumnName="SubscriberId" />
+            </EndProperty>
+          </AssociationSetMapping>
+          <AssociationSetMapping Name="NotificationNotificationType"
+                                 TypeName="FoghornModel.NotificationNotificationType" StoreEntitySet="Notifications">
+            <EndProperty Name="NotificationType">
+              <ScalarProperty Name="NotificationTypeId" ColumnName="NotificationType_NotificationTypeId" />
+            </EndProperty>
+            <EndProperty Name="Notification">
+              <ScalarProperty Name="NotificationId" ColumnName="NotificationId" />
+            </EndProperty>
+          </AssociationSetMapping>
+          <AssociationSetMapping Name="SendingApplicationNotificationType"
+                                 TypeName="FoghornModel.SendingApplicationNotificationType"
+                                 StoreEntitySet="NotificationTypes">
+            <EndProperty Name="SendingApplication">
+              <ScalarProperty Name="SendingApplicationId" ColumnName="SendingApplication_SendingApplicationId" />
+            </EndProperty>
+            <EndProperty Name="NotificationType">
+              <ScalarProperty Name="NotificationTypeId" ColumnName="NotificationTypeId" />
+            </EndProperty>
+          </AssociationSetMapping>
+        </EntityContainerMapping>
+      </Mapping>
+    </edmx:Mappings>
+  </edmx:Runtime>
+  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
+  <Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
+    <Connection>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
+      </DesignerInfoPropertySet>
+    </Connection>
+    <Options>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="ValidateOnBuild" Value="true" />
+        <DesignerProperty Name="EnablePluralization" Value="True" />
+        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
+        <DesignerProperty Name="CodeGenerationStrategy" Value="None" />
+      </DesignerInfoPropertySet>
+    </Options>
+    <!-- Diagram content (shape and connector positions) -->
+    <Diagrams></Diagrams>
+  </Designer>
+</edmx:Edmx>

+ 19 - 0
Foghorn.Core/FoghornModel.edmx.diagram

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
+ <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
+  <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
+    <!-- Diagram content (shape and connector positions) -->
+    <edmx:Diagrams>
+      <Diagram DiagramId="4d7f8f81f2a84815a182e72a89b34d55" Name="Diagram1" >
+        <EntityTypeShape EntityType="FoghornModel.Subscriber" Width="3" PointX="0.625" PointY="2.5" />
+        <EntityTypeShape EntityType="FoghornModel.Notification" Width="2.625" PointX="5.25" PointY="1.375" />
+        <AssociationConnector Association="FoghornModel.SubscriberNotification" />
+        <EntityTypeShape EntityType="FoghornModel.SendingApplication" Width="2.5" PointX="2.375" PointY="5.75" />
+        <AssociationConnector Association="FoghornModel.SendingApplicationSubscriber" />
+        <EntityTypeShape EntityType="FoghornModel.NotificationType" Width="3" PointX="7.5" PointY="5.5" />
+        <AssociationConnector Association="FoghornModel.NotificationNotificationType" />
+        <AssociationConnector Association="FoghornModel.SendingApplicationNotificationType" />
+      </Diagram>
+    </edmx:Diagrams>
+  </edmx:Designer>
+</edmx:Edmx>

+ 213 - 0
Foghorn.Core/FoghornModel.edmx.sql

@@ -0,0 +1,213 @@
+
+-- --------------------------------------------------
+-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
+-- --------------------------------------------------
+-- Date Created: 02/15/2013 18:45:53
+-- Generated from EDMX file: C:\Development\Foghorn\Foghorn.Core\FoghornModel.edmx
+-- --------------------------------------------------
+
+SET QUOTED_IDENTIFIER OFF;
+GO
+USE [Foghorn];
+GO
+IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
+GO
+
+-- --------------------------------------------------
+-- Dropping existing FOREIGN KEY constraints
+-- --------------------------------------------------
+
+IF OBJECT_ID(N'[dbo].[FK_SubscriberNotification_Subscriber]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[SubscriberNotification] DROP CONSTRAINT [FK_SubscriberNotification_Subscriber];
+GO
+IF OBJECT_ID(N'[dbo].[FK_SubscriberNotification_Notification]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[SubscriberNotification] DROP CONSTRAINT [FK_SubscriberNotification_Notification];
+GO
+IF OBJECT_ID(N'[dbo].[FK_SendingApplicationSubscriber]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Subscribers] DROP CONSTRAINT [FK_SendingApplicationSubscriber];
+GO
+IF OBJECT_ID(N'[dbo].[FK_NotificationNotificationType]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Notifications] DROP CONSTRAINT [FK_NotificationNotificationType];
+GO
+IF OBJECT_ID(N'[dbo].[FK_SendingApplicationNotificationType]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[NotificationTypes] DROP CONSTRAINT [FK_SendingApplicationNotificationType];
+GO
+
+-- --------------------------------------------------
+-- Dropping existing tables
+-- --------------------------------------------------
+
+IF OBJECT_ID(N'[dbo].[Subscribers]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Subscribers];
+GO
+IF OBJECT_ID(N'[dbo].[Notifications]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Notifications];
+GO
+IF OBJECT_ID(N'[dbo].[SendingApplications]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[SendingApplications];
+GO
+IF OBJECT_ID(N'[dbo].[NotificationTypes]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[NotificationTypes];
+GO
+IF OBJECT_ID(N'[dbo].[SubscriberNotification]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[SubscriberNotification];
+GO
+
+-- --------------------------------------------------
+-- Creating all tables
+-- --------------------------------------------------
+
+-- Creating table 'Subscribers'
+CREATE TABLE [dbo].[Subscribers] (
+    [SubscriberId] uniqueidentifier  NOT NULL,
+    [SubscriberName] nvarchar(255)  NOT NULL,
+    [Port] int  NULL,
+    [HostName] nvarchar(255)  NOT NULL,
+    [Password] nvarchar(20)  NOT NULL,
+    [SendingApplication_SendingApplicationId] int  NOT NULL
+);
+GO
+
+-- Creating table 'Notifications'
+CREATE TABLE [dbo].[Notifications] (
+    [NotificationId] int IDENTITY(1,1) NOT NULL,
+    [NotificationTitle] nvarchar(max)  NOT NULL,
+    [NotificationMessage] nvarchar(max)  NOT NULL,
+    [SentDateTime] datetime  NOT NULL,
+    [Priority] int  NOT NULL,
+    [Sticky] bit  NOT NULL,
+    [NotificationType_NotificationTypeId] int  NOT NULL
+);
+GO
+
+-- Creating table 'SendingApplications'
+CREATE TABLE [dbo].[SendingApplications] (
+    [SendingApplicationId] int IDENTITY(1,1) NOT NULL,
+    [SendingApplicationName] nvarchar(255)  NOT NULL,
+    [SendingApplicationIcon] varbinary(max)  NULL
+);
+GO
+
+-- Creating table 'NotificationTypes'
+CREATE TABLE [dbo].[NotificationTypes] (
+    [NotificationTypeId] int IDENTITY(1,1) NOT NULL,
+    [NotificationTypeName] nvarchar(32)  NOT NULL,
+    [NotificationTypeDisplayName] nvarchar(255)  NOT NULL,
+    [NotificationTypeIcon] varbinary(max)  NULL,
+    [SendingApplication_SendingApplicationId] int  NOT NULL
+);
+GO
+
+-- Creating table 'SubscriberNotification'
+CREATE TABLE [dbo].[SubscriberNotification] (
+    [SentToSubscribers_SubscriberId] uniqueidentifier  NOT NULL,
+    [NotificationsSent_NotificationId] int  NOT NULL
+);
+GO
+
+-- --------------------------------------------------
+-- Creating all PRIMARY KEY constraints
+-- --------------------------------------------------
+
+-- Creating primary key on [SubscriberId] in table 'Subscribers'
+ALTER TABLE [dbo].[Subscribers]
+ADD CONSTRAINT [PK_Subscribers]
+    PRIMARY KEY CLUSTERED ([SubscriberId] ASC);
+GO
+
+-- Creating primary key on [NotificationId] in table 'Notifications'
+ALTER TABLE [dbo].[Notifications]
+ADD CONSTRAINT [PK_Notifications]
+    PRIMARY KEY CLUSTERED ([NotificationId] ASC);
+GO
+
+-- Creating primary key on [SendingApplicationId] in table 'SendingApplications'
+ALTER TABLE [dbo].[SendingApplications]
+ADD CONSTRAINT [PK_SendingApplications]
+    PRIMARY KEY CLUSTERED ([SendingApplicationId] ASC);
+GO
+
+-- Creating primary key on [NotificationTypeId] in table 'NotificationTypes'
+ALTER TABLE [dbo].[NotificationTypes]
+ADD CONSTRAINT [PK_NotificationTypes]
+    PRIMARY KEY CLUSTERED ([NotificationTypeId] ASC);
+GO
+
+-- Creating primary key on [SentToSubscribers_SubscriberId], [NotificationsSent_NotificationId] in table 'SubscriberNotification'
+ALTER TABLE [dbo].[SubscriberNotification]
+ADD CONSTRAINT [PK_SubscriberNotification]
+    PRIMARY KEY NONCLUSTERED ([SentToSubscribers_SubscriberId], [NotificationsSent_NotificationId] ASC);
+GO
+
+-- --------------------------------------------------
+-- Creating all FOREIGN KEY constraints
+-- --------------------------------------------------
+
+-- Creating foreign key on [SentToSubscribers_SubscriberId] in table 'SubscriberNotification'
+ALTER TABLE [dbo].[SubscriberNotification]
+ADD CONSTRAINT [FK_SubscriberNotification_Subscriber]
+    FOREIGN KEY ([SentToSubscribers_SubscriberId])
+    REFERENCES [dbo].[Subscribers]
+        ([SubscriberId])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating foreign key on [NotificationsSent_NotificationId] in table 'SubscriberNotification'
+ALTER TABLE [dbo].[SubscriberNotification]
+ADD CONSTRAINT [FK_SubscriberNotification_Notification]
+    FOREIGN KEY ([NotificationsSent_NotificationId])
+    REFERENCES [dbo].[Notifications]
+        ([NotificationId])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_SubscriberNotification_Notification'
+CREATE INDEX [IX_FK_SubscriberNotification_Notification]
+ON [dbo].[SubscriberNotification]
+    ([NotificationsSent_NotificationId]);
+GO
+
+-- Creating foreign key on [SendingApplication_SendingApplicationId] in table 'Subscribers'
+ALTER TABLE [dbo].[Subscribers]
+ADD CONSTRAINT [FK_SendingApplicationSubscriber]
+    FOREIGN KEY ([SendingApplication_SendingApplicationId])
+    REFERENCES [dbo].[SendingApplications]
+        ([SendingApplicationId])
+    ON DELETE CASCADE ON UPDATE NO ACTION;
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_SendingApplicationSubscriber'
+CREATE INDEX [IX_FK_SendingApplicationSubscriber]
+ON [dbo].[Subscribers]
+    ([SendingApplication_SendingApplicationId]);
+GO
+
+-- Creating foreign key on [NotificationType_NotificationTypeId] in table 'Notifications'
+ALTER TABLE [dbo].[Notifications]
+ADD CONSTRAINT [FK_NotificationNotificationType]
+    FOREIGN KEY ([NotificationType_NotificationTypeId])
+    REFERENCES [dbo].[NotificationTypes]
+        ([NotificationTypeId])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_NotificationNotificationType'
+CREATE INDEX [IX_FK_NotificationNotificationType]
+ON [dbo].[Notifications]
+    ([NotificationType_NotificationTypeId]);
+GO
+
+-- Creating foreign key on [SendingApplication_SendingApplicationId] in table 'NotificationTypes'
+ALTER TABLE [dbo].[NotificationTypes]
+ADD CONSTRAINT [FK_SendingApplicationNotificationType]
+    FOREIGN KEY ([SendingApplication_SendingApplicationId])
+    REFERENCES [dbo].[SendingApplications]
+        ([SendingApplicationId])
+    ON DELETE CASCADE ON UPDATE NO ACTION;
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_SendingApplicationNotificationType'
+CREATE INDEX [IX_FK_SendingApplicationNotificationType]
+ON [dbo].[NotificationTypes]
+    ([SendingApplication_SendingApplicationId]);
+GO
+
+-- --------------------------------------------------
+-- Script has ended
+-- --------------------------------------------------

+ 845 - 0
Foghorn.Core/FoghornModel.tt

@@ -0,0 +1,845 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF.Utility.CS.ttinclude"#><#@ 
+ output extension=".cs"#><#
+
+const string inputFile = @"FoghornModel.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var	fileManager = EntityFrameworkTemplateFileManager.Create(this);
+var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
+{
+    return string.Empty;
+}
+
+WriteHeader(codeStringGenerator, fileManager);
+
+foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
+{
+    fileManager.StartNewFile(entity.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
+<#=codeStringGenerator.EntityClassOpening(entity)#>
+{
+<#
+    var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
+    var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
+    var complexProperties = typeMapper.GetComplexProperties(entity);
+
+    if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
+    {
+#>
+    public <#=code.Escape(entity)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var navigationProperty in collectionNavigationProperties)
+        {
+#>
+        this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var simpleProperties = typeMapper.GetSimpleProperties(entity);
+    if (simpleProperties.Any())
+    {
+        foreach (var edmProperty in simpleProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var complexProperty in complexProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(complexProperty)#>
+<#
+        }
+    }
+
+    var navigationProperties = typeMapper.GetNavigationProperties(entity);
+    if (navigationProperties.Any())
+    {
+#>
+
+<#
+        foreach (var navigationProperty in navigationProperties)
+        {
+#>
+    <#=codeStringGenerator.NavigationProperty(navigationProperty)#>
+<#
+        }
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
+{
+    fileManager.StartNewFile(complex.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
+{
+<#
+    var complexProperties = typeMapper.GetComplexProperties(complex);
+    var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
+
+    if (propertiesWithDefaultValues.Any() || complexProperties.Any())
+    {
+#>
+    public <#=code.Escape(complex)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var simpleProperties = typeMapper.GetSimpleProperties(complex);
+    if (simpleProperties.Any())
+    {
+        foreach(var edmProperty in simpleProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var edmProperty in complexProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
+{
+    fileManager.StartNewFile(enumType.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#
+    if (typeMapper.EnumIsFlags(enumType))
+    {
+#>
+[Flags]
+<#
+    }
+#>
+<#=codeStringGenerator.EnumOpening(enumType)#>
+{
+<#
+    var foundOne = false;
+    
+    foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
+    {
+        foundOne = true;
+#>
+    <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
+<#
+    }
+
+    if (foundOne)
+    {
+        this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+fileManager.Process();
+
+#>
+<#+
+
+public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
+{
+    fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+// <#=GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=GetResourceString("Template_GeneratedCodeCommentLine3")#>
+// </auto-generated>
+//------------------------------------------------------------------------------
+<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
+<#+
+    fileManager.EndBlock();
+}
+
+public void BeginNamespace(CodeGenerationTools code)
+{
+    var codeNamespace = code.VsNamespaceSuggestion();
+    if (!String.IsNullOrEmpty(codeNamespace))
+    {
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#+
+        PushIndent("    ");
+    }
+}
+
+public void EndNamespace(CodeGenerationTools code)
+{
+    if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
+    {
+        PopIndent();
+#>
+}
+<#+
+    }
+}
+
+public const string TemplateId = "CSharp_DbContext_Types_EF5";
+
+public class CodeStringGenerator
+{
+    private readonly CodeGenerationTools _code;
+    private readonly TypeMapper _typeMapper;
+    private readonly MetadataTools _ef;
+
+    public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(typeMapper, "typeMapper");
+        ArgumentNotNull(ef, "ef");
+
+        _code = code;
+        _typeMapper = typeMapper;
+        _ef = ef;
+    }
+
+    public string Property(EdmProperty edmProperty)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            Accessibility.ForProperty(edmProperty),
+            _typeMapper.GetTypeName(edmProperty.TypeUsage),
+            _code.Escape(edmProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+
+    public string NavigationProperty(NavigationProperty navigationProperty)
+    {
+        var endType = _typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType());
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            AccessibilityAndVirtual(Accessibility.ForProperty(navigationProperty)),
+            navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+            _code.Escape(navigationProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(navigationProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(navigationProperty)));
+    }
+    
+    public string AccessibilityAndVirtual(string accessibility)
+    {
+        return accessibility + (accessibility != "private" ? " virtual" : "");
+    }
+    
+    public string EntityClassOpening(EntityType entity)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1}partial class {2}{3}",
+            Accessibility.ForType(entity),
+            _code.SpaceAfter(_code.AbstractOption(entity)),
+            _code.Escape(entity),
+            _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+    }
+    
+    public string EnumOpening(SimpleType enumType)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} enum {1} : {2}",
+            Accessibility.ForType(enumType),
+            _code.Escape(enumType),
+            _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+        }
+    
+    public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
+    {
+        var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+        foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+        {
+            var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+            var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+            var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + parameter.RawClrTypeName + "))";
+            writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+        }
+    }
+    
+    public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} IQueryable<{1}> {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            _code.Escape(edmFunction),
+            string.Join(", ", parameters.Select(p => p.FunctionParameterType + " " + p.FunctionParameterName).ToArray()));
+    }
+    
+    public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            edmFunction.NamespaceName,
+            edmFunction.Name,
+            string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+            _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+    }
+    
+    public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var paramList = String.Join(", ", parameters.Select(p => p.FunctionParameterType + " " + p.FunctionParameterName).ToArray());
+        if (includeMergeOption)
+        {
+            paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+        }
+
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            _code.Escape(edmFunction),
+            paramList);
+    }
+    
+    public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+        if (includeMergeOption)
+        {
+            callParams = ", mergeOption" + callParams;
+        }
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+            returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            edmFunction.Name,
+            callParams);
+    }
+    
+    public string DbSet(EntitySet entitySet)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} DbSet<{1}> {2} {{ get; set; }}",
+            Accessibility.ForReadOnlyProperty(entitySet),
+            _typeMapper.GetTypeName(entitySet.ElementType),
+            _code.Escape(entitySet));
+    }
+
+    public string UsingDirectives(bool inHeader, bool includeCollections = true)
+    {
+        return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+            ? string.Format(
+                CultureInfo.InvariantCulture,
+                "{0}using System;{1}" +
+                "{2}",
+                inHeader ? Environment.NewLine : "",
+                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+                inHeader ? "" : Environment.NewLine)
+            : "";
+    }
+}
+
+public class TypeMapper
+{
+    private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+    private readonly System.Collections.IList _errors;
+    private readonly CodeGenerationTools _code;
+    private readonly MetadataTools _ef;
+
+    public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(ef, "ef");
+        ArgumentNotNull(errors, "errors");
+
+        _code = code;
+        _ef = ef;
+        _errors = errors;
+    }
+
+    public string GetTypeName(TypeUsage typeUsage)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+    }
+
+    public string GetTypeName(EdmType edmType)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+    }
+
+    public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, string modelNamespace)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+    {
+        if (edmType == null)
+        {
+            return null;
+        }
+
+        var collectionType = edmType as CollectionType;
+        if (collectionType != null)
+        {
+            return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+        }
+
+        var typeName = _code.Escape(edmType.MetadataProperties
+                                .Where(p => p.Name == ExternalTypeNameAttributeName)
+                                .Select(p => (string)p.Value)
+                                .FirstOrDefault())
+            ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+                _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+                _code.Escape(edmType));
+
+        if (edmType is StructuralType)
+        {
+            return typeName;
+        }
+
+        if (edmType is SimpleType)
+        {
+            var clrType = UnderlyingClrType(edmType);
+            if (!IsEnumType(edmType))
+            {
+                typeName = _code.Escape(clrType);
+            }
+
+            return clrType.IsValueType && isNullable == true ?
+                String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+                typeName;
+        }
+
+        throw new ArgumentException("edmType");
+    }
+    
+    public Type UnderlyingClrType(EdmType edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        var primitiveType = edmType as PrimitiveType;
+        if (primitiveType != null)
+        {
+            return primitiveType.ClrEquivalentType;
+        }
+
+        if (IsEnumType(edmType))
+        {
+            return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+        }
+
+        return typeof(object);
+    }
+    
+    public object GetEnumMemberValue(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var valueProperty = enumMember.GetType().GetProperty("Value");
+        return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+    }
+    
+    public string GetEnumMemberName(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var nameProperty = enumMember.GetType().GetProperty("Name");
+        return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+    }
+
+    public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        var membersProperty = enumType.GetType().GetProperty("Members");
+        return membersProperty != null 
+            ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+            : Enumerable.Empty<MetadataItem>();
+    }
+    
+    public bool EnumIsFlags(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+        
+        var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+        return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+    }
+
+    public bool IsEnumType(GlobalItem edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        return edmType.GetType().Name == "EnumType";
+    }
+
+    public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+    }
+
+    public string CreateLiteral(object value)
+    {
+        if (value == null || value.GetType() != typeof(TimeSpan))
+        {
+            return _code.CreateLiteral(value);
+        }
+
+        return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+    }
+    
+    public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
+    {
+        ArgumentNotNull(types, "types");
+        ArgumentNotNull(sourceFile, "sourceFile");
+        
+        var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+        if (types.Any(item => !hash.Add(item)))
+        {
+            _errors.Add(
+                new CompilerError(sourceFile, -1, -1, "6023",
+                    String.Format(CultureInfo.CurrentCulture, GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+            return false;
+        }
+        return true;
+    }
+    
+    public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
+    {
+        return GetItemsToGenerate<SimpleType>(itemCollection)
+            .Where(e => IsEnumType(e));
+    }
+    
+    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
+    {
+        return itemCollection
+            .OfType<T>()
+            .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+            .OrderBy(i => i.Name);
+    }
+
+    public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
+    {
+        return itemCollection
+            .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+            .Select(g => GetGlobalItemName(g));
+    }
+
+    public string GetGlobalItemName(GlobalItem item)
+    {
+        if (item is EdmType)
+        {
+            return ((EdmType)item).Name;
+        }
+        else
+        {
+            return ((EntityContainer)item).Name;
+        }
+    }
+
+    public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+    
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+
+    public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type);
+    }
+    
+    public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    }
+    
+    public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+        return returnParamsProperty == null
+            ? edmFunction.ReturnParameter
+            : ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+    }
+
+    public bool IsComposable(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+        return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+    }
+
+    public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
+    {
+        return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+    }
+
+    public TypeUsage GetReturnType(EdmFunction edmFunction)
+    {
+        var returnParam = GetReturnParameter(edmFunction);
+        return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+    }
+    
+    public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+    {
+        var returnType = GetReturnType(edmFunction);
+        return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+    }
+}
+
+public class EdmMetadataLoader
+{
+    private readonly IDynamicHost _host;
+    private readonly System.Collections.IList _errors;
+
+    public EdmMetadataLoader(IDynamicHost host, System.Collections.IList errors)
+    {
+        ArgumentNotNull(host, "host");
+        ArgumentNotNull(errors, "errors");
+
+        _host = host;
+        _errors = errors;
+    }
+
+    public IEnumerable<GlobalItem> CreateEdmItemCollection(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        if (!ValidateInputPath(sourcePath))
+        {
+            return new EdmItemCollection();
+        }
+
+        var schemaElement = LoadRootElement(_host.ResolvePath(sourcePath));
+        if (schemaElement != null)
+        {
+            using (var reader = schemaElement.CreateReader())
+            {
+                IList<EdmSchemaError> errors;
+                var itemCollection = MetadataItemCollectionFactory.CreateEdmItemCollection(new[] { reader }, out errors);
+
+                ProcessErrors(errors, sourcePath);
+
+                return itemCollection;
+            }
+        }
+        return new EdmItemCollection();
+    }
+
+    public string GetModelNamespace(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        if (!ValidateInputPath(sourcePath))
+        {
+            return string.Empty;
+        }
+
+        var model = LoadRootElement(_host.ResolvePath(sourcePath));
+        if (model == null)
+        {
+            return string.Empty;
+        }
+
+        var attribute = model.Attribute("Namespace");
+        return attribute != null ? attribute.Value : "";
+    }
+
+    private bool ValidateInputPath(string sourcePath)
+    {
+        if (sourcePath == "$" + "edmxInputFile" + "$")
+        {
+            _errors.Add(
+                new CompilerError(_host.TemplateFile ?? sourcePath, 0, 0, string.Empty,
+                    GetResourceString("Template_ReplaceVsItemTemplateToken")));
+            return false;
+        }
+
+        return true;
+    }
+
+    public XElement LoadRootElement(string sourcePath)
+    {
+        ArgumentNotNull(sourcePath, "sourcePath");
+
+        var root = XElement.Load(sourcePath, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo);
+        return root.Elements()
+            .Where(e => e.Name.LocalName == "Runtime")
+            .Elements()
+            .Where(e => e.Name.LocalName == "ConceptualModels")
+            .Elements()
+            .Where(e => e.Name.LocalName == "Schema")
+            .FirstOrDefault()
+                ?? root;
+    }
+
+    private void ProcessErrors(IEnumerable<EdmSchemaError> errors, string sourceFilePath)
+    {
+        foreach (var error in errors)
+        {
+            _errors.Add(
+                new CompilerError(
+                    error.SchemaLocation ?? sourceFilePath,
+                    error.Line,
+                    error.Column,
+                    error.ErrorCode.ToString(CultureInfo.InvariantCulture),
+                    error.Message)
+                {
+                    IsWarning = error.Severity == EdmSchemaErrorSeverity.Warning
+                });
+        }
+    }
+    
+    public bool IsLazyLoadingEnabled(EntityContainer container)
+    {
+        string lazyLoadingAttributeValue;
+        var lazyLoadingAttributeName = MetadataConstants.EDM_ANNOTATION_09_02 + ":LazyLoadingEnabled";
+        bool isLazyLoading;
+        return !MetadataTools.TryGetStringMetadataPropertySetting(container, lazyLoadingAttributeName, out lazyLoadingAttributeValue)
+            || !bool.TryParse(lazyLoadingAttributeValue, out isLazyLoading)
+            || isLazyLoading;
+    }
+}
+
+public static void ArgumentNotNull<T>(T arg, string name) where T : class
+{
+    if (arg == null)
+    {
+        throw new ArgumentNullException(name);
+    }
+}
+    
+private static readonly Lazy<System.Resources.ResourceManager> ResourceManager =
+    new Lazy<System.Resources.ResourceManager>(
+        () => new System.Resources.ResourceManager("System.Data.Entity.Design", typeof(MetadataItemCollectionFactory).Assembly), isThreadSafe: true);
+
+public static string GetResourceString(string resourceName)
+{
+    ArgumentNotNull(resourceName, "resourceName");
+
+    return ResourceManager.Value.GetString(resourceName, null);
+}
+
+#>

+ 30 - 0
Foghorn.Core/ModelAssemblerExtensions.cs

@@ -0,0 +1,30 @@
+// <copyright file="ModelAssemblerExtensions.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Collections.Generic;
+
+namespace Foghorn.Core
+{
+    public partial class SendingApplicationAssembler
+    {
+        static partial void OnDto(this SendingApplication entity, SendingApplicationDto dto)
+        {
+            dto.NotificationTypes = (List<NotificationTypeDto>) entity.NotificationTypes.ToDtos();
+        }
+    }
+}

+ 362 - 0
Foghorn.Core/ModelAssemblers.cs

@@ -0,0 +1,362 @@
+//-------------------------------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by EntitiesToDtos.v3.0 (entitiestodtos.codeplex.com).
+//     Timestamp: 2013/02/15 - 18:47:39
+//
+//     Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
+// </auto-generated>
+//-------------------------------------------------------------------------------------------------------
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Text;
+using System.Linq;
+using System.Data.Objects.DataClasses;
+
+namespace Foghorn.Core
+{
+
+    /// <summary>
+    /// Assembler for <see cref="Subscriber"/> and <see cref="SubscriberDto"/>.
+    /// </summary>
+    public static partial class SubscriberAssembler
+    {
+        /// <summary>
+        /// Invoked when <see cref="ToDto"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="SubscriberDto"/> converted from <see cref="Subscriber"/>.</param>
+        /// <param name="entity"><see cref="Subscriber"/> converted from <see cref="SubscriberDto"/>.</param>
+        static partial void OnDto(this Subscriber entity, SubscriberDto dto);
+
+        /// <summary>
+        /// Invoked when <see cref="ToEntity"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="SubscriberDto"/> converted from <see cref="Subscriber"/>.</param>
+        /// <param name="entity"><see cref="Subscriber"/> converted from <see cref="SubscriberDto"/>.</param>
+        static partial void OnEntity(this SubscriberDto dto, Subscriber entity);
+
+        /// <summary>
+        /// Converts this instance of <see cref="SubscriberDto"/> to an instance of <see cref="Subscriber"/>.
+        /// </summary>
+        /// <param name="dto"><see cref="SubscriberDto"/> to convert.</param>
+        public static Subscriber ToEntity(this SubscriberDto dto)
+        {
+            if (dto == null) return null;
+
+            var entity = new Subscriber();
+
+            entity.SubscriberId = dto.SubscriberId;
+            entity.SubscriberName = dto.SubscriberName;
+            entity.Port = dto.Port;
+            entity.HostName = dto.HostName;
+            entity.Password = dto.Password;
+
+            dto.OnEntity(entity);
+
+            return entity;
+        }
+
+        /// <summary>
+        /// Converts this instance of <see cref="Subscriber"/> to an instance of <see cref="SubscriberDto"/>.
+        /// </summary>
+        /// <param name="entity"><see cref="Subscriber"/> to convert.</param>
+        public static SubscriberDto ToDto(this Subscriber entity)
+        {
+            if (entity == null) return null;
+
+            var dto = new SubscriberDto();
+
+            dto.SubscriberId = entity.SubscriberId;
+            dto.SubscriberName = entity.SubscriberName;
+            dto.Port = entity.Port;
+            dto.HostName = entity.HostName;
+            dto.Password = entity.Password;
+
+            entity.OnDto(dto);
+
+            return dto;
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="SubscriberDto"/> to an instance of <see cref="Subscriber"/>.
+        /// </summary>
+        /// <param name="dtos">An ICollection of <see cref="SubscriberDto"/>s</param>
+        /// <returns>An ICollection of <see cref="Subscriber"/></returns>
+        public static ICollection<Subscriber> ToEntities(this IEnumerable<SubscriberDto> dtos)
+        {
+            if (dtos == null) return null;
+
+            return dtos.Select(e => e.ToEntity()).ToList();
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="Subscriber"/> to an instance of <see cref="SubscriberDto"/>.
+        /// </summary>
+        /// <param name="entities">An ICollection of <see cref="Subscriber"/>s</param>
+        /// <returns>An ICollection of <see cref="SubscriberDto"/></returns>
+        public static ICollection<SubscriberDto> ToDtos(this IEnumerable<Subscriber> entities)
+        {
+            if (entities == null) return null;
+
+            return entities.Select(e => e.ToDto()).ToList();
+        }
+
+    }
+
+    /// <summary>
+    /// Assembler for <see cref="Notification"/> and <see cref="NotificationDto"/>.
+    /// </summary>
+    public static partial class NotificationAssembler
+    {
+        /// <summary>
+        /// Invoked when <see cref="ToDto"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationDto"/> converted from <see cref="Notification"/>.</param>
+        /// <param name="entity"><see cref="Notification"/> converted from <see cref="NotificationDto"/>.</param>
+        static partial void OnDto(this Notification entity, NotificationDto dto);
+
+        /// <summary>
+        /// Invoked when <see cref="ToEntity"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationDto"/> converted from <see cref="Notification"/>.</param>
+        /// <param name="entity"><see cref="Notification"/> converted from <see cref="NotificationDto"/>.</param>
+        static partial void OnEntity(this NotificationDto dto, Notification entity);
+
+        /// <summary>
+        /// Converts this instance of <see cref="NotificationDto"/> to an instance of <see cref="Notification"/>.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationDto"/> to convert.</param>
+        public static Notification ToEntity(this NotificationDto dto)
+        {
+            if (dto == null) return null;
+
+            var entity = new Notification();
+
+            entity.NotificationId = dto.NotificationId;
+            entity.NotificationTitle = dto.NotificationTitle;
+            entity.NotificationMessage = dto.NotificationMessage;
+            entity.SentDateTime = dto.SentDateTime;
+            entity.Priority = dto.Priority;
+            entity.Sticky = dto.Sticky;
+
+            dto.OnEntity(entity);
+
+            return entity;
+        }
+
+        /// <summary>
+        /// Converts this instance of <see cref="Notification"/> to an instance of <see cref="NotificationDto"/>.
+        /// </summary>
+        /// <param name="entity"><see cref="Notification"/> to convert.</param>
+        public static NotificationDto ToDto(this Notification entity)
+        {
+            if (entity == null) return null;
+
+            var dto = new NotificationDto();
+
+            dto.NotificationId = entity.NotificationId;
+            dto.NotificationTitle = entity.NotificationTitle;
+            dto.NotificationMessage = entity.NotificationMessage;
+            dto.SentDateTime = entity.SentDateTime;
+            dto.Priority = entity.Priority;
+            dto.Sticky = entity.Sticky;
+
+            entity.OnDto(dto);
+
+            return dto;
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="NotificationDto"/> to an instance of <see cref="Notification"/>.
+        /// </summary>
+        /// <param name="dtos">An ICollection of <see cref="NotificationDto"/>s</param>
+        /// <returns>An ICollection of <see cref="Notification"/></returns>
+        public static ICollection<Notification> ToEntities(this IEnumerable<NotificationDto> dtos)
+        {
+            if (dtos == null) return null;
+
+            return dtos.Select(e => e.ToEntity()).ToList();
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="Notification"/> to an instance of <see cref="NotificationDto"/>.
+        /// </summary>
+        /// <param name="entities">An ICollection of <see cref="Notification"/>s</param>
+        /// <returns>An ICollection of <see cref="NotificationDto"/></returns>
+        public static ICollection<NotificationDto> ToDtos(this IEnumerable<Notification> entities)
+        {
+            if (entities == null) return null;
+
+            return entities.Select(e => e.ToDto()).ToList();
+        }
+
+    }
+
+    /// <summary>
+    /// Assembler for <see cref="SendingApplication"/> and <see cref="SendingApplicationDto"/>.
+    /// </summary>
+    public static partial class SendingApplicationAssembler
+    {
+        /// <summary>
+        /// Invoked when <see cref="ToDto"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="SendingApplicationDto"/> converted from <see cref="SendingApplication"/>.</param>
+        /// <param name="entity"><see cref="SendingApplication"/> converted from <see cref="SendingApplicationDto"/>.</param>
+        static partial void OnDto(this SendingApplication entity, SendingApplicationDto dto);
+
+        /// <summary>
+        /// Invoked when <see cref="ToEntity"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="SendingApplicationDto"/> converted from <see cref="SendingApplication"/>.</param>
+        /// <param name="entity"><see cref="SendingApplication"/> converted from <see cref="SendingApplicationDto"/>.</param>
+        static partial void OnEntity(this SendingApplicationDto dto, SendingApplication entity);
+
+        /// <summary>
+        /// Converts this instance of <see cref="SendingApplicationDto"/> to an instance of <see cref="SendingApplication"/>.
+        /// </summary>
+        /// <param name="dto"><see cref="SendingApplicationDto"/> to convert.</param>
+        public static SendingApplication ToEntity(this SendingApplicationDto dto)
+        {
+            if (dto == null) return null;
+
+            var entity = new SendingApplication();
+
+            entity.SendingApplicationId = dto.SendingApplicationId;
+            entity.SendingApplicationName = dto.SendingApplicationName;
+            entity.SendingApplicationIcon = dto.SendingApplicationIcon;
+
+            dto.OnEntity(entity);
+
+            return entity;
+        }
+
+        /// <summary>
+        /// Converts this instance of <see cref="SendingApplication"/> to an instance of <see cref="SendingApplicationDto"/>.
+        /// </summary>
+        /// <param name="entity"><see cref="SendingApplication"/> to convert.</param>
+        public static SendingApplicationDto ToDto(this SendingApplication entity)
+        {
+            if (entity == null) return null;
+
+            var dto = new SendingApplicationDto();
+
+            dto.SendingApplicationId = entity.SendingApplicationId;
+            dto.SendingApplicationName = entity.SendingApplicationName;
+            dto.SendingApplicationIcon = entity.SendingApplicationIcon;
+
+            entity.OnDto(dto);
+
+            return dto;
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="SendingApplicationDto"/> to an instance of <see cref="SendingApplication"/>.
+        /// </summary>
+        /// <param name="dtos">An ICollection of <see cref="SendingApplicationDto"/>s</param>
+        /// <returns>An ICollection of <see cref="SendingApplication"/></returns>
+        public static ICollection<SendingApplication> ToEntities(this IEnumerable<SendingApplicationDto> dtos)
+        {
+            if (dtos == null) return null;
+
+            return dtos.Select(e => e.ToEntity()).ToList();
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="SendingApplication"/> to an instance of <see cref="SendingApplicationDto"/>.
+        /// </summary>
+        /// <param name="entities">An ICollection of <see cref="SendingApplication"/>s</param>
+        /// <returns>An ICollection of <see cref="SendingApplicationDto"/></returns>
+        public static ICollection<SendingApplicationDto> ToDtos(this IEnumerable<SendingApplication> entities)
+        {
+            if (entities == null) return null;
+
+            return entities.Select(e => e.ToDto()).ToList();
+        }
+
+    }
+
+    /// <summary>
+    /// Assembler for <see cref="NotificationType"/> and <see cref="NotificationTypeDto"/>.
+    /// </summary>
+    public static partial class NotificationTypeAssembler
+    {
+        /// <summary>
+        /// Invoked when <see cref="ToDto"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationTypeDto"/> converted from <see cref="NotificationType"/>.</param>
+        /// <param name="entity"><see cref="NotificationType"/> converted from <see cref="NotificationTypeDto"/>.</param>
+        static partial void OnDto(this NotificationType entity, NotificationTypeDto dto);
+
+        /// <summary>
+        /// Invoked when <see cref="ToEntity"/> operation is about to return.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationTypeDto"/> converted from <see cref="NotificationType"/>.</param>
+        /// <param name="entity"><see cref="NotificationType"/> converted from <see cref="NotificationTypeDto"/>.</param>
+        static partial void OnEntity(this NotificationTypeDto dto, NotificationType entity);
+
+        /// <summary>
+        /// Converts this instance of <see cref="NotificationTypeDto"/> to an instance of <see cref="NotificationType"/>.
+        /// </summary>
+        /// <param name="dto"><see cref="NotificationTypeDto"/> to convert.</param>
+        public static NotificationType ToEntity(this NotificationTypeDto dto)
+        {
+            if (dto == null) return null;
+
+            var entity = new NotificationType();
+
+            entity.NotificationTypeId = dto.NotificationTypeId;
+            entity.NotificationTypeName = dto.NotificationTypeName;
+            entity.NotificationTypeDisplayName = dto.NotificationTypeDisplayName;
+            entity.NotificationTypeIcon = dto.NotificationTypeIcon;
+
+            dto.OnEntity(entity);
+
+            return entity;
+        }
+
+        /// <summary>
+        /// Converts this instance of <see cref="NotificationType"/> to an instance of <see cref="NotificationTypeDto"/>.
+        /// </summary>
+        /// <param name="entity"><see cref="NotificationType"/> to convert.</param>
+        public static NotificationTypeDto ToDto(this NotificationType entity)
+        {
+            if (entity == null) return null;
+
+            var dto = new NotificationTypeDto();
+
+            dto.NotificationTypeId = entity.NotificationTypeId;
+            dto.NotificationTypeName = entity.NotificationTypeName;
+            dto.NotificationTypeDisplayName = entity.NotificationTypeDisplayName;
+            dto.NotificationTypeIcon = entity.NotificationTypeIcon;
+
+            entity.OnDto(dto);
+
+            return dto;
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="NotificationTypeDto"/> to an instance of <see cref="NotificationType"/>.
+        /// </summary>
+        /// <param name="dtos">An ICollection of <see cref="NotificationTypeDto"/>s</param>
+        /// <returns>An ICollection of <see cref="NotificationType"/></returns>
+        public static ICollection<NotificationType> ToEntities(this IEnumerable<NotificationTypeDto> dtos)
+        {
+            if (dtos == null) return null;
+
+            return dtos.Select(e => e.ToEntity()).ToList();
+        }
+
+        /// <summary>
+        /// Converts each instance of <see cref="NotificationType"/> to an instance of <see cref="NotificationTypeDto"/>.
+        /// </summary>
+        /// <param name="entities">An ICollection of <see cref="NotificationType"/>s</param>
+        /// <returns>An ICollection of <see cref="NotificationTypeDto"/></returns>
+        public static ICollection<NotificationTypeDto> ToDtos(this IEnumerable<NotificationType> entities)
+        {
+            if (entities == null) return null;
+
+            return entities.Select(e => e.ToDto()).ToList();
+        }
+
+    }
+}

+ 28 - 0
Foghorn.Core/ModelDtoExtensions.cs

@@ -0,0 +1,28 @@
+// <copyright file="ModelDtoExtensions.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Runtime.Serialization;
+
+namespace Foghorn.Core
+{
+    public partial class NotificationDto
+    {
+        [DataMember]
+        public string NotificationTypeName { get; set; }
+    }
+}

+ 163 - 0
Foghorn.Core/ModelDtos.cs

@@ -0,0 +1,163 @@
+//-------------------------------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by EntitiesToDtos.v3.0 (entitiestodtos.codeplex.com).
+//     Timestamp: 2013/02/15 - 18:47:38
+//
+//     Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
+// </auto-generated>
+//-------------------------------------------------------------------------------------------------------
+using System;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace Foghorn.Core
+{
+    [DataContract()]
+    public partial class SubscriberDto
+    {
+        [DataMember()]
+        public Guid SubscriberId { get; set; }
+
+        [DataMember()]
+        public String SubscriberName { get; set; }
+
+        [DataMember()]
+        public Nullable<Int32> Port { get; set; }
+
+        [DataMember()]
+        public String HostName { get; set; }
+
+        [DataMember()]
+        public String Password { get; set; }
+
+        [DataMember()]
+        public List<NotificationDto> NotificationsSent { get; set; }
+
+        [DataMember()]
+        public SendingApplicationDto SendingApplication { get; set; }
+
+        public SubscriberDto()
+        {
+        }
+
+        public SubscriberDto(Guid subscriberId, String subscriberName, Nullable<Int32> port, String hostName, String password, List<NotificationDto> notificationsSent, SendingApplicationDto sendingApplication)
+        {
+			this.SubscriberId = subscriberId;
+			this.SubscriberName = subscriberName;
+			this.Port = port;
+			this.HostName = hostName;
+			this.Password = password;
+			this.NotificationsSent = notificationsSent;
+			this.SendingApplication = sendingApplication;
+        }
+    }
+
+    [DataContract()]
+    public partial class NotificationDto
+    {
+        [DataMember()]
+        public Int32 NotificationId { get; set; }
+
+        [DataMember()]
+        public String NotificationTitle { get; set; }
+
+        [DataMember()]
+        public String NotificationMessage { get; set; }
+
+        [DataMember()]
+        public DateTime SentDateTime { get; set; }
+
+        [DataMember()]
+        public Int32 Priority { get; set; }
+
+        [DataMember()]
+        public Boolean Sticky { get; set; }
+
+        [DataMember()]
+        public List<SubscriberDto> SentToSubscribers { get; set; }
+
+        [DataMember()]
+        public NotificationTypeDto NotificationType { get; set; }
+
+        public NotificationDto()
+        {
+        }
+
+        public NotificationDto(Int32 notificationId, String notificationTitle, String notificationMessage, DateTime sentDateTime, Int32 priority, Boolean sticky, List<SubscriberDto> sentToSubscribers, NotificationTypeDto notificationType)
+        {
+			this.NotificationId = notificationId;
+			this.NotificationTitle = notificationTitle;
+			this.NotificationMessage = notificationMessage;
+			this.SentDateTime = sentDateTime;
+			this.Priority = priority;
+			this.Sticky = sticky;
+			this.SentToSubscribers = sentToSubscribers;
+			this.NotificationType = notificationType;
+        }
+    }
+
+    [DataContract()]
+    public partial class SendingApplicationDto
+    {
+        [DataMember()]
+        public Int32 SendingApplicationId { get; set; }
+
+        [DataMember()]
+        public String SendingApplicationName { get; set; }
+
+        [DataMember()]
+        public Byte[] SendingApplicationIcon { get; set; }
+
+        [DataMember()]
+        public List<SubscriberDto> Subscribers { get; set; }
+
+        [DataMember()]
+        public List<NotificationTypeDto> NotificationTypes { get; set; }
+
+        public SendingApplicationDto()
+        {
+        }
+
+        public SendingApplicationDto(Int32 sendingApplicationId, String sendingApplicationName, Byte[] sendingApplicationIcon, List<SubscriberDto> subscribers, List<NotificationTypeDto> notificationTypes)
+        {
+			this.SendingApplicationId = sendingApplicationId;
+			this.SendingApplicationName = sendingApplicationName;
+			this.SendingApplicationIcon = sendingApplicationIcon;
+			this.Subscribers = subscribers;
+			this.NotificationTypes = notificationTypes;
+        }
+    }
+
+    [DataContract()]
+    public partial class NotificationTypeDto
+    {
+        [DataMember()]
+        public Int32 NotificationTypeId { get; set; }
+
+        [DataMember()]
+        public String NotificationTypeName { get; set; }
+
+        [DataMember()]
+        public String NotificationTypeDisplayName { get; set; }
+
+        [DataMember()]
+        public Byte[] NotificationTypeIcon { get; set; }
+
+        [DataMember()]
+        public SendingApplicationDto SendingApplication { get; set; }
+
+        public NotificationTypeDto()
+        {
+        }
+
+        public NotificationTypeDto(Int32 notificationTypeId, String notificationTypeName, String notificationTypeDisplayName, Byte[] notificationTypeIcon, SendingApplicationDto sendingApplication)
+        {
+			this.NotificationTypeId = notificationTypeId;
+			this.NotificationTypeName = notificationTypeName;
+			this.NotificationTypeDisplayName = notificationTypeDisplayName;
+			this.NotificationTypeIcon = notificationTypeIcon;
+			this.SendingApplication = sendingApplication;
+        }
+    }
+}

+ 34 - 0
Foghorn.Core/Notification.cs

@@ -0,0 +1,34 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.Core
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Notification
+    {
+        public Notification()
+        {
+            this.Priority = 0;
+            this.Sticky = false;
+            this.SentToSubscribers = new HashSet<Subscriber>();
+        }
+    
+        public int NotificationId { get; set; }
+        public string NotificationTitle { get; set; }
+        public string NotificationMessage { get; set; }
+        public System.DateTime SentDateTime { get; set; }
+        public int Priority { get; set; }
+        public bool Sticky { get; set; }
+    
+        public virtual ICollection<Subscriber> SentToSubscribers { get; set; }
+        public virtual NotificationType NotificationType { get; set; }
+    }
+}

+ 24 - 0
Foghorn.Core/NotificationType.cs

@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.Core
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class NotificationType
+    {
+        public int NotificationTypeId { get; set; }
+        public string NotificationTypeName { get; set; }
+        public string NotificationTypeDisplayName { get; set; }
+        public byte[] NotificationTypeIcon { get; set; }
+    
+        public virtual SendingApplication SendingApplication { get; set; }
+    }
+}

+ 57 - 0
Foghorn.Core/Properties/AssemblyInfo.cs

@@ -0,0 +1,57 @@
+// <copyright file="AssemblyInfo.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Foghorn.Core")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Foghorn.Core")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("7417fcfc-4be9-405e-ba09-16ae70e40d7f")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 30 - 0
Foghorn.Core/SendingApplication.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.Core
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class SendingApplication
+    {
+        public SendingApplication()
+        {
+            this.Subscribers = new HashSet<Subscriber>();
+            this.NotificationTypes = new HashSet<NotificationType>();
+        }
+    
+        public int SendingApplicationId { get; set; }
+        public string SendingApplicationName { get; set; }
+        public byte[] SendingApplicationIcon { get; set; }
+    
+        public virtual ICollection<Subscriber> Subscribers { get; set; }
+        public virtual ICollection<NotificationType> NotificationTypes { get; set; }
+    }
+}

+ 31 - 0
Foghorn.Core/Subscriber.cs

@@ -0,0 +1,31 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//    This code was generated from a template.
+//
+//    Manual changes to this file may cause unexpected behavior in your application.
+//    Manual changes to this file will be overwritten if the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.Core
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Subscriber
+    {
+        public Subscriber()
+        {
+            this.NotificationsSent = new HashSet<Notification>();
+        }
+    
+        public System.Guid SubscriberId { get; set; }
+        public string SubscriberName { get; set; }
+        public Nullable<int> Port { get; set; }
+        public string HostName { get; set; }
+        public string Password { get; set; }
+    
+        public virtual ICollection<Notification> NotificationsSent { get; set; }
+        public virtual SendingApplication SendingApplication { get; set; }
+    }
+}

+ 5 - 0
Foghorn.Core/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<packages>
+  <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
+</packages>

+ 9 - 0
Foghorn.Test/App.config

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+  <connectionStrings>
+    <add name="FoghornEntities"
+         connectionString="metadata=res://*/FoghornModel.csdl|res://*/FoghornModel.ssdl|res://*/FoghornModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=Foghorn;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
+         providerName="System.Data.EntityClient" />
+  </connectionStrings>
+</configuration>

+ 94 - 0
Foghorn.Test/Foghorn.Test.csproj

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{2CDCD184-CFB4-4173-8E1B-1777B212C522}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Foghorn.Test</RootNamespace>
+    <AssemblyName>Foghorn.Test</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Foghorn.Core\bin\Debug\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Excel">
+      <HintPath>..\Foghorn.CustomAction\bin\Debug\Excel.dll</HintPath>
+    </Reference>
+    <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="FoghornServiceTests.cs" />
+    <Compile Include="WcfTests.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="NotificationTypes.xlsx">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Foghorn.Core\Foghorn.Core.csproj">
+      <Project>{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}</Project>
+      <Name>Foghorn.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Foghorn.WcfService\Foghorn.WcfService.csproj">
+      <Project>{15b3e0d2-6217-493a-a690-158c497f5318}</Project>
+      <Name>Foghorn.WcfService</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="NotificationIcons\Icon.png" />
+    <Content Include="NotificationIcons\TestNotification1.png" />
+    <Content Include="NotificationIcons\TestNotification2.png" />
+    <Content Include="NotificationIcons\OrderPlaced.png" />
+    <Content Include="NotificationIcons\OrderShipped.png" />
+    <Content Include="NotificationIcons\TestNotification0.png" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 176 - 0
Foghorn.Test/FoghornServiceTests.cs

@@ -0,0 +1,176 @@
+// <copyright file="FoghornServiceTests.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Foghorn.Core;
+using Foghorn.WcfService;
+using NLog;
+using Xunit;
+
+namespace Foghorn.Test
+{
+    public class FoghornServiceTests
+    {
+        private const string ApplicationTestName = "TestApplication";
+        private const int NumNotificationTypes = 3;
+        private const string NotificationName = "TestNotification";
+        private const string FailureMessage = "Failed while testing.";
+        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+        private int _testApplicationId;
+
+        [Fact]
+        public void TestRegisterSendingApplication_3NotificationTypes_ApplicationAndNotificationsInDatabase()
+        {
+            var dataContext = new FoghornEntities();
+
+            DeleteTestApplications(dataContext);
+            var service = new FoghornService();
+            RegisterTestApplication(service);
+
+            Assert.True(_testApplicationId > 0);
+
+            var application =
+                dataContext.SendingApplications.FirstOrDefault(x => x.SendingApplicationName == ApplicationTestName);
+            Assert.NotNull(application);
+            Assert.Equal(NumNotificationTypes, application.NotificationTypes.Count);
+            Assert.True(application.NotificationTypes.First().NotificationTypeName.StartsWith(NotificationName));
+            Assert.Equal(_testApplicationId, application.SendingApplicationId);
+        }
+
+        [Fact]
+        public void TestRegisterSubscription_ApplicationExists_SubscriberRegistered()
+        {
+            var service = new FoghornService();
+            if (_testApplicationId <= 0)
+            {
+                RegisterTestApplication(service);
+            }
+            var subscriberDto = new SubscriberDto
+                {
+                    HostName = "localhost",
+                    Password = "elmo123!",
+                    SubscriberName = ApplicationTestName + "TestSubscriber",
+                };
+            var subscriberId = service.RegisterSubscription(subscriberDto, ApplicationTestName);
+            var dataContext = new FoghornEntities();
+            var subscriber = dataContext.Subscribers.FirstOrDefault(x => x.SubscriberId == subscriberId);
+            Assert.NotNull(subscriber);
+        }
+
+        [Fact]
+        public void TestNotify_SetUpConfigurationAndCallNotify_NotificationSentAndLogged()
+        {
+            TestRegisterSubscription_ApplicationExists_SubscriberRegistered();
+            var service = new FoghornService();
+            var notificationDto = new NotificationDto
+                {
+                    NotificationMessage = "This is the message of the test notification.",
+                    NotificationTypeName = NotificationName + "1",
+                    NotificationTitle = "Notification Title",
+                    Sticky = true,
+                    Priority = 2
+                };
+            var notificationDtoReturned = service.Notify(notificationDto, ApplicationTestName);
+            var notificationId = notificationDtoReturned.NotificationId;
+            var dataContext = new FoghornEntities();
+            var checkNotification = dataContext.Notifications.FirstOrDefault(x => x.NotificationId == notificationId);
+            Assert.NotNull(checkNotification);
+        }
+
+        [Fact]
+        public void TestNotify_ApplicationNotRegistered_ReturnsErrorLogsFailure()
+        {
+            var service = new FoghornService();
+            var notificationDto = new NotificationDto
+                {
+                    NotificationMessage = "This is the message of the test notification.",
+                    NotificationTypeName = NotificationName + "1",
+                    NotificationTitle = "Notification Title"
+                };
+            Assert.Throws<ArgumentException>(delegate { service.Notify(notificationDto, "IncorrectApplication"); });
+        }
+
+        private void RegisterTestApplication(IFoghornService service)
+        {
+            var notificationTypeDtos = new List<NotificationTypeDto>();
+            for (var i = 0; i < NumNotificationTypes; i++)
+            {
+                var notificationTypeDto = new NotificationTypeDto
+                    {
+                        NotificationTypeName = NotificationName + i,
+                        NotificationTypeDisplayName = "Test Notfication " + i
+                    };
+                try
+                {
+                    var iconFilePath = string.Format(@"..\..\NotificationIcons\{0}{1}.png", NotificationName, i);
+                    var iconFile = File.OpenRead(iconFilePath);
+                    var iconBuffer = new byte[iconFile.Length];
+                    iconFile.Read(iconBuffer, 0, (int) iconFile.Length);
+                    notificationTypeDto.NotificationTypeIcon = iconBuffer;
+                }
+                catch (Exception exception)
+                {
+                    Logger.LogException(LogLevel.Error, FailureMessage, exception);
+                    throw;
+                }
+                notificationTypeDtos.Add(notificationTypeDto);
+            }
+
+            var sendingApplicationDto = new SendingApplicationDto {SendingApplicationName = ApplicationTestName};
+            try
+            {
+                var iconFilePath = string.Format(@"..\..\NotificationIcons\Icon.png");
+                var iconFile = File.OpenRead(iconFilePath);
+                var iconBuffer = new byte[iconFile.Length];
+                iconFile.Read(iconBuffer, 0, (int) iconFile.Length);
+                sendingApplicationDto.SendingApplicationIcon = iconBuffer;
+            }
+            catch (Exception exception)
+            {
+                Logger.LogException(LogLevel.Error, FailureMessage, exception);
+                throw;
+            }
+
+            _testApplicationId = service.RegisterSendingApplication(sendingApplicationDto, notificationTypeDtos);
+        }
+
+        private void DeleteTestApplications(FoghornEntities dataContext)
+        {
+            var testApplications =
+                dataContext.SendingApplications.Where(x => x.SendingApplicationName.StartsWith(ApplicationTestName));
+            foreach (var sendingApplication in testApplications)
+            {
+                var subscribersToRemove = sendingApplication.Subscribers;
+                foreach (var subscriber in subscribersToRemove)
+                {
+                    var notifications = subscriber.NotificationsSent.ToList();
+                    foreach (var notification in notifications)
+                    {
+                        dataContext.Notifications.Remove(notification);
+                    }
+                }
+                dataContext.SendingApplications.Remove(sendingApplication);
+            }
+            dataContext.SaveChanges();
+            _testApplicationId = 0;
+        }
+    }
+}

BIN
Foghorn.Test/NotificationIcons/Error.png


BIN
Foghorn.Test/NotificationIcons/GreenCheck.png


BIN
Foghorn.Test/NotificationIcons/Icon.png


BIN
Foghorn.Test/NotificationIcons/OrderPlaced.png


BIN
Foghorn.Test/NotificationIcons/OrderShipped.png


BIN
Foghorn.Test/NotificationIcons/TestNotification0.png


BIN
Foghorn.Test/NotificationIcons/TestNotification1.png


BIN
Foghorn.Test/NotificationIcons/TestNotification2.png


BIN
Foghorn.Test/NotificationIcons/Warning.png


BIN
Foghorn.Test/NotificationTypes.xlsx


+ 57 - 0
Foghorn.Test/Properties/AssemblyInfo.cs

@@ -0,0 +1,57 @@
+// <copyright file="AssemblyInfo.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Foghorn.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Foghorn.Test")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("7e6c31fc-b446-4a2d-8f70-aedae2c93b59")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 155 - 0
Foghorn.Test/WcfTests.cs

@@ -0,0 +1,155 @@
+// <copyright file="WcfTests.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.ServiceModel;
+using Excel;
+using Foghorn.Core;
+using Foghorn.WcfService;
+using NLog;
+using Xunit;
+
+namespace Foghorn.Test
+{
+    public class WcfTests
+    {
+        private const string ApplicationTestName = "TestApplication";
+        private const string ServiceUrl = @"http://localhost:8733/Design_Time_Addresses/Foghorn.WcfService/FoghornService/";
+        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+        [Fact]
+        public void TestRegisterSendingApplication_LoadNotificationTypesFromExcel_AllLoaded()
+        {
+            var foghornClient =
+                new ChannelFactory<IFoghornService>(new BasicHttpBinding(), new EndpointAddress(ServiceUrl)).CreateChannel();
+
+            var notificationTypeDtos = new List<NotificationTypeDto>();
+            LoadNotificationTypes(notificationTypeDtos);
+
+            var sendingApplicationDto = new SendingApplicationDto {SendingApplicationName = ApplicationTestName};
+            LoadApplicationIcon(sendingApplicationDto);
+
+            foghornClient.RegisterSendingApplication(sendingApplicationDto, notificationTypeDtos);
+
+            //TODO: Add Assertions
+        }
+
+        [Fact]
+        public void TestRegisterSubscription_ApplicationExists_SubscriberRegistered()
+        {
+            var foghornClient =
+                new ChannelFactory<IFoghornService>(new BasicHttpBinding(), new EndpointAddress(ServiceUrl)).CreateChannel();
+            var subscriberDto = new SubscriberDto {HostName = "localhost", Password = "abc123!", SubscriberName = "jbloggs"};
+            foghornClient.RegisterSubscription(subscriberDto, ApplicationTestName);
+
+            //TODO: Add Assertions
+        }
+
+        [Fact]
+        public void TestNotify_ApplicationExists_NotificationSent()
+        {
+            var foghornClient =
+                new ChannelFactory<IFoghornService>(new BasicHttpBinding(), new EndpointAddress(ServiceUrl)).CreateChannel();
+
+            var notificationDto = new NotificationDto
+                {
+                    NotificationMessage = "This is the message of the test notification.",
+                    NotificationTypeName = "Error",
+                    NotificationTitle = "Notification Title",
+                    Priority = 2,
+                    Sticky = true
+                };
+            foghornClient.Notify(notificationDto, ApplicationTestName);
+            
+            //TODO: Add Assertions
+        }
+
+        private static void LoadApplicationIcon(SendingApplicationDto sendingApplicationDto)
+        {
+            Stream iconStream = null;
+            try
+            {
+                iconStream = File.OpenRead(Path.Combine(@"..\..\NotificationIcons", "Icon.png"));
+                var buffer = new byte[iconStream.Length];
+                iconStream.Read(buffer, 0, (int) iconStream.Length);
+                sendingApplicationDto.SendingApplicationIcon = buffer;
+            }
+            catch (Exception exception)
+            {
+                Logger.LogException(LogLevel.Error, "Exception Ignored", exception);
+                throw;
+            }
+            finally
+            {
+                if (iconStream != null) iconStream.Close();
+            }
+        }
+
+        private static void LoadNotificationTypes(ICollection<NotificationTypeDto> notificationTypeDtos)
+        {
+            Stream excelFile = null;
+            try
+            {
+                excelFile = File.OpenRead(@"..\..\NotificationTypes.xlsx");
+                var excel = ExcelReaderFactory.CreateOpenXmlReader(excelFile);
+                excel.IsFirstRowAsColumnNames = true;
+                var excelData = excel.AsDataSet();
+
+                var sheet = excelData.Tables["NotificationTypes"];
+                foreach (DataRow row in sheet.Rows)
+                {
+                    var notificationTypeDto = new NotificationTypeDto
+                        {
+                            NotificationTypeName = row["NotificationTypeName"].ToString(),
+                            NotificationTypeDisplayName = row["NotificationTypeDescription"].ToString(),
+                        };
+                    Stream notificationIconStream = null;
+                    try
+                    {
+                        notificationIconStream =
+                            File.OpenRead(Path.Combine(@"..\..\NotificationIcons", row["IconFileName"].ToString()));
+                        var buffer = new byte[notificationIconStream.Length];
+                        notificationIconStream.Read(buffer, 0, (int) notificationIconStream.Length);
+                        notificationTypeDto.NotificationTypeIcon = buffer;
+                        notificationTypeDtos.Add(notificationTypeDto);
+                    }
+                    catch (Exception exception)
+                    {
+                        Logger.LogException(LogLevel.Error, "Exception Ignored", exception);
+                        throw;
+                    }
+                    finally
+                    {
+                        if (notificationIconStream != null) notificationIconStream.Close();
+                    }
+                }
+            }
+            catch (Exception exception)
+            {
+                Logger.LogException(LogLevel.Error, "Exception Ignored", exception);
+            }
+            finally
+            {
+                if (excelFile != null) excelFile.Close();
+            }
+        }
+    }
+}

+ 5 - 0
Foghorn.Test/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<packages>
+  <package id="xunit" version="1.9.1" targetFramework="net45" />
+</packages>

+ 74 - 0
Foghorn.WcfService/App.config

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+
+  <configSections>
+    <sectionGroup name="applicationSettings"
+                  type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+      <section name="Foghorn.Service.Properties.Settings"
+               type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+               requirePermission="false" />
+    </sectionGroup>
+  </configSections>
+  <connectionStrings>
+    <add name="FoghornEntities"
+         connectionString="metadata=res://*/FoghornModel.csdl|res://*/FoghornModel.ssdl|res://*/FoghornModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=Foghorn;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
+         providerName="System.Data.EntityClient" />
+  </connectionStrings>
+  <appSettings>
+    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
+  </appSettings>
+  <system.web>
+    <compilation debug="true" />
+  </system.web>
+  <!-- When deploying the service library project, the content of the config file must be added to the host's 
+  app.config file. System.Configuration does not support config files for libraries. -->
+  <system.serviceModel>
+    <services>
+      <service name="Foghorn.WcfService.FoghornService">
+        <host>
+          <baseAddresses>
+            <add baseAddress="http://localhost:8733/Design_Time_Addresses/Foghorn.WcfService/FoghornService/" />
+          </baseAddresses>
+        </host>
+        <!-- Service Endpoints -->
+        <!-- Unless fully qualified, address is relative to base address supplied above -->
+        <endpoint address="" binding="basicHttpBinding" contract="Foghorn.WcfService.IFoghornService">
+          <!-- 
+              Upon deployment, the following identity element should be removed or replaced to reflect the 
+              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
+              automatically.
+          -->
+          <identity>
+            <dns value="localhost" />
+          </identity>
+        </endpoint>
+        <!-- Metadata Endpoints -->
+        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
+        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
+        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
+      </service>
+    </services>
+    <behaviors>
+      <serviceBehaviors>
+        <behavior>
+          <!-- To avoid disclosing metadata information, 
+          set the values below to false before deployment -->
+          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
+          <!-- To receive exception details in faults for debugging purposes, 
+          set the value below to true.  Set to false before deployment 
+          to avoid disclosing exception information -->
+          <serviceDebug includeExceptionDetailInFaults="False" />
+        </behavior>
+      </serviceBehaviors>
+    </behaviors>
+  </system.serviceModel>
+
+  <applicationSettings>
+    <Foghorn.Service.Properties.Settings>
+      <setting name="GrowlDefaultPort" serializeAs="String">
+        <value>23053</value>
+      </setting>
+    </Foghorn.Service.Properties.Settings>
+  </applicationSettings>
+</configuration>

+ 113 - 0
Foghorn.WcfService/Foghorn.WcfService.csproj

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{15B3E0D2-6217-493A-A690-158C497F5318}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Foghorn.WcfService</RootNamespace>
+    <AssemblyName>Foghorn.WcfService</AssemblyName>
+    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <StartArguments>/client:"WcfTestClient.exe"</StartArguments>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <WcfConfigValidationEnabled>True</WcfConfigValidationEnabled>
+    <XsdCodeGenEnabled>True</XsdCodeGenEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework">
+      <HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Growl.Connector">
+      <HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
+    </Reference>
+    <Reference Include="Growl.CoreLibrary">
+      <HintPath>..\packages\Growl.0.6\lib\Growl.CoreLibrary.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="NLog">
+      <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Data.Entity" />
+    <Reference Include="System.Data.Linq" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Xml.Linq" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="IFoghornService.cs" />
+    <Compile Include="Notifier.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="FoghornService.cs" />
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+      <DependentUpon>Settings.settings</DependentUpon>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <Content Include="NLog.config">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+    <None Include="NLog.xsd">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="packages.config" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Foghorn.Core\Foghorn.Core.csproj">
+      <Project>{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}</Project>
+      <Name>Foghorn.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="license.txt" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\WCF\Microsoft.VisualStudio.ServiceModel.targets" />
+  <ProjectExtensions>
+    <VisualStudio>
+      <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
+        <WcfProjectProperties>
+          <AutoStart>True</AutoStart>
+        </WcfProjectProperties>
+      </FlavorProperties>
+    </VisualStudio>
+  </ProjectExtensions>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 175 - 0
Foghorn.WcfService/FoghornService.cs

@@ -0,0 +1,175 @@
+// <copyright file="FoghornService.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using Foghorn.Core;
+using Foghorn.WcfService.Properties;
+using Growl.Connector;
+using Growl.CoreLibrary;
+using NLog;
+using NotificationType = Foghorn.Core.NotificationType;
+
+namespace Foghorn.WcfService
+{
+    public class FoghornService : IFoghornService
+    {
+        private const string FailureMessage = "Something went wrong receiving a service call.";
+        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+        private static readonly FoghornEntities DataContext = new FoghornEntities();
+
+        #region IFoghornService Members
+
+        public int RegisterSendingApplication(SendingApplicationDto sendingApplicationDto,
+                                              IEnumerable<NotificationTypeDto> notificationTypeDtos)
+        {
+            var notificationTypes = new List<NotificationType>();
+
+            foreach (var notificationTypeDto in notificationTypeDtos)
+            {
+                var notificationType =
+                    DataContext.NotificationTypes.FirstOrDefault(
+                        x => x.NotificationTypeName == notificationTypeDto.NotificationTypeName);
+                if (notificationType == null)
+                {
+                    notificationType = notificationTypeDto.ToEntity();
+                    DataContext.NotificationTypes.Add(notificationType);
+                    Logger.Trace("Adding a new NotificationType: {0}, for application: {1}",
+                                 notificationTypeDto.NotificationTypeName, sendingApplicationDto.SendingApplicationName);
+                }
+                notificationType.NotificationTypeIcon = notificationTypeDto.NotificationTypeIcon;
+                notificationType.NotificationTypeDisplayName = notificationTypeDto.NotificationTypeDisplayName;
+                notificationTypes.Add(notificationType);
+            }
+
+            var sendingApplication =
+                DataContext.SendingApplications.FirstOrDefault(
+                    x => x.SendingApplicationName == sendingApplicationDto.SendingApplicationName);
+            if (sendingApplication == null)
+            {
+                sendingApplication = sendingApplicationDto.ToEntity();
+                Logger.Trace("Adding a new SendingApplication: {0}", sendingApplicationDto.SendingApplicationName);
+                DataContext.SendingApplications.Add(sendingApplication);
+            }
+            else
+            {
+                sendingApplication.SendingApplicationIcon = sendingApplicationDto.SendingApplicationIcon;
+            }
+
+            sendingApplication.NotificationTypes.Clear();
+            foreach (var notificationType in notificationTypes)
+            {
+                sendingApplication.NotificationTypes.Add(notificationType);
+            }
+            DataContext.SaveChanges();
+            return sendingApplication.SendingApplicationId;
+        }
+
+
+        public Guid RegisterSubscription(SubscriberDto subscriberDto, string sendingApplicationName)
+        {
+            var sendingApplication =
+                DataContext.SendingApplications.FirstOrDefault(x => x.SendingApplicationName == sendingApplicationName);
+            if (sendingApplication == null)
+            {
+                var exception =
+                    new Exception("Cannot register a subscription for a SendingApplication that is not registered.");
+                Logger.ErrorException(FailureMessage, exception);
+                throw exception;
+            }
+
+            Subscriber subscriber;
+            if (subscriberDto.SubscriberId != Guid.Empty)
+            {
+                subscriber = DataContext.Subscribers.FirstOrDefault(x => x.SubscriberId == subscriberDto.SubscriberId);
+            }
+            else
+            {
+                subscriber = subscriberDto.ToEntity();
+                subscriber.SubscriberId = Guid.NewGuid();
+                DataContext.Subscribers.Add(subscriber);
+            }
+
+            var port = subscriberDto.Port.HasValue ? subscriberDto.Port.Value : Settings.Default.GrowlDefaultPort;
+            var growlConnector = new GrowlConnector(subscriberDto.Password, subscriberDto.HostName, port);
+
+            var growlNotificationTypes = new List<Growl.Connector.NotificationType>();
+            foreach (var notificationType in sendingApplication.NotificationTypes)
+            {
+                var growlNotificationType = new Growl.Connector.NotificationType(notificationType.NotificationTypeName,
+                                                                                 notificationType.NotificationTypeDisplayName);
+                if (notificationType.NotificationTypeIcon != null && notificationType.NotificationTypeIcon.Length > 0)
+                {
+                    growlNotificationType.Icon = new BinaryData(notificationType.NotificationTypeIcon);
+                }
+                growlNotificationTypes.Add(growlNotificationType);
+            }
+
+            var growlApplication = new Application(sendingApplicationName);
+            if (sendingApplication.SendingApplicationIcon != null && sendingApplication.SendingApplicationIcon.Length > 0)
+            {
+                growlApplication.Icon = new BinaryData(sendingApplication.SendingApplicationIcon);
+            }
+            growlConnector.Register(growlApplication, growlNotificationTypes.ToArray());
+
+            if (sendingApplication.Subscribers.Contains(subscriber)) return Guid.Empty;
+
+            Debug.Assert(subscriber != null, "subscriber != null");
+            subscriber.SendingApplication = sendingApplication;
+            DataContext.SaveChanges();
+            return subscriber.SubscriberId;
+        }
+
+        public NotificationDto Notify(NotificationDto notificationDto, string sendingApplicationName)
+        {
+            return Notifier.Notify(notificationDto, sendingApplicationName).ToDto();
+        }
+
+        public ICollection<SendingApplicationDto> GetRegisteredApplications()
+        {
+            return DataContext.SendingApplications.ToDtos();
+        }
+
+        public ICollection<SubscriberDto> GetRegisteredSubscribers()
+        {
+            return DataContext.Subscribers.ToDtos();
+        }
+
+        public ICollection<NotificationDto> GetNotifications(string sendingApplicationName)
+        {
+            return DataContext.Notifications.ToDtos();
+        }
+
+        public SendingApplicationDto GetSendingApplication(string sendingApplicationName)
+        {
+            return
+                DataContext.SendingApplications.FirstOrDefault(x => x.SendingApplicationName == sendingApplicationName)
+                           .ToDto();
+        }
+
+        public SendingApplicationDto GetSendingApplicationAt(int sendingApplicationIndex)
+        {
+            return DataContext.SendingApplications.AsEnumerable().ElementAt(sendingApplicationIndex).ToDto();
+        }
+
+        #endregion
+    }
+}

+ 54 - 0
Foghorn.WcfService/IFoghornService.cs

@@ -0,0 +1,54 @@
+// <copyright file="IFoghornService.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System;
+using System.Collections.Generic;
+using System.ServiceModel;
+using Foghorn.Core;
+
+namespace Foghorn.WcfService
+{
+    [ServiceContract]
+    public interface IFoghornService
+    {
+        [OperationContract]
+        int RegisterSendingApplication(SendingApplicationDto sendingApplicationDto,
+                                       IEnumerable<NotificationTypeDto> notificationTypes);
+
+        [OperationContract]
+        Guid RegisterSubscription(SubscriberDto subscriberDto, string sendingApplicationName);
+
+        [OperationContract]
+        NotificationDto Notify(NotificationDto notificationDto, string sendingApplicationName);
+
+        [OperationContract]
+        ICollection<SendingApplicationDto> GetRegisteredApplications();
+
+        [OperationContract]
+        ICollection<SubscriberDto> GetRegisteredSubscribers();
+
+        [OperationContract]
+        ICollection<NotificationDto> GetNotifications(string sendingApplicationName);
+
+        [OperationContract]
+        SendingApplicationDto GetSendingApplication(string sendingApplicationName);
+
+        [OperationContract]
+        SendingApplicationDto GetSendingApplicationAt(int sendingApplicationIndex);
+    }
+}

+ 29 - 0
Foghorn.WcfService/NLog.config

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <targets>
+    <target xsi:type="Mail" name="email" from="system@yupon.com" to="gobrien@yupon.com" smtpServer="mail.yupon.com"
+            smtpUserName="system@yupon.com" smtpPassword="fix8ed!" smtpAuthentication="Basic"
+            subject="${machinename}: ${logger} Error Logged"
+            body="${longdate}|${level:uppercase=true}|${logger}|${callsite}|${message}|${exception}|${stacktrace}" />
+    <target name="file" xsi:type="File" fileName="${basedir}/logs/${shortdate}-Rocky.log"
+            layout="${longdate} ${uppercase:${level}} ${message}" />
+    <target name="debugger" xsi:type="Debugger" layout="${longdate} ${uppercase:${level}} ${message}" />
+
+    <!--
+    <target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
+            layout="${longdate} ${uppercase:${level}} ${message}" />
+    -->
+  </targets>
+
+  <rules>
+    <logger name="*" minlevel="Trace" writeTo="file" />
+    <logger name="*" minlevel="Trace" writeTo="debugger" />
+    <logger name="*" minlevel="Error" writeTo="email" />
+
+    <!--
+    <logger name="*" minlevel="Trace" writeTo="f" />
+    -->
+  </rules>
+</nlog>

File diff suppressed because it is too large
+ 2704 - 0
Foghorn.WcfService/NLog.xsd


+ 90 - 0
Foghorn.WcfService/Notifier.cs

@@ -0,0 +1,90 @@
+// <copyright file="Notifier.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System;
+using System.Globalization;
+using System.Linq;
+using Foghorn.Core;
+using Foghorn.WcfService.Properties;
+using Growl.Connector;
+using NLog;
+using Notification = Foghorn.Core.Notification;
+
+namespace Foghorn.WcfService
+{
+    public class Notifier
+    {
+        private const string FailureMessage = "Growl Notifier had a problem.";
+        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+        public static Notification Notify(NotificationDto notificationDto, string sendingApplicationName)
+        {
+            var dataContext = new FoghornEntities();
+
+            var sendingApplication =
+                dataContext.SendingApplications.FirstOrDefault(x => x.SendingApplicationName == sendingApplicationName);
+
+            if (sendingApplication == null)
+            {
+                var exception =
+                    new ArgumentException("sendingApplicationName must match a previously registered SendingApplication",
+                                          "sendingApplicationName");
+                Logger.ErrorException(FailureMessage, exception);
+                throw exception;
+            }
+
+            if (notificationDto == null)
+            {
+                var exception = new ArgumentException("notification must not be null", "notificationDto");
+                Logger.ErrorException(FailureMessage, exception);
+                throw exception;
+            }
+
+            if (notificationDto.Priority > 2) notificationDto.Priority = 2;
+            if (notificationDto.Priority < -2) notificationDto.Priority = -2;
+
+            var growlNotification = new Growl.Connector.Notification(sendingApplication.SendingApplicationName,
+                                                                     notificationDto.NotificationTypeName,
+                                                                     notificationDto.NotificationId.ToString(
+                                                                         CultureInfo.InvariantCulture),
+                                                                     notificationDto.NotificationTitle,
+                                                                     notificationDto.NotificationMessage)
+                {
+                    Sticky = notificationDto.Sticky,
+                    Priority = (Priority) notificationDto.Priority
+                };
+
+            var notification = notificationDto.ToEntity();
+            foreach (var subscriber in sendingApplication.Subscribers)
+            {
+                var port = subscriber.Port.HasValue ? subscriber.Port.Value : Settings.Default.GrowlDefaultPort;
+                var growlConnector = new GrowlConnector(subscriber.Password, subscriber.HostName, port);
+                growlConnector.Notify(growlNotification);
+                subscriber.NotificationsSent.Add(notification);
+            }
+
+            notification.SentDateTime = DateTime.UtcNow;
+            notification.NotificationType =
+                dataContext.NotificationTypes.FirstOrDefault(
+                    x => x.NotificationTypeName == notificationDto.NotificationTypeName);
+            dataContext.Notifications.Add(notification);
+            dataContext.SaveChanges();
+            return notification;
+        }
+    }
+}

+ 57 - 0
Foghorn.WcfService/Properties/AssemblyInfo.cs

@@ -0,0 +1,57 @@
+// <copyright file="AssemblyInfo.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Foghorn.Service")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Foghorn.Service")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("e3c0d7c7-1536-45e6-8d40-aa74556a0a9d")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 35 - 0
Foghorn.WcfService/Properties/Settings.Designer.cs

@@ -0,0 +1,35 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.18034
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Foghorn.WcfService.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("23053")]
+        public int GrowlDefaultPort {
+            get {
+                return ((int)(this["GrowlDefaultPort"]));
+            }
+        }
+    }
+}

+ 11 - 0
Foghorn.WcfService/Properties/Settings.settings

@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
+              GeneratedClassNamespace="Foghorn.Service.Properties" GeneratedClassName="Settings">
+  <Profiles />
+  <Settings>
+    <Setting Name="GrowlDefaultPort" Type="System.Int32" Scope="Application">
+      <Value Profile="(Default)">23053</Value>
+    </Setting>
+  </Settings>
+</SettingsFile>

+ 25 - 0
Foghorn.WcfService/license.txt

@@ -0,0 +1,25 @@
+Growl.NET GNTP Connector Library
+-----------------------------------------------
+Copyright (c) 2008 - Growl for Windows
+All rights reserved
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
+DAMAGE.
+

+ 7 - 0
Foghorn.WcfService/packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<packages>
+  <package id="Growl" version="0.6" targetFramework="net45" />
+  <package id="NLog" version="2.0.0.2000" targetFramework="net45" />
+  <package id="NLog.Config" version="2.0.0.2000" targetFramework="net45" />
+</packages>

+ 78 - 0
Foghorn.WindowsService/App.config

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<configuration>
+  <configSections>
+    <sectionGroup name="applicationSettings"
+                  type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+      <section name="Foghorn.Service.Properties.Settings"
+               type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
+               requirePermission="false" />
+    </sectionGroup>
+  </configSections>
+  <connectionStrings>
+    <add name="FoghornEntities"
+         connectionString="metadata=res://*/FoghornModel.csdl|res://*/FoghornModel.ssdl|res://*/FoghornModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local);initial catalog=Foghorn;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
+         providerName="System.Data.EntityClient" />
+  </connectionStrings>
+  <appSettings>
+    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
+  </appSettings>
+  <system.web>
+    <compilation debug="true" />
+  </system.web>
+  <!-- When deploying the service library project, the content of the config file must be added to the host's 
+  app.config file. System.Configuration does not support config files for libraries. -->
+  <system.serviceModel>
+    <services>
+      <service name="Foghorn.WcfService.FoghornService">
+        <host>
+          <baseAddresses>
+            <add baseAddress="http://localhost:23054/Foghorn/" />
+          </baseAddresses>
+        </host>
+        <!-- Service Endpoints -->
+        <!-- Unless fully qualified, address is relative to base address supplied above -->
+        <endpoint address="" binding="basicHttpBinding" contract="Foghorn.WcfService.IFoghornService">
+          <!-- 
+              Upon deployment, the following identity element should be removed or replaced to reflect the 
+              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
+              automatically.
+          -->
+          <identity>
+            <dns value="localhost" />
+          </identity>
+        </endpoint>
+        <!-- Metadata Endpoints -->
+        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
+        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
+        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
+      </service>
+    </services>
+    <behaviors>
+      <serviceBehaviors>
+        <behavior>
+          <!-- To avoid disclosing metadata information, 
+          set the values below to false before deployment -->
+          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
+          <!-- To receive exception details in faults for debugging purposes, 
+          set the value below to true.  Set to false before deployment 
+          to avoid disclosing exception information -->
+          <serviceDebug includeExceptionDetailInFaults="False" />
+        </behavior>
+      </serviceBehaviors>
+    </behaviors>
+  </system.serviceModel>
+
+  <applicationSettings>
+    <Foghorn.Service.Properties.Settings>
+      <setting name="GrowlDefaultPort" serializeAs="String">
+        <value>23053</value>
+      </setting>
+    </Foghorn.Service.Properties.Settings>
+  </applicationSettings>
+
+  <startup>
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+  </startup>
+
+</configuration>

+ 89 - 0
Foghorn.WindowsService/Foghorn.WindowsService.csproj

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{1AF68C16-D92A-44C4-9BA0-1635A50A403A}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Foghorn.WindowsService</RootNamespace>
+    <AssemblyName>Foghorn.WindowsService</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration.Install" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.ServiceModel" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="FoghornWindowsService.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="FoghornWindowsService.Designer.cs">
+      <DependentUpon>FoghornWindowsService.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="ProjectInstaller.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ProjectInstaller.Designer.cs">
+      <DependentUpon>ProjectInstaller.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Foghorn.Core\Foghorn.Core.csproj">
+      <Project>{fe7cc95c-6d69-4a13-af27-aaf125e89dd8}</Project>
+      <Name>Foghorn.Core</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Foghorn.WcfService\Foghorn.WcfService.csproj">
+      <Project>{15b3e0d2-6217-493a-a690-158c497f5318}</Project>
+      <Name>Foghorn.WcfService</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="ProjectInstaller.resx">
+      <DependentUpon>ProjectInstaller.cs</DependentUpon>
+    </EmbeddedResource>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 37 - 0
Foghorn.WindowsService/FoghornWindowsService.Designer.cs

@@ -0,0 +1,37 @@
+namespace Foghorn.WindowsService
+{
+    partial class FoghornWindowsService
+    {
+        /// <summary> 
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Component Designer generated code
+
+        /// <summary> 
+        /// Required method for Designer support - do not modify 
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            components = new System.ComponentModel.Container();
+            this.ServiceName = "FoghornWindowsService";
+        }
+
+        #endregion
+    }
+}

+ 46 - 0
Foghorn.WindowsService/FoghornWindowsService.cs

@@ -0,0 +1,46 @@
+// <copyright file="FoghornWindowsService.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.ServiceModel;
+using System.ServiceProcess;
+using Foghorn.WcfService;
+
+namespace Foghorn.WindowsService
+{
+    partial class FoghornWindowsService : ServiceBase
+    {
+        private readonly ServiceHost _wcfServiceHost = new ServiceHost(typeof (FoghornService));
+
+        public FoghornWindowsService()
+        {
+            InitializeComponent();
+        }
+
+        protected override void OnStart(string[] args)
+        {
+            if (_wcfServiceHost != null) _wcfServiceHost.Open();
+            base.OnStart(args);
+        }
+
+        protected override void OnStop()
+        {
+            if (_wcfServiceHost != null) _wcfServiceHost.Close();
+            base.OnStop();
+        }
+    }
+}

+ 36 - 0
Foghorn.WindowsService/FoghornWindowsServiceInstaller.Designer.cs

@@ -0,0 +1,36 @@
+namespace Foghorn.WindowsService
+{
+    partial class FoghornWindowsServiceInstaller
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Component Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            components = new System.ComponentModel.Container();
+        }
+
+        #endregion
+    }
+}

+ 24 - 0
Foghorn.WindowsService/FoghornWindowsServiceInstaller.cs

@@ -0,0 +1,24 @@
+// <copyright file="FoghornWindowsServiceInstaller.cs" company="Confero Ltd.">
+// 
+// Copyright (c) 2011 - 2013 All Right Reserved.
+// 
+// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
+// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
+// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
+// 
+// </copyright>
+
+using System.ComponentModel;
+using System.Configuration.Install;
+
+namespace Foghorn.WindowsService
+{
+    [RunInstaller(true)]
+    public partial class FoghornWindowsServiceInstaller : Installer
+    {
+        public FoghornWindowsServiceInstaller()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 34 - 0
Foghorn.WindowsService/Program.cs

@@ -0,0 +1,34 @@
+// <copyright file="Program.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.ServiceProcess;
+
+namespace Foghorn.WindowsService
+{
+    internal static class Program
+    {
+        /// <summary>
+        ///     The main entry point for the application.
+        /// </summary>
+        private static void Main()
+        {
+            var servicesToRun = new ServiceBase[] {new FoghornWindowsService()};
+            ServiceBase.Run(servicesToRun);
+        }
+    }
+}

+ 60 - 0
Foghorn.WindowsService/ProjectInstaller.Designer.cs

@@ -0,0 +1,60 @@
+namespace Foghorn.WindowsService
+{
+    partial class ProjectInstaller
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Component Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
+            this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
+            // 
+            // serviceProcessInstaller1
+            // 
+            this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
+            this.serviceProcessInstaller1.Password = null;
+            this.serviceProcessInstaller1.Username = null;
+            // 
+            // serviceInstaller1
+            // 
+            this.serviceInstaller1.Description = "Push notification to Growl for systems using service-oriented architecture";
+            this.serviceInstaller1.DisplayName = "Foghorn (Growl for SOA)";
+            this.serviceInstaller1.ServiceName = "FoghornWindowsService";
+            this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
+            // 
+            // ProjectInstaller
+            // 
+            this.Installers.AddRange(new System.Configuration.Install.Installer[] {
+            this.serviceProcessInstaller1,
+            this.serviceInstaller1});
+
+        }
+
+        #endregion
+
+        private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
+        private System.ServiceProcess.ServiceInstaller serviceInstaller1;
+    }
+}

+ 32 - 0
Foghorn.WindowsService/ProjectInstaller.cs

@@ -0,0 +1,32 @@
+// <copyright file="ProjectInstaller.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.ComponentModel;
+using System.Configuration.Install;
+
+namespace Foghorn.WindowsService
+{
+    [RunInstaller(true)]
+    public partial class ProjectInstaller : Installer
+    {
+        public ProjectInstaller()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 129 - 0
Foghorn.WindowsService/ProjectInstaller.resx

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 56</value>
+  </metadata>
+  <metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>196, 17</value>
+  </metadata>
+  <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+</root>

+ 57 - 0
Foghorn.WindowsService/Properties/AssemblyInfo.cs

@@ -0,0 +1,57 @@
+// <copyright file="AssemblyInfo.cs" company="Objective Advantage Europe Ltd.">
+// 
+// Copyright (c) Objective Advantage Europe Ltd. 2011 - 2013 All Right Reserved.
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// 
+// </copyright>
+
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Foghorn.WindowsService")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Foghorn.WindowsService")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("ad0e7318-27a3-4a00-a225-2da68d752064")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 66 - 0
Foghorn.sln

@@ -0,0 +1,66 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foghorn.Core", "Foghorn.Core\Foghorn.Core.csproj", "{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foghorn.Test", "Foghorn.Test\Foghorn.Test.csproj", "{2CDCD184-CFB4-4173-8E1B-1777B212C522}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foghorn.WindowsService", "Foghorn.WindowsService\Foghorn.WindowsService.csproj", "{1AF68C16-D92A-44C4-9BA0-1635A50A403A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Foghorn.WcfService", "Foghorn.WcfService\Foghorn.WcfService.csproj", "{15B3E0D2-6217-493A-A690-158C497F5318}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Release|Any CPU.Build.0 = Release|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{FE7CC95C-6D69-4A13-AF27-AAF125E89DD8}.Release|x86.ActiveCfg = Release|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Release|Any CPU.Build.0 = Release|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{2CDCD184-CFB4-4173-8E1B-1777B212C522}.Release|x86.ActiveCfg = Release|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{1AF68C16-D92A-44C4-9BA0-1635A50A403A}.Release|x86.ActiveCfg = Release|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Release|Any CPU.Build.0 = Release|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{15B3E0D2-6217-493A-A690-158C497F5318}.Release|x86.ActiveCfg = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal