Skip to content

Commit

Permalink
Merge pull request #143 from SeriaWei/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SeriaWei authored Feb 5, 2018
2 parents 574a5eb + 167f72c commit 326168d
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /build/src/ZKEACMS.WebHost
RUN dotnet publish-zkeacms

# Build runtime image
FROM microsoft/aspnetcore:2.0.3
FROM microsoft/aspnetcore:latest
WORKDIR /zkeacms
COPY --from=builder /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput .
EXPOSE 80
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.MySql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN dotnet publish-zkeacms
RUN cp -f /build/DataBase/MySql/appsettings.json /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput/appsettings.json

# Build runtime image
FROM microsoft/aspnetcore:2.0.3
FROM microsoft/aspnetcore:latest
WORKDIR /zkeacms
COPY --from=builder /build/src/ZKEACMS.WebHost/bin/Release/PublishOutput .
EXPOSE 80
Expand Down
Binary file modified ZKEACMS.Standard.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion ZKEACMS.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
VisualStudioVersion = 15.0.27130.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{43CF214F-8C1A-4433-824E-CBD46BA7223E}"
EndProject
Expand Down
3 changes: 2 additions & 1 deletion src/EasyFrameWork/Constant/DataEnumerate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum ActionType
Design = 4,
Publish = 5,
Unattached = 6,
Continue = 7
Continue = 7,
UnAttach = 8
}
public enum UserType
{
Expand Down
6 changes: 3 additions & 3 deletions src/EasyFrameWork/EasyFrameWork.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="2.7.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.1" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.8.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.1" />
Expand All @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.4.1" />
<PackageReference Include="System.Reflection.Extensions" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
Expand Down
79 changes: 38 additions & 41 deletions src/EasyFrameWork/Mvc/Plugin/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@

namespace Easy.Mvc.Plugin
{
public class AssemblyLoader : AssemblyLoadContext
public class AssemblyLoader
{
private const string ControllerTypeNameSuffix = "Controller";
private static bool Resolving { get; set; }
public AssemblyLoader()
{
DependencyAssemblies = new List<Assembly>();
}

public IServiceProvider ServiceProvider { get; set; }
private Assembly CurrentAssembly;
private List<Assembly> DependencyAssemblies = new List<Assembly>();
public Assembly CurrentAssembly { get; private set; }
public List<Assembly> DependencyAssemblies { get; private set; }
private TypeInfo PluginTypeInfo = typeof(IPluginStartup).GetTypeInfo();
public IEnumerable<Assembly> LoadPlugin(string path)
{
if (CurrentAssembly == null)
{
AssemblyLoadContext.Default.Resolving += Default_Resolving;
var assembly = this.LoadFromAssemblyPath(path);
CurrentAssembly = assembly;
ResolveDenpendency();
RegistAssembly(assembly);
yield return assembly;
//AssemblyLoadContext.Default.Resolving += AssemblyResolving;
CurrentAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(path);
ResolveDenpendency(CurrentAssembly);
RegistAssembly(CurrentAssembly);
yield return CurrentAssembly;
foreach (var item in DependencyAssemblies)
{
yield return item;
Expand All @@ -43,26 +43,43 @@ public IEnumerable<Assembly> LoadPlugin(string path)
else { throw new Exception("A loader just can load one assembly."); }
}

private Assembly Default_Resolving(AssemblyLoadContext arg1, AssemblyName arg2)
{
return Load(arg2);
}
private void ResolveDenpendency()
//private Assembly AssemblyResolving(AssemblyLoadContext arg1, AssemblyName arg2)
//{
// if (arg2.FullName == CurrentAssembly.FullName)
// {
// return CurrentAssembly;
// }
// var deps = DependencyContext.Default;
// if (deps.CompileLibraries.Any(d => d.Name == arg2.Name))
// {
// return Assembly.Load(arg2);
// }

// foreach (var item in DependencyAssemblies)
// {
// if (item.FullName == arg2.FullName)
// {
// return item;
// }
// }
// return null;
//}
private void ResolveDenpendency(Assembly assembly)
{
string currentName = CurrentAssembly.GetName().Name;
var dependencyCompilationLibrary = DependencyContext.Load(CurrentAssembly)
string currentName = assembly.GetName().Name;
var dependencyCompilationLibrary = DependencyContext.Load(assembly)
.CompileLibraries.Where(de => de.Name != currentName && !DependencyContext.Default.CompileLibraries.Any(m => m.Name == de.Name))
.ToList();

dependencyCompilationLibrary.Each(libaray =>
{
bool depLoaded = false;
foreach (var assembly in libaray.Assemblies)
foreach (var item in libaray.Assemblies)
{
var files = new DirectoryInfo(Path.GetDirectoryName(CurrentAssembly.Location)).GetFiles(Path.GetFileName(assembly));
var files = new DirectoryInfo(Path.GetDirectoryName(assembly.Location)).GetFiles(Path.GetFileName(item));
foreach (var file in files)
{
DependencyAssemblies.Add(LoadFromAssemblyPath(file.FullName));
DependencyAssemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(file.FullName));
depLoaded = true;
break;
}
Expand All @@ -73,7 +90,7 @@ private void ResolveDenpendency()
{
if (File.Exists(item))
{
DependencyAssemblies.Add(LoadFromAssemblyPath(item));
DependencyAssemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(item));
break;
}
}
Expand All @@ -82,27 +99,7 @@ private void ResolveDenpendency()


}
protected override Assembly Load(AssemblyName assemblyName)
{
if (assemblyName.FullName == CurrentAssembly.FullName)
{
return CurrentAssembly;
}
var deps = DependencyContext.Default;
if (deps.CompileLibraries.Any(d => d.Name == assemblyName.Name))
{
return Assembly.Load(assemblyName);
}

foreach (var item in DependencyAssemblies)
{
if (item.FullName == assemblyName.FullName)
{
return item;
}
}
return null;
}
private void RegistAssembly(Assembly assembly)
{
List<TypeInfo> controllers = new List<TypeInfo>();
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Article/ZKEACMS.Article.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.FormGenerator/ZKEACMS.FormGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Message/ZKEACMS.Message.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<ItemGroup>
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Product/ZKEACMS.Product.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Redirection/ZKEACMS.Redirection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/ZKEACMS.SectionWidget/ZKEACMS.SectionWidget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.Shop/ZKEACMS.Shop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<PackageReference Include="Alipay.AopSdk.F2FPay.AspnetCore" Version="2.2.4" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/ZKEACMS.Sitemap/ZKEACMS.Sitemap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<ProjectReference Include="..\ZKEACMS\ZKEACMS.csproj" />
</ItemGroup>

Expand Down
22 changes: 15 additions & 7 deletions src/ZKEACMS.WebHost/Views/Shared/EditorTemplates/ListEditor.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@
{
return;
}
var type = ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0];
if (Model.Count == 0 || (Model[0] as Easy.Models.EditorEntity)?.ActionType != ActionType.UnAttach)
{
var unAttach = Activator.CreateInstance(ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0]) as Easy.Models.EditorEntity;
if (unAttach == null)
{
throw new Exception($"{ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0].FullName} 必须继承于 Easy.Models.EditorEntity");
}
unAttach.ActionType = ActionType.UnAttach;
Model.Insert(0, unAttach);
}

}
<div class="input-group-collection container-fluid">
<div class="Template hide">
@Html.Partial("ListEditorItemTemplate", Activator.CreateInstance(type))
@Html.EditorFor(m => m[0], "ListEditorItem")
</div>
<div class="items">
@if (Model != null)
{
@{
Model.RemoveAt(0);
for (int i = 0; i < Model.Count; i++)
{
@Html.EditorFor(m => m[i], "ListEditorItem")
}
}
</div>
<input type="button" value="添加" class="btn btn-primary btn-xs add"
data-value="@ActionType.Create"
data-name-prefex="@ViewData.TemplateInfo.HtmlFieldPrefix" />
<input type="button" value="添加" class="btn btn-primary btn-xs add" data-value="@ActionType.Create" />

</div>
5 changes: 2 additions & 3 deletions src/ZKEACMS.WebHost/ZKEACMS.WebHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<TypeScriptToolsVersion>2.5</TypeScriptToolsVersion>
<ServerGarbageCollection>false</ServerGarbageCollection>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

<ItemGroup>
Expand All @@ -28,12 +27,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="ZKEACMS.Publisher" Version="1.0.1" />
<DotNetCliToolReference Include="ZKEACMS.Publisher" Version="1.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 326168d

Please sign in to comment.