小编Joh*_*ith的帖子

如何在java中获取类注释?

我创建了自己的注释类型,如下所示:

public @interface NewAnnotationType {}
Run Code Online (Sandbox Code Playgroud)

并将其附加到班级:

@NewAnnotationType
public class NewClass {
    public void DoSomething() {}
}
Run Code Online (Sandbox Code Playgroud)

我尝试通过这样的反射得到类注释:

Class newClass = NewClass.class;

for (Annotation annotation : newClass.getDeclaredAnnotations()) {
    System.out.println(annotation.toString());
}
Run Code Online (Sandbox Code Playgroud)

但它不打印任何东西.我究竟做错了什么?

java reflection annotations

40
推荐指数
1
解决办法
4万
查看次数

"call"和"invoke"之间有什么区别?

我正在读Daniel M. Solis的一本名为"Illustrated C#2010"的书.这本书说:

"当调用或调用方法时......"

这两个术语有什么区别?

c# terminology

37
推荐指数
3
解决办法
3万
查看次数

自定义视觉工作室2013主题

我安装了Visual Studio 2013,将其设置为黑暗主题,并导入了黑曜石风格的儿子设置.现在它看起来像这样:

我的视觉工作室

我想要实现的是摆脱恼人的白条,在黑曜石设置的儿子被导入之前一直是黑暗的.

你知道我在设置的哪个位置可以设置这个栏的颜色吗?

settings themes visual-studio-2013

22
推荐指数
2
解决办法
4万
查看次数

Windows XP上的visual studio 2013

是否可以在Windows XP上运行Visual Studio 2013?

我听说在Windows XP上安装.NET Framework 4.5是不可能的.如果我想在Windows XP上使用Visual Studio 2013 for .NET 4.0,该怎么办?

这可能吗?

windows-xp .net-4.0 .net-4.5 visual-studio-2013

15
推荐指数
1
解决办法
3万
查看次数

获取实体框架中属性的映射列名称

在我的项目中,我使用Entity Framework 6.我有这些实体:

   public class Person
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }

        public virtual ICollection<PersonRight> PersonRights { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

 public class PersonRight
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }
    }
Run Code Online (Sandbox Code Playgroud)

当我插入一个填充了PersonRights的person对象时,它在数据库中看起来像这样:

人员实体的表格:

dbo.People with columns Id, Name
Run Code Online (Sandbox Code Playgroud)

PersonRights实体的表

dbo.PersonRights with columns Id, Name, Person_Id
Run Code Online (Sandbox Code Playgroud)

当我从数据库加载一个人时,它没有填充PersonRights属性,因为虚拟关键字使得延迟加载功能变得很好 - 而且没关系.

然后我得到person对象的PersonRights,它也可以正常工作.

问题是,由于PersonRight实体中没有导航属性,因此实体框架必须知道数据库中哪些列是有界的两个属性.在数据库中,ther是连接PersonRights和People表的外键:

FK_dbo.PersonRights_dbo.People_Person_Id
Run Code Online (Sandbox Code Playgroud)

问题是:有没有办法如何获取列名称,这两个属性是连接的?如何在代码中获取字符串"Person_Id"?

有一种方法可以找出哪个表是数据库中的实体:

http://www.codeproject.com/Articles/350135/Entity-Framework-Get-mapped-table-name-from-an-ent

非常感谢你的回答 :)

编辑:

我发现列名称属性在这里:

  var …
Run Code Online (Sandbox Code Playgroud)

c# sql entity-framework

9
推荐指数
1
解决办法
2万
查看次数

绑定到WPF中的扩展方法

我在C#中有一个简单的类:

public class Dog {
    public int Age {get; set;}
    public string Name {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

我创建了一个像这样的扩展方法:

public static class DogExt {
    public static string BarkYourName(this Dog dog) {
        return dog.Name + "!!!";
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法将BarkYourName方法的结果绑定到wpf组件?

基本上:有什么方法可以将它绑定到扩展方法?

c# wpf extension-methods binding

7
推荐指数
2
解决办法
5918
查看次数

cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'mvc:annotation-driven'的声明

我想这是一个xml解析问题,但我无法看到它在哪里.我读了一些关于这个主题的文章并没有任何帮助:

我有这个春天的mvc配置:

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:mvc="http://www.springframework.org/schema/mvc" 
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
       http://www.springframework.org/schema/aop 
       http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-4.0.xsd 
       http://www.springframework.org/schema/security
       http://www.springframework.org/schema/mvc 
       http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-4.0.xsd"
       >

    <mvc:annotation-driven />
    <context:component-scan base-package="controllers" />


    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" /> 

</beans>
Run Code Online (Sandbox Code Playgroud)

这是tomcat所说的:

org.xml.sax.SAXParseException; lineNumber: 23; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:458)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3237)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1917)
    com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:766)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:356)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848) …
Run Code Online (Sandbox Code Playgroud)

java xml spring spring-mvc xml-parsing

4
推荐指数
1
解决办法
2万
查看次数

log4net - 如何仅记录某些命名空间中的错误

有没有办法登录log4net来自某个命名空间的所有消息,但只有来自其他每个命名空间的错误?

我通过LoggerMatchFilter尝试了它,但似乎这个过滤器不能用日志级别操作.

.net logging log4net namespaces filter

2
推荐指数
1
解决办法
1400
查看次数