Skip to content

Commit

Permalink
NReco.Application: added LazyDelegateFactory + updated NI.Ioc depende…
Browse files Browse the repository at this point in the history
…ncy to 2.0.3
  • Loading branch information
VitaliyMF committed Nov 27, 2014
1 parent 336f50d commit 1bbf5e6
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 27 deletions.
Expand Up @@ -57,9 +57,9 @@
<Reference Include="Mvp.Xml">
<HintPath>..\packages\Mvp.Xml.2.3.0\lib\net20\Mvp.Xml.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand Down Expand Up @@ -96,6 +96,9 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Application.Console/packages.config
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0" targetFramework="net40" />
Expand Down
12 changes: 9 additions & 3 deletions src/NReco.Application.Web/NReco.Application.Web.csproj
Expand Up @@ -40,8 +40,9 @@
<Reference Include="NI.Data">
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc">
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand Down Expand Up @@ -90,7 +91,12 @@
<ItemGroup>
<None Include="config\common\common.xml.config" />
<None Include="config\web\common.xml.config" />
<None Include="packages.config" />
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Application.Web/packages.config
Expand Up @@ -3,7 +3,7 @@
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Data" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0.0" targetFramework="net40" />
Expand Down
43 changes: 43 additions & 0 deletions src/NReco.Application/Ioc/LazyDelegateFactory.cs
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NReco;
using NI.Ioc;

namespace NReco.Application.Ioc {

/// <summary>
/// Creates lazy delegate adapter that uses IComponentFactory for resolving real delegate instance.
/// </summary>
public class LazyDelegateFactory : IFactoryComponent, IComponentFactoryAware {

public IComponentFactory ComponentFactory { private get; set; }

private Type DelegateType { get; set; }

private string DelegateComponentName { get; set; }

public LazyDelegateFactory(string delegateComponentName, Type delegateType) {
DelegateType = delegateType;
DelegateComponentName = delegateComponentName;
}

protected Delegate GetRealDelegate() {
return (Delegate)ComponentFactory.GetComponent(DelegateComponentName, DelegateType);
}

public object GetObject() {
var lazyDelegAdapter = new LazyDelegateAdapter(GetRealDelegate);
return lazyDelegAdapter.GetDelegate(DelegateType);
}

public Type GetObjectType() {
return DelegateType;
}


}

}
8 changes: 6 additions & 2 deletions src/NReco.Application/NReco.Application.csproj
Expand Up @@ -55,9 +55,9 @@
<Reference Include="Mvp.Xml">
<HintPath>..\packages\Mvp.Xml.2.3.0\lib\net20\Mvp.Xml.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand All @@ -77,6 +77,7 @@
<Compile Include="EventBroker.cs" />
<Compile Include="Ioc\ComponentFactory.cs" />
<Compile Include="Ioc\LambdaProvider.cs" />
<Compile Include="Ioc\LazyDelegateFactory.cs" />
<Compile Include="Ioc\XmlComponentConfiguration.cs" />
<Compile Include="Log4Net\LogFactory.cs" />
<Compile Include="Mail\SendMailSmtpConfiguration.cs" />
Expand Down Expand Up @@ -109,6 +110,9 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand Down
4 changes: 2 additions & 2 deletions src/NReco.Application/Properties/AssemblyInfo.cs
Expand Up @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyVersion("2.0.2.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]
2 changes: 1 addition & 1 deletion src/NReco.Application/packages.config
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
</packages>
Expand Up @@ -42,8 +42,9 @@
<Reference Include="NI.Data">
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc">
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand Down Expand Up @@ -95,6 +96,9 @@
</Content>
<Content Include="config\xsl\model-webforms-layout.xsl.install.xdt" />
<Content Include="config\xsl\model-webforms-layout.xsl.uninstall.xdt" />
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<Content Include="Web.config.install.xdt" />
<Content Include="Web.config.uninstall.xdt" />
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Dsm.WebForms.Bootstrap/packages.config
Expand Up @@ -3,7 +3,7 @@
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Data" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0.0" targetFramework="net40" />
Expand Down
Expand Up @@ -42,8 +42,9 @@
<Reference Include="NI.Data">
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc">
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand Down Expand Up @@ -89,6 +90,9 @@
<Content Include="config\xsd\model-webforms-layout.xsd.uninstall.xdt" />
<Content Include="config\xsl\model-webforms-layout.xsl.install.xdt" />
<Content Include="config\xsl\model-webforms-layout.xsl.uninstall.xdt" />
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Dsm.WebForms.ConditionBuilder/packages.config
Expand Up @@ -3,7 +3,7 @@
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Data" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0.0" targetFramework="net40" />
Expand Down
8 changes: 6 additions & 2 deletions src/NReco.Dsm.WebForms.Vfs/NReco.Dsm.WebForms.Vfs.csproj
Expand Up @@ -42,8 +42,9 @@
<Reference Include="NI.Data">
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc">
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs">
<HintPath>..\packages\NI.Vfs.2.0.0.0\lib\net40\NI.Vfs.dll</HintPath>
Expand Down Expand Up @@ -102,6 +103,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="config\common\mainFilesystem.xml.config" />
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<Content Include="templates\renderers\FileLink.ascx">
<SubType>ASPXCodeBehind</SubType>
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Dsm.WebForms.Vfs/packages.config
Expand Up @@ -3,7 +3,7 @@
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Data" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2.0" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0.0" targetFramework="net40" />
Expand Down
8 changes: 6 additions & 2 deletions src/NReco.Dsm.WebForms/NReco.Dsm.WebForms.csproj
Expand Up @@ -61,8 +61,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc">
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -191,6 +192,9 @@
<SubType>ASPXCodeBehind</SubType>
</Content>
<None Include="config\web\common.xml.config" />
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Dsm.WebForms/packages.config
Expand Up @@ -3,7 +3,7 @@
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Mvp.Xml" version="2.3.0" targetFramework="net40" />
<package id="NI.Data" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0" targetFramework="net40" />
<package id="NReco" version="2.0.1.0" targetFramework="net40" />
<package id="NReco.Application" version="2.0.0" targetFramework="net40" />
Expand Down
10 changes: 10 additions & 0 deletions src/NReco.Tests/DelegateAdapterTests.cs
Expand Up @@ -59,6 +59,16 @@ public class DelegateAdapterTests {
Assert.AreEqual(10, lazyDeleg(5));
Assert.AreEqual(1, factoryCounter);

Func<Delegate> strDelegFactory = () => {
return (Func<string>)testMethod;
};
var lazyStrDelegAdapter = new LazyDelegateAdapter(strDelegFactory);
var lazyStrDeleg = lazyStrDelegAdapter.GetDelegate<Func<string>>();
Assert.AreEqual("test", lazyStrDeleg() );
}

string testMethod() {
return "test";
}

}
Expand Down
7 changes: 5 additions & 2 deletions src/NReco.Tests/NReco.Tests.csproj
Expand Up @@ -56,9 +56,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Data.2.0.2.0\lib\net40\NI.Data.dll</HintPath>
</Reference>
<Reference Include="NI.Ioc, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="NI.Ioc, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NI.Ioc.2.0.2.0\lib\net40\NI.Ioc.dll</HintPath>
<HintPath>..\packages\NI.Ioc.2.0.3.0\lib\net40\NI.Ioc.dll</HintPath>
</Reference>
<Reference Include="NI.Vfs, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -133,6 +133,9 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="config\xsd\ComponentConfiguration.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
2 changes: 1 addition & 1 deletion src/NReco.Tests/packages.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NI.Data" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.2" targetFramework="net40" />
<package id="NI.Ioc" version="2.0.3.0" targetFramework="net40" />
<package id="NI.Vfs" version="2.0.0" targetFramework="net40" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
</packages>

0 comments on commit 1bbf5e6

Please sign in to comment.