First go of it
This commit is contained in:
Коммит
b4dc09489d
|
@ -0,0 +1,24 @@
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
||||||
|
|
||||||
|
*.jpg binary
|
||||||
|
*.png binary
|
||||||
|
*.gif binary
|
||||||
|
|
||||||
|
core.eol crlf
|
||||||
|
|
||||||
|
*.cs diff=csharp
|
||||||
|
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
*.sln merge=union
|
|
@ -0,0 +1,252 @@
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# DNX
|
||||||
|
project.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignoreable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
node_modules/
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25420.1
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutoMapper.Extensions.Microsoft.DependencyInjection", "src\AutoMapper.Extensions.Microsoft.DependencyInjection\AutoMapper.Extensions.Microsoft.DependencyInjection.xproj", "{CD3BCC44-44C0-4A5A-9041-34B558A9FBF2}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AutoMapper.Extensions.Microsoft.DependencyInjection.Tests", "test\AutoMapper.Extensions.Microsoft.DependencyInjection.Tests\AutoMapper.Extensions.Microsoft.DependencyInjection.Tests.xproj", "{A93A7F85-292A-4130-891D-4307D3F60C30}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1082ED20-13D1-444F-BAFD-17EFB9152981}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
appveyor.yml = appveyor.yml
|
||||||
|
Build.ps1 = Build.ps1
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TestApp", "src\TestApp\TestApp.xproj", "{DE95F633-80B5-4248-A594-7FB357C8DAC9}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{CD3BCC44-44C0-4A5A-9041-34B558A9FBF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CD3BCC44-44C0-4A5A-9041-34B558A9FBF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CD3BCC44-44C0-4A5A-9041-34B558A9FBF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CD3BCC44-44C0-4A5A-9041-34B558A9FBF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A93A7F85-292A-4130-891D-4307D3F60C30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A93A7F85-292A-4130-891D-4307D3F60C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A93A7F85-292A-4130-891D-4307D3F60C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A93A7F85-292A-4130-891D-4307D3F60C30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{DE95F633-80B5-4248-A594-7FB357C8DAC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{DE95F633-80B5-4248-A594-7FB357C8DAC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{DE95F633-80B5-4248-A594-7FB357C8DAC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{DE95F633-80B5-4248-A594-7FB357C8DAC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,100 @@
|
||||||
|
function Install-Dotnet
|
||||||
|
{
|
||||||
|
& where.exe dotnet 2>&1 | Out-Null
|
||||||
|
|
||||||
|
if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true))
|
||||||
|
{
|
||||||
|
Write-Host "Dotnet CLI not found - downloading latest version"
|
||||||
|
|
||||||
|
# Prepare the dotnet CLI folder
|
||||||
|
$env:DOTNET_INSTALL_DIR="$(Convert-Path "$PSScriptRoot")\.dotnet\win7-x64"
|
||||||
|
if (!(Test-Path $env:DOTNET_INSTALL_DIR))
|
||||||
|
{
|
||||||
|
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Download the dotnet CLI install script
|
||||||
|
if (!(Test-Path .\dotnet\install.ps1))
|
||||||
|
{
|
||||||
|
Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.ps1" -OutFile ".\.dotnet\dotnet-install.ps1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run the dotnet CLI install
|
||||||
|
& .\.dotnet\dotnet-install.ps1
|
||||||
|
|
||||||
|
# Add the dotnet folder path to the process.
|
||||||
|
Remove-PathVariable $env:DOTNET_INSTALL_DIR
|
||||||
|
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Remove-PathVariable
|
||||||
|
{
|
||||||
|
[cmdletbinding()]
|
||||||
|
param([string] $VariableToRemove)
|
||||||
|
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
|
||||||
|
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
|
||||||
|
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
|
||||||
|
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
|
||||||
|
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
|
||||||
|
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
|
||||||
|
}
|
||||||
|
|
||||||
|
function Restore-Packages
|
||||||
|
{
|
||||||
|
param([string] $DirectoryName)
|
||||||
|
& dotnet restore -v Warning ("""" + $DirectoryName + """")
|
||||||
|
}
|
||||||
|
|
||||||
|
function Test-Project
|
||||||
|
{
|
||||||
|
param([string] $DirectoryName)
|
||||||
|
& dotnet test -c Release ("""" + $DirectoryName + """")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Taken from psake https://github.com/psake/psake
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
|
||||||
|
to see if an error occcured. If an error is detected then an exception is thrown.
|
||||||
|
This function allows you to run command-line programs without having to
|
||||||
|
explicitly check the $lastexitcode variable.
|
||||||
|
.EXAMPLE
|
||||||
|
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
|
||||||
|
#>
|
||||||
|
function Exec
|
||||||
|
{
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
|
||||||
|
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
|
||||||
|
)
|
||||||
|
& $cmd
|
||||||
|
if ($lastexitcode -ne 0) {
|
||||||
|
throw ("Exec: " + $errorMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
########################
|
||||||
|
# THE BUILD!
|
||||||
|
########################
|
||||||
|
|
||||||
|
Push-Location $PSScriptRoot
|
||||||
|
|
||||||
|
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
|
||||||
|
|
||||||
|
# Install Dotnet CLI
|
||||||
|
Install-Dotnet
|
||||||
|
|
||||||
|
# Package restore
|
||||||
|
Get-ChildItem -Path . -Filter *.xproj -Recurse | ForEach-Object { Restore-Packages $_.DirectoryName }
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Project $_.DirectoryName }
|
||||||
|
|
||||||
|
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
|
||||||
|
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
|
||||||
|
|
||||||
|
exec { & dotnet pack .\src\AutoMapper.Extensions.Microsoft.DependencyInjection -c Release -o .\artifacts --version-suffix=$revision }
|
||||||
|
|
||||||
|
Pop-Location
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2016 Jimmy Bogard
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,15 @@
|
||||||
|
# MediatR extensions for Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
|
Scans assemblies and adds handlers implementations to the container. To use, with an `IServiceCollection` instance:
|
||||||
|
|
||||||
|
```
|
||||||
|
services.AddMediatR(typeof(MyHander));
|
||||||
|
```
|
||||||
|
|
||||||
|
or with an assembly:
|
||||||
|
|
||||||
|
```
|
||||||
|
services.AddMediatR(typeof(Startup).Assembly);
|
||||||
|
```
|
||||||
|
|
||||||
|
Supports generic variance of handlers.
|
|
@ -0,0 +1,29 @@
|
||||||
|
version: '{build}'
|
||||||
|
pull_requests:
|
||||||
|
do_not_increment_build_number: true
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
nuget:
|
||||||
|
disable_publish_on_pr: true
|
||||||
|
build_script:
|
||||||
|
- ps: .\Build.ps1
|
||||||
|
test: off
|
||||||
|
artifacts:
|
||||||
|
- path: .\artifacts\**\*.nupkg
|
||||||
|
name: NuGet
|
||||||
|
deploy:
|
||||||
|
- provider: NuGet
|
||||||
|
server: https://www.myget.org/F/automapperdev/api/v2/package
|
||||||
|
api_key:
|
||||||
|
secure: zKeQZmIv9PaozHQRJmrlRHN+jMCI64Uvzmb/vwePdXFR5CUNEHalnZdOCg0vrh8t
|
||||||
|
skip_symbols: true
|
||||||
|
on:
|
||||||
|
branch: master
|
||||||
|
- provider: NuGet
|
||||||
|
name: production
|
||||||
|
api_key:
|
||||||
|
secure: t3blEIQiDIYjjWhOSTTtrcAnzJkmSi+0zYPxC1v4RDzm6oI/gIpD6ZtrOGsYu2jE
|
||||||
|
on:
|
||||||
|
branch: master
|
||||||
|
appveyor_repo_tag: true
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"projects": [ "src", "test" ],
|
||||||
|
"sdk": {
|
||||||
|
"version": "1.0.0-preview2-003121"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>cd3bcc44-44c0-4a5a-9041-34b558a9fbf2</ProjectGuid>
|
||||||
|
<RootNamespace>MediatR.Extensions.Microsoft.DependencyInjection</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
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: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("AutoMapper.Extensions.Microsoft.DependencyInjection")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
|
||||||
|
// 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("cd3bcc44-44c0-4a5a-9041-34b558a9fbf2")]
|
|
@ -0,0 +1,68 @@
|
||||||
|
namespace AutoMapper
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
#if DEPENDENCY_MODEL
|
||||||
|
using Microsoft.Extensions.DependencyModel;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
#if DEPENDENCY_MODEL
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddAutoMapper(DependencyContext.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services, DependencyContext dependencyContext)
|
||||||
|
{
|
||||||
|
services.AddAutoMapper(dependencyContext.RuntimeLibraries
|
||||||
|
.SelectMany(lib => lib.GetDefaultAssemblyNames(dependencyContext).Select(Assembly.Load)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services, params Assembly[] assemblies)
|
||||||
|
{
|
||||||
|
AddAutoMapperClasses(services, assemblies);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services, IEnumerable<Assembly> assemblies)
|
||||||
|
{
|
||||||
|
AddAutoMapperClasses(services, assemblies);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services, params Type[] profileAssemblyMarkerTypes)
|
||||||
|
{
|
||||||
|
AddAutoMapperClasses(services, profileAssemblyMarkerTypes.Select(t => t.GetTypeInfo().Assembly));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAutoMapper(this IServiceCollection services, IEnumerable<Type> profileAssemblyMarkerTypes)
|
||||||
|
{
|
||||||
|
AddAutoMapperClasses(services, profileAssemblyMarkerTypes.Select(t => t.GetTypeInfo().Assembly));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void AddAutoMapperClasses(IServiceCollection services, IEnumerable<Assembly> assembliesToScan)
|
||||||
|
{
|
||||||
|
assembliesToScan = assembliesToScan as Assembly[] ?? assembliesToScan.ToArray();
|
||||||
|
|
||||||
|
var profiles =
|
||||||
|
assembliesToScan.SelectMany(a => a.ExportedTypes).Where(t => typeof(Profile).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo()));
|
||||||
|
|
||||||
|
Mapper.Initialize(cfg =>
|
||||||
|
{
|
||||||
|
foreach (var profile in profiles)
|
||||||
|
{
|
||||||
|
cfg.AddProfile(profile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddSingleton(Mapper.Configuration);
|
||||||
|
services.AddScoped<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-alpha-*",
|
||||||
|
"authors": [ "Jimmy Bogard" ],
|
||||||
|
"copyright": "Copyright Jimmy Bogard",
|
||||||
|
"description": "AutoMapper extensions for ASP.NET Core",
|
||||||
|
"packOptions": {
|
||||||
|
"copyright": "Copyright Jimmy Bogard",
|
||||||
|
"owners": [ "Jimmy Bogard" ],
|
||||||
|
"licenseUrl": "https://github.com/AutoMapper/AutoMapper/blob/master/LICENSE.txt",
|
||||||
|
"projectUrl": "http://automapper.org",
|
||||||
|
"iconUrl": "https://s3.amazonaws.com/automapper/icon.png",
|
||||||
|
"requireLicenseAcceptance": false,
|
||||||
|
"summary": "AutoMapper extensions for ASP.NET Core"
|
||||||
|
},
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0",
|
||||||
|
"AutoMapper": "5.0.2"
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"net451": {
|
||||||
|
"frameworkAssemblies": {
|
||||||
|
"System.Runtime": ""
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.Extensions.DependencyModel": "1.0.0"
|
||||||
|
},
|
||||||
|
"buildOptions": {
|
||||||
|
"define": [ "DEPENDENCY_MODEL" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"netstandard1.1": {
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"netstandard1.6": {
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0",
|
||||||
|
"Microsoft.Extensions.DependencyModel": "1.0.0"
|
||||||
|
},
|
||||||
|
"buildOptions": {
|
||||||
|
"define": [ "DEPENDENCY_MODEL" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TestApp
|
||||||
|
{
|
||||||
|
using System.Reflection;
|
||||||
|
using AutoMapper;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
IServiceCollection services = new ServiceCollection();
|
||||||
|
services.AddTransient<ISomeService>(sp => new FooService(5));
|
||||||
|
services.AddAutoMapper(typeof(Source));
|
||||||
|
var provider = services.BuildServiceProvider();
|
||||||
|
provider.GetService<IMapper>();
|
||||||
|
|
||||||
|
foreach (var service in services)
|
||||||
|
{
|
||||||
|
Console.WriteLine(service.ServiceType + " - " + service.ImplementationType);
|
||||||
|
}
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Source
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Dest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Source2
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Dest2
|
||||||
|
{
|
||||||
|
public int ResolvedValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile1 : Profile
|
||||||
|
{
|
||||||
|
public Profile1()
|
||||||
|
{
|
||||||
|
CreateMap<Source, Dest>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile2 : Profile
|
||||||
|
{
|
||||||
|
public Profile2()
|
||||||
|
{
|
||||||
|
CreateMap<Source2, Dest2>()
|
||||||
|
.ForMember(d => d.ResolvedValue, opt => opt.ResolveUsing<DependencyResolver>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DependencyResolver : IValueResolver<object, object, int>
|
||||||
|
{
|
||||||
|
private readonly ISomeService _service;
|
||||||
|
|
||||||
|
public DependencyResolver(ISomeService service)
|
||||||
|
{
|
||||||
|
_service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Resolve(object source, object destination, int destMember, ResolutionContext context)
|
||||||
|
{
|
||||||
|
return _service.Modify(destMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISomeService
|
||||||
|
{
|
||||||
|
int Modify(int value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FooService : ISomeService
|
||||||
|
{
|
||||||
|
private readonly int _value;
|
||||||
|
|
||||||
|
public FooService(int value)
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Modify(int value) => value + _value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("TestApp")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
|
||||||
|
// 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("de95f633-80b5-4248-a594-7fb357c8dac9")]
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>de95f633-80b5-4248-a594-7fb357c8dac9</ProjectGuid>
|
||||||
|
<RootNamespace>TestApp</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"AutoMapper.Extensions.Microsoft.DependencyInjection": { "target": "project" },
|
||||||
|
"Microsoft.Extensions.DependencyInjection": "1.0.0",
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace AutoMapper.Extensions.Microsoft.DependencyInjection.Tests
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Shouldly;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
public class AssemblyResolutionTests
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
|
public AssemblyResolutionTests()
|
||||||
|
{
|
||||||
|
IServiceCollection services = new ServiceCollection();
|
||||||
|
services.AddAutoMapper(typeof(Source).GetTypeInfo().Assembly);
|
||||||
|
_provider = services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldResolveConfiguration()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldConfigureProfiles()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().GetAllTypeMaps().Length.ShouldBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldResolveMapper()
|
||||||
|
{
|
||||||
|
_provider.GetService<IMapper>().ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldInitializeStatically()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().ShouldBeSameAs(Mapper.Configuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>a93a7f85-292a-4130-891d-4307d3f60c30</ProjectGuid>
|
||||||
|
<RootNamespace>MediatR.Extensions.Microsoft.DependencyInjection.Tests</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,30 @@
|
||||||
|
namespace AutoMapper.Extensions.Microsoft.DependencyInjection.Tests
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using global::Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Shouldly;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
public class DependencyTests
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
|
public DependencyTests()
|
||||||
|
{
|
||||||
|
IServiceCollection services = new ServiceCollection();
|
||||||
|
services.AddTransient<ISomeService>(sp => new FooService(5));
|
||||||
|
services.AddTransient<DependencyResolver>();
|
||||||
|
services.AddAutoMapper(typeof(Source));
|
||||||
|
_provider = services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldResolveWithDependency()
|
||||||
|
{
|
||||||
|
var mapper = _provider.GetService<IMapper>();
|
||||||
|
var dest = mapper.Map<Source2, Dest2>(new Source2());
|
||||||
|
|
||||||
|
dest.ResolvedValue.ShouldBe(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
namespace AutoMapper.Extensions.Microsoft.DependencyInjection.Tests
|
||||||
|
{
|
||||||
|
public class Source
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Dest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Source2
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Dest2
|
||||||
|
{
|
||||||
|
public int ResolvedValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile1 : Profile
|
||||||
|
{
|
||||||
|
public Profile1()
|
||||||
|
{
|
||||||
|
CreateMap<Source, Dest>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile2 : Profile
|
||||||
|
{
|
||||||
|
public Profile2()
|
||||||
|
{
|
||||||
|
CreateMap<Source2, Dest2>()
|
||||||
|
.ForMember(d => d.ResolvedValue, opt => opt.ResolveUsing<DependencyResolver>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DependencyResolver : IValueResolver<object, object, int>
|
||||||
|
{
|
||||||
|
private readonly ISomeService _service;
|
||||||
|
|
||||||
|
public DependencyResolver(ISomeService service)
|
||||||
|
{
|
||||||
|
_service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Resolve(object source, object destination, int destMember, ResolutionContext context)
|
||||||
|
{
|
||||||
|
return _service.Modify(destMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISomeService
|
||||||
|
{
|
||||||
|
int Modify(int value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FooService : ISomeService
|
||||||
|
{
|
||||||
|
private readonly int _value;
|
||||||
|
|
||||||
|
public FooService(int value)
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Modify(int value) => value + _value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
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: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("AutoMapper.Extensions.Microsoft.DependencyInjection.Tests")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
|
||||||
|
// 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("a93a7f85-292a-4130-891d-4307d3f60c30")]
|
|
@ -0,0 +1,44 @@
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace AutoMapper.Extensions.Microsoft.DependencyInjection.Tests
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using Shouldly;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
public class TypeResolutionTests
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _provider;
|
||||||
|
|
||||||
|
public TypeResolutionTests()
|
||||||
|
{
|
||||||
|
IServiceCollection services = new ServiceCollection();
|
||||||
|
services.AddAutoMapper(typeof(Source));
|
||||||
|
_provider = services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldResolveConfiguration()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldConfigureProfiles()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().GetAllTypeMaps().Length.ShouldBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldResolveMapper()
|
||||||
|
{
|
||||||
|
_provider.GetService<IMapper>().ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ShouldInitializeStatically()
|
||||||
|
{
|
||||||
|
_provider.GetService<IConfigurationProvider>().ShouldBeSameAs(Mapper.Configuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"testRunner": "xunit",
|
||||||
|
"dependencies": {
|
||||||
|
"AutoMapper.Extensions.Microsoft.DependencyInjection": { "target": "project" },
|
||||||
|
"Shouldly": "2.7.0",
|
||||||
|
"Microsoft.Extensions.DependencyInjection": "1.0.0",
|
||||||
|
"xunit": "2.2.0-beta2-build3300",
|
||||||
|
"dotnet-test-xunit": "2.2.0-preview2-build1029"
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"net452": {
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.Platforms": "1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"type": "platform",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"imports": [
|
||||||
|
"dnxcore50",
|
||||||
|
"portable-net45+win8"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче