小编Nee*_*eta的帖子

从Thread返回值

我有一个方法HandlerThread.一个值在内部发生变化Thread,我想将它返回给test()方法.有没有办法做到这一点?

public void test()
{   
    Thread uiThread = new HandlerThread("UIHandler"){
        public synchronized void run(){
            int value; 
            value = 2; //To be returned to test()
        }
    };
    uiThread.start();
}
Run Code Online (Sandbox Code Playgroud)

java multithreading android

86
推荐指数
6
解决办法
18万
查看次数

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

Firefox和Safari的css3 flexbox兼容性问题

我正在尝试整理我的flexbox布局,以便与最新版本的IE/Firefox/Safari兼容,而且我遇到了Firefox/Safari的问题.

拟议布局:

-----------------
     header
-----------------
    |
    |
    |
nav |  section
    |
    |
    |
    |
Run Code Online (Sandbox Code Playgroud)

在Firefox和Safari <section>下面nav

CSS:

body {
  width:50%;
  height:100%;
  display: -ms-flexbox;
  -ms-box-orient: horizontal;

  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flexbox;
  display: flexbox;

  -webkit-flex-flow: row wrap;
  -moz-flex-flow: row wrap;
  -ms-flex-flow: row wrap;
  flex-flow: row wrap;
}

header {
    padding-top:100px;
    -webkit-flex: 1 100%;
    -moz-flex: 1 100%;
    -ms-flex: 1 100%;
    flex: 1 100%;
}

nav {
    -webkit-flex: 1;
    -moz-flex: 1;
    -ms-flex: 1;
    flex: 1;
    width:10%;
    height:100%;
}

section { …
Run Code Online (Sandbox Code Playgroud)

css layout flexbox

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

如何知道存储图像的SD卡在哪里,DCIM /相机,DCIM/100MEDIA?

我的应用程序中有一个方法,它检索我的DCIM/Camera文件夹中最后保存的图像并将其复制到SD卡上的另一个位置.我刚刚在另一部手机上测试了它,发现默认保存为DCIM/100MEDIA.我怎么能得到这条路?

我最后编写了一些代码,这些代码循环遍历DCIM文件夹中的所有文件夹,并检索lastModified()文件夹的路径.

compatibility android save copying

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

使用可选参数

我有一个带有2个可选参数的方法.

public IList<Computer> GetComputers(Brand? brand = null, int? ramSizeInGB = null)
{
    return new IList<Computer>();
}
Run Code Online (Sandbox Code Playgroud)

我现在正尝试在其他地方使用此方法,我不想指定Brand参数,只是int但我使用此代码时遇到错误:

_order.GetComputers(ram);
Run Code Online (Sandbox Code Playgroud)

我收到的错误:

Error   1   The best overloaded method match for 'ComputerWarehouse.Order.GetComputers(ComputerWarehouse.Brand?, int?)' has some invalid arguments  C:\Users\avmin!\Documents\InnerWorkings Content\630dd6cf-c1a2-430a-ae2d-2bfd995881e7\content\T0062A2-CS\task\ComputerWarehouse\ComputerStore.cs 108 59  ComputerWarehouse
Error   2   Argument 1: cannot convert from 'int?' to 'ComputerWarehouse.Brand?'    C:\Users\avmin!\Documents\InnerWorkings Content\630dd6cf-c1a2-430a-ae2d-2bfd995881e7\content\T0062A2-CS\task\ComputerWarehouse\ComputerStore.cs 108 79  ComputerWarehouse
Run Code Online (Sandbox Code Playgroud)

c# optional-arguments

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

无法解析类型名称.请检查配置文件

尝试使用moq和unity对我的应用程序进行单元测试,我收到的错误是我的服务是一个接口,无法解决:

错误信息:

    Test method Ecommerce_Test.Tests.LoginSuccessfulRedirectToActionLoad threw exception: 
System.InvalidOperationException: The type name or alias Ecommerce_Test.AuthenticationMock could not be resolved. Please check your configuration file and verify this type name.
Run Code Online (Sandbox Code Playgroud)

错误堆栈跟踪:

    Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.TypeResolverImpl.ResolveType(String typeNameOrAlias, Boolean throwIfResolveFails) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\ConfigurationHelpers\TypeResolverImpl.cs: line 110
Microsoft.Practices.Unity.Configuration.RegisterElement.GetMappedType() in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\RegisterElement.cs: line 128
Microsoft.Practices.Unity.Configuration.RegisterElement.ConfigureContainer(IUnityContainer container) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\RegisterElement.cs: line 0
Microsoft.Practices.Unity.Configuration.ContainerElement.<>c__DisplayClass1.<ConfigureContainer>b__0(ContainerConfiguringElement element) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\ContainerElement.cs: line 114
Microsoft.Practices.ObjectBuilder2.EnumerableExtensions.ForEach[TItem](IEnumerable`1 sequence, Action`1 action) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Utility\EnumerableExtensions.cs: line 36
Microsoft.Practices.Unity.Configuration.ContainerElement.ConfigureContainer(IUnityContainer container) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\ContainerElement.cs: line 110
Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.Configure(IUnityContainer container, String configuredContainerName) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity.Configuration\Src\UnityConfigurationSection.cs: line 151
Microsoft.Practices.Unity.Configuration.UnityContainerExtensions.LoadConfiguration(IUnityContainer container, UnityConfigurationSection section, …
Run Code Online (Sandbox Code Playgroud)

unit-testing moq unity-container unity2.0

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

无法查看我的新MVC 4应用程序

我刚刚在VS 2010中创建了一个新的基本MVC 4应用程序.我只是单击了播放按钮来测试它在Web浏览器中出现并且我得到以下页面:

在此输入图像描述

我想我需要改变我的虚拟路径,但我不知道是什么.

编辑:无法在图片中看到它说的正确:

Server Error in '/' Application.
--------------------------------------------------------------------------------


The resource cannot be found. 
  Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

 Requested URL: /
Run Code Online (Sandbox Code Playgroud)

visual-studio-2010 asp.net-mvc-4

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

从Linq查询返回IEnumerable <string>

我正在尝试IEnumerable<string>从linq查询返回一个我收到错误:无法转换IEnumerable<AnonymousType>IEnumerable<string>

我不知道如何解决这个问题.

private IEnumerable<string> GetAllMembers(Type type)
        {    

            var query =
                (from member in type.GetMembers()
                 select new
                 {
                     Member = member.GetType() + " " + member.ToString()

                 }
                );

            return query;
        }
Run Code Online (Sandbox Code Playgroud)

c# linq ienumerable

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

通过 JMeter JSR223 采样器表单提供参数的正确语法是什么?

我似乎找不到任何与此相关的文档,是不是很简单:

//option 1
${something},${something1}
//option 2
123,234,762
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激。

jmeter jsr223 parameter-list

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

不能'推'到阵列

我试图将一个元素推到这个数组的末尾,我得到一个我不明白的错误.

main.rb的:

require 'shop.rb'
so = Shop.new()
so.get(2)
so.get(1)
Run Code Online (Sandbox Code Playgroud)

shop.rb

class Shop

    def new()
       @products = []
    end


    def get(product)
       @products.push(product)
    end
end
Run Code Online (Sandbox Code Playgroud)

错误:

NoMethodError: undefined method `push' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)

ruby arrays

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

asp.net授权 - 除登记页面外,在登录前拒绝所有内容

我正在使用ASP.NET授权在登录前拒绝用户访问我的网站,但这也阻止了Register.cshtml页面.如何整理授权以允许此页面通过?

<system.web>
<authorization>
      <deny users="?" />
    </authorization>
  </system.web>

  <location path="Content">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>

  <location path="Register.cshtml">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc authorization

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

理解LINQ查询 - 按升序排序

我不明白为什么代码A是正确的,代码B是不正确的:

代码A.

IEnumerable<decimal> loanQuery = 
from amount in loanAmounts
where amount % 2 == 0
orderby amount 
select ascending amount //this line
Run Code Online (Sandbox Code Playgroud)

代码B(不正确)

IEnumerable<decimal> loanQuery = 
from amount in loanAmounts
where amount % 2 == 0
select amount 
orderby ascending amount
Run Code Online (Sandbox Code Playgroud)

由于很多人都回答不正确,我现在发布了正确的代码:

IEnumerable<decimal> loanQuery = 
from amount in loanAmounts
where amount % 2 == 0
orderby amount ascending
select amount
Run Code Online (Sandbox Code Playgroud)

c# linq

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