Skip to content

Commit

Permalink
Upgrade to latest components
Browse files Browse the repository at this point in the history
  • Loading branch information
quynh-ng committed Sep 9, 2020
1 parent c7c18b3 commit 685bcc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Enyim.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.7" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.8" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.5" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
Expand Down
12 changes: 7 additions & 5 deletions Enyim.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Reflection;
using System.Runtime.Loader;
using System.Collections.Generic;

using System.Collections.Concurrent;
using Microsoft.Extensions.DependencyModel;
using Microsoft.Extensions.DependencyModel.Resolution;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -410,9 +410,9 @@ public AssemblyLoader(string assemblyPath)
/// <param name="typeName">The type name (full class name)</param>
/// <returns></returns>
public static Type GetType(string assemblyFilePath, string typeName)
=> string.IsNullOrWhiteSpace(assemblyFilePath) || string.IsNullOrWhiteSpace(typeName) || !File.Exists(assemblyFilePath)
? null
: new AssemblyLoader(assemblyFilePath).Assembly.GetExportedTypes().FirstOrDefault(type => typeName.Equals(type.ToString()));
=> !string.IsNullOrWhiteSpace(assemblyFilePath) && !string.IsNullOrWhiteSpace(typeName) && File.Exists(assemblyFilePath)
? new AssemblyLoader(assemblyFilePath).Assembly.GetExportedTypes().FirstOrDefault(type => typeName.Equals(type.ToString()))
: null;

/// <summary>
/// Gets the type by the specified type name (full class name with assembly)
Expand All @@ -423,12 +423,14 @@ public static Type GetType(string typeNameWithAssembly)
{
if (string.IsNullOrWhiteSpace(typeNameWithAssembly) || typeNameWithAssembly.IndexOf(",") < 0)
return null;

var type = Type.GetType(typeNameWithAssembly);
if (type == null)
{
var info = typeNameWithAssembly.Trim().Split(',').Select(data => data.Trim()).ToList();
type = AssemblyLoader.GetType(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{info[1]}{(info[1].EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ? "" : ".dll")}"), info[0]);
}

return type;
}
}
Expand All @@ -441,7 +443,7 @@ public static Type GetType(string typeNameWithAssembly)
/// </summary>
public static class FastActivator
{
static Dictionary<Type, Func<object>> Factories { get; } = new Dictionary<Type, Func<object>>();
static ConcurrentDictionary<Type, Func<object>> Factories { get; } = new ConcurrentDictionary<Type, Func<object>>();

/// <summary>
/// Creates an instance of the specified type using a generated factory to avoid using Reflection.
Expand Down

0 comments on commit 685bcc5

Please sign in to comment.