我已经通过所有SO的解决方案来解决NetworkOnMainThreadException包括ASync类 - 但仍然有问题
这是我的简单代码:
ActivityMain类:
public class MainActivity extends Activity
{
ArrayList<City> alCities = new ArrayList<City>();
Activity activity=null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activity=this;
new MyTask(activity, alCities).execute(); //<--- running ASYNC here
}
}
Run Code Online (Sandbox Code Playgroud)
MyTask类:
public class MyTask extends AsyncTask<Void, Void, ArrayList<City>>
{
ArrayList<City> alCities = null;
Activity ac = null;
public MyTask(Activity activity, ArrayList<City> al) //ctor
{
alCities = al;
this.activity= activity;
}
@Override
protected ArrayList<City> doInBackground(Void... params)
{
try
{
Object myJsonObject …Run Code Online (Sandbox Code Playgroud) 看看这个解构分配(ES6):
var {a, b} = {a:1, b:2}
console.log(b); //2
Run Code Online (Sandbox Code Playgroud)
很显然,a将1和b会2.
巴别塔将其视为:
"use strict";
var _a$b = { a: 1, b: 2 };
var a = _a$b.a;
var b = _a$b.b;
console.log(b);
Run Code Online (Sandbox Code Playgroud)
好.
但看看这段代码:
var { x : { y = 10 } } = { x : 15 };
console.log(y); //10
Run Code Online (Sandbox Code Playgroud)
如你所见,结果是10.根据凯尔辛普森的说法,这里有一种隐含的强制.
题:
这里发生的隐含强制y是10什么?为什么/如何?
我有一个工作代码,该代码通过服务将任何组件注入HTML:
ModalWindow.ts:
@Component({
selector: 'modal-window'
template: `
<div class="modal-dialog" role="document">
<div class="modal-content"><ng-content></ng-content></div>
</div>
`
})
export class ModalWindow {
}
Run Code Online (Sandbox Code Playgroud)
Modalcontent.ts:
@Component({
selector: 'modal-content'
template: `
I'm beeing opened as modal!
`
})
export class ModalContent {
}
Run Code Online (Sandbox Code Playgroud)
ModalService.ts:
/*1*/ @Injectable()
/*2*/ export class ModalService {
/*3*/
/*4*/ constructor(private _appRef: ApplicationRef, private _cfr: ComponentFactoryResolver, private _injector: Injector) {
/*5*/ }
/*6*/
/*7*/ open(content: any) {
/*8*/ const contentCmpFactory = this._cfr.resolveComponentFactory(content);
/*9*/ const windowCmpFactory = this._cfr.resolveComponentFactory(ModalWindow);
/*10*/
/*11*/ const contentCmpt = …Run Code Online (Sandbox Code Playgroud) 我有一个独立的hello组件-包含一个Input
<input type='text' [(ngModel)]='innerValue' />
Run Code Online (Sandbox Code Playgroud)
该组件所做的所有操作(为了简化问题)是添加红色边框
(此组件已在整个应用程序中的许多地方使用。)
但是如果我像这样使用它:
<hello [(ngModel)]="v1.a" ></hello>
{{v1 | json}}
Run Code Online (Sandbox Code Playgroud)
哪里:
public v1 ={a:'123'};
Run Code Online (Sandbox Code Playgroud)
然后最初它具有相同的值:
但是,如果我更改输入值-我看不到反映的值:
我知道我可以传递整个对象v1并v1.a在home组件中使用,但是我想在许多不总是ngModeled的地方使用该文本框v1.a
因此,在香蕉组件中应为:
<hello type='text' [(ngModel)]='myBanana.name' />
Run Code Online (Sandbox Code Playgroud)
在Apple组件中,它应该是:
<hello type='text' [(ngModel)]='myapple.color' />
Run Code Online (Sandbox Code Playgroud)
题:
如何使home组件“支持”任何ngModel值并更新外部模型?
我已阅读Microsoft有关如何检测目标框架的文章,例如:
netcoreapp2.2
net47
net58
Run Code Online (Sandbox Code Playgroud)
但是在某些情况下,我并不关心确切的版本,而是一般的框架目标:
NETCORE
.Net Framework
Run Code Online (Sandbox Code Playgroud)
但是我没有找到这样的标志。
题:
是否有任何通用标记?或更好的是,如何在不指定所有选项的情况下区分这两者?
.net compiler-directives visual-studio .net-core .net-standard
Linqpad 6 支持 .Net Core。
当我在 Visual Studio 中创建一个新的空 .Net Core API 解决方案时,我得到了一个带有简单演示控制器的简单模板。
当我在 Visual Studio 中运行它时,它使用命令行服务器(kestrel)来运行项目:
所以我想看看我是否可以在 Linqpad 6 中运行这个项目。
所以我已经安装了所有 nugets 并将代码复制到 Linqpad :
https://i.stack.imgur.com/lwRyU.png
void Main()
{
CreateWebHostBuilder(new string[] { "" }).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
}
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration …Run Code Online (Sandbox Code Playgroud) 我正在连接到 mongodb 实例,一切正常:
async void Main()
{
string connection = "mongodb://....:27017/authdb?connectTimeoutMS=3000&socketTimeoutMS=3000";
MongoClient client = new MongoClient(connection);
Console.WriteLine(client.Settings.ConnectTimeout );
try
{
client.ListDatabaseNames(); //dummy operation
Console.WriteLine("done");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
00:00:03
done
Run Code Online (Sandbox Code Playgroud)
这意味着查询字符串值已插入到client.Settings.ConnectTimeout属性中。
但现在我想看看我在查询字符串中声明的超时是否有效。所以我要改一个错误的IP地址。
当我更改为错误的 IP 时,30 秒后出现以下异常:
Run Code Online (Sandbox Code Playgroud)A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors =MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector,LatencyLimitingServerSelector{AllowedLatencyRange = 00:00:00.0150000 } }。集群状态的客户端视图为 { ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : …
如何检查我的Visual Studio 2010上是否安装了SP1?
我在"关于"屏幕中找不到它.

例如,在Visual Studio 2005中:
在左侧,我没有看到任何Service Pack,但在右侧窗格中我看到了框架的SP2.
它是一样的吗?是否有框架的服务包和Visual Studio的另一个服务包?或者只有一个框架的服务包?
我用sql写的:
CREATE SYMMETRIC KEY SecureSymmetricKey
WITH ALGORITHM = TRIPLE_DES
ENCRYPTION BY PASSWORD = 'StrongPassword';
Run Code Online (Sandbox Code Playgroud)
DECLARE @str NVARCHAR(1000)
SET @str = 'lala';
OPEN SYMMETRIC KEY SecureSymmetricKey
DECRYPTION BY PASSWORD = 'StrongPassword';
Run Code Online (Sandbox Code Playgroud)
DECLARE @encrypted_str VARBINARY(MAX)
SET @encrypted_str =
EncryptByKey(Key_GUID('SecureSymmetricKey'), @str);
Run Code Online (Sandbox Code Playgroud)
我怎样才能在c#中阅读它?(并在c#中解密)
我有代码:
function (i)
{
alert(i);
}(3);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我没有看到警报.
这个语法是什么意思?
为什么这段代码:
( function (i)
{
alert(i);
}(3))();
Run Code Online (Sandbox Code Playgroud)
有用吗?
有什么不同?
我想念的是什么?
javascript ×4
c# ×3
.net ×2
.net-core ×2
angular ×2
android ×1
asp.net-core ×1
ecmascript-6 ×1
encryption ×1
exception ×1
java ×1
linqpad ×1
mongodb ×1