我想通过MEF将泛型类导出到通用接口.我的目标是:
public interface IService<T> { }
[Export(typeof(IService<T>))] // error!!!!!!
public class Service<T> { }
public class Client<T> {
[Import]
private IService<T> _service;
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试导出时IService<T>,我收到此错误:
属性参数不能使用类型参数
有人可以指导我这样做吗?
喜.我正在阅读Digi Traffic Accelerator反编译源(我认为这是最好的学习方法),直到我得到一些不可理解的代码!请看一下:
internal class ProxyFarm
{
private static Random rand = new Random();
private static Regex UserPassAtHostPort = new Regex("\r\n ^\r\n (?<user>[^:]+?) : (?<pass>[^@]+?)\r\n @\r\n (?<host>[^:]+? (?: : \\d+)? )\r\n $", RegexOptions.IgnorePatternWhitespace);
private static Regex HostPortUserPass = new Regex("\r\n ^\r\n (?<host>[^:]+? : \\d+) : (?<user>[^:]+?) : (?<pass>.+?)\r\n $", RegexOptions.IgnorePatternWhitespace);
public const string NEW = "new";
public const string ACTIVE = "active";
public const string BLOCKED_BY_GOOGLE = "blocked by Google";
public const string INACTIVE = "inactive";
public const …Run Code Online (Sandbox Code Playgroud) 最近,我看到了一个开源的新格局(新的我)ASP.NET MVC 3项目,长谷多Command,CommandHandler和CommandInvoker-with他们的接口-我无法理解的模式!你能告诉我这个模式的名称是什么,我在哪里可以了解它?请问有什么好处?提前致谢.
更新:我在谈论这个项目:
是什么区别(S)GotFocus和GotKeyboardFocus-和同样LostFocus和LostKeyboardFocus?
对不起这个简单的问题,但是,我搜索了它并阅读了很多博客文章,但我仍然感到困惑.似乎没有人确切知道有什么区别):
更新:
我的用法:
我通过扩展Control类来创建自定义控件.有些东西,ComboBox但有一些其他的影响.我试图Popup通过设置属性来打开和关闭:IsDropDownOpen就像ComboBox通过GotFocus和LostFocus事件一样.Popup当我Alt+Tab编辑窗口时,我不想关闭,但是当我点击一个Button例子或者我去一个窗口时关闭TextBox.我做了:
private static void OnGotFocusHandler(object sender, RoutedEventArgs e) {
if (e.Handled)
return;
((SearchBox)sender).IsDropDownOpen = true;
e.Handled = true;
}
private static void OnLostFocusHandler(object sender, RoutedEventArgs e) {
if (e.Handled)
return;
((SearchBox)sender).IsDropDownOpen = false;
e.Handled = true;
}
Run Code Online (Sandbox Code Playgroud)
该GotFocus作品.但那Lost个人没有.如果我做的Lost东西在LostKeyboardFocus那么当我 …
我正在努力学习NHibernate 3.2 built-in mapping by code api(不是 FluentNHibernate,也不是xml).你能帮我勾画出这些实体之间的多对多关系吗?
public class Post {
public virtual Id { get; set; }
public IList<Tag> Tags { get; set; }
}
public class Tag {
public virtual Id { get; set; }
public IList<Post> Posts { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的主要关键策略是:
Id(
t => t.Id,
t => {
t.Generator(Generators.HighLow, g => g.Params(new { max_low = 100 }));
t.Column(typeof(TEntity).Name + "Id");
});
Run Code Online (Sandbox Code Playgroud)
我试试这个:
// TagMap : ClassMapping<Tag>
Bag(t => t.Posts, bag => …Run Code Online (Sandbox Code Playgroud) mapping nhibernate many-to-many nhibernate-3 nhibernate-mapping-by-code
您建议以哪种方式在和中创建安全密码重置链接?我的意思是,我会创建一个随机令牌,对吧?如何在发送给用户之前对其进行编码?是MD5不够好?你知道其他任何安全方式吗?MVCC#
我在JavaScript中创建了一个类,如下所示:
var Test = function(){
this.element = null;
this.init = function() {
if(Test.html == "") {
Test.loadHtml(this);
return;
}
this.initElements();
this.someMethodInternalCall();
};
this.initElements = function() {
// append the loaded html to body
// etc...
this.element = $("some-element-contained-in-loaded-html-apended-to-body");
}
this.someMethodInternalCall = function() {
this.element.css({some:style}); // works in this place
}
this.someMethodExternalCall = function() {
this.element.css({some:style}); // dosn't work in this place
// I mean here this.element is null. WHY?
}
};
Test.html = "";
Test.loadHtml = function() {
// load …Run Code Online (Sandbox Code Playgroud) 这是我之前提出的另一个问题的问题.我有一个重载的方法:
public void Add<T>(SomeType<T> some) { }
public void Add<T>(AnotherType<T> another) { }
Run Code Online (Sandbox Code Playgroud)
如何通过反射找到每种方法?例如,如何Add<T>(SomeType<T> some)通过反射获得方法?你能帮我吗?提前致谢.
我正在尝试使用以下CQRS模式创建一个ASP.NET MVC应用程序(这是我第一次尝试CQRS).我明白命令方面,没有任何结果.在这个答案中,@ Johannes Rudolph说如果我们需要在命令端获得结果,我们可以创建一个事件并订阅,以解决问题.现在,假设我们正在创建一个登录页面:
public class AuthController : Controller {
private ICommandHandler<LoginCommand> _handler;
public AuthController(ICommandHandler<LoginCommand> handler) {
_handler = handler;
}
public ActionResult Login(LoginModel model) {
if(ModelState.IsValid) {
var cmd = new LoginCommand(model.Username, model.Password);
_handler.Handle(cmd);
// how to notify about login success or failed?
}
return View(model);
}
}
Run Code Online (Sandbox Code Playgroud)
如何通知登录命令成功或失败?我知道我可以LoginCommand在上面的方法中创建一个事件并订阅它.但是,我的订阅是一个单独的方法,不能返回(例如:)指定的视图.看到:
public ActionResult Login(LoginModel model) {
if(ModelState.IsValid) {
var result = true;
var cmd = new LoginCommand(model.Username, …Run Code Online (Sandbox Code Playgroud) 我正在使用此css创建自定义复选框:
input[type="checkbox"] {
background: transparent;
border: inherit;
width: auto;
}
input[type=checkbox] {
display: none;
}
input[type=checkbox] + input + label,
input[type=checkbox] + label,
div:not(#foo) > input[type=checkbox] + label,
div:not(#foo) > input[type=checkbox] + input + label {
cursor: pointer;
height: 16px;
padding: 0 0 0 18px;
background: transparent url(/assets/images/checkbox-unchecked.png) no-repeat left 3px;
}
input[type=checkbox]:checked + input + label,
input[type=checkbox]:checked + label,
div:not(#foo) > input[type=checkbox]:checked + label,
div:not(#foo) > input[type=checkbox]:checked + input + label {
background: transparent url(/assets/images/checkbox-checked.png) no-repeat left 3px;
} …Run Code Online (Sandbox Code Playgroud) c# ×7
asp.net-mvc ×2
c#-4.0 ×2
generics ×2
checkbox ×1
class ×1
command ×1
cqrs ×1
css ×1
css3 ×1
decompiler ×1
dotpeek ×1
html ×1
javascript ×1
many-to-many ×1
mapping ×1
mef ×1
methodinfo ×1
nhibernate ×1
nhibernate-3 ×1
oop ×1
properties ×1
reflection ×1
security ×1
wpf ×1
wpf-4.0 ×1
wpf-controls ×1