添加缩略图同步功能
This commit is contained in:
@@ -12,7 +12,7 @@ using CSRedis;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public class CacheClientDB
|
||||
public class CacheInvoker
|
||||
{
|
||||
|
||||
public delegate T MyAction<T>(CSRedisClient client);
|
||||
@@ -22,7 +22,7 @@ namespace Yi.Framework.Core
|
||||
private CSRedisClient Client { get; set; }
|
||||
|
||||
public CSRedisClient _Db { get { return Client; } set { } }
|
||||
public CacheClientDB(IOptionsMonitor<RedisConnOptions> redisConnOptions)
|
||||
public CacheInvoker(IOptionsMonitor<RedisConnOptions> redisConnOptions)
|
||||
{
|
||||
this._RedisOptions = redisConnOptions.CurrentValue;
|
||||
Client = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
|
||||
410
Yi.Framework.Net6/Yi.Framework.Core/ThumbnailSharpInvoer.cs
Normal file
410
Yi.Framework.Net6/Yi.Framework.Core/ThumbnailSharpInvoer.cs
Normal file
@@ -0,0 +1,410 @@
|
||||
/*MIT License
|
||||
|
||||
Copyright(c) 2017 Mirza Ghulam Rasyid
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Image format to use when creating a thumbnail.
|
||||
/// </summary>
|
||||
public enum Format
|
||||
{
|
||||
Jpeg,
|
||||
Bmp,
|
||||
Png,
|
||||
Gif,
|
||||
Tiff
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Thumbnail class that holds various methods to create an image thumbnail.
|
||||
/// </summary>
|
||||
public class ThumbnailSharpInvoer
|
||||
{
|
||||
private Bitmap CreateBitmapThumbnail(uint thumbnailSize, string imageFileLocation)
|
||||
{
|
||||
Bitmap bitmap = null;
|
||||
Image image = null;
|
||||
float actualHeight = default(float);
|
||||
float actualWidth = default(float);
|
||||
uint thumbnailHeight = default(uint);
|
||||
uint thumbnailWidth = default(uint);
|
||||
try
|
||||
{
|
||||
image = Image.FromFile(imageFileLocation);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (image != null)
|
||||
image = null;
|
||||
}
|
||||
if (image != null)
|
||||
{
|
||||
actualHeight = image.Height;
|
||||
actualWidth = image.Width;
|
||||
if (actualHeight > actualWidth)
|
||||
{
|
||||
if ((uint)actualHeight <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than actual height (portrait image)");
|
||||
thumbnailHeight = thumbnailSize;
|
||||
thumbnailWidth = (uint)((actualWidth / actualHeight) * thumbnailSize);
|
||||
}
|
||||
else if (actualWidth > actualHeight)
|
||||
{
|
||||
|
||||
if ((uint)actualWidth <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than actual width (landscape image)");
|
||||
thumbnailWidth = thumbnailSize;
|
||||
thumbnailHeight = (uint)((actualHeight / actualWidth) * thumbnailSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((uint)actualWidth <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than image's size");
|
||||
thumbnailWidth = thumbnailSize;
|
||||
thumbnailHeight = thumbnailSize;
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
bitmap = new Bitmap((int)thumbnailWidth, (int)thumbnailHeight);
|
||||
Graphics resizedImage = Graphics.FromImage(bitmap);
|
||||
resizedImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
resizedImage.CompositingQuality = CompositingQuality.HighQuality;
|
||||
resizedImage.SmoothingMode = SmoothingMode.HighQuality;
|
||||
resizedImage.DrawImage(image, 0, 0, thumbnailWidth, thumbnailHeight);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (bitmap != null)
|
||||
bitmap = null;
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
private Bitmap CreateBitmapThumbnail(uint thumbnailSize, Stream imageStream)
|
||||
{
|
||||
Bitmap bitmap = null;
|
||||
Image image = null;
|
||||
float actualHeight = default(float);
|
||||
float actualWidth = default(float);
|
||||
uint thumbnailHeight = default(uint);
|
||||
uint thumbnailWidth = default(uint);
|
||||
try
|
||||
{
|
||||
image = Image.FromStream(imageStream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (image != null)
|
||||
image = null;
|
||||
}
|
||||
if (image != null)
|
||||
{
|
||||
actualHeight = image.Height;
|
||||
actualWidth = image.Width;
|
||||
if (actualHeight > actualWidth)
|
||||
{
|
||||
if ((uint)actualHeight <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than actual height (portrait image)");
|
||||
thumbnailHeight = thumbnailSize;
|
||||
thumbnailWidth = (uint)((actualWidth / actualHeight) * thumbnailSize);
|
||||
}
|
||||
else if (actualWidth > actualHeight)
|
||||
{
|
||||
|
||||
if ((uint)actualWidth <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than actual width (landscape image)");
|
||||
thumbnailWidth = thumbnailSize;
|
||||
thumbnailHeight = (uint)((actualHeight / actualWidth) * thumbnailSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((uint)actualWidth <= thumbnailSize)
|
||||
throw new Exception("Thumbnail size must be less than image's size");
|
||||
thumbnailWidth = thumbnailSize;
|
||||
thumbnailHeight = thumbnailSize;
|
||||
}
|
||||
try
|
||||
{
|
||||
bitmap = new Bitmap((int)thumbnailWidth, (int)thumbnailHeight);
|
||||
Graphics resizedImage = Graphics.FromImage(bitmap);
|
||||
resizedImage.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
resizedImage.CompositingQuality = CompositingQuality.HighQuality;
|
||||
resizedImage.SmoothingMode = SmoothingMode.HighQuality;
|
||||
resizedImage.DrawImage(image, 0, 0, thumbnailWidth, thumbnailHeight);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (bitmap != null)
|
||||
bitmap = null;
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
private ImageFormat GetImageFormat(Format format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case Format.Jpeg:
|
||||
return ImageFormat.Jpeg;
|
||||
case Format.Bmp:
|
||||
return ImageFormat.Bmp;
|
||||
case Format.Png:
|
||||
return ImageFormat.Png;
|
||||
case Format.Gif:
|
||||
return ImageFormat.Gif;
|
||||
default:
|
||||
return ImageFormat.Tiff;
|
||||
}
|
||||
}
|
||||
private async Task<Stream> GetImageStreamFromUrl(Uri urlAddress)
|
||||
{
|
||||
Stream result = null;
|
||||
try
|
||||
{
|
||||
byte[] bytes = await GetImageBytesFromUrl(urlAddress);
|
||||
result = new MemoryStream(bytes);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private async Task<byte[]> GetImageBytesFromUrl(Uri urlAddress)
|
||||
{
|
||||
byte[] buffer = null;
|
||||
try
|
||||
{
|
||||
using (HttpClient client = new HttpClient())
|
||||
{
|
||||
buffer = await client.GetByteArrayAsync(urlAddress);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
buffer = null;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a thumbnail from file and returns as stream.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageFileLocation">Correct image file location.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as stream. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageFileLocation' is null.</exception>
|
||||
/// <exception cref="FileNotFoundException">'imageFileLocation' does not exist.</exception>
|
||||
public Stream CreateThumbnailStream(uint thumbnailSize, string imageFileLocation, Format imageFormat)
|
||||
{
|
||||
if (String.IsNullOrEmpty(imageFileLocation))
|
||||
throw new ArgumentNullException(nameof(imageFileLocation), "'imageFileLocation' cannot be null");
|
||||
if (!File.Exists(imageFileLocation))
|
||||
throw new FileNotFoundException($"'{imageFileLocation}' cannot be found");
|
||||
Bitmap bitmap = CreateBitmapThumbnail(thumbnailSize, imageFileLocation);
|
||||
if (bitmap != null)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
bitmap.Save(stream, GetImageFormat(imageFormat));
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a thumbnail from image stream and returns as stream.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageStream">Valid image stream object.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as stream. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageStream' is null.</exception>
|
||||
public Stream CreateThumbnailStream(uint thumbnailSize, Stream imageStream, Format imageFormat)
|
||||
{
|
||||
if (imageStream == null)
|
||||
throw new ArgumentNullException(nameof(imageStream), "'imageStream' cannot be null");
|
||||
Bitmap bitmap = CreateBitmapThumbnail(thumbnailSize, imageStream);
|
||||
if (bitmap != null)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
bitmap.Save(stream, GetImageFormat(imageFormat));
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a thumbnail from image in bytes and returns as stream.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageBytes">Valid image bytes array.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as stream. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageBytes' is null.</exception>
|
||||
public Stream CreateThumbnailStream(uint thumbnailSize, byte[] imageBytes, Format imageFormat)
|
||||
{
|
||||
if (imageBytes == null)
|
||||
throw new ArgumentNullException(nameof(imageBytes), "'imageStream' cannot be null");
|
||||
Bitmap bitmap = CreateBitmapThumbnail(thumbnailSize, new MemoryStream(imageBytes));
|
||||
if (bitmap != null)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
bitmap.Save(stream, GetImageFormat(imageFormat));
|
||||
stream.Position = 0;
|
||||
return stream;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a thumbnail from file and returns as bytes.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageFileLocation">Correct image file location.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as bytes. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageFileLocation' is null.</exception>
|
||||
/// <exception cref="FileNotFoundException">'imageFileLocation' does not exist.</exception>
|
||||
public byte[] CreateThumbnailBytes(uint thumbnailSize, string imageFileLocation, Format imageFormat)
|
||||
{
|
||||
if (String.IsNullOrEmpty(imageFileLocation))
|
||||
throw new ArgumentNullException(nameof(imageFileLocation), "'imageFileLocation' cannot be null");
|
||||
if (!File.Exists(imageFileLocation))
|
||||
throw new FileNotFoundException($"'{imageFileLocation}' cannot be found");
|
||||
Stream stream = CreateThumbnailStream(thumbnailSize, imageFileLocation, imageFormat);
|
||||
if (stream != null)
|
||||
{
|
||||
byte[] streamBytes = new byte[stream.Length];
|
||||
stream.Read(streamBytes, 0, streamBytes.Length);
|
||||
return streamBytes;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a thumbnail from image stream and returns as bytes.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageStream">Valid image stream object.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as bytes. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageStream' is null.</exception>
|
||||
public byte[] CreateThumbnailBytes(uint thumbnailSize, Stream imageStream, Format imageFormat)
|
||||
{
|
||||
if (imageStream == null)
|
||||
throw new ArgumentNullException(nameof(imageStream), "'imageStream' cannot be null");
|
||||
|
||||
Stream stream = CreateThumbnailStream(thumbnailSize, imageStream, imageFormat);
|
||||
if (stream != null)
|
||||
{
|
||||
byte[] streamBytes = new byte[stream.Length];
|
||||
stream.Read(streamBytes, 0, streamBytes.Length);
|
||||
return streamBytes;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Create a thumbnail from image in bytes and returns as bytes.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="imageBytes">Valid image bytes array.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as bytes. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'imageBytes' is null.</exception>
|
||||
public byte[] CreateThumbnailBytes(uint thumbnailSize, byte[] imageBytes, Format imageFormat)
|
||||
{
|
||||
if (imageBytes == null)
|
||||
throw new ArgumentNullException(nameof(imageBytes), "'imageStream' cannot be null");
|
||||
Stream stream = CreateThumbnailStream(thumbnailSize, imageBytes, imageFormat);
|
||||
if (stream != null)
|
||||
{
|
||||
byte[] streamBytes = new byte[stream.Length];
|
||||
stream.Read(streamBytes, 0, streamBytes.Length);
|
||||
return streamBytes;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a thumbnail from valid image url asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="urlAddress">Valid absolute url address with proper scheme.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as stream. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'urlAddress' is null.</exception>
|
||||
public async Task<Stream> CreateThumbnailStreamAsync(uint thumbnailSize, Uri urlAddress, Format imageFormat)
|
||||
{
|
||||
if (urlAddress == null)
|
||||
throw new ArgumentNullException(nameof(urlAddress), "'urlAddress' cannot be null");
|
||||
Stream result = null;
|
||||
Stream stream = await GetImageStreamFromUrl(urlAddress);
|
||||
if (stream != null)
|
||||
{
|
||||
result = CreateThumbnailStream(thumbnailSize, stream, imageFormat);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a thumbnail from valid image url asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="thumbnailSize">Thumbnail size. For portrait image, thumbnail size must be less than its height.
|
||||
/// For landscape image, thumbnail size must be less than its width. For the same size image (Proportional), thumbnail size must be less than its width and height.</param>
|
||||
/// <param name="urlAddress">Valid absolute url address with proper scheme.</param>
|
||||
/// <param name="imageFormat">Image format to use.</param>
|
||||
/// <returns>A thumbnail image as bytes. Returns null if it fails.</returns>
|
||||
/// <exception cref="ArgumentNullException">'urlAddress' is null.</exception>
|
||||
public async Task<byte[]> CreateThumbnailBytesAsync(uint thumbnailSize, Uri urlAddress, Format imageFormat)
|
||||
{
|
||||
if (urlAddress == null)
|
||||
throw new ArgumentNullException(nameof(urlAddress), "'urlAddress' cannot be null");
|
||||
byte[] result = null;
|
||||
byte[] imageBytes = await GetImageBytesFromUrl(urlAddress);
|
||||
if (imageBytes != null)
|
||||
{
|
||||
result = CreateThumbnailBytes(thumbnailSize, imageBytes, imageFormat);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public static class TreeMenuBuild
|
||||
{
|
||||
// /// <summary>
|
||||
// /// 过滤所有已经删除的菜单
|
||||
// /// </summary>
|
||||
// /// <param name="menu_data"></param>
|
||||
// /// <returns></returns>
|
||||
// public static menu Normal(menu menu_data)
|
||||
// {
|
||||
// for (int i = menu_data.children.Count() - 1; i >= 0; i--)
|
||||
// {
|
||||
// if (menu_data.children[i].is_delete == (short)Common.Enum.DelFlagEnum.Deleted)
|
||||
// {
|
||||
// menu_data.children.Remove(menu_data.children[i]);
|
||||
// }
|
||||
// else if (menu_data.children[i] != null)
|
||||
// {
|
||||
// Normal(menu_data.children[i]);
|
||||
// }
|
||||
// }
|
||||
// return menu_data;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// public static menu ShowFormat(menu menu_data, List<int> allMenuIds)
|
||||
// {
|
||||
// return Format(Show(menu_data, allMenuIds));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 过滤用户不展示及已删除及未拥有的菜单
|
||||
// /// </summary>
|
||||
// /// <param name="menu_data"></param>
|
||||
// /// <param name="allMenuIds"></param>
|
||||
// /// <returns></returns>
|
||||
// private static menu Show(menu menu_data, List<int> allMenuIds)
|
||||
// {
|
||||
// for (int i = menu_data.children.Count() - 1; i >= 0; i--)
|
||||
// {
|
||||
// if (!allMenuIds.Contains(menu_data.children[i].id) || menu_data.children[i].is_delete == (short)Common.Enum.DelFlagEnum.Deleted || menu_data.children[i].is_show == (short)Common.Enum.ShowFlagEnum.NoShow)
|
||||
// {
|
||||
// menu_data.children.Remove(menu_data.children[i]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Show(menu_data.children[i], allMenuIds);
|
||||
// }
|
||||
// }
|
||||
// return menu_data;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 为了匹配前端格式,通常和show方法一起
|
||||
// /// </summary>
|
||||
// /// <param name="menu_data"></param>
|
||||
// /// <returns></returns>
|
||||
// private static menu Format(menu menu_data)
|
||||
// {
|
||||
// for (int i = menu_data.children.Count() - 1; i >= 0; i--)
|
||||
// {
|
||||
// if (menu_data.children[i].icon == null)
|
||||
// {
|
||||
// menu_data.children[i].icon = "mdi-view-dashboard";
|
||||
// }
|
||||
// if (menu_data.children != null || menu_data.children.Count() != 0)
|
||||
// {
|
||||
// Format(menu_data.children[i]);
|
||||
// }
|
||||
// }
|
||||
// if (menu_data.children.Count() == 0)
|
||||
// {
|
||||
// menu_data.children = null;
|
||||
// }
|
||||
|
||||
// return menu_data;
|
||||
// }
|
||||
|
||||
// public static menu Sort(menu menu_data)
|
||||
// {
|
||||
// if (menu_data.children != null)
|
||||
// {
|
||||
// for (int i = menu_data.children.Count() - 1; i >= 0; i--)
|
||||
// {
|
||||
// menu_data.children = menu_data.children.AsEnumerable().OrderByDescending(u => u.sort).ToList();
|
||||
|
||||
// if (menu_data.children != null || menu_data.children.Count() != 0)
|
||||
// {
|
||||
// Sort(menu_data.children[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return menu_data;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
Reference in New Issue
Block a user