cs-Panination

ylbtech-Unitity: cs-Panination

Pager.cs 

IPagingOption.cs IPagedList.cs

PagingOption.cs PagedList.cs

PagingExtensions.cs

1.A,效果图返回顶部
1.B,源代码返回顶部
1.B.1,Pager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Routing;
using Healthcare.Framework.Web.URL;namespace Healthcare.Framework.Web.Mvc.Pagination
{public class Pager{ private ViewContext viewContext;private int currentPage;private int pageCount;private RouteValueDictionary pageLinkValueDictionary;private readonly int pageSize;private readonly int totalItemCount;private readonly RouteValueDictionary linkWithoutPageValuesDictionary;private readonly AjaxOptions ajaxOptions;private readonly string sortBy;private readonly bool? sortDescending;public Pager(ViewContext viewContext, int pageSize, int currentPage, int totalItemCount, RouteValueDictionary valuesDictionary, AjaxOptions ajaxOptions){this.viewContext = viewContext;this.pageSize = pageSize;this.currentPage = currentPage;this.totalItemCount = totalItemCount;this.linkWithoutPageValuesDictionary = valuesDictionary;this.ajaxOptions = ajaxOptions;this.ensureCollectionPageLinkValue();}public Pager(ViewContext viewContext, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending, RouteValueDictionary valuesDictionary, AjaxOptions ajaxOptions){this.viewContext = viewContext;this.pageSize = pageSize;this.currentPage = currentPage;this.totalItemCount = totalItemCount;this.sortBy = sortBy;this.sortDescending = sortDescending;this.linkWithoutPageValuesDictionary = valuesDictionary;this.ajaxOptions = ajaxOptions;this.ensureCollectionPageLinkValue();}public HtmlString RenderHtml(){pageCount = (int)Math.Ceiling(totalItemCount / (double)pageSize);if (pageCount == 0) pageCount = 1;const int nrOfPagesToDisplay = 4;if (pageCount < currentPage)currentPage = pageCount;var sb = new StringBuilder();// Previoussb.Append("<ul class=\"pagination pull-right\">");sb.Append(currentPage > 1 ? GeneratePageLink("«", 1, "first") : "<li class=\"first disabled\"><a>«</a></li>");sb.Append(currentPage > 1 ? GeneratePageLink("", currentPage - 1, "previous") : "<li class=\"previous disabled\"><a>‹</a></li>");var start = 1;var end = pageCount;if (pageCount > nrOfPagesToDisplay){var middle = (int)Math.Ceiling(nrOfPagesToDisplay / 2d) - 1;var below = (currentPage - middle);var above = (currentPage + middle);if (below < 4){above = nrOfPagesToDisplay;below = 1;}else if (above > (pageCount - 4)){above = pageCount;below = (pageCount - nrOfPagesToDisplay);}start = below;end = above;}if (start > 3){sb.Append(GeneratePageLink("1", 1));sb.Append(GeneratePageLink("2", 2));sb.Append("<li class=\"disabled\"><a>...</a></li>");}for (var i = start; i <= end; i++){if (i == currentPage || (currentPage <= 0 && i == 0)){sb.AppendFormat("<li class=\"active\"><a>{0}</a></li>", i);}else{sb.Append(GeneratePageLink(i.ToString(), i));}}//if (end < (pageCount - 5))//{//    sb.Append("<li class=\"disabled\"><a>...</a></li>");//    sb.Append(GeneratePageLink((pageCount - 3).ToString(), pageCount - 3));//    sb.Append(GeneratePageLink((pageCount - 2).ToString(), pageCount - 2));//    sb.Append(GeneratePageLink((pageCount - 1).ToString(), pageCount - 1));//    sb.Append(GeneratePageLink(pageCount.ToString(), pageCount));//}if (end  < pageCount)//后面还有其它页码
            {int tempmin = pageCount - 3;sb.Append("<li class=\"disabled\"><a>...</a></li>");for (int k = tempmin; k <= pageCount; k++){sb.Append(GeneratePageLink(k.ToString(), k));}//sb.Append(GeneratePageLink(pageCount.ToString(), pageCount));
            }// Nextsb.Append(currentPage < pageCount ? GeneratePageLink("", (currentPage + 1), "next") : "<li class=\"next disabled\"><a>›</a></li>");sb.Append(currentPage < pageCount ? GeneratePageLink("»", pageCount, "last") : "<li class=\"last disabled\"><a>»</a></li>");sb.Append("</ul>");return new HtmlString(sb.ToString());}private string GeneratePageLink(string linkText, int pageNumber, string classText = ""){if (pageLinkValueDictionary.ContainsKey("Page")){pageLinkValueDictionary.Remove("Page");}pageLinkValueDictionary.Add("Page", pageNumber);// 'Render' virtual path.var virtualPathForArea = RouteTable.Routes.GetVirtualPathForArea(viewContext.RequestContext, pageLinkValueDictionary);if (virtualPathForArea == null)return null;var stringBuilder = new StringBuilder("<li class=\"" + classText + "\"><a");if (ajaxOptions != null)foreach (var ajaxOption in ajaxOptions.ToUnobtrusiveHtmlAttributes())stringBuilder.AppendFormat(" {0}=\"{1}\"", ajaxOption.Key, ajaxOption.Value);stringBuilder.AppendFormat(" href=\"{0}\">{1}</a></li>", virtualPathForArea.VirtualPath, linkText);return stringBuilder.ToString();}public HtmlString RenderGotoBaseUrl(){if (pageLinkValueDictionary.ContainsKey("Page")){pageLinkValueDictionary.Remove("Page");}var virtualPathForArea = RouteTable.Routes.GetVirtualPathForArea(viewContext.RequestContext, pageLinkValueDictionary);return new HtmlString(virtualPathForArea.VirtualPath);}public HtmlString RenderSwitchPageSizeBaseUrl(){if (pageLinkValueDictionary.ContainsKey("PageSize")){pageLinkValueDictionary.Remove("PageSize");}if (pageLinkValueDictionary.ContainsKey("Page")){pageLinkValueDictionary.Remove("Page");}var virtualPathForArea = RouteTable.Routes.GetVirtualPathForArea(viewContext.RequestContext, pageLinkValueDictionary);return new HtmlString(virtualPathForArea.VirtualPath);}private void ensureCollectionPageLinkValue(){pageLinkValueDictionary = new RouteValueDictionary(linkWithoutPageValuesDictionary) { { "SortBy", sortBy }, { "SortDescending", sortDescending } };//{ { "Page", pageNumber }, { "PageSize", pageSize }, };
Dictionary<string, string> dict = new Dictionary<string, string>();QueryStringHelper.ExtractQueryStringValuesFromUri(viewContext.HttpContext.Request.Url, ref dict);dict.Keys.ToList().ForEach(key =>{if (!pageLinkValueDictionary.ContainsKey(key)){pageLinkValueDictionary.Add(key, dict[key]);}});// To be sure we get the right route, ensure the controller and action are specified.var routeDataValues = viewContext.RequestContext.RouteData.Values;routeDataValues.Keys.ToList().ForEach(key =>{if (!pageLinkValueDictionary.ContainsKey(key)){pageLinkValueDictionary.Add(key, routeDataValues[key]);}});}}
}
View Code

1.B.2,IPagingOption.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;namespace Healthcare.Framework.Web.Mvc.Pagination
{public interface IPagingOption{ int Page { get; set; }int PageSize { get; set; }int? TotalCount { get; set; }string SortBy { get; set; }bool? SortDescending { get; set; }string OrderByExpression { get; }RouteValueDictionary RouteValues { get; set; }}
}
View Code

1.B.3,IPagedList.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;namespace Healthcare.Framework.Web.Mvc.Pagination
{public interface IPagedList<T> : IList<T>{ int PageCount { get; }int TotalItemCount { get; }int PageIndex { get; }int PageNumber { get; }int PageSize { get; }bool HasPreviousPage { get; }bool HasNextPage { get; }bool IsFirstPage { get; }bool IsLastPage { get; }string SortBy { get; }bool? SortDescending { get; }RouteValueDictionary RouteValues { get; }}
}
View Code

1.B.4,PagingOption.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;namespace Healthcare.Framework.Web.Mvc.Pagination
{public class PagingOption : IPagingOption{public int Page { get; set; }public int PageSize { get; set; }public int? TotalCount { get; set; }public Int32? IsPagination { get; set; }public string ActionName { get; set; }public string SortBy { get; set; }public bool? SortDescending { get; set; }public bool ShowSummary { get; set; }public bool ShowGoto { get; set; }public bool ShowPageSize { get; set; }public PagingOption(){TotalCount = 0;PageSize = 10;Page = 1;}public RouteValueDictionary RouteValues { get; set; }public string OrderByExpression{get{return this.SortDescending.HasValue && this.SortDescending.Value ? this.SortBy + " desc" : this.SortBy + " asc";}}public int PageTotal{get{if (TotalCount == null){return (int)Math.Ceiling(0 / (double)PageSize);}return (int)Math.Ceiling(TotalCount.Value / (double)PageSize);}}}
}
View Code

1.B.5,PagedList.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Text;
using System.Threading.Tasks;
using System.Web.Routing;namespace Healthcare.Framework.Web.Mvc.Pagination
{public class PagedList<T> : List<T>, IPagedList<T>{ public PagedList(IEnumerable<T> source, IPagingOption option): this(source.AsQueryable(), option){}public PagedList(IQueryable<T> source, IPagingOption option){if (option == null)throw new ArgumentOutOfRangeException("PagingOption", "Value can not be null.");if (option.Page < 0)throw new ArgumentOutOfRangeException("index", "Value must be greater than 0.");if (option.PageSize < 1)throw new ArgumentOutOfRangeException("pageSize", "Value must be greater than 1.");if (source == null)source = new List<T>().AsQueryable();var realTotalCount = source.Count();PageSize = option.PageSize;PageIndex = option.Page;RouteValues = option.RouteValues;TotalItemCount = option.TotalCount.HasValue ? option.TotalCount.Value : realTotalCount;PageCount = TotalItemCount > 0 ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0;SortBy = option.SortBy;SortDescending = option.SortDescending;if (!string.IsNullOrEmpty(option.SortBy))source = source.OrderBy(option.OrderByExpression);HasPreviousPage = (PageIndex > 0);HasNextPage = (PageIndex < (PageCount - 1));IsFirstPage = (PageIndex <= 0);IsLastPage = (PageIndex >= (PageCount - 1));if (TotalItemCount <= 0)return;var realTotalPages = (int)Math.Ceiling(realTotalCount / (double)PageSize);if (realTotalCount < TotalItemCount && realTotalPages <= PageIndex)AddRange(source.Skip((realTotalPages - 1) * PageSize).Take(PageSize));elseAddRange(source.Skip(PageIndex * PageSize).Take(PageSize));}#region IPagedList Memberspublic int PageCount { get; private set; }public int TotalItemCount { get; private set; }public int PageIndex { get; private set; }public int PageNumber { get { return PageIndex + 1; } }public int PageSize { get; private set; }public bool HasPreviousPage { get; private set; }public bool HasNextPage { get; private set; }public bool IsFirstPage { get; private set; }public bool IsLastPage { get; private set; }public string SortBy { get; private set; }public bool? SortDescending { get; private set; }public RouteValueDictionary RouteValues { get; set; }#endregion}
}
View Code

1.B.6,PagingExtensions.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;namespace Healthcare.Framework.Web.Mvc.Pagination
{public static class PagingExtensions{ #region AjaxHelper extensionspublic static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, null, null, ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending, string actionName, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, sortBy, sortDescending, actionName, null, ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, string actionName, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, actionName, null, ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, object values, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, null, new RouteValueDictionary(values), ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, string actionName, object values, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, null, null, actionName, new RouteValueDictionary(values), ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, RouteValueDictionary valuesDictionary, AjaxOptions ajaxOptions){return Pager(ajaxHelper, pageSize, currentPage, totalItemCount, null, valuesDictionary, ajaxOptions);}public static HtmlString Pager(this AjaxHelper ajaxHelper, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending, string actionName, RouteValueDictionary valuesDictionary, AjaxOptions ajaxOptions){if (valuesDictionary == null){valuesDictionary = new RouteValueDictionary();}if (actionName != null){if (valuesDictionary.ContainsKey("action")){throw new ArgumentException("The valuesDictionary already contains an action.", "actionName");}valuesDictionary.Add("action", actionName);}var pager = new Pager(ajaxHelper.ViewContext, pageSize, currentPage, totalItemCount, sortBy, sortDescending, valuesDictionary, ajaxOptions);return pager.RenderHtml();}#endregion#region HtmlHelper extensionspublic static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, null, null);}public static HtmlString PagerT(this HtmlHelper htmlHelper, PagingOption options){if (options == null)return new HtmlString("");if (options.RouteValues == null){options.RouteValues = new RouteValueDictionary();}var pager = new PagerT(htmlHelper.ViewContext, options.PageSize, options.Page, options.TotalCount.HasValue ? options.TotalCount.Value : 0, options.SortBy, options.SortDescending, options.RouteValues, null);return pager.RenderHtml();}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, sortBy, sortDescending, null, null);}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string actionName){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, actionName, null);}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, object values){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, null, new RouteValueDictionary(values));}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string actionName, object values){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, null, null, actionName, new RouteValueDictionary(values));}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, RouteValueDictionary valuesDictionary){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, null, valuesDictionary);}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending, string actionName){return Pager(htmlHelper, pageSize, currentPage, totalItemCount, sortBy, sortDescending, actionName, null);}public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string sortBy, bool? sortDescending, string actionName, RouteValueDictionary valuesDictionary){if (valuesDictionary == null){valuesDictionary = new RouteValueDictionary();}if (actionName != null){if (valuesDictionary.ContainsKey("action")){throw new ArgumentException("The valuesDictionary already contains an action.", "actionName");}valuesDictionary.Add("action", actionName);}var pager = new Pager(htmlHelper.ViewContext, pageSize, currentPage, totalItemCount, sortBy, sortDescending, valuesDictionary, null);return pager.RenderHtml();}public static HtmlString Pager(this HtmlHelper htmlHelper, PagingOption options){if (options == null)return new HtmlString("");if (options.RouteValues == null){options.RouteValues = new RouteValueDictionary();}var pager = new Pager(htmlHelper.ViewContext, options.PageSize, options.Page, options.TotalCount.HasValue ? options.TotalCount.Value : 0, options.SortBy, options.SortDescending, options.RouteValues, null);return pager.RenderHtml();}public static HtmlString PagerGotoURL(this HtmlHelper htmlHelper, PagingOption options){if (options == null)return new HtmlString("");if (options.RouteValues == null){options.RouteValues = new RouteValueDictionary();}var pager = new Pager(htmlHelper.ViewContext, options.PageSize, options.Page, options.TotalCount.HasValue ? options.TotalCount.Value : 0, options.SortBy, options.SortDescending, options.RouteValues, null);return pager.RenderGotoBaseUrl();}public static HtmlString PagerGotoURL(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, object values = null){PagingOption options = new PagingOption(){Page = 1,PageSize = pageSize,TotalCount = totalItemCount,RouteValues = new RouteValueDictionary(values)};return PagerGotoURL(htmlHelper, options);}public static HtmlString PagerSwitchPageSizeBaseUrl(this HtmlHelper htmlHelper, PagingOption options){if (options == null)return new HtmlString("");if (options.RouteValues == null){options.RouteValues = new RouteValueDictionary();}var pager = new Pager(htmlHelper.ViewContext, options.PageSize, options.Page, options.TotalCount.HasValue ? options.TotalCount.Value : 0, options.SortBy, options.SortDescending, options.RouteValues, null);return pager.RenderSwitchPageSizeBaseUrl();}public static HtmlString PagerSwitchPageSizeBaseUrl(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, object values = null){PagingOption options = new PagingOption(){Page = 1,PageSize = pageSize,TotalCount = totalItemCount,RouteValues = new RouteValueDictionary(values)};return PagerSwitchPageSizeBaseUrl(htmlHelper, options);}#endregion#region ActionLink extensionspublic static HtmlString ActionLink<T>(this AjaxHelper ajaxHelper, string name, string actionName, IPagedList<T> model, AjaxOptions ajaxOptions){var sortDescending = model.SortBy != null && model.SortBy.Equals(name) && model.SortDescending.HasValue && model.SortDescending.Value ? false : true;var routeValues = new RouteValueDictionary();routeValues.Add("SortBy", name);routeValues.Add("SortDescending", sortDescending);if (model.RouteValues != null){foreach (var r in model.RouteValues){routeValues.Add(r.Key, r.Value);}}IDictionary<string, object> htmlAttributes = new Dictionary<string, object>();var css = "";if (!string.IsNullOrEmpty(model.SortBy) && model.SortBy.Equals(name)){if (model.SortDescending.HasValue && model.SortDescending.Value)css = "sort-desc";elsecss = "sort-asc";}elsecss = "sort-off";htmlAttributes.Add("class", css);return ajaxHelper.ActionLink(name, actionName, routeValues, ajaxOptions, htmlAttributes);}public static HtmlString ActionLink<T>(this AjaxHelper ajaxHelper, string label, string name, string actionName, IPagedList<T> model, AjaxOptions ajaxOptions){var sortDescending = model.SortBy != null && model.SortBy.Equals(name) && model.SortDescending.HasValue && model.SortDescending.Value ? false : true;var routeValues = new RouteValueDictionary();routeValues.Add("SortBy", name);routeValues.Add("SortDescending", sortDescending);if (model.RouteValues != null){foreach (var r in model.RouteValues){routeValues.Add(r.Key, r.Value);}}IDictionary<string, object> htmlAttributes = new Dictionary<string, object>();var css = "";if (!string.IsNullOrEmpty(model.SortBy) && model.SortBy.Equals(name)){if (model.SortDescending.HasValue && model.SortDescending.Value)css = "sort-desc";elsecss = "sort-asc";}elsecss = "sort-off";htmlAttributes.Add("class", css);return ajaxHelper.ActionLink(label, actionName, routeValues, ajaxOptions, htmlAttributes);}public static HtmlString ActionLink<T>(this HtmlHelper htmlHelper, string name, string actionName, IPagedList<T> model){var sortDescending = model.SortBy != null && model.SortBy.Equals(name) && model.SortDescending.HasValue && model.SortDescending.Value ? false : true;var routeValues = new { SortBy = name, SortDescending = sortDescending };var css = "";if (!string.IsNullOrEmpty(model.SortBy) && model.SortBy.Equals(name)){if (model.SortDescending.HasValue && model.SortDescending.Value)css = "sort-desc";elsecss = "sort-asc";}elsecss = "sort-off";var htmlAttributes = new { @class = css };return htmlHelper.ActionLink(name, actionName, routeValues, htmlAttributes);}#endregion#region IQueryable<T> extensionspublic static IPagedList<T> ToPagedList<T>(this IQueryable<T> source, IPagingOption option){return new PagedList<T>(source, option);}#endregion#region IEnumerable<T> extensionspublic static IPagedList<T> ToPagedList<T>(this IEnumerable<T> source, IPagingOption option){return new PagedList<T>(source, option);}#endregion}
}
View Code

1.B.7,

1.C,下载地址返回顶部

 

warn作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/290423.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SignalR的使用

什么是 SignalR&#xff1f;ASP.NET Core SignalR 是一个开放源代码库&#xff0c;可用于简化向应用添加实时 Web 功能。实时 Web 功能使服务器端代码能够将内容推送到客户端。适合 SignalR 的候选项&#xff1a;需要从服务器进行高频率更新的应用。示例包括游戏、社交网络、投…

NHibernate之旅(7):初探NHibernate中的并发控制

本节内容 什么是并发控制&#xff1f; 悲观并发控制(Pessimistic Concurrency)乐观并发控制(Optimistic Concurrency)NHibernate支持乐观并发控制实例分析结语什么是并发控制&#xff1f; 当很多人试图同一时候改动数据库中的数据时&#xff0c;必须实现一个控制系统&#xff0…

C和指针之数组名和数组名和首元素以及sizeof(数组名)和sizeof(数组名作为参数)区别

1、先看我的测试Demo #include <stdio.h> #include <stdlib.h>int get_size(int *p) {int size = sizeof(p);return size; }int main() {int a[6] = {1, 2, 3, 4, 5, 6};int b[] = {1, 2, 3, 4, 5, 6};int c[10] = {1, 2, 3, 4, 5, 6};int size_a = sizeof(a);int …

html常用标签(form标签)

一、form标签 form标签是html标签中非常重要的一个标签。常用于注册、登录页面的使用。 <form action"提交地址" method"提交方式"> </form> 注&#xff1a;method的值有两个。get&#xff08;默认值&#xff09;和post。get数据安全性没有pos…

期望DP

期望DP的一般做法是从末状态開始递推&#xff1a; Problem DescriptionAkemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl).Homura wants to help her friend Madoka save the world. But because of the plot of the Boss Incubator, she is trapped in a labyrinth …

神奇的[Caller*]属性

前言上次&#xff0c;我们《使用 CallerArgumentExpression 检查弃元参数》&#xff0c;它实际是利用编译器编译时将变量名称传入。其实&#xff0c;.NET中提供了多个[Caller*]属性&#xff0c;帮助我们轻松获取调用者信息。CallerFilePathAttribute允许获取包含调用方的源文件…

eshop截取字符串长度 和去掉省略号

<!-- {if $goods.goods_brief} --> {$goods.goods_brief|truncate:17}<!-- {/if} --> 去掉省略号&#xff1a; 找到includes/lib_base.php 第63行 $newstr . ... 去掉... 即可转载于:https://www.cnblogs.com/wesky/p/4819319.html

C和指针之字符串之实现strcpy函数

1、问题 实现strcpy函数2、代码实现 #include <stdio.h> #include <assert.h> char *str_copy(char *des, const char *src) {assert(src ! NULL);assert(des ! NULL);while ((*des *src) ! \0);return des; } int main() {const char *src "chenyu";c…

java dateTime + long

2019独角兽企业重金招聘Python工程师标准>>> public static void main(String[] args) throws Exception{SimpleDateFormat sdfnew SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // long timeStartsdf.parse("2011-09-20 12:30:45").getTime();l…

IOS 开发环境,证书和授权文件是什么?

一、成员介绍 1. Certification(证书) 证书是对电脑开发资格的认证&#xff0c;每个开发者帐号有一套&#xff0c;分为两种&#xff1a; 1) Developer Certification(开发证书) 安装在电脑上提供权限&#xff1a;开发人员通过设备进行真机测试。 可以生成副本供多台电脑安…

.NET Core中异常过滤器ExceptionFilter的使用介绍

介绍实现需要继承IExceptionFilter 或 IAsyncExceptionFilter。可用于实现常见的错误处理策略。使用场景首先讲一下我们为什么要使用异常过滤器 &#xff0c;如果业务场景复杂&#xff0c;只使用HttpStatusCode&#xff0c;抛出异常后,后期要加很多字段来描述。那么这种就比较不…

程序一启动检查网络,如果没有网络就退出程序

转载于:https://www.cnblogs.com/songxing10000/p/4823812.html

C和指针之多维数组一行存满后会轮到下一行

1、问题 比如二位数组名赋值给一个指针&#xff0c;指针在递增&#xff0c;超过这个行的最后一列后会得到怎么样结果。2、代码举例 #include <stdio.h>int main() {int a[3][3] {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};int *p NULL;p &a[1][1];printf("first val…

看小说的这些年

从大一开始&#xff0c;就开始看起了小说&#xff0c;不是那种名著类型&#xff0c;而是快餐小说&#xff0c;玄幻、都市、言情、科幻&#xff0c;什么都会看&#xff0c;因为看多了&#xff0c;就会发现&#xff0c;已经没什么可以看的。 谈起快餐小说&#xff0c;已经有很多被…

如何使用 .NET Core 安全地加/解密文件

前言由于客户网络安全限制&#xff0c;连接到互联网的设备不能访问内网。需要先从客户端应用中导出数据到文件&#xff0c;再将文件复制到U盘&#xff0c;最后通过内网机器上传数据。如何保证&#xff0c;在复制、传输过程中&#xff0c;文件的安全性&#xff1f;思路首先想到的…

使用Css截取字符串

white-space:nowrap; /* 禁止自动换行 */ overflow:hidden; /* 隐藏溢出的内容 */ text-overflow:ellipsis; /* 溢出文本使用...代替 */ 转载于:https://www.cnblogs.com/xiaoxian1369/p/4083974.html

广度优先算法BFS

package myalgorithm;import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; /*BFS用于记录的位置和值的结构*/ class node {node(int xparam,int yparam,int valparam){this.x xparam;this.y yparam;this.value valparam;}int x,y,value; } publ…

COMA(一): Learning to Communicate with Deep Multi-Agent Reinforcement Learning 论文讲解

Learning to Communicate with Deep Multi-Agent Reinforcement Learning 论文讲解 论文链接&#xff1a;https://papers.nips.cc/paper/6042-learning-to-communicate-with-deep-multi-agent-reinforcement-learning.pdf &#xff08;这篇论文是COMA三部曲中的第&#xff08…

C和指针之指针数组和指向数组的指针

1、指针数组 定义一个指针数组&#xff0c;该数组中每个元素是一个指针&#xff0c;每个指针指向哪里就需要程序中后续再定义int *p[10]; 2、指向数组的指针 定义一个数组指针&#xff0c;该指针指向含10个元素的一维数组&#xff08;数组中每个元素是int型&#xff09;int (*p…

SSH 远程执行任务

SSH 是 Linux 下进行远程连接的基本工具&#xff0c;但是如果仅仅用它来登录那可是太浪费啦&#xff01;SSH 命令可是完成远程操作的神器啊&#xff0c;借助它我们可以把很多的远程操作自动化掉&#xff01;下面就对 SSH 的远程操作功能进行一个小小的总结。远程执行命令如果我…