castle

Min Length Custom AbstractValidationAttribute and Implementing Castle.Components.Validator.IValidator

*爱你&永不变心* 提交于 2019-12-25 08:48:42
问题 I see with the Castle validators I can use a length validation attribute. [ValidateLength(6, 30, "some error message")] public string SomeProperty { get; set; } I am trying to find a MinLength only attribute is there a way to do this with the out of the box attributes? So far my idea is implementing AbstractValidationAttribute public class ValidateMinLengthAttribute : AbstractValidationAttribute and making its Build method return a MinLengthValidator, then using ValidateMinLength on

What is the expected LifeStyle of a Castle Windsor component activator?

好久不见. 提交于 2019-12-25 06:33:08
问题 I'm using Castle Windsor and DynamicProxy to implement persistence Lazy Loading from scratch (I know NHibernate could be an option etc.) I have implemented a custom component activator to always instantiate my business classes as proxies. I found that the default mixin proxies automatically created when using interceptors were not being used when class methods are called from inside the class itself, which was a problem. So I inherited DefaultComponentActivator and overriding CreateInstance()

Scope was not available. Did you forget to call container.BeginScope()?

我是研究僧i 提交于 2019-12-24 07:16:18
问题 Hello I want to using castle windosr in .net core and I have get bellow error in .net core: Scope was not available. Did you forget to call container.BeginScope()? my code is : public IServiceProvider ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode

Error loading one of the NHibernate dependent dll's

左心房为你撑大大i 提交于 2019-12-23 12:29:18
问题 I am building an application using NHibernate. Because I could not add the DLL's of my current version of NHibernate (I cannot add reference when framework 4.0 is target). I tried to get the latest and greatest of the w.w.w., this is what I have now: NHibernate.dll (3.2.0.4000) NHibernate.ByteCode.Castle (3.0.0.4000) FluentNHibernate.dll (1.2.0.694) Castle.Core (2.5.2.0) Castle.Services.Logging.NLogIntegration (2.5.2.0) Antlr.Runtim (3.1.3.42154) Iesi.Collections (3.2.0.400) These I can

Localized Attribute parameters in C#

此生再无相见时 提交于 2019-12-22 12:19:27
问题 In C#, attribute parameters require to be a constant expression, typeof or array creation expression. Various libraries, like for example Castle validator, allow specifying passing what seems like localized error messages to attribute constructor: //this works [ValidateNonEmpty("Can not be empty")] //this does not compile [ValidateNonEmpty(Resources.NonEmptyValidationMessage)] Is there any way how to approach this problem and localize these arguments? In case there is no workaround for this

Localized Attribute parameters in C#

无人久伴 提交于 2019-12-22 12:18:40
问题 In C#, attribute parameters require to be a constant expression, typeof or array creation expression. Various libraries, like for example Castle validator, allow specifying passing what seems like localized error messages to attribute constructor: //this works [ValidateNonEmpty("Can not be empty")] //this does not compile [ValidateNonEmpty(Resources.NonEmptyValidationMessage)] Is there any way how to approach this problem and localize these arguments? In case there is no workaround for this

Handling PropertyChanging/PropertyChanged via Castle's DynamicProxy

女生的网名这么多〃 提交于 2019-12-22 00:42:25
问题 I currently have a setter method which looks like this: private string _a; public virtual string A { get { return _a; } set { if (_a!= value) { if (this.OnPropertyChanging("A", _a, value)) { var previousValue = _a; _a = value; this.OnPropertyChanged("A", previousValue, value); } } } } I have implemented this with help from Dr Wily's Apprentice (http://stackoverflow.com/a/8578507/981225), with a custom Changing handler that keeps track of the old and current value, as well as the ability to

NHibernate 2.1.2 in medium trust

爱⌒轻易说出口 提交于 2019-12-21 17:25:32
问题 I'm trying to configure nhibernate 2.1.2 to run in medium trust, without any luck. I have tried follwing the suggestions to run in medium trust and pre-generating the proxies. I then tried to remove all references to lazy loading setting the default-lazy="false" on all classes and bags. However this threw an exception asking me to configure the proxyfactory.factory_class None of these methds worked as they kept throwing generic security exceptions or throwing easying that libraries do not

codeforces 608 div2 portals(带反悔的贪心)

落爺英雄遲暮 提交于 2019-12-19 09:27:19
题目大意:我们要攻略n个城堡,每个城堡有ai,bi,ci三个参数,我们到达城堡i时必须至少有ai个人才能攻略,不能攻略输出-1 到达一个城堡后能够加bi个人。同时我们允许放1个人在城堡i防守,这样我们能得到ci的分数。注意过了这个城堡就不能再选择之前的城堡进行防守。但是,这里有一些道路允许我们在城堡b到城堡a,其中b大于a。 解题思路: 很自然地,我们每次到达一个城堡都尽可能进行defend,每次到达一个城堡若人数不够,我们就反悔,把之前分数低的defend的城市取消。大概思路就是这样,我们只用维护一个优先队列就可以了。但是上面的思路有些问题,我们在人数不够的时候,优先pop出来的是分数低的,这样有个bug,比如可能到达某座城市i,它可能和一些城市连起来,这时候我们应该pop掉和i连接的城市。那怎么避免这种情况呢?这里有一个key hint。 一个城市若是后面可以defend,我们不要在前面就defend,这样总是最优的,比如i和j是连起来的,其中j>i,这时候我们假如不在i defend在jdefend的好处是:[i+1,j]区间人数多了一个,更有利于我们攻略城堡。而且这样可以避免我们之前所说的bug。 #include <bits/stdc++.h> using namespace std; typedef struct{ int a,b,c; }cas; vector

Testing Castle windsor Component with PerWebRequest lifestyle

我怕爱的太早我们不能终老 提交于 2019-12-18 12:58:09
问题 I'm trying to do some testing with castle windsor involved, in one of my tests I want to check the windsor installers, so I check that the container can resolve my components given its interface. So far, so good, the problem starts when the component has PerWebRequest lifestyle in its installer, at first it complained about HttpContext.Current is null, having that one solved creating a fake Context in test setup I'm now having this exception in nunit test System.Exception : Looks like you