问题列表 - 第40410页

如何验证集合是否包含所有唯一对象

我有一个C#集合的对象没有实现IEquatable或IComparable.我想检查集合是否包含重复的对象.即我想知道我的列表中的任何x和y的Object.ReferenceEquals(x,y)是否为false.

我该如何有效地做到这一点?

使用C#和LINQ方法会很好.

c# collections

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

ASP.Net Button没有提高回发

我在我们的一个Web应用程序中有一个简单的页面,它有以下标记:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewUpload.aspx.cs" Inherits="Mass_Upload.NewUpload" MasterPageFile="~/Master" Title="Document Mass Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" type="text/css" href="./../CSS/ScrollingTable.css" />
    <script type="text/javascript" src="../Help/HelpPopup.js" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CenterH1" runat="server">
    Document Mass Upload <a href="javascript:loadHelpVid(5)"><img style="Border:None;" src="../Help/help_icon.gif" /></a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CenterBody" runat="server">
    <h3>Add New Upload</h3>
    <table class="list">
        <tr>
            <td class="label" style="text-align:right;">Local File:</td>
            <td class="normal">
                <asp:FileUpload ID="fuFilename" runat="server" Width="405" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="*"
                            ErrorMessage="A file to upload is required"
                            Display="Dynamic"
                            ControlToValidate="fuFilename"
                            ValidationGroup="DocumentUpload"
                            runat="server" />
            </td>
        </tr>
        <tr>
            <td class="label" style="text-align:right;">Document …
Run Code Online (Sandbox Code Playgroud)

c# asp.net postback asp.net-2.0

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

什么是回调方法?

我是一个编程菜鸟,并不太了解回调方法背后的概念.尝试在维基中阅读它并且它超越了我的头脑.有人可以用简单的语言解释一下吗?

language-agnostic methods callback

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

根据Predicate <T>清除List <T>的最可靠方法

我有List<T> dataPredicate<T> condition.

我应该data根据condition结果使用什么方法来清除?

c# linq predicate list

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

PHP可以与各种SQL一起使用吗?

我一直使用mySQL,但最近收到了一份合同规范,要求在ASP.net中构建网站,以便从SQL数据库中读取和写入数据.

我必须这样做吗?或者这是错误的信息?我还可以在PHP中工作并且可以访问SQL数据库吗?

php sql

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

EF4 Code-First导致InvalidOperationException

我每次构建时都试图运行我的项目时遇到问题.似乎初始化程序运行,但是当涉及第一个查询时 - 它会死于以下内容InvalidOperationException.

This operation requires a connection to the 'master' database. Unable to create a
connection to the 'master' database because the original database connection has
been opened and credentials have been removed from the connection string. Supply
an unopened connection.
Run Code Online (Sandbox Code Playgroud)

作为参考,我使用的是直接导入NuGet的EF Code First CTP4.连接到SQL Server 2008 R2

我想要发生的是,如果有任何模型修改,则重新创建数据库,并为查找表提供一些值.这些东西似乎都支持*开箱即用.

我的设置是这样的:

Global.asax中

 protected void Application_Start()
 {
    Database.SetInitializer<CoreDB>(new CoreDBInitialiser());
    // et al...
 }
Run Code Online (Sandbox Code Playgroud)

CoreDB.cs

public class CoreDB : DbContext
{
    public DbSet<User> Users { get; set; }
    public DbSet<Login> …
Run Code Online (Sandbox Code Playgroud)

c# database entity-framework code-first ef-code-first

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

NoSuchMethodError:org.hibernate.SessionFactory.getCurrentSession()

大家好,

我收到这个非常奇怪的错误:

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.getCurrentSession()Lor
g/hibernate/classic/Session;
        at org.cometd.hibernate.util.HibernateUtil.getSessionFactory(HibernateUt
il.java:29)
        at org.cometd.hibernate.util.HibernateUtil.getSession(HibernateUtil.java
:54)
Run Code Online (Sandbox Code Playgroud)

但是这个方法存在于JavaDocs的SessionFactory类中!
我的Eclipse也在自动完成中向我展示了它.
但是其他一些方法,即openSession()或closeSession()工作正确.
问题可以隐藏在哪里?
我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">



    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <overlays>
                        <overlay />
                        <overlay>
                            <groupId>org.cometd.javascript</groupId>
                            <artifactId>cometd-javascript-dojo</artifactId>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.24</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webAppConfig>
                        <contextPath>/sample</contextPath>
                    </webAppConfig>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.cometd.java</groupId>
            <artifactId>cometd-api</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.cometd.javascript</groupId>
            <artifactId>cometd-javascript-dojo</artifactId>
            <version>1.1.2</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.cometd.java</groupId> …
Run Code Online (Sandbox Code Playgroud)

java maven-2 hibernate

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

使用org.apache.commons.httpclient时,我可以在命令行上设置代理吗?

如果应用程序使用java.net.*例程,我可以在调用应用程序时设置代理,如下所示:

java -Dhttp.proxyHost=proxy.server.com -Dhttp.proxyPort=8000 <whatever-the-app-is>
Run Code Online (Sandbox Code Playgroud)

但是,我有一个应用程序(我无法更改)使用org.apache.commons.httpclient来进行http通信.它没有指定procxy服务器,但它确实使用默认的HttpConnection.有什么方法可以从命令行告诉apache http客户端使用代理服务器吗?

java proxy http apache-commons

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

我可以从变量参数函数中提前返回吗?

假设我有两个用于调试输出的C++函数:

void Trace( const wchar_t* format, ... )
{
    va_list args;
    va_start( args, format );
    VarArgTrace( format, args );
    va_end( args );
}

void VarArgTrace( const wchar_t* format, va_list args )
{
    WCHAR buffer[1024];
    //use ::_vsnwprintf_s to format the string
    ::OutputDebugStringW( buffer );
}
Run Code Online (Sandbox Code Playgroud)

以上使用Win32 OutputDebugStringW(),但它并不重要.现在我想优化格式化,以便在没有调试器附加格式化时(我测量 - 加速很重要):

void Trace( const wchar_t* format, ... )
{
    if( !IsDebuggerPresent() ) {
        return;
    }
    //proceed as previously
    va_list args;
    .....
 }
Run Code Online (Sandbox Code Playgroud)

将我提前IsDebuggerPresent()返回一次返回null 的事实会影响除格式化之外的所有内容吗?

我的意思是我不再打电话va_startva_end-这还重要?会跳过va_start …

c++ variadic-functions visual-c++

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

不安全的JavaScript尝试使用URL访问框架

当我尝试从包含另一个域网址的iframe将哈希值设置为父网址时,我收到以下错误:

不安全的JavaScript尝试从URL"URL2"的框架访问URL"URL1"的框架.域,协议和端口必须匹配.

我该如何解决这个问题?

javascript iframe webkit cross-domain

111
推荐指数
4
解决办法
18万
查看次数