Permalink
Browse files

Merge branch 'master' of https://github.com/mikoskinen/blog

  • Loading branch information...
2 parents 9bf3804 + a614666 commit 4aa8810d270c0a06bc0cf96581ab393c28609abd @mikoskinen committed Feb 19, 2012
Showing with 15,171 additions and 0 deletions.
  1. +14 −0 unity-custom-constructor-parameters/TestSubject/MyClass.cs
  2. +36 −0 unity-custom-constructor-parameters/TestSubject/Properties/AssemblyInfo.cs
  3. +54 −0 unity-custom-constructor-parameters/TestSubject/TestSubject.csproj
  4. +30 −0 unity-custom-constructor-parameters/TestsAndCustomResolverOverride/OrderedParametersOverride.cs
  5. +36 −0 unity-custom-constructor-parameters/TestsAndCustomResolverOverride/Properties/AssemblyInfo.cs
  6. +37 −0 unity-custom-constructor-parameters/TestsAndCustomResolverOverride/Tests.cs
  7. +77 −0 ...ustom-constructor-parameters/TestsAndCustomResolverOverride/TestsAndCustomResolverOverride.csproj
  8. +5 −0 unity-custom-constructor-parameters/TestsAndCustomResolverOverride/packages.config
  9. +29 −0 unity-custom-constructor-parameters/UnityCustomConstructorParameters.sln
  10. BIN unity-custom-constructor-parameters/packages/CommonServiceLocator.1.0/CommonServiceLocator.1.0.nupkg
  11. +280 −0 ...or-parameters/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.XML
  12. BIN ...or-parameters/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.dll
  13. BIN ...or-parameters/packages/CommonServiceLocator.1.0/lib/NET35/Microsoft.Practices.ServiceLocation.pdb
  14. +280 −0 ...tor-parameters/packages/CommonServiceLocator.1.0/lib/SL30/Microsoft.Practices.ServiceLocation.XML
  15. BIN ...tor-parameters/packages/CommonServiceLocator.1.0/lib/SL30/Microsoft.Practices.ServiceLocation.dll
  16. BIN unity-custom-constructor-parameters/packages/Unity.2.1.505.0/Unity.2.1.505.0.nupkg
  17. BIN ...tructor-parameters/packages/Unity.2.1.505.0/lib/NET35/Microsoft.Practices.Unity.Configuration.dll
  18. +2,451 −0 ...tructor-parameters/packages/Unity.2.1.505.0/lib/NET35/Microsoft.Practices.Unity.Configuration.xml
  19. BIN unity-custom-constructor-parameters/packages/Unity.2.1.505.0/lib/NET35/Microsoft.Practices.Unity.dll
  20. +5,910 −0 unity-custom-constructor-parameters/packages/Unity.2.1.505.0/lib/NET35/Microsoft.Practices.Unity.xml
  21. BIN ...onstructor-parameters/packages/Unity.2.1.505.0/lib/SL30/Microsoft.Practices.Unity.Silverlight.dll
  22. +5,928 −0 ...onstructor-parameters/packages/Unity.2.1.505.0/lib/SL30/Microsoft.Practices.Unity.Silverlight.xml
  23. BIN unity-custom-constructor-parameters/packages/Unity.2.1.505.0/tools/Utils.psm1
  24. BIN unity-custom-constructor-parameters/packages/Unity.2.1.505.0/tools/install.ps1
  25. +4 −0 unity-custom-constructor-parameters/packages/repositories.config
@@ -0,0 +1,14 @@
+namespace TestSubject
+{
+ public class MyClass
+ {
+ public string Hello { get; set; }
+ public int Number { get; set; }
+
+ public MyClass(string hello, int number)
+ {
+ Hello = hello;
+ Number = number;
+ }
+ }
+}
@@ -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("ClassLibrary1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ClassLibrary1")]
+[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("46e91b9a-4239-4af9-95bd-866b2f0fa426")]
+
+// 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")]
@@ -0,0 +1,54 @@
+<?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.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E662CD84-A7E1-41B6-A9D8-E948A3DC9130}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TestSubject</RootNamespace>
+ <AssemblyName>TestSubject</AssemblyName>
+ <TargetFrameworkVersion>v4.0</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="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="MyClass.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </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>
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using Microsoft.Practices.ObjectBuilder2;
+using Microsoft.Practices.Unity;
+
+namespace ClassLibrary2
+{
+ public class OrderedParametersOverride : ResolverOverride
+ {
+ private readonly Queue<InjectionParameterValue> parameterValues;
+
+ public OrderedParametersOverride(IEnumerable<object> parameterValues)
+ {
+ this.parameterValues = new Queue<InjectionParameterValue>();
+ foreach (var parameterValue in parameterValues)
+ {
+ this.parameterValues.Enqueue(InjectionParameterValue.ToParameter(parameterValue));
+ }
+ }
+
+ public override IDependencyResolverPolicy GetResolver(IBuilderContext context, Type dependencyType)
+ {
+ if (parameterValues.Count < 1)
+ return null;
+
+ var value = this.parameterValues.Dequeue();
+ return value.GetResolverPolicy(dependencyType);
+ }
+ }
+}
@@ -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("ClassLibrary2")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ClassLibrary2")]
+[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("321313c3-5d29-4fc5-a6f3-11f1bc97b727")]
+
+// 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")]
@@ -0,0 +1,37 @@
+using TestSubject;
+using Microsoft.Practices.Unity;
+using NUnit.Framework;
+
+namespace ClassLibrary2
+{
+ [TestFixture]
+ public class Tests
+ {
+ [Test]
+ public void TestParameterOverride()
+ {
+ var unity = new UnityContainer();
+ unity.RegisterType<MyClass>();
+
+ var myObj = unity.Resolve<MyClass>(new ResolverOverride[]
+ {
+ new ParameterOverride("hello", "hi there"), new ParameterOverride("number", 21)
+ });
+
+ Assert.That(myObj.Hello, Is.EqualTo("hi there"));
+ Assert.That(myObj.Number, Is.EqualTo(21));
+ }
+
+ [Test]
+ public void TestOrderedParametersOverride()
+ {
+ var unity = new UnityContainer();
+ unity.RegisterType<MyClass>();
+
+ var myObj = unity.Resolve<MyClass>(new OrderedParametersOverride(new object[] {"greetings", 24 }));
+
+ Assert.That(myObj.Hello, Is.EqualTo("greetings"));
+ Assert.That(myObj.Number, Is.EqualTo(24));
+ }
+ }
+}
@@ -0,0 +1,77 @@
+<?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.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tests</RootNamespace>
+ <AssemblyName>Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</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="Microsoft.Practices.ServiceLocation">
+ <HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Practices.Unity">
+ <HintPath>..\packages\Unity.2.1.505.0\lib\NET35\Microsoft.Practices.Unity.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.Practices.Unity.Configuration">
+ <HintPath>..\packages\Unity.2.1.505.0\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.5.9.10348, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\projects\companymanagement\lib\nunit.framework.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="Tests.cs" />
+ <Compile Include="OrderedParametersOverride.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\TestSubject\TestSubject.csproj">
+ <Project>{E662CD84-A7E1-41B6-A9D8-E948A3DC9130}</Project>
+ <Name>TestSubject</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>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="CommonServiceLocator" version="1.0" />
+ <package id="Unity" version="2.1.505.0" />
+</packages>
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSubject", "TestSubject\TestSubject.csproj", "{E662CD84-A7E1-41B6-A9D8-E948A3DC9130}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestsAndCustomResolverOverride", "TestsAndCustomResolverOverride\TestsAndCustomResolverOverride.csproj", "{5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E662CD84-A7E1-41B6-A9D8-E948A3DC9130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E662CD84-A7E1-41B6-A9D8-E948A3DC9130}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E662CD84-A7E1-41B6-A9D8-E948A3DC9130}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E662CD84-A7E1-41B6-A9D8-E948A3DC9130}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5113FB7A-BAFE-474E-BCC0-033AB4CAA26B}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.0\lib\NET35
+ EndGlobalSection
+EndGlobal
Oops, something went wrong.

0 comments on commit 4aa8810

Please sign in to comment.