using System; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; using System.Text; namespace YiSha.Enum.ZX { /// /// 是否推荐 枚举 /// public enum NewManagerModelsIsHotEnum { /// /// 不推荐 /// [Description("不推荐")] 不推荐 = 0, /// /// 推荐 /// [Description("推荐")] 推荐 = 1 } /// /// 是否生成 /// public enum NewManagerModelsIsGeneratedEnum { /// /// 不生成 /// [Description("不生成")] 不生成 = 0, /// /// 生成 /// [Description("生成")] 生成 = 1 } /// /// 发布量统计类型枚举 /// public enum PublishStatisticsType { /// /// 内容发布量 /// [Description("内容发布量")] 内容发布量 = 0, /// /// 栏目发布统计 /// [Description("栏目发布统计")] 栏目发布统计 = 1 } #region 老系统数据 /// /// 模板类型 来源老系统 /// public enum TemplateType : int { // 0.$$TitleDescription$$ 标题描述 // 1.$$Keywords$$ 关键字 // 2.$$Description$$ 描述 // 3.$$NewsTitle$$ 新闻标题 // 4.$$AuthorAndNewsAddtime$$ 作者和资讯添加时间 // 5.$$NewsContentKeywords$$ 资讯关键字 // 6.$$NewsContent$$ 资讯详情 // 7.$$NewsLatestUpdate$$ 最新更新 // 8.$$Navigation$$ 面包屑导航 // 9.$$PuzzlesTypeName$$ 字谜类型 /// /// 福彩3D /// [Description("福彩3D")] [Text("../../Template/InformationDetails_Template.html", "3d")] Fucai3D_1 = 14, /// /// 福彩3D /// [Description("福彩3D")] [Text("../../Template/InformationDetails_Template.html", "3d")] Fucai3D_2 = 55, /// /// 排列三 /// [Description("排列三")] [Text("../../Template/InformationDetails_Template.html", "p3")] ArrangementThree_1 = 22, /// /// 排列三 /// [Description("排列三")] [Text("../../Template/InformationDetails_Template.html", "p3")] ArrangementThree_2 = 57, /// /// 太湖字谜 /// [Description("太湖字谜")] [Text("../../Template/Puzzles_Template.html", "3d/thzm")] TaihuPuzzles = 18, /// /// 彩神通字谜 /// [Description("彩神通字谜")] [Text("../../Template/Puzzles_Template.html", "3d/cstzm")] CrosswordPuzzle = 25, /// /// 双色球 /// [Description("双色球")] [Text("../../Template/InformationDetails_Template.html", "ssq")] Chromosphere_1 = 41, /// /// 双色球 /// [Description("双色球")] [Text("../../Template/InformationDetails_Template.html", "ssq")] Chromosphere_2 = 56, /// /// 其他彩种 /// [Description("其他彩种")] [Text("../../Template/InformationDetails_Template.html", "qita")] OtherColoredSpecies = 44, /// /// 大乐透 /// [Description("大乐透")] [Text("../../Template/InformationDetails_Template.html", "qita")] Lotto = 58, /// /// 55128专题 /// Special55128 = 54, /// /// 友情链接 /// [Description("友情链接")] [Text("../../../Template/FriendlyLink_Template.html", "")] FriendshipLink = 99, /// /// 推广广告 /// [Description("推广广告")] [Text("../../../Template/Advertisement_Template.html", "../../../Template/json.txt")] Advertisement = 98, /// /// 福彩快乐8 /// [Description("福彩快乐8")] [Text("../../Template/InformationDetails_Template.html", "kl8")] Fucaikl8 =114 } /// /// 获取实体类Attribute自定义属性 /// public static class EnumAttribute { private static Dictionary> _enumCache; /// /// 缓存 /// private static Dictionary> EnumCache { get { return _enumCache ?? (_enumCache = new Dictionary>()); } set { _enumCache = value; } } /// /// 返回枚举项的描述信息。 /// /// 要获取描述信息的枚举项。 /// 枚举想的描述信息。 public static string GetEnumDescription(this System.Enum value) { Type enumType = value.GetType(); // 获取枚举常数名称。 string name = System.Enum.GetName(enumType, value); if (name != null) { // 获取枚举字段。 FieldInfo fieldInfo = enumType.GetField(name); if (fieldInfo != null) { // 获取描述的属性。 DescriptionAttribute attr = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute), false) as DescriptionAttribute; if (attr != null) { return attr.Description; } } } return null; } /// /// 获取自定义枚举描述信息 /// /// /// public static string[] GetEnumText(this System.Enum en) { string enString = string.Empty; if (null == en) return new[] { "", "" }; Type type = en.GetType(); enString = en.ToString(); if (type.FullName != null && !EnumCache.ContainsKey(type.FullName)) { System.Reflection.FieldInfo[] fields = type.GetFields(); Dictionary temp = new Dictionary(); foreach (FieldInfo item in fields) { object[] attrs = item.GetCustomAttributes(typeof(TextAttribute), false); if (attrs.Length == 1) { string v = ((TextAttribute)attrs[0]).Value; string e = ((TextAttribute)attrs[0]).Ex; temp.Add(item.Name, new[] { v, e }); } } EnumCache.Add(type.FullName, temp); } if (type.FullName != null && EnumCache[type.FullName].ContainsKey(enString)) { return EnumCache[type.FullName][enString]; } return new[] { "", "" }; } } /// /// 枚举值描述 来源老系统 /// public class TextAttribute : Attribute { public TextAttribute(string value, string ex = "") { Value = value; Ex = ex; } /// /// 描述信息 /// public string Value { get; private set; } public string Ex { get; private set; } } public static class ZxCzTemplateTypeHelper { public static readonly Dictionary dict = new Dictionary { { 14,TemplateType.Fucai3D_1 }, { 55,TemplateType.Fucai3D_2 }, { 22,TemplateType.ArrangementThree_1 }, { 57,TemplateType.ArrangementThree_2 }, { 18,TemplateType.TaihuPuzzles }, { 25,TemplateType.CrosswordPuzzle }, { 41,TemplateType.Chromosphere_1 }, { 56,TemplateType.Chromosphere_2 }, { 44,TemplateType.OtherColoredSpecies }, { 58,TemplateType.Lotto }, { 54,TemplateType.Special55128 }, { 99,TemplateType.FriendshipLink }, { 98,TemplateType.Advertisement }, { 114,TemplateType.Fucaikl8 }, }; } #endregion }