NHibernate Validator没有与Fluent NHibernate集成(NHibernate Validator not integrating with Fluent NHibernate)
我在让NHV与Fluent NHibernate合作时遇到了一些麻烦。 我拥有的单元测试有一个应该失败的实体,最终会抛出一个ADO异常。 我有以下方式配置NHV:
private static void Init() { _SessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString) .ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactory>() .ExportTo(pathToExportMappingsTo)) .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu") .ExposeConfiguration(ConfigureNhibernateValidator) .BuildSessionFactory(); } private static void ConfigureNhibernateValidator(Configuration config) { var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration(); nhvConfiguration .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal) .Register(Assembly.Load("Business.Objects") .ValidationDefinitions()) .IntegrateWithNHibernate .RegisteringListeners(); ValidatorEngine validatorEngine = new ValidatorEngine(); validatorEngine.Configure(nhvConfiguration); ValidatorInitializer.Initialize(config, validatorEngine); }
我现在已经多次查看过这个配置并搜索了互联网,试图找出这个问题。 我还查看了NHV源中提供的示例,但我无法弄清楚为什么我的单元测试不会抛出InvalidStateException。 我有一个单元测试来验证应该失败的同一个实体,它通过验证引擎直接验证它,这是有效的。
有没有人看到上述配置有什么问题?
我正在使用NHibernate 3.1 , NHibernate Validator 1.3和Fluent NHibernate 1.2.0.712
I'm having some trouble getting NHV to work with Fluent NHibernate. A unit test that I have that has an entity that SHOULD be failing validation ends up throwing an ADO exception. I have NHV configured the following way:
private static void Init() { _SessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString) .ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactory>() .ExportTo(pathToExportMappingsTo)) .ProxyFactoryFactory("NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu") .ExposeConfiguration(ConfigureNhibernateValidator) .BuildSessionFactory(); } private static void ConfigureNhibernateValidator(Configuration config) { var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration(); nhvConfiguration .SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal) .Register(Assembly.Load("Business.Objects") .ValidationDefinitions()) .IntegrateWithNHibernate .RegisteringListeners(); ValidatorEngine validatorEngine = new ValidatorEngine(); validatorEngine.Configure(nhvConfiguration); ValidatorInitializer.Initialize(config, validatorEngine); }
I've looked over this configuration several times now and scoured the internet to try and find out what's wrong with this. I've also looked at examples provided in the NHV source but I haven't been able to figure out why my unit test does not throw an InvalidStateException. I have a unit test to validate the same entity that should be failing that validates it directly via the validation engine and this works.
Does anyone see anything wrong with the above configuration?
I'm using NHibernate 3.1, NHibernate Validator 1.3 and Fluent NHibernate 1.2.0.712
原文:https://stackoverflow.com/questions/5590250
最满意答案
您需要定义正确的ComponentName:
new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity");
试试看:
try { ActivityInfo info = pm.getActivityInfo(cn, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); }
You need to define the proper ComponentName:
new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity");
and have a try catch:
try { ActivityInfo info = pm.getActivityInfo(cn, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); }
相关问答
更多-
为什么android leanback开发这么少[2022-05-05]
毕竟这是给tv提的概念,这个行业还是比较少人在接触: Android TV中,更多被提及的是“Leanback”,这个“Leanback”就是指以放松的姿势倒在沙发上,也就是强调了不同于如智能手机等“以主观动向”为主的使用方式。 在基调演讲中,Google的UI开发者Matias Duarte引用了以下的这句话。“When your butt hits the sofa you lose 20 IQ point。”(当你的屁股挨着沙发时,你的IQ就降低了20)虽然这种说法有点不雅,但事实确实如此。无论是谁, ... -
我认为您可以在移动设备上使用某种PIN码。 例如,当用户需要登录时,他们可以选择在电视中登录,或输入显示在已登录的移动应用程序上的某些PIN码。 I think you can use some kind of PIN code with your mobile device. For example, when user need to log in, they can choose login in TV, or enter some PIN code that display on your mobi ...
-
总之:不。 BrowseFragment和DetailsFragment旨在为开发人员提供内容到电视的快速而简单的方法。 他们强迫你去那个特定的结构,这很容易理解和导航。 如果您愿意全力以赴进行自定义体验,则需要使用HeadersFragment和RowsFragment构建您的BrowseFragment版本。 这证明是相当头疼的 ,但我设法为我的公司的应用做到了。 如果你有兴趣,我会写一篇关于此的文章/文章。 编辑 这是文章 ! 如果你想看一看,它是Android TV的一个更大的集合的一部分。 In ...
-
在创建/初始化对象时,您不能使用Service (或该事件的Activity )作为Context 。 相反,重写onCreate()并在那里进行初始化并摆脱显式构造函数。 You cannot use a Service (or an Activity for that matter) as a Context when the object is being created/initialized. Instead, override onCreate() and do your initializat ...
-
这是一个不受支持的黑客,但它将完成工作。 您可以在项目的colors.xml文件中将颜色lb_speech_orb_recording覆盖为颜色。 然后它看起来像下面的图像: This is an unsupported hack, but it'll get the job done. You can override the color lb_speech_orb_recording as a color in your colors.xml file in your project. Then it ...
-
GuidedStepSupportFragment (扩展android.support.v4.app.Fragment )在leanback从27.1.0开始 There is GuidedStepSupportFragment (extends android.support.v4.app.Fragment) in leanback starting from 27.1.0
-
Leanback rowsfragment(Leanback rowsfragment)[2021-10-10]
在您的活动内部扩展BrowseFragment,这将删除左侧抽屉的标题... setHeadersState(HEADERS_DISABLED); 如果您使用的是Android TV示例应用程序,则可以通过以下方法在MainFragment类中进行... setupUIElements() Inside of your activity that extends BrowseFragment, this will remove the left drawer with the headings... s ... -
没有getPackageManager的Android getPackageInfo(Android getPackageInfo without getPackageManager)[2020-01-19]
在非活动类的构造函数中获取Context的实例,并使用它来调用所有此类方法。 像这样的东西: public class NonActivityClass implements SensorListener{ Context mContext; public NonActivtiyClass(Context context) { this.mContext = context; } //Rest of your code } 然后执行此操作以在Activtiy的onCreate()创建该类的对象: NonA ... -
您需要定义正确的ComponentName: new ComponentName("com.valecast.myapp", "com.valecast.myapp.SecondaryActivity"); 试试看: try { ActivityInfo info = pm.getActivityInfo(cn, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } You need t ...
-
与Leanback几乎所有东西一样,有不止一种方法可以给猫皮肤涂抹。 我们需要自定义ListRow以向标头添加更多填充。 我们通过覆盖onBindRowViewHolder的ListRowPresenter实现了这种级别的自定义,抓取了标题的View (通过View header = holder.getHeaderViewHolder().view; )。 然后我们用header.getLayoutParams().height = rowItem.getRowHeaderHeight();更改了它的高度 ...