我试图触发绑定到布尔属性的转换,但这似乎没有触发.
这是我的动画触发器的缩减版本
trigger(
'trueFalseAnimation', [
transition('* => true', [
style({backgroundColor: '#00f7ad'}),
animate('2500ms', style({backgroundColor: '#fff'}))
]),
transition('* => false', [
style({backgroundColor: '#ff0000'}),
animate('2500ms', style({backgroundColor: '#fff'}))
])
]
)
Run Code Online (Sandbox Code Playgroud)
HTML:
<div [@trueFalseAnimation]="model.someProperty">Content here</div>
Run Code Online (Sandbox Code Playgroud)
去测试:
ngOnInit() {
setTimeout(() => {
this.model.someProperty = true;
setTimeOut(() => {
this.model.someProperty = false;
}, 5000);
}, 1000)
}
Run Code Online (Sandbox Code Playgroud)
someProperty更改时,触发器永远不会发生.
作为一个快速测试我更改了触发器以使用字符串,它的工作原理
trigger(
'trueFalseAnimation', [
transition('* => Success', [
style({backgroundColor: '#00f7ad'}),
animate('2500ms', style({backgroundColor: '#fff'}))
]),
transition('* => Failed', [
style({backgroundColor: '#ff0000'}),
animate('2500ms', style({backgroundColor: '#fff'}))
])
]
)
Run Code Online (Sandbox Code Playgroud)
去测试: …
我知道这些帖子很多,我之前已经处理过这些问题,除了这次之外没有任何问题.这是因为我无法从Windows Azure中获取所需的调试信息,并希望有人能够帮助我.
这一切都在我的本地环境,调试和发布中完美无缺.
我收到此错误:无法加载文件或程序集"Lib"或其依赖项之一.尝试加载格式不正确的程序.
Lib确实存在于目录中,它仅依赖于System.Drawing和mscorlib.
通常我会AppDomain.Current.AssemblyResolve在它抛出时附加或检查异常.我无法使用Azure执行此操作,因为异常发生在预加载期间.
[BadImageFormatException: Could not load file or assembly 'Lib' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr …Run Code Online (Sandbox Code Playgroud) 所有,
我有一个安全服务器,其唯一目的是从单个端点提供承载令牌:http://example.com/token
示例请求:
POST http://example.com/token HTTP/1.1
User-Agent: Fiddler
Content-Type: x-www-form-urlencoded
Host: example.com
Content-Length: 73
grant_type=password&username=example@example.com&password=examplePassword
Run Code Online (Sandbox Code Playgroud)
响应示例:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Expires: -1
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Tue, 16 Aug 2016 12:04:39 GMT
{
"access_token": "xxxx",
"token_type": "bearer",
"expires_in": 17999,
"refresh_token": "xxxx",
".issued": "Tue, 16 Aug 2016 12:04:38 GMT",
".expires": "Tue, 16 Aug 2016 17:04:38 GMT"
}
Run Code Online (Sandbox Code Playgroud)
我们有一个角度应用程序,它使用此端点进行身份验证,并且这样做很好.
我们试图在没有太大成功的情况下实现的是创建一个使用相同服务器进行身份验证的MVC应用程序,我们希望代码尽可能位于Identity 2.0之上.
在我们的AccountController(示例项目)中,我们有Login(LoginModel model)处理登录的方法,看起来像这样(与示例项目模板相同):
var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, …Run Code Online (Sandbox Code Playgroud) 所有,
这是代码:
var Person = function (name) {
this.name = name;
this.printName = function(){
console.log("My name is " + this.name);
}
};
var p = new Person("Steve");
var funcRef = p["printName"];
p.printName();//Works
p["printName"]();//Works
funcRef();//returns incorrect value
Run Code Online (Sandbox Code Playgroud)
在这里找到一个有用的例子:http://plnkr.co/edit/57LS6oXPfqccAWf6uqQV?p = preview
我的问题是最后两个之间有什么区别?我以相同的方式访问对象方法,唯一的区别是它被调用的方式.
为什么会返回差异结果?
我第一次在javascript中遇到过这个问题.我知道这是在一个不同的范围,但我不知道它是如何与我想要了解的对象分离.
谢谢
史蒂夫
批量上传文件Azure Blob存储的最快方法是什么?我试过两种方法,sync并async上传,async显然是最快的,但我不知道是否有更好的方法?是否内置了对批量上传的支持?我在文档中找不到任何内容但可能错过了它.
这是我跑的测试:
static void Main(string[] args)
{
int totalFiles = 10; //10, 50, 100
byte[] randomData = new byte[2097152]; //2mb
for (int i = 0; i < randomData.Length; i++)
{
randomData[i] = 255;
}
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
var blobClient = cloudStorageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("something");
container.CreateIfNotExists();
TimeSpan tsSync = Test1(totalFiles, randomData, container);
TimeSpan tsAsync = Test2(totalFiles, randomData, container);
Console.WriteLine($"Sync: {tsSync}");
Console.WriteLine($"Async: {tsAsync}");
Console.ReadLine();
}
public static TimeSpan Test2(int total, byte[] …Run Code Online (Sandbox Code Playgroud) 如果我使用实体框架作为MVC Web API的后端,一个控制器可能看起来像这样(快速模型):
public class PersonController : ApiController
{
[HttpPost]
public void AddPerson(Person val)
{
DbContext context = new DbContext();
if(!context.Persons.Any(x=>x.Email == val.Email))
{
context.Persons.Add(val)
context.SaveChanges();
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题在于,如果此操作被称为50,每隔几秒100次(可能不是一个好例子),则很可能可以使用相同的电子邮件地址添加多个条目.
如果val参数是一个列表,Person您可以检查changetracker以查看是否有人在您之前添加了电子邮件地址,SaveChanges()但是当您有来自不同来源的大量呼叫时,这不起作用.
你不能有一个静态DBContext,因为它会抛出一个异常,说它很忙.
我想到的一个想法是相同的设置,但有一个静态方法,它返回一个实例(相同的实例),dbcontext但lock()在其上创建一种类似的队列,但这可能会影响性能,这不是一个好主意.
你怎么解决这个问题?
这个例子与我正在做的事情无关,只是简单地解释一下这个场景.我猜它也不一定具体.
谢谢
史蒂夫
c# entity-framework duplicates asp.net-web-api asp.net-web-api2
因为无法保证解决模块的顺序,所以我遇到了一些问题:
我有一个注册到一个模块ScheduleService这ScheduleService是负责在设定的时间间隔等的触发事件
我可以加载不同的IScheduable项目,我这样做使用XML Configuration.我遇到的问题是,IScheduable物品需要IScheduleService准备好才能注册它自己.
所以在我的<autofac><modules>身上
<module type="Namespace.ScheduleServiceModule, Namespace" />
Run Code Online (Sandbox Code Playgroud)
然后我的想法是我可以装入尽可能多的不同ISchedulable物品
<module type="SomeNamespace.ScheudleItem1, SomeNamespace />
<module type="SomeNamespace.ScheudleItem2, SomeNamespace />
<module type="SomeNamespace.ScheudleItem3, SomeNamespace />
<module type="SomeNamespace.ScheudleItem4, SomeNamespace />
Run Code Online (Sandbox Code Playgroud)
目前这是我在那些scheduleitem模块中的方式:
protected override void Load(ContainerBuilder builder)
{
builder.RegisterCallback(registry =>
{
var scheduleService = new TypedService(typeof(IScheduleService));
var registrations = registry.RegistrationsFor(scheduleService);
if (registrations != null && registrations.Any())
{
IComponentRegistration componentRegistration = registrations.First();
componentRegistration.Activated += (sender, args) =>
{
IScheduleService scheduleService …Run Code Online (Sandbox Code Playgroud) 我收到以下错误
参数"p"未绑定在指定的LINQ to Entities查询表达式中.
我理解这个问题(ParameterExpression应该与树中的所有表达式一起使用的相同实例)并尝试使用我在网上找到但没有运气的解决方案.
这是我的方法
private void SeedEntity<TEntity>(DatabaseContext context, ref TEntity entity, params Expression<Func<TEntity, object>>[] identifierExpressions) where TEntity : class
{
Expression<Func<TEntity, bool>> allExpresions = null;
var parameters = identifierExpressions.SelectMany(x => x.Parameters).GroupBy(x => x.Name).Select(p => p.First()).ToList();
foreach (Expression<Func<TEntity, object>> identifierExpression in identifierExpressions)
{
Func<TEntity, object> vv = identifierExpression.Compile();
object constant = vv(entity);
ConstantExpression constExp = Expression.Constant(constant, typeof(object));
BinaryExpression equalExpression1 = Expression.Equal(identifierExpression.Body, constExp);
Expression<Func<TEntity, bool>> equalExpression2 = Expression.Lambda<Func<TEntity, bool>>(equalExpression1, parameters);
if (allExpresions == null)
{
allExpresions = equalExpression2; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将父组件中的函数绑定到子组件的属性中.
这就是我所拥有的
@Component({
selector: 'awesome',
templateUrl: 'awesome.html'
})
export class AwesomeComponent {
@Input() callback: Function;
ngOnInit() {
this.callback();//Error, this.callback is not a function, but contains a string value on the fuction call
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我使用它的方式
<awesome callback="nameOfFuncFromAnotherComponent"></awesome>
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用
在构建插入到简单链接表中的存储过程时,是否应检查FK是否存在并正常返回错误或只是让SQL抛出异常?
以防万一有人不理解我的问题:
Table A Table B Table AB我应该这样做:
IF EXISTS(SELECT 1 FROM A WHERE Id = @A) AND EXISTS(SELECT 1 FROM B WHERE Id = @B)
BEGIN
INSERT AB (AId,BId) VALUES (@A, @B)
END
ELSE
--handle gracefully, return error code or something
Run Code Online (Sandbox Code Playgroud)
要么
INSERT AB (AId,BId) VALUES (@A, @B)
Run Code Online (Sandbox Code Playgroud)
并让SQL抛出异常
谢谢
c# ×5
.net ×3
angular ×2
typescript ×2
asp.net-mvc ×1
autofac ×1
azure ×1
duplicates ×1
javascript ×1
owin ×1
scope ×1
sql ×1
sql-server ×1
this ×1