Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
**使用Nuget安装**

```PM
Install-Package CatLib.Core -Version 1.2.3
Install-Package CatLib.Core -Version 1.2.4
```

**直接下载发布版本**
Expand Down
1 change: 1 addition & 0 deletions src/CatLib.Core.NetStandard/CatLib.Core.NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<Compile Include="..\CatLib.Core\Support\Container\IGivenData.cs" Link="Support\Container\IGivenData.cs" />
<Compile Include="..\CatLib.Core\Support\Container\IMethodBind.cs" Link="Support\Container\IMethodBind.cs" />
<Compile Include="..\CatLib.Core\Support\Container\InjectAttribute.cs" Link="Support\Container\InjectAttribute.cs" />
<Compile Include="..\CatLib.Core\Support\Container\IParams.cs" Link="Support\Container\IParams.cs" />
<Compile Include="..\CatLib.Core\Support\Container\IVariant.cs" Link="Support\Container\IVariant.cs" />
<Compile Include="..\CatLib.Core\Support\Container\MethodBind.cs" Link="Support\Container\MethodBind.cs" />
<Compile Include="..\CatLib.Core\Support\Container\MethodContainer.cs" Link="Support\Container\MethodContainer.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/CatLib.Core.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CatLib")]
[assembly: AssemblyProduct("CatLib.Core.Tests")]
[assembly: AssemblyCopyright("Copyright © CatLib 2017")]
[assembly: AssemblyCopyright("Copyright © CatLib 2017-2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("3c9f4024-910c-4881-a04d-34a6c3a09019")]

[assembly: AssemblyVersion("1.2.3.0")]
[assembly: AssemblyFileVersion("1.2.3.0")]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]
1 change: 1 addition & 0 deletions src/CatLib.Core/CatLib.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="Support\Container\BindDataExtend.cs" />
<Compile Include="Support\Container\IBindable.cs" />
<Compile Include="Support\Container\IMethodBind.cs" />
<Compile Include="Support\Container\IParams.cs" />
<Compile Include="Support\Container\IVariant.cs" />
<Compile Include="Support\Container\MethodBind.cs" />
<Compile Include="Support\Container\MethodContainer.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/CatLib.Core/CatLib/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ public static string Type2Service(Type type)
{
return Handler.Type2Service(type);
}
#endregion
#endregion

#region Container Extend API
#region Container Extend API
/// <summary>
/// 获取服务的绑定数据,如果绑定不存在则返回null
/// </summary>
Expand Down Expand Up @@ -1269,6 +1269,6 @@ public static string Type2Service<TService>()
{
return Handler.Type2Service<TService>();
}
#endregion
#endregion
}
}
2 changes: 1 addition & 1 deletion src/CatLib.Core/CatLib/Facade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static void Rebind(IBindData newBinder)
/// <returns>服务实例</returns>
private static TService Build(params object[] userParams)
{
return (TService) App.Make(service, userParams);
return (TService)App.Make(service, userParams);
}
}
}
6 changes: 3 additions & 3 deletions src/CatLib.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("CatLib")]
[assembly: AssemblyProduct("CatLib.Core")]
[assembly: AssemblyCopyright("Copyright © CatLib 2017")]
[assembly: AssemblyCopyright("Copyright © CatLib 2017-2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("4204658e-81fd-4106-a347-890cd369c8a4")]

[assembly: AssemblyVersion("1.2.3.0")]
[assembly: AssemblyFileVersion("1.2.3.0")]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]

[assembly: InternalsVisibleTo("Assembly-CSharp-Editor"),
InternalsVisibleTo("Assembly-CSharp-Editor-firstpass"),
Expand Down
16 changes: 8 additions & 8 deletions src/CatLib.Core/Support/Container/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ protected virtual object GetCompactInjectUserParams(ParameterInfo baseParam, ref
}

/// <summary>
/// 获取参数(<see cref="Params"/>)匹配器
/// 获取参数(<see cref="IParams"/>)匹配器
/// <para>开发者重写后可以实现自己的匹配器</para>
/// <para>如果调用获取到的匹配器后返回结果为null则表示没有匹配到参数</para>
/// </summary>
Expand Down Expand Up @@ -1733,27 +1733,27 @@ private BindData GetBindFillable(string service)
}

/// <summary>
/// 从<paramref name="userParams"/>中获取<see cref="Params"/>类型的变量
/// 从<paramref name="userParams"/>中获取<see cref="IParams"/>类型的变量
/// </summary>
/// <param name="userParams">用户传入参数</param>
/// <returns>获取到的参数</returns>
private Params[] GetParamsTypeInUserParams(ref object[] userParams)
private IParams[] GetParamsTypeInUserParams(ref object[] userParams)
{
var elements = Arr.Remove(ref userParams, value => value is Params);
var results = new Params[elements.Length];
var elements = Arr.Remove(ref userParams, value => value is IParams);
var results = new IParams[elements.Length];
for (var i = 0; i < elements.Length; i++)
{
results[i] = (Params)elements[i];
results[i] = (IParams)elements[i];
}
return results;
}

/// <summary>
/// 生成一个默认的参数<see cref="Params" />匹配器
/// 生成一个默认的参数<see cref="IParams" />匹配器
/// </summary>
/// <param name="tables">参数表</param>
/// <returns>匹配器</returns>
private Func<ParameterInfo, object> MakeParamsMatcher(Params[] tables)
private Func<ParameterInfo, object> MakeParamsMatcher(IParams[] tables)
{
// 默认匹配器策略将会将参数名和参数表的参数名进行匹配
// 最先匹配到的有效参数值将作为返回值返回
Expand Down
27 changes: 27 additions & 0 deletions src/CatLib.Core/Support/Container/IParams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* This file is part of the CatLib package.
*
* (c) Yu Bin <support@catlib.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Document: http://catlib.io/
*/

namespace CatLib
{
/// <summary>
/// 参数名注入表
/// </summary>
public interface IParams
{
/// <summary>
/// 获取一个参数
/// </summary>
/// <param name="key">参数名</param>
/// <param name="value">参数值</param>
/// <returns>是否成功获取</returns>
bool TryGetValue(string key, out object value);
}
}
25 changes: 21 additions & 4 deletions src/CatLib.Core/Support/Container/Params.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace CatLib
/// 参数名注入表
/// </summary>
[ExcludeFromCodeCoverage]
public sealed class Params : IEnumerable<KeyValuePair<string, object>>
public sealed class Params : IParams, IEnumerable<KeyValuePair<string, object>>
{
/// <summary>
/// 参数表
/// </summary>
private readonly Dictionary<string, object> table = new Dictionary<string, object>();
private readonly IDictionary<string, object> table;

/// <summary>
/// 迭代器
Expand All @@ -34,14 +34,31 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
}

/// <summary>
///
/// 迭代器
/// </summary>
/// <returns></returns>
/// <returns>迭代器</returns>
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
{
return table.GetEnumerator();
}

/// <summary>
/// 参数名注入表
/// </summary>
public Params()
{
table = new Dictionary<string, object>();
}

/// <summary>
/// 参数名注入表
/// </summary>
/// <param name="args">参数表</param>
public Params(IDictionary<string, object> args)
{
table = args;
}

/// <summary>
/// 获取或者设定一个参数
/// </summary>
Expand Down