-
Notifications
You must be signed in to change notification settings - Fork 219
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
Showing
12 changed files
with
235 additions
and
13 deletions.
There are no files selected for viewing
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
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
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Natasha.CSharp\Component\Core\Natasha.CSharp.Compiler.Domain\Natasha.CSharp.Compiler.Domain.csproj" /> | ||
<ProjectReference Include="..\..\src\Natasha.CSharp\Extension\Natasha.CSharp.Extension.MethodCreator\Natasha.CSharp.Extension.MethodCreator.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,17 @@ | ||
namespace ExtensionSample | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
NatashaManagement.RegistDomainCreator<NatashaDomainCreator>(); | ||
|
||
var func = "return arg1+arg2;" | ||
.WithAssemblyBuilder(opt=>opt.AddReferenceAndUsingCode<object>()) | ||
.ToFunc<int, int, int>(); | ||
|
||
Console.WriteLine(func(1,2)); | ||
Console.ReadKey(); | ||
} | ||
} | ||
} |
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
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
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
110 changes: 110 additions & 0 deletions
110
...atasha.CSharp/Extension/Natasha.CSharp.Extension.MethodCreator/SystemDelegateExtension.cs
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,110 @@ | ||
| ||
namespace System | ||
{ | ||
public static class SystemDelegateExtension | ||
{ | ||
#region Action Delegate | ||
public static Action<T1>? ToAction<T1>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1>>(); | ||
} | ||
public static Action<T1, T2>? ToAction<T1, T2>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2>>(); | ||
} | ||
public static Action<T1, T2, T3>? ToAction<T1, T2, T3>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3>>(); | ||
} | ||
public static Action<T1, T2, T3, T4>? ToAction<T1, T2, T3, T4>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5>? ToAction<T1, T2, T3, T4, T5>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6>? ToAction<T1, T2, T3, T4, T5, T6>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7>? ToAction<T1, T2, T3, T4, T5, T6, T7>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8>? ToAction<T1, T2, T3, T4, T5, T6, T7, T8>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>? ToAction<T1, T2, T3, T4, T5, T6, T7, T8, T9>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>? ToAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>? ToAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>? ToAction<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); | ||
} | ||
#endregion | ||
|
||
|
||
#region Func Delegate | ||
public static Func<T1>? ToFunc<T1>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1>>(); | ||
} | ||
public static Func<T1, T2>? ToFunc<T1, T2>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2>>(); | ||
} | ||
public static Func<T1, T2, T3>? ToFunc<T1, T2, T3>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3>>(); | ||
} | ||
public static Func<T1, T2, T3, T4>? ToFunc<T1, T2, T3, T4>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5>? ToFunc<T1, T2, T3, T4, T5>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6>? ToFunc<T1, T2, T3, T4, T5, T6>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7>? ToFunc<T1, T2, T3, T4, T5, T6, T7>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8>? ToFunc<T1, T2, T3, T4, T5, T6, T7, T8>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7, T8>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>? ToFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>? ToFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>? ToFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>>(); | ||
} | ||
public static Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>? ToFunc<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(in this (string script, AssemblyCSharpBuilder builder) buildInfo) | ||
{ | ||
return buildInfo.CreateMethod<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>>(); | ||
} | ||
#endregion | ||
|
||
} | ||
} |
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
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
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
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