这让我疯了.
我有以下代码,当单击一个按钮时,将根据客户端输入文本框(tbxHowMany)的数字填充网格视图.
protected void btnDisplayTopReport_Click(object sender, EventArgs e)
{
if (radPa.Checked)
{
CompleteWeightsDataContext db = new CompleteWeightsDataContext
int max = 0;
if (int.TryParse(tbxHowMany.Text, out max))
{
var queryPa = db.tblOnlineReportingCOMPLETEWeights
.Where (x => x.MaterialLevel == "Primary" && x.MaterialText == "Paper")
.OrderByDescending (x => x.ProductPercentage).Take(max);
GridView1.DataSourceID = "queryPa";
GridView1.DataBind();
}
}
else if (radGl.Checked)
{
CompleteWeightsDataContext db = new CompleteWeightsDataContext
int max = 0;
if (int.TryParse(tbxHowMany.Text, out max))
{
var queryGl = db.tblOnlineReportingCOMPLETEWeights
.Where (x => x.MaterialLevel == "Primary" && x.MaterialText …Run Code Online (Sandbox Code Playgroud) 免责声明:
这是.NET GUI尝试围绕JAVA工作的经典案例.
问题描述:
我正在尝试使用JFace和SWT构建一个非常简单的GUI - 代码很简单(有很多教程),它不是那么简单,我似乎无法让JFace和SWT在插件项目之外工作.
我希望能够在我的项目中使用JFace和SWT没有麻烦,因为我把"C:/ eclipse 3.5/plugins"放在我的CLASSPATH中(从我的计算机 - >属性 - >高级 - >环境变量)以及我在PATH中找到的所有swt - *.dll(可以确定本地用户和全局PATH),如本文在"安装SWT和JFace"框中所示.
问题是我无法从eclipse.org导入任何东西,除非我直接引用buildpath中的jar - > libraries - >添加外部jar(为了构建它我必须添加以下jar:org.eclipse.swt .win32.win32.x86_3.5.1.v3555a.jar,org.eclipse.jface_3.5.1.M20090826-0800.jar).一旦我这样做它构建良好但然后当我作为"Java应用程序"运行时,我得到以下错误(我应该运行其他东西吗?):
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
at demo.ui.test.EntryPoint.main(EntryPoint.java:18)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 1 more
Run Code Online (Sandbox Code Playgroud)
我试图调试它,基本上它会在尝试实例化ApplicationWindow类(org.eclipse.jface.window.ApplicationWindow)时抛出.试图重现错误,我注释掉了我的所有代码并将其替换为我的main中的以下内容,它在第一行引发了与上面相同的错误:
ApplicationWindow w = new ApplicationWindow(null); //<-- error on this line
w.setBlockOnOpen(true);
w.open();
Display.getCurrent().dispose(); …Run Code Online (Sandbox Code Playgroud) 我有一个有趣的XSL场景由你们运行.到目前为止,我的解决方案似乎效率低下(转换时间显着增加),所以我想把它放在那里.
场景 从以下XML我们需要获取每个类别的最新新闻项的ID.
XML 在XML中我有一个新闻项列表,一个新闻类别列表和一个项目类别关系列表.项目列表和项目类别列表也可以是随机顺序(不是按日期排序).
<news>
<itemlist>
<item id="1">
<attribute name="title">Great new products</attribute>
<attribute name="startdate">2009-06-13T00:00:00</attribute>
</item>
<item id="2">
<attribute name="title">FTSE down</attribute>
<attribute name="startdate">2009-10-01T00:00:00</attribute>
</item>
<item id="3">
<attribute name="title">SAAB go under</attribute>
<attribute name="startdate">2008-01-22T00:00:00</attribute>
</item>
<item id="4">
<attribute name="title">M&A on increase</attribute>
<attribute name="startdate">2010-05-11T00:00:00</attribute>
</item>
</itemlist>
<categorylist>
<category id="1">
<name>Finance</name>
</category>
<category id="2">
<name>Environment</name>
</category>
<category id="3">
<name>Health</name>
</category>
</categorylist>
<itemcategorylist>
<itemcategory itemid="1" categoryid="2" />
<itemcategory itemid="2" categoryid="3" />
<itemcategory itemid="3" categoryid="1" />
<itemcategory itemid="4" categoryid="1" />
<itemcategory itemid="4" categoryid="2" />
<itemcategory itemid="2" …Run Code Online (Sandbox Code Playgroud) 我正在使用Listview,我想在视图加载时向下滚动到列表的10项,怎么办????
当一个文件说从浏览器上传100 MB大小时,Spring将整个数据保存在内存中或临时存储在磁盘中.在通过Spring doc之后,我知道如何设置临时目录,但我想知道如果我不提及会发生什么.
我有以下声明:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
Run Code Online (Sandbox Code Playgroud)
豆 :
public class FileHolder {
private MultipartFile file;
public void setFile(MultipartFile file) {
this.file = file;
}
public MultipartFile getFile() {
return file;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的bean中的"file"对象是否会保存100 MB的数据?
在C#中,以下方法将无法编译:
public bool IsItTrue()
{
}
Run Code Online (Sandbox Code Playgroud)
编译器错误:'IsItTrue()':并非所有代码路径都返回一个值,这非常有意义.但是下面的编译没有任何问题.
public bool IsItTrue()
{
while (true)
{
}
}
Run Code Online (Sandbox Code Playgroud)
哪个看起来不对,因为根本没有退货声明.为什么会这样?这里有任何帮助...,
我有一个简单的Windows窗体(C#,. NET 2.0)应用程序,使用Visual Studio 2008构建.
我想支持多种UI语言,并使用表单的"Localizable"属性和特定于文化的.resx文件,本地化方面可以无缝轻松地工作.Visual Studio会自动将特定于文化的resx文件编译为附属程序集,因此在我编译的应用程序文件夹中,存在包含这些附属程序集的特定于文化的子文件夹.
我希望将应用程序部署(复制到位)作为单个程序集,但仍保留包含多组特定于文化的资源的能力.
使用ILMerge(或ILRepack),我可以将附属程序集合并到主可执行程序集中,但标准的.NET ResourceManager回退机制找不到编译到主程序集中的特定于文化的资源.
有趣的是,如果我采用我的合并(可执行)程序集并将其副本放入特定于文化的子文件夹中,那么一切正常!同样,当我使用Reflector(或ILSpy)时,我可以在合并的组合中看到主要和特定于文化的资源.但是将主程序集复制到特定于文化的子文件夹中无论如何都会破坏合并的目的 - 我真的需要只有一个单一程序集的副本......
我想知道是否有任何方法可以劫持或影响ResourceManager回退机制,以在同一个程序集中查找特定于文化的资源,而不是在GAC和文化命名的子文件夹中查找.我看到了以下文章中描述的回退机制,但没有关于它如何被修改的线索:BCL团队关于ResourceManager的博客文章.
有谁有想法吗?这似乎是一个相对常见的在线问题(例如,Stack Overflow上的另一个问题:" ILMerge和本地化资源程序集 "),但我没有在任何地方找到任何权威答案.
按照下面的casperOne的建议,我终于能够做到这一点.
我在这里提出解决方案代码,因为casperOne提供了唯一的答案,我不想添加自己的答案.
通过从"InternalGetResourceSet"方法中实现的Framework资源查找回退机制中拉出内容并使我们的同一组件搜索成为第一个使用的机制,我能够使它工作.如果在当前程序集中找不到资源,那么我们调用基本方法来启动默认搜索机制(感谢下面的@Wouter注释).
为此,我派生了"ComponentResourceManager"类,并且只覆盖了一个方法(并重新实现了一个私有框架方法):
class SingleAssemblyComponentResourceManager :
System.ComponentModel.ComponentResourceManager
{
private Type _contextTypeInfo;
private CultureInfo _neutralResourcesCulture;
public SingleAssemblyComponentResourceManager(Type t)
: base(t)
{
_contextTypeInfo = t;
}
protected override ResourceSet InternalGetResourceSet(CultureInfo culture,
bool createIfNotExists, bool tryParents)
{
ResourceSet rs = (ResourceSet)this.ResourceSets[culture];
if (rs == null) …Run Code Online (Sandbox Code Playgroud) 如果我们有一个人员目录应用程序,我们可以在那里查看特定人员的详细信息(例如,ID为239的人)
http://person-directory.com/detail.jsp?id=239
Run Code Online (Sandbox Code Playgroud)
我们怎样才能在其中创建虚荣网址?即不是输入上面的网址,我们使用
http://person-directory.com/julius
Run Code Online (Sandbox Code Playgroud)
打开ID为239和用户名julius的人的详细信息页面.
谢谢
欧麦尔
我有2个Linq2Sql类:Parent和Child.我想做一些事情,比如删除父母的所有孩子,或更新所有子记录.在SQL中我会写:
delete Child where ParentID = @p
Run Code Online (Sandbox Code Playgroud)
要么
update Child set Val = Val+1 where ParentID = @p
Run Code Online (Sandbox Code Playgroud)
我可以在Linq中以蛮力的方式在Parent课堂内这样做:
Children.ToList().ForEach(c => c.DeleteOnSubmit()); // DeleteOnSubmit is my own method
Run Code Online (Sandbox Code Playgroud)
和
Children.ToList().ForEach(c => c.Val++);
Run Code Online (Sandbox Code Playgroud)
但鉴于Linq对ForEach循环的固有性能损失,这似乎是一种非常低效的方法.是否有某种方法可以实现所需的结束,只会触发一个查询?
c# ×4
.net ×3
java ×3
android ×1
assemblies ×1
classpath ×1
eclipse ×1
java-ee ×1
jface ×1
linq ×1
linq-to-sql ×1
listview ×1
localization ×1
performance ×1
spring-mvc ×1
swt ×1
unicode ×1
url ×1
winforms ×1
xslt ×1