Permalink
Browse files

Added simple demo

  • Loading branch information...
1 parent fba1fb7 commit 71013d842eee4493c863d642342e487ff0b5b2a9 @digitalBush committed Nov 29, 2011
View
@@ -1,26 +1,54 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Settings", "src\Autofac.Settings\Autofac.Settings.csproj", "{EF1587DD-B120-4D3F-ADAD-F54243C97730}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Settings.Specs", "specs\Autofac.Settings.Specs\Autofac.Settings.Specs.csproj", "{A20C6CAC-A71B-4862-B8BD-046A21964FAC}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Any CPU.Build.0 = Release|Any CPU
- {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Settings", "src\Autofac.Settings\Autofac.Settings.csproj", "{EF1587DD-B120-4D3F-ADAD-F54243C97730}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Settings.Specs", "specs\Autofac.Settings.Specs\Autofac.Settings.Specs.csproj", "{A20C6CAC-A71B-4862-B8BD-046A21964FAC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "src\Demo\Demo.csproj", "{A185899B-12D9-442D-8E50-BB892C366BCC}"
+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
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {EF1587DD-B120-4D3F-ADAD-F54243C97730}.Release|x86.ActiveCfg = Release|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {A20C6CAC-A71B-4862-B8BD-046A21964FAC}.Release|x86.ActiveCfg = Release|Any CPU
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Debug|x86.ActiveCfg = Debug|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Debug|x86.Build.0 = Debug|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Release|Any CPU.ActiveCfg = Release|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Release|Mixed Platforms.Build.0 = Release|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Release|x86.ActiveCfg = Release|x86
+ {A185899B-12D9-442D-8E50-BB892C366BCC}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -1,6 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Linq;
namespace Autofac.Settings {
@@ -3,27 +3,27 @@
using System.Configuration;
using System.Linq;
using System.Reflection;
-using System.ComponentModel;
-
-namespace Autofac.Settings {
- public class SettingsFactory : ISettingsFactory {
- readonly IEnumerable<ISettingsProvider> _providers;
-
- public SettingsFactory(IEnumerable<ISettingsProvider> providers) {
- _providers = providers;
- }
-
- public object Create(Type type) {
+using System.ComponentModel;
+
+namespace Autofac.Settings {
+ public class SettingsFactory : ISettingsFactory {
+ readonly IEnumerable<ISettingsProvider> _providers;
+
+ public SettingsFactory(IEnumerable<ISettingsProvider> providers) {
+ _providers = providers;
+ }
+
+ public object Create(Type type) {
var obj = Activator.CreateInstance(type);
var propertiesMissed = PopulateProperties(type, obj);
if (propertiesMissed.Any()) {
var message = String.Format("{0} is missing the following properties in configuration: {1}", type.Name, String.Join(",", propertiesMissed));
throw new ConfigurationErrorsException(message);
- }
-
- return obj;
+ }
+
+ return obj;
}
private List<string> PopulateProperties(Type type, object obj) {
@@ -44,7 +44,5 @@ public class SettingsFactory : ISettingsFactory {
}
return propertiesMissed;
}
-
-
- }
+ }
}
View
@@ -0,0 +1,72 @@
+<?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>{A185899B-12D9-442D-8E50-BB892C366BCC}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Demo</RootNamespace>
+ <AssemblyName>Demo</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </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>
+ <ItemGroup>
+ <Reference Include="Autofac">
+ <HintPath>..\..\lib\Autofac\lib\NET40\Autofac.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <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="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Worker.cs" />
+ <Compile Include="WorkerSettings.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Autofac.Settings\Autofac.Settings.csproj">
+ <Project>{EF1587DD-B120-4D3F-ADAD-F54243C97730}</Project>
+ <Name>Autofac.Settings</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </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>
View
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Autofac;
+using Autofac.Settings;
+
+namespace Demo {
+
+
+ class Program {
+ static void Main(string[] args) {
+ var builder = new ContainerBuilder();
+ builder.RegisterType<Worker>();
+ builder.RegisterSource(new SettingsSource());
+ builder.RegisterType<SettingsFactory>().AsImplementedInterfaces();
+ builder.RegisterType<AppConfigSettingsProvider>().AsImplementedInterfaces();
+ var container = builder.Build();
+ container.Resolve<Worker>().DoWork();
+ Console.ReadKey();
+ }
+ }
+}
@@ -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("Demo")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Demo")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
+[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("8c49830f-454e-4564-b393-cf71cb0635b2")]
+
+// 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")]
View
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Demo {
+ public class Worker {
+
+ readonly WorkerSettings _settings;
+
+ public Worker(WorkerSettings settings) {
+ _settings = settings;
+ }
+
+ public void DoWork() {
+ Console.WriteLine("Connecting to {0} on port {1}", _settings.Server, _settings.Port);
+ }
+ }
+}
View
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Demo {
+ public class WorkerSettings {
+ public string Server { get; set; }
+ public int Port { get; set; }
+ }
+}
View
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<configuration>
+ <appSettings>
+ <add key="WorkerSettings.Server" value="freshbrewedcode.com" />
+ <add key="WorkerSettings.Port" value="80" />
+ </appSettings>
+</configuration>

0 comments on commit 71013d8

Please sign in to comment.