草庐IT

CRC_and_checksum

全部标签

c# - 在 winforms 应用程序中缓存 GDI+ 对象 : is it worth it and how to do it right?

对于我的一些winforms应用程序,我需要创建一大堆GDI+对象(画笔、笔、字体等)并一遍又一遍地使用它们。我创建了一个ghetto缓存单例来完成我需要的,但是代码味道太重了......publicsealedclassGraphicsPalette{publicstaticreadonlyGraphicsPaletteInstance=newGraphicsPalette();staticGraphicsPalette(){}privateDictionarysolidBrushes;//multithreadingprivateobjectbrushLock;privateGra

c# - Entity Framework Linq 查询 : runs instantly in SSMS and 8-10s in EF LINQ 出现问题

我在SQL中得到了以下查询(混淆了变量名),它试图获取值(Ch、Wa、Bu、Hi),从而导致最大数量(cnt)的Pi条目。selecttop1Pi.Ch,Pi.Wa,Pi.Bu,Pi.Hi,COUNT(1)ascntfromProduct,Si,PiwhereProduct.Id=Si.ProductIdandSi.Id=Pi.SiIdandProduct.Code=@CodeParametergroupbyPi.Ch,Pi.Wa,Pi.Bu,Pi.Hiorderbycntdesc它在我们的生产数据库上的SQL管理工作室中立即运行。我已经在C#LINQ和EntityFramework中

c# - MVC 5 : Custom AuthorizeAttribute and Caching

我试图通过从中派生并覆盖其某些方法来找到实现自定义System.Web.Mvc.AuthorizeAttribute的解决方案。我正在尝试的每一种方法,我都面临着MVC5的默认授权机制中的某些问题,这使我无法正确扩展它。我已经在SO和许多专用资源上对该领域进行了大量研究,但是我无法像我目前的场景那样为这种场景找到可靠的解决方案。第一个限制:我的授权逻辑需要额外的数据,例如Controller和方法名称以及应用于它们的属性而不是HttpContextBase能够提供的有限部分数据。例子:publicoverridevoidOnAuthorization(AuthorizationCont

c# - Code First 迁移种子错误 : The binary operator Equal is not defined for the types 'System.Nullable` 1[System. Int32 ]' and ' System.Int32'

在我的数据库中播种时,我的更新标识符出现以下问题:context.ClientPromos.AddOrUpdate(cp=>new{cp.ClientID,cp.Recommendation_ID,cp.PromoCode_ID},newClientPromo{ClientID=0,Recommendation_ID=Rec30Off.RecommendationID,PromoCode_ID=pc30PerOffProd.PromoCodeID},newClientPromo{ClientID=0,Recommendation_ID=RecKnow.RecommendationID,

c# - Visual Studio : edit-and-continue on handled exceptions?

这是重现我期望得到的行为的代码:staticvoidMain(string[]args){//try//#2{stringx=null;//#1AssertNotNull(x,nameof(x));}//catch(ArgumentNullException){}//#2Console.WriteLine("Passed.");Console.ReadKey();}[DebuggerHidden]publicstaticvoidAssertNotNull(Targ,stringargName)whereT:class{if(arg==null)thrownewArgumentNullE

c# - PNG CRC 是如何精确计算的?

在过去的4个小时里,我一直在研究CRC算法。我很确定我已经掌握了窍门。我正在尝试编写一个png编码器,我不希望将外部库用于CRC计算,也不希望用于png编码本身。我的程序已经能够获得与教程示例相同的CRC。喜欢Wikipedia:使用与示例中相同的多项式和消息,我能够在两种情况下产生相同的结果。我也能够为其他几个示例执行此操作。但是,我似乎无法正确计算png文件的CRC。我通过在Paint中创建一个空白的、一个像素大的.png文件并使用它的CRC作为比较来测试它。我从png(whichtheCRCiscalculatedfrom)的IDATblock中复制数据(和block名称),并使

c# - 存储库模式 : Implementation and lazy loading of model relationships

我有一个处理产品和产品类别的应用程序。对于其中的每一个,我都有使用POCO定义的模型。//Representsaproduct.classProduct{publicvirtualintID{get;set;}publicvirtualstringName{get;set;}publicvirtualProductCategoryCategory{get;set;}}//Representsaproductcategory.classProductCategory{publicvirtualintID{get;set;}publicvirtualstringName{get;set;}

c# - LINQ to SQL - 如何高效地对多个条件执行 AND 或 OR 搜索

我有一个ASP.NETMVC站点(它使用LinqToSql作为ORM),并且客户想要一个针对定制数据库的搜索工具,他们可以选择进行“AND”搜索(所有条件匹配)或“或”搜索(任何条件匹配)。该查询非常复杂且冗长,我想知道是否有一种简单的方法可以使它同时执行这两项操作,而无需创建和维护两个不同版本的查询。例如,当前的“AND”搜索看起来像这样(但这是一个大大的简化版本):privateIQueryableGetSampleSearchQuery(SamplesCriteriacriteria){varresults=fromrinTablewhere(r.Id==criteria.Sam

c# - 如何修复 "The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time"错误

我已经在C#.netCore的项目上启用了CORS在startup.cs中我添加了行...services.AddCors();...app.UseCors(builder=>builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());但是当我尝试在另一个Blazor项目中使用API时,我在Host上的API项目日志中看到了这个错误TheCORSprotocoldoesnotallowspecifyingawildcard(any)originandcredentialsatthesame

c# - ASP.NET 核心 : [FromQuery] usage and URL format

我正在尝试在我的网络API中使用[FromQuery],但我不确定如何使用它。这是Controller中的GetAllBooks()方法:[HttpGet][Route("api/v1/ShelfID/{shelfID}/BookCollection")]publicasyncTaskGetAllBooks(stringshelfID,[FromQuery]Bookbookinfo){//dosomething}这是Book模型类:publicclassBook{publicstringID{get;set;}publicstringName{get;set;}publicstring