当我初始化Angular-cli项目时,我没有systemjs.config.ts文件.
在许多角度插件中,提到了适应systemjs.config.ts.示例说明:
并将这些行添加到systemjs.config.js:
var map = {
'angular2-tree-component': 'node_modules/angular2-tree-component',
'lodash': 'node_modules/lodash',
};
var packages = {
'angular2-tree-component' : { main: 'dist/angular2-tree-component.js', defaultExtension: 'js' },
'lodash' : { main: 'lodash.js', defaultExtension: 'js' },
};
Run Code Online (Sandbox Code Playgroud)
那么systemjs.config.js在哪里?
这是一个标准的angular-cli创建README.md
create src/app/app.component.css
create src/app/app.component.html
create src/app/app.component.spec.ts
create src/app/app.component.ts
create src/app/app.module.ts
create src/app/index.ts
create src/app/shared/index.ts
create src/environments/environment.prod.ts
create src/environments/environment.ts
create src/favicon.ico
create src/index.html
create src/main.ts
create src/polyfills.ts
create src/styles.css
create src/test.ts
create src/tsconfig.json
create src/typings.d.ts
create angular-cli.json
create e2e/app.e2e-spec.ts
create e2e/app.po.ts
create …Run Code Online (Sandbox Code Playgroud) 以下代码让我困惑:
Object[] arr1 = new String[]{"a", "b", "c"};
Object[] arr2 = {"a", "b", "c"};
String[] a = (String[]) arr1; // ok
String[] b = (String[]) arr2; // ClassCastException
System.out.println(arr1.getClass().getName()); // [Ljava.lang.String;
System.out.println(arr2.getClass().getName()); // [Ljava.lang.Object;
Run Code Online (Sandbox Code Playgroud)
我试图理解为什么两个初始化彼此不同.第一个是帖子声明,第二个是捷径.这两个都被宣布为Object[]
我天真的理解是:
Object[] arr2 = {"a", "b", "c"}; // is a syntax sugar of
Object[] arr2 = new Object[] {"a", "b", "c"};
Run Code Online (Sandbox Code Playgroud)
因此运行时类型arr2正好Object[]无法转换为String[].
但是,事情就变得怪怪的,因为Java数组是协变:
String[]是的子类Object[],并arr2确切地是String[],从后面投射Object[]到String[]上arr2应该工作.
对此的任何解释都非常感谢.
我想DataGridView在Windows窗体上对具有相同名称的行进行分组,这是我想要实现的图像.
是否可以在不使用任何第三方工具的情况下实施?


将以下 xml 文件的元素和属性加载到树视图后,编辑节点并将树视图保存回同一个 xml 文件中。所有元素和属性都需要保存。然而,只有嵌套元素的属性在保存过程中消失。保存后,元素d和e的所有属性都丢失了!这是因为我无法检索存储在 addTreeNode 函数中标记属性中的属性值。(请参阅内联注释)有谁知道更简单或更干净的方法来实现此目的?提供代码片段会很有帮助。
XML 结构:
<?xml version="1.0" encoding="utf-8"?>
<root>
<a axa="1" axb="2" axc="3">content_of_tag _a</a>
<b bxa="10" bxb="20" bxc="30">content_of_tag_b</b>
<c cxa="11" cxb="21" cxc="31">
content_of_tag_c
<d dxa="101" dxb="201" dxc="301">
content_of_tag_d
<e exa="110" exb="210" exc="310">
content_of_tag_e
</e>
</d>
</c>
</root>
Run Code Online (Sandbox Code Playgroud)
C#代码:
private void Xml2TreeNode(XElement xNode, TreeNode treeNode)
{
if (xNode.HasElements) //if node has children
{
TreeNode tNode = null;
int i = 0;
foreach (XElement subNode in xNode.Elements())
{
if (subNode.Descendants().Count() > 0)
{
TreeNode tn = treeNode.Nodes.Add(subNode.Name.ToString().Trim());
tn.Nodes.Add(new …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中添加了一个JWT中间件:
app.UseJwtBearerAuthentication(options => { options.AutomaticAuthenticate = true;} )
Run Code Online (Sandbox Code Playgroud)
现在,如果我的令牌未验证(例如已过期),我仍然会收到生命周期验证未通过的错误.有没有办法让中间件仅为受保护资源验证令牌?如果没有,那么我应该如何以及在哪里调用自己的中间件(将令牌读入HttpContext.User)?
PS这是我添加保护的方式:
services.AddMvc(config =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
config.Filters.Add(new AuthorizeFilter(policy));
});
Run Code Online (Sandbox Code Playgroud)
这就是我允许公共访问的方式:
[HttpGet]
[AllowAnonymous]
public string Get(int id)
{
}
Run Code Online (Sandbox Code Playgroud)
澄清:如果没有令牌,这将有效,但如果令牌无效(例如已过期),即使公共资源将无法访问,也会抛出500(由于某些内部错误导致401应该真的存在).
我有一个大问题。我使用 C# 开发 UWP Windows 10 应用程序,我想使用 OAuth 1。
一切都差不多了,但签名是错误的。不过,我在 Microsoft GitHub 上找到了示例代码。显然,我做了一些修改......
我的代码:
private async Task GoCo()
{
String LifeInvaderUrl = "http://stage.api.lolilolz.be/v8/login";
string timeStamp = GetTimeStamp();
string nonce = GetNonce();
string consumerKey = "noob-stage";
string consumerSecret = "TOPSECRETxxXXxx";
string SigBaseStringParams = "oauth_consumer_key=" + consumerKey;
SigBaseStringParams += "&" + "oauth_signature_method=HMAC-SHA1";
SigBaseStringParams += "&" + "oauth_timestamp=" + timeStamp;
SigBaseStringParams += "&" + "oauth_nonce=" + nonce;
SigBaseStringParams += "&" + "oauth_version=1.0";
string SigBaseString = "POST&";
SigBaseString += Uri.EscapeDataString(LifeInvaderUrl) + "&" + Uri.EscapeDataString(SigBaseStringParams); …Run Code Online (Sandbox Code Playgroud) 在IIS 8.5,Asp.net核心上部署应用程序
3个应用程序,前端,API和登录(在同一站点上);
所有3个都在VS2015的IIS Express中完美地工作;
前端(只有html/AngularJS)和API在IIS 8.5上运行良好
但是对于Login(IdentityServer4):
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
- ~/UI/Home/Views/Index.cshtml
- ~/UI/SharedViews/Index.cshtml
Run Code Online (Sandbox Code Playgroud)
我明白'〜/'是指批准;
我的VS2015结构:

经测试/检查:
CustomViewLocationExpander:
public class CustomViewLocationExpander : IViewLocationExpander {
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations){
yield return "~/UI/{1}/Views/{0}.cshtml";
yield return "~/UI/SharedViews/{0}.cshtml";
}
public void PopulateValues(ViewLocationExpanderContext context)
{
}
}
Run Code Online (Sandbox Code Playgroud)我可以在'wwwroot'上免费访问所有内容js/images/css
我对这一点毫无头绪.
我创建了一个ASP.NET MVC Core项目并注册了一些自定义文件夹来搜索Views.我用这样的自定义IViewLocationExpander类做了这个:
public class AppsViewLocationExpander : IViewLocationExpander
{
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context,
IEnumerable<string> viewLocations)
{
yield return "/MyViewLocation/A/Views";
//and so on...
}
Run Code Online (Sandbox Code Playgroud)
并在Startup.cs中使用此类:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new AppsViewLocationExpander());
});
}
Run Code Online (Sandbox Code Playgroud)
在MyViewLocation/A/Views文件夹中有一些*.cshtml文件,本地调试会话继续进行,没有任何错误.现在我将Web应用程序发布到Azure,我收到了500内部服务器错误.我附加Visual Studio来调试此错误并收到此消息:
System.InvalidOperationException:找不到视图"索引".搜索了以下位置:/
MyViewLocation/A/Views/Index.cshtml
我错了什么?我是否还必须在其他地方添加Views-Folder?
编辑:
我在初始设置时修改了我的project.json,但这对我的Azure问题没有帮助.但可能有必要在我本地调试期间找到视图.
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"MyViewLocation/**/Views",
"appsettings.json",
"web.config"
]
},
Run Code Online (Sandbox Code Playgroud)
编辑2:
我手动将*.cshtml文件上传到FTP服务器.然而,他们仍然没有找到.
尝试将数据绑定到下拉列表,但不绑定任何内容,下拉列表显示 NOTHING SELECTED.
<select #classProductTypeCombobox
name="classProductTypeCombobox"
class="form-control col-md-3"
[(ngModel)]="classification.codeType"
[attr.data-live-search]="true"
jq-plugin="selectpicker"
required>
<option *ngFor="let classType of classificationTypes"
[value]="classType">{{classType}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
角度代码:
getClassificationTypes(): void {
//need to remove hard coding
this._commonService.getLookupItems(1, 6).subscribe((result) => {
this.classificationTypes= result.items;
});
}
ngOnInit(): void {
this.getClassificationTypes();
}
Run Code Online (Sandbox Code Playgroud)
当我尝试调试代码时,classificationTypes有适当的数据,我用作硬编码值的相同数据.它工作正常.
方法getClassificationTypes是调用API从数据库中获取数据.
我正在使用ASP.NET Zero框架编写此应用程序.
我尝试了以下解决方案.这是将数据绑定到下拉列表,但是下拉列表的自动搜索功能已经消失,它显示简单的下拉列表.并在控制台中,它提供以下错误消息.
getClassificationTypes(): any {
return this._commonService.getLookupItems(2, 6).subscribe((result) => {
console.log(result.items)
return this.classificationTypes = result.items;
});
}
classificationTypes: TaxonomyItemsLocDto[] = this.getClassificationTypes();
ERROR Error: Cannot find a differ supporting object '[object Object]' …Run Code Online (Sandbox Code Playgroud) 当我放入postgres -D /usr/local/var/postgres终端时,我得到了回复:
日志:无法将主机名"localhost",服务"5432"转换为地址:提供的nodename或servname,或者未知
警告:无法为"localhost"创建监听套接字
FATAL:无法创建任何TCP/IP套接字
有人可以帮我解决这个问题吗?
c# ×4
angular ×2
oauth ×2
angular-cli ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
azure ×1
casting ×1
datagridview ×1
iis-8.5 ×1
java ×1
jwt ×1
linq-to-xml ×1
osx-yosemite ×1
postgresql ×1
signature ×1
treeview ×1
typescript ×1
view ×1
windows ×1
winforms ×1
xml ×1