问题列表 - 第12246页

11
推荐指数
2
解决办法
6680
查看次数

如何使用RedirectToRoute?

我在Global.asax.cs中有这个:

routes.MapRoute("BetaAccess", "beta-access", new { controller = "Beta", action = "Index" });
Run Code Online (Sandbox Code Playgroud)

这在我的控制器(HomeController上的索引操作)中肯定会受到打击:

RedirectToRoute("BetaAccess");
Run Code Online (Sandbox Code Playgroud)

但仍然没有重定向...它只是进入正常的主页.我用错了吗?

此外,我可以做Response.Redirect("〜/ beta-access"),然后进入测试页面......

asp.net asp.net-mvc routing redirecttoroute

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

绘制自定义JScrollBar

我想完全改变scollbar的外观但是覆盖JScrollBar并且paintComponent方法不起作用,轨道和拇指被绘制但左右箭头保持不变.
我也在JScrollPane中使用它们并使用
setHorizontalScrollBar( new CustomScrollBar() )将滚动条设置为我的自定义滚动条,但它不能很好地工作,水平滚动条不会改变它的方向,它不会更改为垂直滚动条.

如何绘制一个全新的JScrollBar并在其中使用它JScrollPane

java swing

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

如何使std :: vector的operator []编译在DEBUG中进行边界检查,但不在RELEASE中进行

我正在使用Visual Studio 2008.

我知道std :: vector已经使用at()函数进行边界检查,并且如果您尝试使用operator []错误地访问某些内容(超出范围),则会有未定义的行为.

我很好奇是否可以使用边界检查来编译我的程序.这样,operator []将使用at()函数,并在某些事物超出范围时抛出std :: out_of_range.

将在没有边界检查operator []的情况下编译释放模式,因此性能不会降低.

我开始考虑这个问题,因为我正在将使用Borland C++编写的应用程序迁移到Visual Studio,并且在我的代码的一小部分中将其迁移(i = 0,j = 1):

v[i][j]; //v is a std::vector<std::vector<int> >
Run Code Online (Sandbox Code Playgroud)

向量'v'的大小为[0] [1](因此向量的元素0只有一个元素).这是未定义的行为,我知道,但是Borland在这里返回0,VS正在崩溃.我喜欢崩溃比返回0更好,所以如果我可以通过抛出std :: out_of_range异常得到更多'崩溃',迁移将更快完成(因此它会暴露更多Borland隐藏的错误).

c++ visual-studio-2008 bounds-checker

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

如何从IP地址列表中查找IP地址范围

我有大约20000个IP地址.我期待找到这些IP地址的网络块范围.目的是提供在防火墙中有漏洞的信息,以便允许这些地址.我可以查看abcd/x位格式.可能有几个范围.

更新:我的apache日志文件中已经有IP地址,而不是创建新的.

networking

0
推荐指数
1
解决办法
752
查看次数

从SharePoint字段选择列中检索所有项目

我正在玩一个SharePoint服务器,我正在尝试以编程方式向微软的呼叫中心应用程序模板添加服务请求.到目前为止,我取得了相当不错的成功.我可以为指定客户添加呼叫并分配特定的支持技术:

private enum FieldNames
{
    [EnumExtension.Value("Service Request")]
    ServiceRequest,
    [EnumExtension.Value("Customer")]
    Customer,
    [EnumExtension.Value("Service Representative")]
    ServiceRepresentative,
    [EnumExtension.Value("Assigned To")]
    AssignedTo,
    [EnumExtension.Value("Software")]
    Software,
    [EnumExtension.Value("Category")]
    Category
}
private void CreateServiceCall(string serviceCallTitle, string customerName, string serviceRep)
{
    SPSite allSites = new SPSite(siteURL);
    SPWeb site = allSites.AllWebs[siteName];
    SPListItemCollection requestsList = site.Lists[serviceRequests].Items;
    SPListItem item = requestsList.Add();

    SPFieldLookup customerLookup = item.Fields[FieldNames.Customer.Value()] as SPFieldLookup;

    item[FieldNames.ServiceRequest.Value()] = serviceCallTitle;

    if (customerLookup != null)
    {
        using (SPWeb lookupWeb = allSites.OpenWeb(customerLookup.LookupWebId))
        {
            SPList lookupList = lookupWeb.Lists.GetList(new Guid(customerLookup.LookupList), false);
            foreach (SPListItem listItem in lookupList.Items)
            {
                if …
Run Code Online (Sandbox Code Playgroud)

c# sharepoint

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

有什么办法从墨盒执行DS代码?

据我所知,在DS上运行的代码必须加载到RAM中,因此从已经限制的4M开始.有没有办法直接从图像运行DS代码?

runtime nintendo-ds libnds

5
推荐指数
1
解决办法
354
查看次数

如何加入2个通用IEnumerators

我想知道它是否有可能加入IEnumerable.

基本上我有一大堆用户需要从数据库中获取内容,以便我可以搜索和翻阅它.

我正在使用LINQ to SQL,我的代码目前:

        public IEnumerable<content> allcontent;

        //Get users friends
        IEnumerable<relationship> friends = from f in db.relationships
                                            where f.userId == int.Parse(userId)
                                            select f;

        IEnumerable<relationship> freindData = friends.ToList();

        foreach (relationship r in freindData)
        {
          IEnumerable<content> content = from c in db.contents
                                          where c.userId == r.userId
                                          orderby c.contentDate descending
                                          select c;

         // This is where I need to merge everything together
        }
Run Code Online (Sandbox Code Playgroud)

我希望有道理!

马特

c# linq asp.net

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

你如何在gen_servers中进行选择性接收?

我把我的大部分应用移植到了OTP行为,但是我被卡住了.我无法弄清楚如何使用gen_server进行选择性接收.如果没有回调函数子句与消息匹配,而不是将消息放回邮箱中,则会出错!

现在,无论我走到哪里,人们都会选择接受.我去的每个地方,人们都称赞OTP.你真的不能同时拥有这两个吗?这不是一个重大的,可纠正的缺点吗?

erlang程序员如何处理这个问题?

编辑(回应zed的评论):

这是一个示例,我希望看到按排序顺序打印的整数列表:

-module(sel_recv).
-behaviour(gen_server).

-export([start_link/0]).

-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
     terminate/2, code_change/3]).

-export([test/0]).

start_link() ->
    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

test() ->
    gen_server:cast(?MODULE, test).

init([]) ->
    {ok, 0}.

handle_call(_Request, _From, State) ->
    Reply = ok,
    {reply, Reply, State}.

handle_cast(test, _State) ->
    lists:map(fun(N) ->
                      gen_server:cast(?MODULE, {result, N})
              end, [9,8,7,6,5,4,3,2,1]),
    {noreply, [1,2,4,5,6,7,8,9]};
handle_cast({result, N}, [N|R]) ->
    io:format("result: " ++ integer_to_list(N) ++ "~n"),
    {noreply, R}.

handle_info(_Info, State) ->
    {noreply, State}.

terminate(_Reason, _State) ->
    ok.

code_change(_OldVsn, State, _Extra) ->
    {ok, State}.
Run Code Online (Sandbox Code Playgroud)

当然,在我的真实应用程序中,存在计时器延迟,并且需要按顺序处理的消息与其他消息交错.特别是,我发送了http请求,有时是多次发送,有时一次发送一次,间隔时间间隔.无论如何,我需要按顺序收集它们.

erlang

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

使用LINQ查询文本文件

我有一个简单的文本文件,其中包含一些具有以下结构的CSV:

@Parent1_Field1, Parent1_Field2, Parent1_Field3
Child1_Field1, Child1_Field2
Child2_Field1, Child2_Field2
...etc.
@Parent2_Field1, Parent2_Field2, Parent2_Field3
Child1_Field1, Child1_Field2
Child2_Field1, Child2_Field2
...etc.
Run Code Online (Sandbox Code Playgroud)

'@'表示紧邻其下方的子对象的父对象.(这可以使用XML更好地表示,但在我的情况下,这不是一个选项.)

我的目的是使用LINQ查询此文件而不将其整个内容加载到内存中.首先,我创建了一个实现IEnumerable的类(此处:MyCustomReader),其中我使用StreamReader获取文件的每一行.

例如,以下内容获取所有Parent对象(没有子对象):

from line in MyCustomReader
where line.StartsWith("@")
select Parent.Create(line)
Run Code Online (Sandbox Code Playgroud)

但是,当我想创建涉及Parent和Child对象的查询时,我陷入困境.例如,获取特定父对象的所有子对象或获取特定子字段包含相同值的所有父对象.

例如,这将获取特定Parent对象的所有子项:

public IEnumerable<Child> GetChildrenForAParent(string uniqueParentName)
{
    Parent parent = null;
    foreach (string line in MyCustomReader)
    {
        if (line.StartsWith("@"))
            parent = Parent.Create(line);
        else if (parent.UniqueName == uniqueParentName)
            yield return Child.Create(line);
    }
}
Run Code Online (Sandbox Code Playgroud)

和第二个例子:

public IEnumerable<Parent> GetParentsWhereChildHasThisValue(string childFiledValue)
{
    Parent parent = null;
    foreach (string line in MyCustomReader)
    {
        if (line.StartsWith("@"))
        {
            parent …
Run Code Online (Sandbox Code Playgroud)

c# linq csv text-files

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