SmartSQL/SmartSQL.DocUtils/Extensions.cs

(开头部分) 8KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using ZetaLongPaths;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;

namespace SmartSQL.DocUtils
{
    public static class Extensions
    {
        public static void WriteAllText(StringBuilder builder, string filePath, string enc = "gbk")
        {
            ZlpIOHelper.WriteAllText(filePath, builder.ToString(), Encoding.GetEncoding(enc));
        }

        public static void WriteAllText(StringBuilder builder, string filePath, Encoding encoding)
        {
            ZlpIOHelper.WriteAllText(filePath, builder.ToString(), encoding);
        }

        public static string GetResourceContent(this Assembly assembly, string name)
        {
            var buffer = assembly.GetResourceBuffer(name);
            return System.Text.Encoding.UTF8.GetString(buffer);
        }

        public static byte[] GetResourceBuffer(this Assembly assembly, string name)
        {
            var stream = assembly.GetManifestResourceStream(name);
            var buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            stream.Dispose();
            return buffer;
        }

        public static EM GetEnum<EM>(this string enumName)
            where EM : struct, Enum
        {
            if (!Enum.TryParse<EM>(enumName, out EM em))
            {
                throw new ArgumentException("枚举转换失败!", nameof(enumName));
            }
            return em;
        }

        public static Dictionary<string, string> ToDictionary(this NameValueCollection nvc)
        {
            var dict = new Dictionary<string, string>();
            foreach (var key in nvc.AllKeys)
            {
                dict.Add(key, nvc[key]);
            }
            return dict;
后面还有 191 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。