using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Web;
using JGDJWeb.Helper;
/*
* Created by Calos 2015年5月20日 15:28:59
**/
namespace System {
/// <summary>
/// 0519本次的所有pageNames
/// </summary>
public enum PageNames {
机关讯息, 工委动态, 热点聚焦, 党员驿站, 群团风采, 工作研究, 视频点播, 党建宝典, 图片新闻, 他山之石
}
/// <summary>
/// 设计静态存储类
/// 2015年5月22日 10:35:11 change the method
/// </summary>
public class PageNamesCollection {
private static readonly Dictionary<PageNames, String> UrlCollection = new Dictionary<PageNames, string>()
{
{PageNames.机关讯息,"List"},{PageNames.工委动态,"List"},{PageNames.工作研究,"List"},{PageNames.图片新闻,"Index_Pic"},{PageNames.党建宝典,"List"},{PageNames.党员驿站,"Index_DYYZ"},{PageNames.他山之石,"List"},{PageNames.群团风采,"List"},{PageNames.视频点播,"List"},{PageNames.热点聚焦,"List"}
};
private const String Prefix = "";
private const String Suffix = ".aspx";
public static String GetPageName(PageNames pageName) {
if (!UrlCollection.Keys.Contains(pageName)) throw new ArgumentException(pageName.ToString());
return Prefix + UrlCollection[pageName] + Suffix;
}
}
public static partial class Extensions {
/// <summary>
/// 添加扩展方法
/// </summary>
/// <param name="pageName"></param>
/// <returns></returns>
public static String ToPageTitleCn(this PageNames pageName) {
return pageName.ToString();
}
public static String ToPageName(this PageNames pageName) {
return PageNamesCollection.GetPageName(pageName);
}
public static String ToTitleString(this String source) {
return source.ToTitleString(10);
}
public static String ToTitleString(this String source, int length) {
if (length < 0) throw new ArgumentException("length不能为负数");
return length > source.Length ? source : source.Substring(0, length) + "...";
}
public static String ToFString(this DateTime? nullableDateTime) {
if (nullableDateTime == null) return "";
return nullableDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
}
public static String NoHtml(this String source) {
return HtmlHelper.NoHTML(source);
}
}