Skip to content

Commit

Permalink
First commit of reboot codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
phatboyg committed Jul 24, 2012
1 parent b514cd7 commit 4c152b3
Show file tree
Hide file tree
Showing 93 changed files with 6,147 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build_artifacts/*
*.user
packages
*.dotCover
*.dotSettings

bin
obj
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/Topshelf/Internals"]
path = src/Topshelf/Internals
url = https://github.com/phatboyg/Internals.git
21 changes: 21 additions & 0 deletions src/SampleTopshelfService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2007-2012 The Apache Software Foundation.
//
// 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.
namespace SampleTopshelfService
{
class Program
{
static void Main()
{
}
}
}
36 changes: 36 additions & 0 deletions src/SampleTopshelfService/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
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("SampleTopshelfService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SampleTopshelfService")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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("aa8c21f6-4cca-46c5-85c5-0f4c0701e6a8")]

// 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")]
92 changes: 92 additions & 0 deletions src/SampleTopshelfService/SampleTopshelfService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?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)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SampleTopshelfService</RootNamespace>
<AssemblyName>SampleTopshelfService</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</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|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Debug\SampleTopshelfService.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\SampleTopshelfService.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Topshelf\Topshelf.csproj">
<Project>{A52AD64D-6455-4A22-8CCF-581851086578}</Project>
<Name>Topshelf</Name>
</ProjectReference>
</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>
48 changes: 48 additions & 0 deletions src/Topshelf.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Topshelf", "Topshelf\Topshelf.csproj", "{A52AD64D-6455-4A22-8CCF-581851086578}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{94D59671-81F3-44B9-B54D-8E5D616DB0BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTopshelfService", "SampleTopshelfService\SampleTopshelfService.csproj", "{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}"
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
{A52AD64D-6455-4A22-8CCF-581851086578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Debug|x86.ActiveCfg = Debug|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Release|Any CPU.Build.0 = Release|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A52AD64D-6455-4A22-8CCF-581851086578}.Release|x86.ActiveCfg = Release|Any CPU
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|Mixed Platforms.Build.0 = Debug|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|x86.ActiveCfg = Debug|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Debug|x86.Build.0 = Debug|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Release|Any CPU.ActiveCfg = Release|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Release|Mixed Platforms.ActiveCfg = Release|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Release|Mixed Platforms.Build.0 = Release|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Release|x86.ActiveCfg = Release|x86
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E5A0AD7B-1806-4F99-84F0-55BD72C1C7A3} = {94D59671-81F3-44B9-B54D-8E5D616DB0BB}
EndGlobalSection
EndGlobal
81 changes: 81 additions & 0 deletions src/Topshelf/Configuration/Builders/ControlServiceBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright 2007-2012 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// 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.
namespace Topshelf.Builders
{
using System;
using Runtime;

public class ControlServiceBuilder<T> :
ServiceBuilder
where T : class, ServiceControl
{
readonly ServiceFactory<T> _serviceFactory;

public ControlServiceBuilder(ServiceFactory<T> serviceFactory)
{
_serviceFactory = serviceFactory;
}

public ServiceHandle Build(HostSettings settings)
{
try
{
T service = _serviceFactory(settings);

return new ControlServiceHandle(service);
}
catch (Exception ex)
{
throw new ServiceBuilderException("An exception occurred creating the service: " + typeof(T).Name, ex);
}
}

class ControlServiceHandle :
ServiceHandle
{
readonly T _service;

public ControlServiceHandle(T service)
{
_service = service;
}

public void Dispose()
{
var disposable = _service as IDisposable;
if (disposable != null)
disposable.Dispose();
}

public bool Start(HostControl hostControl)
{
return _service.Start(hostControl);
}

public bool Pause(HostControl hostControl)
{
return _service.Pause(hostControl);
}

public bool Continue(HostControl hostControl)
{
return _service.Continue(hostControl);
}

public bool Stop(HostControl hostControl)
{
return _service.Stop(hostControl);
}
}
}
}
99 changes: 99 additions & 0 deletions src/Topshelf/Configuration/Builders/DelegateServiceBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2007-2012 Chris Patterson, Dru Sellers, Travis Smith, et. al.
//
// 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.
namespace Topshelf.Builders
{
using System;
using Runtime;

public class DelegateServiceBuilder<T> :
ServiceBuilder
where T : class
{
readonly ServiceFactory<T> _serviceFactory;
Func<T, HostControl, bool> _continue;
Func<T, HostControl, bool> _pause;
Func<T, HostControl, bool> _start;
Func<T, HostControl, bool> _stop;

public DelegateServiceBuilder(ServiceFactory<T> serviceFactory, Func<T, HostControl, bool> start,
Func<T, HostControl, bool> stop, Func<T, HostControl, bool> pause, Func<T, HostControl, bool> @continue)
{
_serviceFactory = serviceFactory;
_start = start;
_stop = stop;
_pause = pause;
_continue = @continue;
}

public ServiceHandle Build(HostSettings settings)
{
try
{
T service = _serviceFactory(settings);

return new DelegateServiceHandle(service, _start, _stop, _pause, _continue);
}
catch (Exception ex)
{
throw new ServiceBuilderException("An exception occurred creating the service: " + typeof(T).Name, ex);
}
}

class DelegateServiceHandle :
ServiceHandle
{
readonly Func<T, HostControl, bool> _continue;
readonly Func<T, HostControl, bool> _pause;
readonly T _service;
readonly Func<T, HostControl, bool> _start;
readonly Func<T, HostControl, bool> _stop;

public DelegateServiceHandle(T service, Func<T, HostControl, bool> start, Func<T, HostControl, bool> stop,
Func<T, HostControl, bool> pause, Func<T, HostControl, bool> @continue)
{
_service = service;
_start = start;
_stop = stop;
_pause = pause;
_continue = @continue;
}

public void Dispose()
{
var disposable = _service as IDisposable;
if (disposable != null)
disposable.Dispose();
}

public bool Start(HostControl hostControl)
{
return _start(_service, hostControl);
}

public bool Pause(HostControl hostControl)
{
return _pause(_service, hostControl);
}

public bool Continue(HostControl hostControl)
{
return _continue(_service, hostControl);
}

public bool Stop(HostControl hostControl)
{
return _stop(_service, hostControl);
}
}
}
}
Loading

0 comments on commit 4c152b3

Please sign in to comment.