-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jieqiang
authored and
jieqiang
committed
Dec 23, 2017
1 parent
fbf3a74
commit 566cd8a
Showing
1,876 changed files
with
1,672,176 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Empty file.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp | ||
{ | ||
public class Addition : IAlgorithmStrategy | ||
{ | ||
public int Num1; | ||
public int Num2; | ||
public void Calculation(int a, int b) | ||
{ | ||
Console.WriteLine("计算结果:"+(a+b)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.Algorithm | ||
{ | ||
public class GenericsFactory<T> : IGenericsFactory<T> where T : IAlgorithmStrategy | ||
{ | ||
protected Dictionary<string, Type> Strategys; | ||
protected Func<Type, T> Creator; | ||
public void InitStrategy() | ||
{ | ||
if (Strategys == null) { | ||
|
||
} | ||
} | ||
public void CreatorSetting(Func<Type, T> creator) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public T GetStrategy(string name) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public List<T> GetStrategyList() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Type GetStrategyType() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Register(Type type) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
public static class CommonHelp | ||
{ | ||
|
||
|
||
/// <summary> | ||
/// 去重 | ||
/// </summary> | ||
/// <typeparam name="TSource"></typeparam> | ||
/// <typeparam name="Tkey"></typeparam> | ||
/// <param name="source"></param> | ||
/// <param name="selector"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> selector) | ||
{ | ||
HashSet<TKey> seenKeys = new HashSet<TKey>(); | ||
foreach (TSource element in source) | ||
{ | ||
if (seenKeys.Add(selector(element))) | ||
{ | ||
yield return element; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.Algorithm | ||
{ | ||
public interface IGenericsFactory<T>where T:IAlgorithmStrategy | ||
{ | ||
/// <summary> | ||
/// 可以通过外部配置 | ||
/// </summary> | ||
/// <param name="creator"></param> | ||
void CreatorSetting(Func<Type, T> creator); | ||
|
||
void Register(Type type); | ||
/// <summary> | ||
/// 根据名称获取 | ||
/// </summary> | ||
/// <param name="name"></param> | ||
/// <returns></returns> | ||
T GetStrategy(string name); | ||
|
||
List<T> GetStrategyList(); | ||
|
||
Type GetStrategyType(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ConsoleApp | ||
{ | ||
public interface IAlgorithmStrategy | ||
{ | ||
void Calculation(int a,int b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.Algorithm | ||
{ | ||
public class Multiplication | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp | ||
{ | ||
public class StrategyContext | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp | ||
{ | ||
public class Subtraction : IAlgorithmStrategy | ||
{ | ||
public void Calculation(int a, int b) | ||
{ | ||
Console.WriteLine("计算结果为:"+(a-b)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9EFED439-767F-4F0F-9D09-9EF025B13C7C}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>ConsoleApp</RootNamespace> | ||
<AssemblyName>ConsoleApp</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Algorithm\Addition.cs" /> | ||
<Compile Include="Algorithm\GenericsFactory.cs" /> | ||
<Compile Include="Algorithm\IGenericsFactory.cs" /> | ||
<Compile Include="Algorithm\Multiplication.cs" /> | ||
<Compile Include="HanDuck\Duck.cs" /> | ||
<Compile Include="HanDuck\FlyBehavior.cs" /> | ||
<Compile Include="HanDuck\IFlyBehavior.cs" /> | ||
<Compile Include="HanDuck\IQuackbehavior.cs" /> | ||
<Compile Include="HanDuck\ISweepingBehavior.cs" /> | ||
<Compile Include="HanDuck\QuackBehavior.cs" /> | ||
<Compile Include="HanDuck\RubberDuck.cs" /> | ||
<Compile Include="HanDuck\SweepingBehavior.cs" /> | ||
<Compile Include="HanDuck\WoodDuck.cs" /> | ||
<Compile Include="Algorithm\IAlgorithmStrategy.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Algorithm\StrategyContext.cs" /> | ||
<Compile Include="Algorithm\Subtraction.cs" /> | ||
<Compile Include="Reflection\AssemblyFinder.cs" /> | ||
<Compile Include="Reflection\TypeFinder.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public abstract class Duck | ||
{ | ||
public IFlyBehavior FlyBehavior { get; set; } | ||
public IQuackbehavior Quackbehavior { get; set; } | ||
public ISweepingBehavior SweepingBehavior { get; set; } | ||
|
||
public abstract void Display(); | ||
public void PerformFly() | ||
{ | ||
FlyBehavior.Fly(); | ||
} | ||
public void PerformQuack() | ||
{ | ||
Quackbehavior.Quack(); | ||
} | ||
public void PerformSweeping() | ||
{ | ||
SweepingBehavior.Swimming(); | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public class FlyBehavior : IFlyBehavior | ||
{ | ||
public void Fly() | ||
{ | ||
Console.WriteLine("WO 快要飞起来了"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public interface IFlyBehavior | ||
{ | ||
void Fly(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public interface IQuackbehavior | ||
{ | ||
void Quack(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public interface ISweepingBehavior | ||
{ | ||
void Swimming(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ConsoleApp.HanDuck | ||
{ | ||
public class QuackBehavior : IQuackbehavior | ||
{ | ||
public void Quack() | ||
{ | ||
Console.WriteLine("呱呱,呱呱 ,呱呱呱。。。"); ; | ||
} | ||
} | ||
} |
Oops, something went wrong.