src/ZKEACMS.SectionWidget/Service/SectionGroupService.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* http://www.zkea.net/
* Copyright (c) ZKEASOFT. All rights reserved.
* http://www.zkea.net/licenses */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using ZKEACMS.SectionWidget.Models;
using Easy.Extend;
using Easy.Reflection;
using Easy.RepositoryPattern;
using Microsoft.AspNetCore.Hosting;
using Easy;
using Microsoft.EntityFrameworkCore;
using Easy.Mvc.Plugin;
namespace ZKEACMS.SectionWidget.Service
{
public class SectionGroupService : ServiceBase<SectionGroup, CMSDbContext>, ISectionGroupService
{
private readonly ISectionContentProviderService _sectionContentProviderService;
private readonly IPluginLoader _pluginLoader;
public SectionGroupService(ISectionContentProviderService sectionContentProviderService,
IPluginLoader pluginLoader, IApplicationContext applicationContext, CMSDbContext dbContext) : base(applicationContext, dbContext)
{
_sectionContentProviderService = sectionContentProviderService;
_pluginLoader = pluginLoader;
}
public override IQueryable<SectionGroup> Get()
{
return CurrentDbSet.AsNoTracking();
}
public SectionGroup GenerateContentFromConfig(SectionGroup group)
{
string configFile = PluginBase.GetPath<SectionPlug>().CombinePath("Thumbnail/{0}.xml".FormatWith(group.PartialView).ToFilePath());
List<SectionContent> contents = new List<SectionContent>();
if (File.Exists(configFile))
{
using (FileStream fileStream = new FileStream(configFile, FileMode.Open))
{
XmlDocument doc = new XmlDocument();
doc.Load(fileStream);
var nodes = doc.SelectNodes("/required/item");
const string fullNameSpace = "ZKEACMS.SectionWidget.Models.{0}";
foreach (XmlNode item in nodes)
{
var attr = item.Attributes["type"];
if (attr != null && attr.Value.IsNotNullAndWhiteSpace())
{
var typeInfoArray = attr.Value.Split('.');
string fullTypeInfo = fullNameSpace.FormatWith(typeInfoArray[typeInfoArray.Length - 1]);
if (SectionPlug.ContentTypes.ContainsKey(fullTypeInfo))
{
var content = Activator.CreateInstance(SectionPlug.ContentTypes[fullTypeInfo]) as SectionContent;
var properties = item.SelectNodes("property");
foreach (XmlNode property in properties)
后面还有 63 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。