懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
我一直在ASP.NET 4.5 Webforms应用程序上做一些性能统计,在初始部署后初始启动时看起来有些迟钝。
我注意到的一点是创建AutoMapper地图确实需要一些时间。
由于这些地图只是很少使用,我想知道我是否可能“延迟”创建这些地图,直到他们第一次需要它们 - 这是一种“懒惰的初始化”。
在这种情况下,我必须有一些“非破坏性”(例如,没有抛出异常)的方式来检查给定的地图是否存在 - 如果在AutoMapper中有类似的东西?
谢谢!
I've been doing some performance stats on an ASP.NET 4.5 Webforms app, which seems a bit sluggish on initial startup after a fresh deployment.
One of the points I noticed is that creating the AutoMapper maps does take some time.
Since those maps are only used rather rarely, I was wondering if I could possibly "delay" creating those maps until the first time they're needed - sort of a "lazy initialization".
In that case, I would have to have some "non-destructive" (e.g. without throwing an exception) way of checking whether or not a given map exists - if there something like that in AutoMapper?
Thanks!
原文:https://stackoverflow.com/questions/33640358
满意答案
你不完全适合Zip的工作。
试试这个片段:
if (entry.getName().equals("xl/worksheets/sheet1.xml")) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zipInput, bos); String xml = bos.toString(); assert xml.contains("A1"); assert xml.contains("B2"); assert xml.contains("C3"); break; }
You not exactly rigth work with Zip.
Try this snippet:
if (entry.getName().equals("xl/worksheets/sheet1.xml")) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(zipInput, bos); String xml = bos.toString(); assert xml.contains("A1"); assert xml.contains("B2"); assert xml.contains("C3"); break; }
相关问答
更多使用java.util.zip。*解压缩使用Apache POI创建的xlsx blob时失败(Failure when using java.util.zip.* to unzip an xlsx blob created with Apache POI)
读取XLSX工作簿时,Apache POI抛出IOException(Apache POI throwing IOException when reading XLSX workbook)
使用apache-poi java在xlsx文件上无效的验证(Validations not working on xlsx file using apache-poi java)
如何使用java apache poi从xlsx文件的特定单元获取值(How to get value from a specific cell of an xlsx file using java apache poi)
使用Apache POI打开xls和xlsx(Open xls and xlsx with Apache POI)
Oracle - 直接使用XLSX数据的最佳方式,而不是使用Apache POI(Oracle - best way to use XLSX data directly, not using Apache POI)
Apache POI阅读xlsx NPE(Apache POI Read xlsx NPE)
使用POI从.xls升级到.xlsx(Upgrading from .xls to .xlsx with POI)
Apache poi XLSX到XLS(Apache poi XLSX to XLS)
Apache POI创建xlsx文件,以后无法打开。(Apache POI creates xlsx file which it can't open later. Zip bomb detected)
相关文章
更多初始化-Oceanus编码调用
MultiComboBox 多选以及初始化问题
二维数组的初始化!
初始化activiti数据库
初始SolrJ开发, schema.xml的配置与服务初始化.
请问关于Ext对数据进行edit操作时的初始化问题
Rails 下拉框 初始化设定值
使用配置文件初始化activiti数据库
ValueInjecter----最好用的OOM(以微信消息转对象举例)
Java序列化
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!