зеркало из https://github.com/SteeltoeOSS/Common.git
Initial checkin
This commit is contained in:
Родитель
ae24a4a2e2
Коммит
ec08ecc17a
|
@ -0,0 +1,50 @@
|
|||
*.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
|
||||
|
||||
*.cs text=auto diff=csharp
|
||||
*.vb text=auto
|
||||
*.resx text=auto
|
||||
*.c text=auto
|
||||
*.cpp text=auto
|
||||
*.cxx text=auto
|
||||
*.h text=auto
|
||||
*.hxx text=auto
|
||||
*.py text=auto
|
||||
*.rb text=auto
|
||||
*.java text=auto
|
||||
*.html text=auto
|
||||
*.htm text=auto
|
||||
*.css text=auto
|
||||
*.scss text=auto
|
||||
*.sass text=auto
|
||||
*.less text=auto
|
||||
*.js text=auto
|
||||
*.lisp text=auto
|
||||
*.clj text=auto
|
||||
*.sql text=auto
|
||||
*.php text=auto
|
||||
*.lua text=auto
|
||||
*.m text=auto
|
||||
*.asm text=auto
|
||||
*.erl text=auto
|
||||
*.fs text=auto
|
||||
*.fsx text=auto
|
||||
*.hs text=auto
|
||||
|
||||
*.csproj text=auto
|
||||
*.vbproj text=auto
|
||||
*.fsproj text=auto
|
||||
*.dbproj text=auto
|
||||
*.sln text=auto eol=crlf
|
|
@ -0,0 +1,200 @@
|
|||
## 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/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Visual Studo 2015 cache/options directory
|
||||
.vs/
|
||||
|
||||
# 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
|
||||
|
||||
*_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
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# 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 addin-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
*.[Cc]ache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
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/
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# DNX-based projects have a project.lock.json file. This should not be checked-in during development
|
||||
project.lock.json
|
||||
.vscode
|
|
@ -0,0 +1,23 @@
|
|||
language: csharp
|
||||
dist: trusty
|
||||
env:
|
||||
global:
|
||||
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
mono: none
|
||||
dotnet: 2.0.0
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
osx_image: xcode8.2
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- dev
|
||||
- /^update[0-9]{3}/
|
||||
script:
|
||||
- ./scripts/travis_install.sh
|
||||
- ./scripts/travis_build.sh
|
||||
- ./scripts/travis_test.sh
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then ulimit -n 1024; fi
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26730.16
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D9798FDE-76F4-4848-8AE0-95249C0101F0}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CC77ED1F-BC03-4B9D-A07A-186C9A13042B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{473B575D-8871-4E77-9212-C2BBA20D702E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
config\nuget-dev.config = config\nuget-dev.config
|
||||
config\nuget-master.config = config\nuget-master.config
|
||||
config\nuget-update.config = config\nuget-update.config
|
||||
config\nuget.config = config\nuget.config
|
||||
config\versions-dev.props = config\versions-dev.props
|
||||
config\versions-master.props = config\versions-master.props
|
||||
config\versions-update.props = config\versions-update.props
|
||||
config\versions.props = config\versions.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{CFAB804F-F398-4EAF-9D19-65CC180DB8C5}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
scripts\appveyor_build.cmd = scripts\appveyor_build.cmd
|
||||
scripts\appveyor_install.cmd = scripts\appveyor_install.cmd
|
||||
scripts\appveyor_tests.cmd = scripts\appveyor_tests.cmd
|
||||
scripts\travis_build.sh = scripts\travis_build.sh
|
||||
scripts\travis_install.sh = scripts\travis_install.sh
|
||||
scripts\travis_test.sh = scripts\travis_test.sh
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{99524EB1-60C2-4069-B4F5-C89344678ABD}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.travis.yml = .travis.yml
|
||||
appveyor.yml = appveyor.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common", "src\Steeltoe.Common\Steeltoe.Common.csproj", "{4AEA9704-3B99-4317-A959-7D6E4CDD4811}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common.Autofac", "src\Steeltoe.Common.Autofac\Steeltoe.Common.Autofac.csproj", "{E9C17268-1B23-4183-8F88-8FEFE95A3CAB}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common.Http", "src\Steeltoe.Common.Http\Steeltoe.Common.Http.csproj", "{C9CF9265-7343-4080-AD23-BFCD6E571865}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common.Autofac.Test", "test\Steeltoe.Common.Autofac.Test\Steeltoe.Common.Autofac.Test.csproj", "{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common.Http.Test", "test\Steeltoe.Common.Http.Test\Steeltoe.Common.Http.Test.csproj", "{7FF75564-423A-4EE6-B7AD-9D35C428757F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Steeltoe.Common.Test", "test\Steeltoe.Common.Test\Steeltoe.Common.Test.csproj", "{101DF01E-FDE9-4B97-9666-C3777CC308D0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4AEA9704-3B99-4317-A959-7D6E4CDD4811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4AEA9704-3B99-4317-A959-7D6E4CDD4811}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4AEA9704-3B99-4317-A959-7D6E4CDD4811}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4AEA9704-3B99-4317-A959-7D6E4CDD4811}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E9C17268-1B23-4183-8F88-8FEFE95A3CAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E9C17268-1B23-4183-8F88-8FEFE95A3CAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E9C17268-1B23-4183-8F88-8FEFE95A3CAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E9C17268-1B23-4183-8F88-8FEFE95A3CAB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9CF9265-7343-4080-AD23-BFCD6E571865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C9CF9265-7343-4080-AD23-BFCD6E571865}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C9CF9265-7343-4080-AD23-BFCD6E571865}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9CF9265-7343-4080-AD23-BFCD6E571865}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7FF75564-423A-4EE6-B7AD-9D35C428757F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7FF75564-423A-4EE6-B7AD-9D35C428757F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7FF75564-423A-4EE6-B7AD-9D35C428757F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7FF75564-423A-4EE6-B7AD-9D35C428757F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{101DF01E-FDE9-4B97-9666-C3777CC308D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{101DF01E-FDE9-4B97-9666-C3777CC308D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{101DF01E-FDE9-4B97-9666-C3777CC308D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{101DF01E-FDE9-4B97-9666-C3777CC308D0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{4AEA9704-3B99-4317-A959-7D6E4CDD4811} = {D9798FDE-76F4-4848-8AE0-95249C0101F0}
|
||||
{E9C17268-1B23-4183-8F88-8FEFE95A3CAB} = {D9798FDE-76F4-4848-8AE0-95249C0101F0}
|
||||
{C9CF9265-7343-4080-AD23-BFCD6E571865} = {D9798FDE-76F4-4848-8AE0-95249C0101F0}
|
||||
{A2C46127-6D02-46FA-9AFC-9C27A11F1FB6} = {CC77ED1F-BC03-4B9D-A07A-186C9A13042B}
|
||||
{7FF75564-423A-4EE6-B7AD-9D35C428757F} = {CC77ED1F-BC03-4B9D-A07A-186C9A13042B}
|
||||
{101DF01E-FDE9-4B97-9666-C3777CC308D0} = {CC77ED1F-BC03-4B9D-A07A-186C9A13042B}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4A85F9DA-2C2D-48E9-A28C-9B35C473C150}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
84
README.md
84
README.md
|
@ -1 +1,83 @@
|
|||
# Common
|
||||
# .NET CloudFoundry Connectors
|
||||
|
||||
This repo contains several connectors which simplify the process of connecting to services on CloudFoundry.
|
||||
|
||||
Windows Master (Stable): [![AppVeyor Master](https://ci.appveyor.com/api/projects/status/ivdciaopp5kxo3cp/branch/master?svg=true)](https://ci.appveyor.com/project/steeltoe/connectors/branch/master)
|
||||
|
||||
Windows Dev (Less Stable): [![AppVeyor Dev](https://ci.appveyor.com/api/projects/status/ivdciaopp5kxo3cp/branch/dev?svg=true)](https://ci.appveyor.com/project/steeltoe/connectors/branch/dev)
|
||||
|
||||
Linux/OS X Master (Stable): [![Travis Master](https://travis-ci.org/SteeltoeOSS/Connectors.svg?branch=master)](https://travis-ci.org/SteeltoeOSS/Connectors)
|
||||
|
||||
Linux/OS X Dev (Less Stable): [![Travis Dev](https://travis-ci.org/SteeltoeOSS/Connectors.svg?branch=dev)](https://travis-ci.org/SteeltoeOSS/Connectors)
|
||||
|
||||
# .NET Runtime & Framework Support
|
||||
Like ASP.NET Core, the connectors are intended to support both .NET 4.5.1+ and .NET Core (CoreCLR/CoreFX) runtimes. Note that some connectors only support .NET 4.5.1+ since the libraries they depend on do not yet support .NET Core.
|
||||
|
||||
Where supported the connectors are built and unit tested on Windows, Linux and OSX.
|
||||
|
||||
While the primary usage of the connectors is intended to be with ASP.NET Core applications, they should also work fine with UWP, Console and ASP.NET 4.x apps.
|
||||
|
||||
Depending on their level of support, the connectors and samples have been tested on .NET Core 1.1, .NET 4.5.1/4.6.x, and on ASP.NET Core 1.1.0.
|
||||
|
||||
# Usage
|
||||
For more information on how to use these components see the online [Steeltoe documentation](http://steeltoe.io/).
|
||||
|
||||
# Nuget Feeds
|
||||
All new connector development is done on the dev branch. More stable versions of the connectors can be found on the master branch. The latest prebuilt packages from each branch can be found on one of two MyGet feeds. Released version can be found on nuget.org.
|
||||
|
||||
[Development feed (Less Stable)](https://www.myget.org/gallery/steeltoedev) - https://www.myget.org/gallery/steeltoedev
|
||||
|
||||
[Master feed (Stable)](https://www.myget.org/gallery/steeltoemaster) - https://www.myget.org/gallery/steeltoemaster
|
||||
|
||||
[Release or Release Candidate feed](https://www.nuget.org/) - https://www.nuget.org/.
|
||||
|
||||
# Building Pre-requisites
|
||||
To build and run the unit tests:
|
||||
|
||||
1. .NET Core SDK 1.0.4 or greater
|
||||
2. .NET Core Runtime 1.1
|
||||
|
||||
# Building Packages & Running Tests - Windows
|
||||
To build the packages on windows:
|
||||
|
||||
1. git clone ...
|
||||
2. cd `<clone directory>`
|
||||
3. Install .NET Core SDK
|
||||
4. dotnet restore --configfile nuget.config src
|
||||
5. cd src\ `<project>` (e.g. cd src\Steeltoe.CloudFoundry.Connector)
|
||||
6. dotnet pack --configuration `<Release or Debug>`
|
||||
|
||||
The resulting artifacts can be found in the bin folder under the corresponding project. (e.g. src\Steeltoe.CloudFoundry.Connector\bin)
|
||||
|
||||
To run the unit tests:
|
||||
|
||||
1. git clone ...
|
||||
2. cd `<clone directory>`
|
||||
3. Install .NET Core SDK
|
||||
4. dotnet restore --configfile nuget.config test
|
||||
5. cd test\ `<test project>` (e.g. cd test\Steeltoe.CloudFoundry.Connector.Test)
|
||||
6. dotnet xunit -verbose
|
||||
|
||||
# Building Packages & Running Tests - Linux/OSX
|
||||
To build the packages on Linux/OSX: ( Note: Some connectors do not support CoreCLR.)
|
||||
|
||||
1. git clone ...
|
||||
2. cd `<clone directory>`
|
||||
3. Install .NET Core SDK
|
||||
4. dotnet restore --configfile nuget.config src
|
||||
5. cd src/ `<project>` (e.g.. cd src/Steeltoe.CloudFoundry.Connector)
|
||||
6. dotnet pack --configuration `<Release or Debug>`
|
||||
|
||||
The resulting artifacts can be found in the bin folder under the corresponding project. (e.g. src/Steeltoe.CloudFoundry.Connector/bin
|
||||
|
||||
To run the unit tests: ( Note: Some connectors do not support CoreCLR.)
|
||||
|
||||
1. git clone ...
|
||||
2. cd `<clone directory>`
|
||||
3. Install .NET Core SDK
|
||||
4. dotnet restore --configfile nuget.config test
|
||||
5. cd test\ `<test project>` (e.g. cd test/Steeltoe.CloudFoundry.Connector.Test)
|
||||
6. dotnet xunit -verbose -framework netcoreapp1.1
|
||||
|
||||
# Sample Applications
|
||||
See the [Samples](https://github.com/SteeltoeOSS/Samples) repo for examples of how to use these packages.
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
version: '2.0.0-{branch}-{build}'
|
||||
init:
|
||||
- git config --global core.autocrlf true
|
||||
image: Visual Studio 2017
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- dev
|
||||
- /^update[0-9]{3}/
|
||||
install:
|
||||
- scripts\appveyor_install.cmd
|
||||
test_script:
|
||||
- scripts\appveyor_tests.cmd
|
||||
build_script:
|
||||
- scripts\appveyor_build.cmd
|
||||
artifacts:
|
||||
- path: 'src\Steeltoe.Common\bin\Release\*.nupkg'
|
||||
- path: 'src\Steeltoe.Common.Http\bin\Release\*.nupkg'
|
||||
- path: 'src\Steeltoe.Common.Autofac\bin\Release\*.nupkg'
|
||||
- path: 'src\Steeltoe.Common\bin\Debug\*.nupkg'
|
||||
- path: 'src\Steeltoe.Common.Http\bin\Debug\*.nupkg'
|
||||
- path: 'src\Steeltoe.Common.Autofac\bin\Debug\*.nupkg'
|
||||
deploy:
|
||||
- provider: NuGet
|
||||
skip_symbols: false
|
||||
artifact: /.*\.nupkg/
|
||||
server: https://www.myget.org/F/steeltoemaster/api/v2/package
|
||||
symbol_server: https://www.myget.org/F/steeltoemaster/symbols/api/v2/package
|
||||
api_key:
|
||||
secure: 246ApObnMYYvzDo9Ki72CxxuKfuoqYbrbUK2HLevGIGHXYY6f0OkAdE3EWCwNJ7g
|
||||
on:
|
||||
branch: master
|
||||
appveyor_repo_tag: false
|
||||
- provider: NuGet
|
||||
skip_symbols: false
|
||||
artifact: /.*\.nupkg/
|
||||
server: https://www.myget.org/F/steeltoedev/api/v2/package
|
||||
symbol_server: https://www.myget.org/F/steeltoedev/symbols/api/v2/package
|
||||
api_key:
|
||||
secure: 246ApObnMYYvzDo9Ki72CxxuKfuoqYbrbUK2HLevGIGHXYY6f0OkAdE3EWCwNJ7g
|
||||
on:
|
||||
branch: dev
|
||||
appveyor_repo_tag: false
|
||||
- provider: NuGet
|
||||
skip_symbols: true
|
||||
artifact: /.*\.nupkg/
|
||||
api_key:
|
||||
secure: RGkpu8xIMDC75IAd1qPRdueeTaYj+ddW2bNEw8S7e81940ELu+WV04uWAzqV34/C
|
||||
on:
|
||||
branch: master
|
||||
appveyor_repo_tag: true
|
||||
- provider: NuGet
|
||||
skip_symbols: true
|
||||
artifact: /.*\.nupkg/
|
||||
server: https://www.myget.org/F/steeltoeupdates/api/v2/package
|
||||
symbol_server: https://www.myget.org/F/steeltoeupdates/symbols/api/v2/package
|
||||
api_key:
|
||||
secure: 246ApObnMYYvzDo9Ki72CxxuKfuoqYbrbUK2HLevGIGHXYY6f0OkAdE3EWCwNJ7g
|
||||
on:
|
||||
branch: /^update[0-9]{3}/
|
||||
appveyor_repo_tag: false
|
||||
- provider: NuGet
|
||||
skip_symbols: true
|
||||
artifact: /.*\.nupkg/
|
||||
api_key:
|
||||
secure: RGkpu8xIMDC75IAd1qPRdueeTaYj+ddW2bNEw8S7e81940ELu+WV04uWAzqV34/C
|
||||
on:
|
||||
branch: /^update[0-9]{3}/
|
||||
appveyor_repo_tag: true
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="SteeltoeUpdate" value="https://www.myget.org/F/steeltoeupdates/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
|
@ -0,0 +1,16 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SteeltoeVersion>$(STEELTOE_VERSION)</SteeltoeVersion>
|
||||
<SteeltoeVersionSuffix>$(STEELTOE_DASH_VERSION_SUFFIX)</SteeltoeVersionSuffix>
|
||||
<AspNetCoreVersion>2.0.0</AspNetCoreVersion>
|
||||
<AspNetCoreTestVersion>2.0.0</AspNetCoreTestVersion>
|
||||
<AspNetCoreMvcTestVersion>2.0.0</AspNetCoreMvcTestVersion>
|
||||
<AutofacVersion>4.6.1</AutofacVersion>
|
||||
<HttpVersion>4.3.3</HttpVersion>
|
||||
<CoreFxVersion>4.4.0</CoreFxVersion>
|
||||
<JsonNetVersion>10.0.1</JsonNetVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-rc3-build3818</XunitVersion>
|
||||
<XunitStudioVersion>2.3.0-rc3-build3818</XunitStudioVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,16 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SteeltoeVersion>$(STEELTOE_VERSION)</SteeltoeVersion>
|
||||
<SteeltoeVersionSuffix>$(STEELTOE_DASH_VERSION_SUFFIX)</SteeltoeVersionSuffix>
|
||||
<AspNetCoreVersion>2.0.0</AspNetCoreVersion>
|
||||
<AspNetCoreTestVersion>2.0.0</AspNetCoreTestVersion>
|
||||
<AspNetCoreMvcTestVersion>2.0.0</AspNetCoreMvcTestVersion>
|
||||
<AutofacVersion>4.6.1</AutofacVersion>
|
||||
<HttpVersion>4.3.3</HttpVersion>
|
||||
<CoreFxVersion>4.4.0</CoreFxVersion>
|
||||
<JsonNetVersion>10.0.1</JsonNetVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-rc3-build3818</XunitVersion>
|
||||
<XunitStudioVersion>2.3.0-rc3-build3818</XunitStudioVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,16 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SteeltoeVersion>$(STEELTOE_VERSION)</SteeltoeVersion>
|
||||
<SteeltoeVersionSuffix>$(STEELTOE_DASH_VERSION_SUFFIX)</SteeltoeVersionSuffix>
|
||||
<AspNetCoreVersion>1.1.0</AspNetCoreVersion>
|
||||
<AspNetCoreTestVersion>1.1.2</AspNetCoreTestVersion>
|
||||
<AspNetCoreMvcTestVersion>1.1.3</AspNetCoreMvcTestVersion>
|
||||
<AutofacVersion>4.6.1</AutofacVersion>
|
||||
<HttpVersion>4.3.1</HttpVersion>
|
||||
<CoreFxVersion>4.3.0</CoreFxVersion>
|
||||
<JsonNetVersion>9.0.1</JsonNetVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-rc3-build3818</XunitVersion>
|
||||
<XunitStudioVersion>2.3.0-rc3-build3818</XunitStudioVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,16 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<SteeltoeVersion>$(STEELTOE_VERSION)</SteeltoeVersion>
|
||||
<SteeltoeVersionSuffix>$(STEELTOE_DASH_VERSION_SUFFIX)</SteeltoeVersionSuffix>
|
||||
<AspNetCoreVersion>2.0.0</AspNetCoreVersion>
|
||||
<AspNetCoreTestVersion>2.0.0</AspNetCoreTestVersion>
|
||||
<AspNetCoreMvcTestVersion>2.0.0</AspNetCoreMvcTestVersion>
|
||||
<AutofacVersion>4.6.1</AutofacVersion>
|
||||
<HttpVersion>4.3.3</HttpVersion>
|
||||
<CoreFxVersion>4.4.0</CoreFxVersion>
|
||||
<JsonNetVersion>10.0.1</JsonNetVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-rc3-build3818</XunitVersion>
|
||||
<XunitStudioVersion>2.3.0-rc3-build3818</XunitStudioVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,41 @@
|
|||
:: @ECHO OFF
|
||||
|
||||
:: Build packages
|
||||
cd src\Steeltoe.Common
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" (
|
||||
IF NOT "%STEELTOE_VERSION_SUFFIX%"=="" (
|
||||
dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX%
|
||||
nuget add "bin\%BUILD_TYPE%\Steeltoe.Common.%STEELTOE_VERSION%-%STEELTOE_VERSION_SUFFIX%.nupkg" -Source "%USERPROFILE%\localfeed"
|
||||
) ELSE (
|
||||
dotnet pack --configuration %BUILD_TYPE%
|
||||
nuget add "bin\%BUILD_TYPE%\Steeltoe.Common.%STEELTOE_VERSION%.nupkg" -Source "%USERPROFILE%\localfeed"
|
||||
)
|
||||
)
|
||||
IF "%APPVEYOR_REPO_TAG_NAME%"=="" (dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX% --include-symbols --include-source)
|
||||
IF "%APPVEYOR_REPO_TAG_NAME%"=="" (nuget add bin\%BUILD_TYPE%\Steeltoe.Common.%STEELTOE_VERSION%-%STEELTOE_VERSION_SUFFIX%.nupkg -Source %USERPROFILE%\localfeed)
|
||||
cd ..\..
|
||||
|
||||
cd src\Steeltoe.Common.Http
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" (
|
||||
IF NOT "%STEELTOE_VERSION_SUFFIX%"=="" (
|
||||
dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX%
|
||||
) ELSE (
|
||||
dotnet pack --configuration %BUILD_TYPE%
|
||||
)
|
||||
)
|
||||
IF "%APPVEYOR_REPO_TAG_NAME%"=="" (dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX% --include-symbols --include-source)
|
||||
cd ..\..
|
||||
|
||||
cd src\Steeltoe.Common.Autofac
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" (
|
||||
IF NOT "%STEELTOE_VERSION_SUFFIX%"=="" (
|
||||
dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX%
|
||||
) ELSE (
|
||||
dotnet pack --configuration %BUILD_TYPE%
|
||||
)
|
||||
)
|
||||
IF "%APPVEYOR_REPO_TAG_NAME%"=="" (dotnet pack --configuration %BUILD_TYPE% --version-suffix %STEELTOE_VERSION_SUFFIX% --include-symbols --include-source)
|
||||
cd ..\..
|
|
@ -0,0 +1,28 @@
|
|||
@ECHO OFF
|
||||
:: Output dotnet info
|
||||
dotnet --info
|
||||
|
||||
SET CI_BUILD=%APPVEYOR%
|
||||
SET number=00000%APPVEYOR_BUILD_NUMBER%
|
||||
SET STEELTOE_VERSION=2.0.0
|
||||
SET STEELTOE_VERSION_SUFFIX=%APPVEYOR_REPO_BRANCH%-%number:~-5%
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" SET STEELTOE_VERSION_SUFFIX=%APPVEYOR_REPO_TAG_NAME:~6,5%
|
||||
IF NOT "%STEELTOE_VERSION_SUFFIX%"=="" (
|
||||
SET STEELTOE_VERSION_SUFFIX=%STEELTOE_VERSION_SUFFIX: =%
|
||||
SET STEELTOE_DASH_VERSION_SUFFIX=-%STEELTOE_VERSION_SUFFIX%
|
||||
) ELSE (
|
||||
SET STEELTOE_DASH_VERSION_SUFFIX=
|
||||
)
|
||||
echo "Version Suffix:" %STEELTOE_VERSION_SUFFIX%
|
||||
SET BUILD_TYPE=Release
|
||||
IF "%APPVEYOR_REPO_BRANCH%"=="master" COPY config\nuget-master.config .\nuget.config
|
||||
IF "%APPVEYOR_REPO_BRANCH%"=="dev" COPY config\nuget-dev.config .\nuget.config
|
||||
IF "%APPVEYOR_REPO_BRANCH:~0,3%"=="upd" COPY config\nuget-update.config .\nuget.config
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" COPY config\nuget.config .\nuget.config
|
||||
IF "%APPVEYOR_REPO_BRANCH%"=="master" COPY config\versions-master.props .\versions.props
|
||||
IF "%APPVEYOR_REPO_BRANCH%"=="dev" COPY config\versions-dev.props .\versions.props
|
||||
IF "%APPVEYOR_REPO_BRANCH:~0,3%"=="upd" COPY config\versions-update.props .\versions.props
|
||||
IF NOT "%APPVEYOR_REPO_TAG_NAME%"=="" COPY config\versions.props .\versions.props
|
||||
IF "%APPVEYOR_REPO_BRANCH%"=="dev" SET BUILD_TYPE=Debug
|
||||
mkdir %USERPROFILE%\localfeed
|
||||
nuget sources add -Name localfeed -Source %USERPROFILE%\localfeed -ConfigFile .\nuget.config
|
|
@ -0,0 +1,27 @@
|
|||
@ECHO OFF
|
||||
|
||||
:: Run unit tests
|
||||
cd test\Steeltoe.Common.Test
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
dotnet xunit -verbose
|
||||
if not "%errorlevel%"=="0" goto failure
|
||||
cd ..\..
|
||||
|
||||
cd test\Steeltoe.Common.Http.Test
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
dotnet xunit -verbose
|
||||
if not "%errorlevel%"=="0" goto failure
|
||||
cd ..\..
|
||||
|
||||
cd test\Steeltoe.Common.Autofac.Test
|
||||
dotnet restore --configfile ..\..\nuget.config
|
||||
dotnet xunit -verbose
|
||||
if not "%errorlevel%"=="0" goto failure
|
||||
cd ..\..
|
||||
|
||||
echo Unit Tests Pass
|
||||
goto success
|
||||
:failure
|
||||
echo Unit Tests Failure
|
||||
exit -1
|
||||
:success
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo Code is built in Unit Tests
|
||||
|
||||
|
||||
cd src/Steeltoe.Common
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
cd ../..
|
||||
|
||||
cd src/Steeltoe.Common.Http
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
cd ../..
|
||||
|
||||
cd src/Steeltoe.Common.Autofac
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
cd ../..
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
dotnet --info
|
||||
|
||||
export CI_BUILD=True
|
||||
export STEELTOE_VERSION=2.0.0
|
||||
if [[ "$TRAVIS_BRANCH" == "master" ]]; then cp config/nuget-master.config ./nuget.config ; fi
|
||||
if [[ "$TRAVIS_BRANCH" == "dev" ]]; then cp config/nuget-dev.config ./nuget.config ; fi
|
||||
if [[ "${TRAVIS_BRANCH:0:3}" == "upd" ]]; then cp config/nuget-update.config ./nuget.config ; fi
|
||||
if [[ "$TRAVIS_TAG" != "" ]]; then cp config/nuget.config ./nuget.config ; fi
|
||||
if [[ "$TRAVIS_BRANCH" == "master" ]]; then cp config/versions-master.props ./versions.props ; fi
|
||||
if [[ "$TRAVIS_BRANCH" == "dev" ]]; then cp config/versions-dev.props ./versions.props ; fi
|
||||
if [[ "${TRAVIS_BRANCH:0:3}" == "upd" ]]; then cp config/versions-update.props ./versions.props ; fi
|
||||
if [[ "$TRAVIS_TAG" != "" ]]; then cp config/versions.props ./versions.props ; fi
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run unit tests
|
||||
cd test/Steeltoe.Common.Test
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
dotnet xunit -verbose -framework netcoreapp2.0
|
||||
if [[ $? != 0 ]]; then exit 1 ; fi
|
||||
cd ../..
|
||||
|
||||
cd test/Steeltoe.Common.Http.Test
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
dotnet xunit -verbose -framework netcoreapp2.0
|
||||
if [[ $? != 0 ]]; then exit 1 ; fi
|
||||
cd ../..
|
||||
|
||||
cd test/Steeltoe.Common.Autofac.Test
|
||||
dotnet restore --configfile ../../nuget.config
|
||||
dotnet xunit -verbose -framework netcoreapp2.0
|
||||
if [[ $? != 0 ]]; then exit 1 ; fi
|
||||
cd ../..
|
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Autofac;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Steeltoe.Common.Configuration.Autofac
|
||||
{
|
||||
public static class ConfigurationContainerBuilderExtensions
|
||||
{
|
||||
public static void RegisterConfiguration(this ContainerBuilder container, IConfiguration configuration)
|
||||
{
|
||||
if (container == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
if (configuration == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
container.RegisterInstance(configuration).As<IConfigurationRoot>().SingleInstance();
|
||||
container.RegisterInstance(configuration).As<IConfiguration>().SingleInstance();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Autofac;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Steeltoe.Common.Options.Autofac
|
||||
{
|
||||
public static class OptionsContainerBuilderExtensions
|
||||
{
|
||||
public static void RegisterOptions(this ContainerBuilder container)
|
||||
{
|
||||
if (container == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
container.RegisterGeneric(typeof(OptionsManager<>)).As(typeof(IOptions<>)).SingleInstance();
|
||||
container.RegisterGeneric(typeof(OptionsMonitor<>)).As(typeof(IOptionsMonitor<>)).SingleInstance();
|
||||
container.RegisterGeneric(typeof(OptionsCache<>)).As(typeof(IOptionsMonitorCache<>)).SingleInstance();
|
||||
container.RegisterGeneric(typeof(OptionsManager<>)).As(typeof(IOptionsSnapshot<>)).InstancePerRequest();
|
||||
container.RegisterGeneric(typeof(OptionsFactory<>)).As(typeof(IOptionsFactory<>)).InstancePerDependency();
|
||||
}
|
||||
|
||||
public static void RegisterOption<TOption>(this ContainerBuilder container, IConfiguration config) where TOption : class
|
||||
=> container.RegisterOption<TOption>(Microsoft.Extensions.Options.Options.DefaultName, config);
|
||||
|
||||
public static void RegisterOption<TOption>(this ContainerBuilder container, string name, IConfiguration config) where TOption : class
|
||||
{
|
||||
if (container == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(config));
|
||||
}
|
||||
|
||||
container.RegisterInstance(new ConfigurationChangeTokenSource<TOption>(name, config)).As<IOptionsChangeTokenSource<TOption>>().SingleInstance();
|
||||
container.RegisterInstance(new NamedConfigureFromConfigurationOptions<TOption>(name, config)).As<IConfigureOptions<TOption>>().SingleInstance();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Steeltoe Common Library for Autofac</Description>
|
||||
<VersionPrefix>$(SteeltoeVersion)</VersionPrefix>
|
||||
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
|
||||
<Authors>Pivotal;dtillman</Authors>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AssemblyName>Steeltoe.Common.Autofac</AssemblyName>
|
||||
<PackageId>Steeltoe.Common.Autofac</PackageId>
|
||||
<PackageTags>NET Core;NET Framework;Autofac</PackageTags>
|
||||
<PackageIconUrl>http://steeltoe.io/images/transparent.png</PackageIconUrl>
|
||||
<PackageProjectUrl>http://steeltoe.io</PackageProjectUrl>
|
||||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="$(AutofacVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,116 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
|
||||
namespace Steeltoe.Common.Http
|
||||
{
|
||||
public static class HttpClientHelper
|
||||
{
|
||||
public static HttpClient GetHttpClient(bool validateCertificates, int timeout)
|
||||
{
|
||||
HttpClient client = null;
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
client = new HttpClient();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (!validateCertificates)
|
||||
{
|
||||
var handler = new HttpClientHandler();
|
||||
handler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
||||
handler.SslProtocols = SslProtocols.Tls12;
|
||||
client = new HttpClient(handler);
|
||||
}
|
||||
else
|
||||
{
|
||||
client = new HttpClient();
|
||||
}
|
||||
}
|
||||
client.Timeout = TimeSpan.FromMilliseconds(timeout);
|
||||
return client;
|
||||
}
|
||||
public static void ConfigureCertificateValidatation(bool validateCertificates, out SecurityProtocolType protocolType, out RemoteCertificateValidationCallback prevValidator)
|
||||
{
|
||||
prevValidator = null;
|
||||
protocolType = (SecurityProtocolType)0;
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
if (!validateCertificates)
|
||||
{
|
||||
protocolType = ServicePointManager.SecurityProtocol;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
prevValidator = ServicePointManager.ServerCertificateValidationCallback;
|
||||
ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void RestoreCertificateValidation(bool validateCertificates, SecurityProtocolType protocolType, RemoteCertificateValidationCallback prevValidator)
|
||||
{
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
if (!validateCertificates)
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = protocolType;
|
||||
ServicePointManager.ServerCertificateValidationCallback = prevValidator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static string GetEncodedUserPassword(string user, string password)
|
||||
{
|
||||
if (user == null)
|
||||
user = string.Empty;
|
||||
if (password == null)
|
||||
password = string.Empty;
|
||||
return Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + password));
|
||||
}
|
||||
|
||||
public static HttpRequestMessage GetRequestMessage(HttpMethod method, string requestUri, string userName, string password)
|
||||
{
|
||||
if (method == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(method));
|
||||
}
|
||||
|
||||
if (requestUri == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(requestUri));
|
||||
}
|
||||
|
||||
var request = new HttpRequestMessage(method, requestUri);
|
||||
if (!string.IsNullOrEmpty(password))
|
||||
{
|
||||
AuthenticationHeaderValue auth = new AuthenticationHeaderValue("Basic",
|
||||
GetEncodedUserPassword(userName, password));
|
||||
request.Headers.Authorization = auth;
|
||||
}
|
||||
|
||||
return request;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Steeltoe.Common.Http
|
||||
{
|
||||
public static class SerializationHelper
|
||||
{
|
||||
public static T Deserialize<T>(Stream stream, ILogger logger = null)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(stream));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (JsonReader reader = new JsonTextReader(new StreamReader(stream)))
|
||||
{
|
||||
JsonSerializer serializer = new JsonSerializer();
|
||||
return (T)serializer.Deserialize(reader, typeof(T));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger?.LogError("Serialization exception: {0}", e);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Steeltoe Common Library</Description>
|
||||
<VersionPrefix>$(SteeltoeVersion)</VersionPrefix>
|
||||
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
|
||||
<Authors>Pivotal;dtillman</Authors>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AssemblyName>Steeltoe.Common.Http</AssemblyName>
|
||||
<PackageId>Steeltoe.Common.Http</PackageId>
|
||||
<PackageTags>NET Core;NET Framework</PackageTags>
|
||||
<PackageIconUrl>http://steeltoe.io/images/transparent.png</PackageIconUrl>
|
||||
<PackageProjectUrl>http://steeltoe.io</PackageProjectUrl>
|
||||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(JsonNetVersion)" />
|
||||
<PackageReference Include="System.Net.Http" Version="$(HttpVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(CI_BUILD)' == ''">
|
||||
<ProjectReference Include="..\Steeltoe.Common\Steeltoe.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(CI_BUILD)' == 'True'">
|
||||
<PackageReference Include="Steeltoe.Common" Version="$(SteeltoeVersion)$(SteeltoeVersionSuffix)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,182 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Steeltoe.Common.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for working with configuration values that have placeholders in them.
|
||||
/// A placeholder takes the form of <code ${some:config:reference?default_if_not_present}></code>
|
||||
///
|
||||
/// Note: This was "inspired" by the Spring class: PropertyPlaceholderHelper
|
||||
///
|
||||
/// </summary>
|
||||
public static class PropertyPlaceholderHelper
|
||||
{
|
||||
private const string PREFIX = "${";
|
||||
private const string SUFFIX = "}";
|
||||
private const string SEPARATOR = "?";
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all placeholders of the form <code ${some:config:reference?default_if_not_present}/>
|
||||
/// with the corresponding value from the supplied <see cref="IConfiguration"/>.
|
||||
/// </summary>
|
||||
/// <param name="property">the string containing one or more placeholders</param>
|
||||
/// <param name="config">the configuration used for finding replace values.</param>
|
||||
/// <param name="logger">optional logger</param>
|
||||
/// <returns>the supplied value with the placeholders replaced inline</returns>
|
||||
public static string ResolvePlaceholders(string property, IConfiguration config, ILogger logger = null)
|
||||
{
|
||||
return ParseStringValue(property, config, new HashSet<string>(), logger);
|
||||
}
|
||||
|
||||
private static string ParseStringValue(string property, IConfiguration config, ISet<string> visitedPlaceHolders, ILogger logger = null)
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(property))
|
||||
return property;
|
||||
|
||||
StringBuilder result = new StringBuilder(property);
|
||||
|
||||
int startIndex = property.IndexOf(PREFIX);
|
||||
while (startIndex != -1)
|
||||
{
|
||||
int endIndex = FindEndIndex(result, startIndex);
|
||||
if (endIndex != -1)
|
||||
{
|
||||
|
||||
string placeholder = result.Substring(startIndex + PREFIX.Length, endIndex);
|
||||
string originalPlaceholder = placeholder;
|
||||
|
||||
if (!visitedPlaceHolders.Add(originalPlaceholder))
|
||||
{
|
||||
throw new ArgumentException(String.Format("Circular placeholder reference '{0}' in property definitions",
|
||||
originalPlaceholder));
|
||||
}
|
||||
// Recursive invocation, parsing placeholders contained in the placeholder key.
|
||||
placeholder = ParseStringValue(placeholder, config, visitedPlaceHolders);
|
||||
// Handle array references foo:bar[1]:baz format -> foo:bar:1:baz
|
||||
string lookup = placeholder.Replace('[', ':').Replace("]", "");
|
||||
// Now obtain the value for the fully resolved key...
|
||||
string propVal = config[lookup];
|
||||
if (propVal == null)
|
||||
{
|
||||
int separatorIndex = placeholder.IndexOf(SEPARATOR);
|
||||
if (separatorIndex != -1)
|
||||
{
|
||||
string actualPlaceholder = placeholder.Substring(0, separatorIndex);
|
||||
string defaultValue = placeholder.Substring(separatorIndex + SEPARATOR.Length);
|
||||
propVal = config[actualPlaceholder];
|
||||
if (propVal == null)
|
||||
{
|
||||
propVal = defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (propVal != null)
|
||||
{
|
||||
// Recursive invocation, parsing placeholders contained in these
|
||||
// previously resolved placeholder value.
|
||||
propVal = ParseStringValue(propVal, config, visitedPlaceHolders);
|
||||
result.Replace(startIndex, endIndex + SUFFIX.Length, propVal);
|
||||
logger?.LogDebug("Resolved placeholder '{0}'" + placeholder);
|
||||
startIndex = result.IndexOf(PREFIX, startIndex + propVal.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Proceed with unprocessed value.
|
||||
startIndex = result.IndexOf(PREFIX, endIndex + PREFIX.Length);
|
||||
}
|
||||
visitedPlaceHolders.Remove(originalPlaceholder);
|
||||
}
|
||||
else
|
||||
{
|
||||
startIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
|
||||
private static int FindEndIndex(StringBuilder property, int startIndex)
|
||||
{
|
||||
int index = startIndex + PREFIX.Length;
|
||||
int withinNestedPlaceholder = 0;
|
||||
while (index < property.Length)
|
||||
{
|
||||
|
||||
if (SubstringMatch(property, index, SUFFIX))
|
||||
{
|
||||
if (withinNestedPlaceholder > 0)
|
||||
{
|
||||
withinNestedPlaceholder--;
|
||||
index = index + SUFFIX.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
else if (SubstringMatch(property, index, PREFIX))
|
||||
{
|
||||
withinNestedPlaceholder++;
|
||||
index = index + PREFIX.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
private static bool SubstringMatch(StringBuilder str, int index, string substring)
|
||||
{
|
||||
for (int j = 0; j < substring.Length; j++)
|
||||
{
|
||||
int i = index + j;
|
||||
if (i >= str.Length || str[i] != substring[j])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Replace(this StringBuilder builder, int start, int end, string str)
|
||||
{
|
||||
builder.Remove(start, end - start);
|
||||
builder.Insert(start, str);
|
||||
}
|
||||
private static int IndexOf(this StringBuilder builder, string str, int start)
|
||||
{
|
||||
if (start >= builder.Length)
|
||||
return -1;
|
||||
return builder.ToString().IndexOf(str, start);
|
||||
}
|
||||
private static string Substring(this StringBuilder builder, int start, int end)
|
||||
{
|
||||
return builder.ToString().Substring(start, end - start);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Steeltoe.Common
|
||||
{
|
||||
public static class Platform
|
||||
{
|
||||
public const string NET_FRAMEWORK = ".NET Framework";
|
||||
public const string NET_CORE = ".NET Core";
|
||||
|
||||
|
||||
public static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(NET_FRAMEWORK);
|
||||
public static bool IsNetCore => RuntimeInformation.FrameworkDescription.StartsWith(NET_CORE);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>Steeltoe Common Library</Description>
|
||||
<VersionPrefix>$(SteeltoeVersion)</VersionPrefix>
|
||||
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
|
||||
<Authors>Pivotal;dtillman</Authors>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AssemblyName>Steeltoe.Common</AssemblyName>
|
||||
<PackageId>Steeltoe.Common</PackageId>
|
||||
<PackageTags>NET Core;NET Framework</PackageTags>
|
||||
<PackageIconUrl>http://steeltoe.io/images/transparent.png</PackageIconUrl>
|
||||
<PackageProjectUrl>http://steeltoe.io</PackageProjectUrl>
|
||||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="$(AspNetCoreVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Autofac;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.Common.Configuration.Autofac.Test
|
||||
{
|
||||
public class ConfigurationContainerBuilderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RegisterConfiguration_ThrowsNulls()
|
||||
{
|
||||
ContainerBuilder container = null;
|
||||
Assert.Throws<ArgumentNullException>(() => container.RegisterConfiguration(null));
|
||||
ContainerBuilder container2 = new ContainerBuilder();
|
||||
Assert.Throws<ArgumentNullException>(() => container2.RegisterConfiguration(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RegisterConfiguration_Registers()
|
||||
{
|
||||
ContainerBuilder container = new ContainerBuilder();
|
||||
IConfiguration config = new ConfigurationBuilder().Build();
|
||||
container.RegisterConfiguration(config);
|
||||
|
||||
var built = container.Build();
|
||||
Assert.True(built.IsRegistered<IConfigurationRoot>());
|
||||
Assert.True(built.IsRegistered<IConfiguration>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Autofac;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.Common.Options.Autofac.Test
|
||||
{
|
||||
public class OptionsContainerBuilderExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void RegisterOptions_ThrowsNulls()
|
||||
{
|
||||
ContainerBuilder container = null;
|
||||
Assert.Throws<ArgumentNullException>(() => container.RegisterOptions());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RegisterOption_ThrowsNulls()
|
||||
{
|
||||
ContainerBuilder container = null;
|
||||
Assert.Throws<ArgumentNullException>(() => container.RegisterOption<MyOption>(null));
|
||||
ContainerBuilder container2 = new ContainerBuilder();
|
||||
Assert.Throws<ArgumentNullException>(() => container2.RegisterOption<MyOption>(null));
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RegisterOption_Registers_AndBindsConfiguration()
|
||||
{
|
||||
ContainerBuilder container = new ContainerBuilder();
|
||||
var dict = new Dictionary<string, string>()
|
||||
{
|
||||
{ "f1", "foobar" }
|
||||
};
|
||||
|
||||
IConfiguration config = new ConfigurationBuilder().AddInMemoryCollection(dict).Build();
|
||||
container.RegisterOptions();
|
||||
|
||||
container.RegisterOption<MyOption>(config);
|
||||
var built = container.Build();
|
||||
|
||||
var service = built.Resolve<IOptions<MyOption>>();
|
||||
Assert.NotNull(service);
|
||||
Assert.NotNull(service.Value);
|
||||
Assert.Equal("foobar", service.Value.f1);
|
||||
}
|
||||
|
||||
class MyOption
|
||||
{
|
||||
public string f1 { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Steeltoe.Common.Autofac\Steeltoe.Common.Autofac.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitStudioVersion)" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="$(XunitVersion)" />
|
||||
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"maxParallelThreads": 1,
|
||||
"parallelizeTestCollections": false
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.Common.Http.Test
|
||||
{
|
||||
public class HttpClientHelperTest
|
||||
{
|
||||
[Fact]
|
||||
public void GetHttpClient_SetsTimeout()
|
||||
{
|
||||
var client = HttpClientHelper.GetHttpClient(false, 100);
|
||||
Assert.Equal(100, client.Timeout.TotalMilliseconds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConfigureCertificateValidatation_ValidateFalse()
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
|
||||
ServicePointManager.ServerCertificateValidationCallback = null;
|
||||
|
||||
RemoteCertificateValidationCallback prevValidator;
|
||||
SecurityProtocolType protocolType;
|
||||
|
||||
HttpClientHelper.ConfigureCertificateValidatation(false, out protocolType, out prevValidator);
|
||||
|
||||
if (Platform.IsNetCore)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls, ServicePointManager.SecurityProtocol);
|
||||
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls12, ServicePointManager.SecurityProtocol);
|
||||
Assert.NotNull(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConfigureCertificateValidatation_ValidateTrue()
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
|
||||
ServicePointManager.ServerCertificateValidationCallback = null;
|
||||
|
||||
RemoteCertificateValidationCallback prevValidator;
|
||||
SecurityProtocolType protocolType;
|
||||
|
||||
HttpClientHelper.ConfigureCertificateValidatation(false, out protocolType, out prevValidator);
|
||||
|
||||
if (Platform.IsNetCore)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls, ServicePointManager.SecurityProtocol);
|
||||
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls, ServicePointManager.SecurityProtocol);
|
||||
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void RestoreCertificateValidation_ValidateFalse()
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
||||
|
||||
RemoteCertificateValidationCallback prevValidator = null;
|
||||
SecurityProtocolType protocolType = SecurityProtocolType.Tls;
|
||||
|
||||
HttpClientHelper.RestoreCertificateValidation(false, protocolType, prevValidator);
|
||||
|
||||
if (Platform.IsNetCore)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls12, ServicePointManager.SecurityProtocol);
|
||||
Assert.NotNull(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls, ServicePointManager.SecurityProtocol);
|
||||
Assert.Null(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RestoreCertificateValidation_ValidateTrue()
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true;
|
||||
|
||||
RemoteCertificateValidationCallback prevValidator = null;
|
||||
SecurityProtocolType protocolType = SecurityProtocolType.Tls;
|
||||
|
||||
HttpClientHelper.RestoreCertificateValidation(false, protocolType, prevValidator);
|
||||
|
||||
if (Platform.IsNetCore)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls12, ServicePointManager.SecurityProtocol);
|
||||
Assert.NotNull(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
|
||||
if (Platform.IsFullFramework)
|
||||
{
|
||||
Assert.Equal(SecurityProtocolType.Tls12, ServicePointManager.SecurityProtocol);
|
||||
Assert.NotNull(ServicePointManager.ServerCertificateValidationCallback);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetEncodedUserPassword_Nulls()
|
||||
{
|
||||
string result = HttpClientHelper.GetEncodedUserPassword(null, null);
|
||||
Assert.Equal(Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Empty + ":" + string.Empty)), result);
|
||||
|
||||
string result2 = HttpClientHelper.GetEncodedUserPassword("foo", null);
|
||||
Assert.Equal(Convert.ToBase64String(Encoding.ASCII.GetBytes("foo" + ":" + string.Empty)), result2);
|
||||
|
||||
string result3 = HttpClientHelper.GetEncodedUserPassword(null, "bar");
|
||||
Assert.Equal(Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Empty + ":" + "bar")), result3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetEncodedUserPassword_NotNulls()
|
||||
{
|
||||
string result = HttpClientHelper.GetEncodedUserPassword("foo", "bar");
|
||||
Assert.Equal(Convert.ToBase64String(Encoding.ASCII.GetBytes("foo" + ":" + "bar")), result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetRequestMessage_ThrowsNulls()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => HttpClientHelper.GetRequestMessage(null, null, null, null));
|
||||
Assert.Throws<ArgumentNullException>(() => HttpClientHelper.GetRequestMessage(HttpMethod.Get, null, null, null));
|
||||
}
|
||||
[Fact]
|
||||
public void GetRequestMessage_CreatesCorrectMessage()
|
||||
{
|
||||
var message = HttpClientHelper.GetRequestMessage(HttpMethod.Put, "http://localhost/foobar", null, null);
|
||||
Assert.NotNull(message);
|
||||
Assert.Equal(HttpMethod.Put, message.Method);
|
||||
Assert.Equal("http://localhost/foobar", message.RequestUri.ToString());
|
||||
Assert.Null(message.Headers.Authorization);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetRequestMessage_CreatesCorrectMessage_WithBasicAuth()
|
||||
{
|
||||
var message = HttpClientHelper.GetRequestMessage(HttpMethod.Put, "http://localhost/foobar", "foo", "bar");
|
||||
Assert.NotNull(message);
|
||||
Assert.Equal(HttpMethod.Put, message.Method);
|
||||
Assert.Equal("http://localhost/foobar", message.RequestUri.ToString());
|
||||
Assert.NotNull(message.Headers.Authorization);
|
||||
var bytes = Convert.ToBase64String(Encoding.ASCII.GetBytes("foo" + ":" + "bar"));
|
||||
Assert.Equal("Basic", message.Headers.Authorization.Scheme);
|
||||
Assert.Equal(bytes, message.Headers.Authorization.Parameter);
|
||||
}
|
||||
}
|
||||
//public static void RestoreCertificateValidation(bool validateCertificates, SecurityProtocolType protocolType, RemoteCertificateValidationCallback prevValidator)
|
||||
//{
|
||||
//}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.Common.Http.Test
|
||||
{
|
||||
public class SerializationHelperTest
|
||||
{
|
||||
[Fact]
|
||||
public void Deserialize_ThrowsNulls()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => SerializationHelper.Deserialize<Test>(null, null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_ReturnsNullOnException()
|
||||
{
|
||||
MemoryStream s = new MemoryStream();
|
||||
var result = SerializationHelper.Deserialize<Test>(s);
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_ReturnsValid()
|
||||
{
|
||||
var memStream = new MemoryStream();
|
||||
var textWriter = new StreamWriter(memStream);
|
||||
textWriter.Write("{\"f1\":100,\"f2\":200}");
|
||||
textWriter.Flush();
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
var result = SerializationHelper.Deserialize<Test>(memStream);
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(100, result.f1);
|
||||
Assert.Equal(200, result.f2);
|
||||
}
|
||||
class Test
|
||||
{
|
||||
public int f1=0;
|
||||
public long f2=0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Steeltoe.Common.Http\Steeltoe.Common.Http.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitStudioVersion)" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="$(XunitVersion)" />
|
||||
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"maxParallelThreads": 1,
|
||||
"parallelizeTestCollections": false
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
//
|
||||
// Copyright 2017 the original author or authors.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
namespace Steeltoe.Common.Configuration.Test
|
||||
{
|
||||
public class PropertyPlaceholderHelperTest
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_ResolvesSinglePlaceholder()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
string text = "foo=${foo}";
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
var dic1 = new Dictionary<string, string>()
|
||||
{
|
||||
{"foo", "bar"}
|
||||
};
|
||||
builder.AddInMemoryCollection(dic1);
|
||||
var config = builder.Build();
|
||||
|
||||
// Act and Assert
|
||||
string result = PropertyPlaceholderHelper.ResolvePlaceholders(text, config);
|
||||
Assert.Equal("foo=bar", result);
|
||||
}
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_ResolvesMultiplePlaceholders()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
string text = "foo=${foo},bar=${bar}";
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
var dic1 = new Dictionary<string, string>()
|
||||
{
|
||||
{"foo", "bar"},
|
||||
{"bar", "baz" }
|
||||
|
||||
};
|
||||
builder.AddInMemoryCollection(dic1);
|
||||
var config = builder.Build();
|
||||
|
||||
// Act and Assert
|
||||
string result = PropertyPlaceholderHelper.ResolvePlaceholders(text, config);
|
||||
Assert.Equal("foo=bar,bar=baz", result);
|
||||
}
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_ResolvesMultipleRecursivePlaceholders()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
string text = "foo=${bar}";
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
var dic1 = new Dictionary<string, string>()
|
||||
{
|
||||
{"bar", "${baz}"},
|
||||
{"baz", "bar"}
|
||||
|
||||
};
|
||||
builder.AddInMemoryCollection(dic1);
|
||||
var config = builder.Build();
|
||||
|
||||
// Act and Assert
|
||||
string result = PropertyPlaceholderHelper.ResolvePlaceholders(text, config);
|
||||
Assert.Equal("foo=bar", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_ResolvesMultipleRecursiveInPlaceholders()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
string text1 = "foo=${b${inner}}";
|
||||
ConfigurationBuilder builder1 = new ConfigurationBuilder();
|
||||
var dic1 = new Dictionary<string, string>()
|
||||
{
|
||||
{"bar", "bar"},
|
||||
{"inner", "ar"}
|
||||
|
||||
};
|
||||
builder1.AddInMemoryCollection(dic1);
|
||||
var config1 = builder1.Build();
|
||||
|
||||
string text2 = "${top}";
|
||||
ConfigurationBuilder builder2 = new ConfigurationBuilder();
|
||||
var dic2 = new Dictionary<string, string>()
|
||||
{
|
||||
{"top", "${child}+${child}"},
|
||||
{"child", "${${differentiator}.grandchild}" },
|
||||
{"differentiator", "first" },
|
||||
{"first.grandchild", "actualValue" }
|
||||
};
|
||||
builder2.AddInMemoryCollection(dic2);
|
||||
var config2 = builder2.Build();
|
||||
|
||||
|
||||
// Act and Assert
|
||||
string result1 = PropertyPlaceholderHelper.ResolvePlaceholders(text1, config1);
|
||||
Assert.Equal("foo=bar", result1);
|
||||
string result2 = PropertyPlaceholderHelper.ResolvePlaceholders(text2, config2);
|
||||
Assert.Equal("actualValue+actualValue", result2);
|
||||
|
||||
}
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_UnresolvedPlaceholderIsIgnored()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
string text = "foo=${foo},bar=${bar}";
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
var dic1 = new Dictionary<string, string>()
|
||||
{
|
||||
{"foo", "bar"}
|
||||
|
||||
};
|
||||
builder.AddInMemoryCollection(dic1);
|
||||
var config = builder.Build();
|
||||
|
||||
// Act and Assert
|
||||
string result = PropertyPlaceholderHelper.ResolvePlaceholders(text, config);
|
||||
Assert.Equal("foo=bar,bar=${bar}", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolvePlaceholders_ResolvesArrayRefPlaceholder()
|
||||
{
|
||||
|
||||
// Arrange
|
||||
var json1 = @"
|
||||
{
|
||||
'vcap': {
|
||||
'application': {
|
||||
'application_id': 'fa05c1a9-0fc1-4fbd-bae1-139850dec7a3',
|
||||
'application_name': 'my-app',
|
||||
'application_uris': [
|
||||
'my-app.10.244.0.34.xip.io'
|
||||
],
|
||||
'application_version': 'fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca',
|
||||
'limits': {
|
||||
'disk': 1024,
|
||||
'fds': 16384,
|
||||
'mem': 256
|
||||
},
|
||||
'name': 'my-app',
|
||||
'space_id': '06450c72-4669-4dc6-8096-45f9777db68a',
|
||||
'space_name': 'my-space',
|
||||
'uris': [
|
||||
'my-app.10.244.0.34.xip.io',
|
||||
'my-app2.10.244.0.34.xip.io'
|
||||
],
|
||||
'users': null,
|
||||
'version': 'fb8fbcc6-8d58-479e-bcc7-3b4ce5a7f0ca'
|
||||
}
|
||||
}
|
||||
}";
|
||||
var path = CreateTempFile(json1);
|
||||
string directory = Path.GetDirectoryName(path);
|
||||
string fileName = Path.GetFileName(path);
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
builder.SetBasePath(directory);
|
||||
|
||||
builder.AddJsonFile(fileName);
|
||||
var config = builder.Build();
|
||||
|
||||
string text = "foo=${vcap:application:uris[1]}";
|
||||
|
||||
// Act and Assert
|
||||
string result = PropertyPlaceholderHelper.ResolvePlaceholders(text, config);
|
||||
Assert.Equal("foo=my-app2.10.244.0.34.xip.io", result);
|
||||
}
|
||||
|
||||
static string CreateTempFile(string contents)
|
||||
{
|
||||
var tempFile = Path.GetTempFileName();
|
||||
File.WriteAllText(tempFile, contents);
|
||||
return tempFile;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\versions.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Steeltoe.Common\Steeltoe.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(AspNetCoreTestVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitStudioVersion)" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="$(XunitVersion)" />
|
||||
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"maxParallelThreads": 1,
|
||||
"parallelizeTestCollections": false
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<Project>
|
||||
<Import Project="config\versions-dev.props" />
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче