我有这个代码:
using System.Collections;
using System.Windows;
using System.Windows.Controls;
public static class SelectedItems
{
private static readonly DependencyProperty SelectedItemsBehaviorProperty = DependencyProperty.RegisterAttached(
"SelectedItemsBehavior",
typeof(SelectedItemsBehavior),
typeof(ListView),
null);
public static readonly DependencyProperty ItemsProperty = DependencyProperty.RegisterAttached(
"Items",
typeof(IList),
typeof(SelectedItems),
new PropertyMetadata(null, ItemsPropertyChanged));
public static void SetItems(ListView listView, IList list)
{
listView.SetValue(ItemsProperty, list);
}
public static IList GetItems(ListView listView)
{
return listView.GetValue(ItemsProperty) as IList;
}
private static void ItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var target = d as ListView;
if (target != null)
{
CreateBehavior(target, e.NewValue as …Run Code Online (Sandbox Code Playgroud) 我有一个专用的 IdServer 运行,它具有其他应用程序将未经身份验证的用户引导到的登录页面。
我目前的管道是:
app.UseCookieAuthentication
app.UseOpenIdConnectAuthentication
app.UseDefaultFiles // because it is a SPA app
app.UseStaticFiles // the SPA app
Run Code Online (Sandbox Code Playgroud)
所以所有的教程都说要[Authorize]在你的控制器上使用......
但是,我希望中间人授权我的所有控制器和静态文件。
那么我如何编写一个中间件来处理这个问题。
我目前的设置是:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions<IdentityServerAppOptions> identityServerAppOptions)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
var serverAppOptions = identityServerAppOptions.Value;
loggerFactory.CreateLogger("Configure").LogDebug("Identity Server Authority Configured: {0}", serverAppOptions.Authority);
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = serverAppOptions.Authority,
RequireHttpsMetadata = false,
ClientId = "Video",
SaveTokens = true
});
app.Use(async (context, …Run Code Online (Sandbox Code Playgroud) 我有问题ui-router和使用bootstrap崩溃.
<div class="panel panel-default" id="accordion" >
<div role="tab" id="headingOne">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
Click me
</a>
</div>
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
Data
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是页面localhost/#/root/mypage/.所以指向"点击我" localhost:\#collapseOne会引导我进入我网站的默认页面.
javascript twitter-bootstrap angularjs angular-ui-bootstrap angular-ui-router
我当前的版本隐藏了每一行,但它发生得太快了,正如您 在我的 codepen 中看到的那样。通过删除顶部元素来重现。
我希望事件是这样展开的:
我不确定如何使用 CSS 转换和 ReactTransitionGroup 来做到这一点
如果我能到达你看到元素消失的阶段,那么所有的东西都会聚集在一起,这将是一个很好的开始!
我的过渡材料:
const CustomerList = ({ onDelete, customers }) => {
return (
<div class="customer-list">
<TransitionGroup>
{customers.map((c, i) =>
<CSSTransition
key={i}
classNames="customer"
timeout={{ enter: 500, exit: 1200 }}
>
<CustomerRow
customer={c}
onDelete={() => onDelete(i, c)}
/>
</CSSTransition>
)}
</TransitionGroup>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
我的CSS:
.customer-enter {
opacity: 0.01;
}
.customer-enter.customer-enter-active {
opacity: 1;
transition: 500ms;
}
.customer-exit {
opacity: 1;
}
.customer-exit.customer-exit-active {
opacity: 0.01;
transition: …Run Code Online (Sandbox Code Playgroud) 所以,
// this doesn't work or make sense
services.AddScoped<IReadSomething>(sp => new Something());
services.AddScoped<IWriteSomething>(sp => new Something());
Run Code Online (Sandbox Code Playgroud)
所以我有两个接口用于同一个Class,IReadSomething而IWriteSomethingClass只是Something.
它们需要作用域,因为它们将数据子集从HttpContext独立的"DTO"框架转移到任意框架.
它们都应该引用相同的实例Something,显然只是暴露了一些读取,而另一些只是暴露了一些写入操作.所以它被编写在Middleware管道中的某个地方 - 应用程序的其余部分可以只使用IReadSomething和读取数据,这样我们就可以减少意外的数据覆盖.
这样做,
services.AddScoped<IReadSomething, Something>();
services.AddScoped<IWriteSomething, Something>();
Run Code Online (Sandbox Code Playgroud)
没有意义,因为它应该为每个接口创建一个新实例.
我想让Interface Segregation和Scoped Dependency Resolution协同工作让我感到失望 - 我觉得我不得不担心ASP.NET Core Scoped Service Factory还是什么?
我也使用结构图作为我的主要依赖项解析 - 所以使用它的答案很好.
我有一个ASP.NET MVC 3应用程序.
我有Model,ViewModel,View,Controller.
我Ninject用作IoC.
我Controller使用a ViewModel将数据传递给View.
我已经开始使用Services(具体和接口类型)从中获取信息ViewModel并对数据库进行查询以对其进行操作.
我可以使用相同Service的设置ViewModel吗?或者这是否违背设计模式?
即我可以ViewModel在Service图层中抽象设置吗?
脚本
情景是; 我Model有很多对其他的引用Models,所以当我ViewModel在控制器中设置时,它是详细的,我觉得Controller这样做太多了.所以我希望能够做到这样的事情:
var vm = _serviceProvider.SetupViewModel(Guid model1Id, Guid model2Id, /*etc..*/)
看起来像这样的SetupViewModel函数ServiceProvider:
public MyModelViewModel SetupViewModel(Guid model1Id, Guid model2Id, /*etc...*/)
{
var vm = new MyModelViewModel();
var model1 = _repository.Model1s.FirstOrDefault(x => x.Id.Equals(model1Id)); …Run Code Online (Sandbox Code Playgroud) 我正在使用带有HTML CSS jQuery KnockoutJs前端的ASP.NET MVC C#.
我的HTML页面上有一个模态联系表单.我的想法是,如果我创建一个新的联系人,模式表单会弹出空白值,包括一个空白隐藏的id字段.
如果我编辑了一个联系人,那么模态表单会弹出填充的字段,包括隐藏的id字段.
在我的控制器中,我打算这样做:
public JsonResult Contact(string values)
{
var contact = JsonConvert.DeserializeObject<contact>(values);
if (contact.Id.Equals(Guid.Empty))
{
// create a new contact in the database
} else
{
// update an existing one
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我得到一个错误说 can't convert "" to type Guid
你如何解决这个问题有NewtonSoft JSON,我看这里的自定义JsonConverter,它似乎是沿着正确的线,但我不知道在哪里这个去.
所以在我的班上,我有这个私人的readonly成员ICollection<IMusicItem> playlist.我更喜欢使用界面ICollection<T>.
我想用List<T>.AddRange(IEnumerable<T> items).在我的方法会是危险的铸ICollection到List<T>即使我实例化ICollection<T>一个new List<T>()在构造函数中.
这是不好的做法,还有更好的方法吗?
或者只是拥有一个 List<T>
所以我有一个接口和类:
public interface IMyInterface<T> where T : ISomeEntity {}
public class MyClass<T> : IMyInterface<T>
where T : ISomeEntity {}
Run Code Online (Sandbox Code Playgroud)
我会有一些课程要求它:
public class SomeClass : ISomeClass
{
public SomeClass (IMyInterface<AuditEntity> myInterface) {}
}
Run Code Online (Sandbox Code Playgroud)
我已经做了各种各样的事情来让它注册开放的通用接口和类没有运气.
我只想说:
container.RegisterType(typeof(MyClass<>)).As(typeof(IMyInterface<>));
Run Code Online (Sandbox Code Playgroud)
如果我必须通过并明确地执行以下操作,那将是令人讨厌的:
container.RegisterType<MyClass<AuditEntity>>().As<IMyInterface<AuditEntity>>();
Run Code Online (Sandbox Code Playgroud)
这不应该是微不足道的吗?
所以我做了:
$ jspm install github:Eonasdan/bootstrap-datetimepicker
$ jspm install npm:moment
Run Code Online (Sandbox Code Playgroud)
然后在我的js文件的顶部我做了:
import moment from 'moment';
import {datepicker} from 'eonasdan/bootstrap-datetimepicker';
import 'eonasdan/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css!';
Run Code Online (Sandbox Code Playgroud)
在我的浏览器中它正在寻找/dist/eonasdan/bootstrap-datetimepicker.js哪个返回a 404,为什么不使用系统映射来找出实际文件所在的位置?或者它应该做什么....
作为旁注,它不会moment.js像它应该的那样去做
c# ×7
javascript ×3
asp.net-mvc ×2
.net-core ×1
angularjs ×1
asp.net-core ×1
aurelia ×1
autofac ×1
css ×1
ecmascript-6 ×1
generics ×1
json ×1
jspm ×1
knockout.js ×1
mvvm ×1
reactjs ×1
structuremap ×1
wpf ×1