长类名会影响 XAP 文件的大小吗?
我的 Silverlight 应用程序中有一个自定义控件,它被放置在画布上大约一千次。我担心这个应用程序的 XAP 文件的大小。
XAP 文件是否会明确包含相同数量的该控件的名称?我可以通过将自定义控件的名称从 10 个字母更改为仅 2 个字母来减小 XAP 文件的大小吗?如何计算类名长度对 XAP 文件最终大小的影响?
There is a custom control in my Silverlight application, which is put on the canvas about one thousand times. I'm concerned about the size of a XAP file of this app.
Will XAP file contain explicitely the names of this control in the same quantity? Will I reduce the size of the XAP file by changing the name of the custom control from, say, 10 letters to only 2 letters. How I can calculate the impact of the length of the class names on the final size of the XAP file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简单的答案:你可以测试一下。构建 XAP 文件,重命名类,重建 XAP 文件,然后查看大小差异(如果有)。
我希望类的名称在元数据中只出现一次,但如果您在 XAML 中为实例提供长名称,那么可能不同之处。
Simple answer: you could test it. Build your XAP file, rename the class, rebuild the XAP file, and see what the size difference is, if any.
I'd expect the name of the class to only occur once in the metadata, but if you're giving long names to the instances in the XAML, that may make a difference.
如果尺寸对您来说很重要,我认为您担心的是错误的事情。与名称太长相比,您更有可能包含未使用的代码、DLL 或大型资源。请记住,文件是压缩的,并且文本压缩非常好,因此重复相同的长控件名称 1000 次的影响很小。
另外,不要忘记使用更好的 zip 软件重新压缩您的 XAP 文件(因为 Visual Studio 构建的 XAP 文件中的 zip 压缩不是最佳的!)
您最好不要担心渐进式加载,因为大多数 Silverlight 应用程序都在那里太大了(并且比大多数网络用户预期/建议的 8 秒注意力持续时间要长)。
If size is important to you I think you are worrying about the wrong thing. You are more likely to include unused code, or DLLs, or large resources, than have names that are too long. Remember the file is zipped and text compression is very good so the effect of repeating the same long control name 1000s of times is minimal.
Also don't forget to re-zip your XAP files with better zip software (as the zip compression you get in XAP files built by Visual Studio is not optimal!)
You are much better off worrying about progressive loading as most Silverlight apps out there are way too bulky (and take way more than the expected/recommended 8 second attention span of most web-users).
XAP 文件只是一个包含已编译的二进制文件的 ZIP 文件。您的 XAML 文件作为资源嵌入到这些编译的二进制文件中。
所以是的 - 控件名称的长度将影响 XAP 文件的文件大小。
多少钱是另一个问题。 XAP 文件是压缩的 ZIP 文件。作为一个例子,我有一个包含 2 个 DLL 的 XAP 文件。一个从 282k 压缩到 94k,另一个从 46k 压缩到 16k。
然而,我更担心为什么你的控件在单个页面中出现 1000 次。当然必须有更好的方法来做到这一点。也许甚至用代码来做会更容易/更好?
A XAP file is just a ZIP file containing your compiled binaries. Your XAML files are embedded as resources in those compiled binaries.
So yes - the length of the name of your control will affect the file size of your XAP file.
How much is a different question. The XAP file is a compressed ZIP file. As an example I have a XAP file with 2 DLLs in. One compressed down from 282k to 94k, the other from 46k to 16k.
I would worry more about why your control appears 1000 times in a single page however. Surely there must be a better way of doing this. Perhaps even doing it in code would be easier/better?