Search Results

Search found 399 results on 16 pages for 'castle windsor'.

Page 5/16 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Castle windsor registration

    - by nivlam
    interface IUserService class LocalUserService : IUserService class RemoteUserService : IUserService interface IUserRepository class UserRepository : IUserRepository If I have the following interfaces and classes, where the IUserService classes have a dependency on IUserRepository. I can register these components by doing something like: container.AddComponent("LocalUserService", typeof(IUserService), typeof(LocalUserService)); container.AddComponent("RemoteUserService", typeof(IUserService), typeof(RemoteUserService)); container.AddComponent("UserRepository", typeof(IUserRepository), typeof(UserRepository)); ... and get the service I want by calling: IUserService userService = container.Resolve<IUserService>("RemoteUserService"); However, if I have the following interfaces and classes: interface IUserService class UserService : IUserService interface IUserRepository class WebUserRepository : IUserRepository class LocalUserRepository : IUserRepository class DBUserRepository : IUserRepository How do I register these components so that the IUserService component can "choose" which repository to inject at runtime? My idea is to allow the user to choose which repository to query from by providing 3 radio buttons (or whatever) and ask the container to resolve a new IUserService each time.

    Read the article

  • Windsor OnCreated for all components

    - by jeffn825
    Hi, How would I go about globally intercepting the creation/resolution of all instances by my container? I know I can do this individually with OnCreated on a per-component basis, but I want to do this globally for all objects resolved by the container. Thanks.

    Read the article

  • Need help configuring Castle-Windsor

    - by Jonathas Costa
    I have these base interfaces and providers in one assembly (Assembly1): public interface IEntity { } public interface IDao { } public interface IReadDao<T> : IDao where T : IEntity { IEnumerable<T> GetAll(); } public class NHibernate<T> : IReadDao<T> where T : IEntity { public IEnumerable<T> GetAll() { return new List<T>(); } } And I have this implementation inside another assembly (Assembly2): public class Product : IEntity { public string Code { get; set; } } public interface IProductDao : IReadDao<Product> { IEnumerable<Product> GetByCode(string code); } public class ProductDao : NHibernate<Product>, IProductDao { public IEnumerable<Product> GetByCode(string code) { return new List<Product>(); } } I want to be able to get IRead<Product> and IProductDao from the container. I am using this registration: container.Register( AllTypes.FromAssemblyNamed("Assembly2") .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(), AllTypes.FromAssemblyNamed("Assembly1") .BasedOn(typeof(IReadDao<>)).WithService.Base()); The IReadDao<Product> works great. The container gives me ProductDao. But if I try to get IProductDao, the container throws ComponentNotFoundException. How can I correctly configure the registration?

    Read the article

  • Castle ActiveRecord: session error search and access to lazy loading property in different threads

    - by sc911
    Hi *, I've got a problem with an multi-threaded desktop application using Castle ActiveRecord in C#: To keep the GUI alive while searching for the objects based on userinput I'm using the BackgroundWorker for the search-function. Some of the properties of the objects, especially some HasMany-Relations, are marked as Lazy. Now, when the search is finished and the user selects an resulting object, some of the properties of this object should be displayed. But as the search was done by the BackgroundWorker in a different thread, accessing the properties fails as the session for the lazy-access is no longer available. What will be the best way to do the search in an extra thread to keep the GUI alive and to access all properties correctly including those marked as lazy? Thanks for any advise! Regards sc911

    Read the article

  • DI/IoC in Java for a .NET'er used to Castle.Windsor

    - by Ciddan
    Is there a Java DI container that works in a similar way to the most excellent Castle.Windsor container on the .NET side? The Java containers I've had a look at all seem to rely on annotations (Guice) within my services, which I don't dig all that much - I'd like to go POJO all the way if possible. Spring on the other hand can do without the annotations, but it requires a lot of XML. XML configuration != maintainability. One of the really nice things about Castle.Windsor is the wiring you're able to set up in code with Installers, auto wiring based on naming conventions and whatnot. Ideally the container should also support lifecycle management and configuration; i.e. registering components as transient, singleton, pooled etc. Another bonus would be support for interceptors. Any tips would be greatly appreciated.

    Read the article

  • Castle Active Record - Working with the cache

    - by David
    Hi All, im new to the Castle Active Record Pattern and Im trying to get my head around how to effectivley use cache. So what im trying to do (or want to do) is when calling the GetAll, find out if I have called it before and check the cache, else load it, but I also want to pass a bool paramter that will force the cache to clear and requery the db. So Im just looking for the final bits. thanks public static List<Model.Resource> GetAll(bool forceReload) { List<Model.Resource> resources = new List<Model.Resource>(); //Request to force reload if (forceReload) { //need to specify to force a reload (how?) XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); ActiveRecordStarter.Initialize(source, typeof(Model.Resource)); resources = Model.Resource.FindAll().ToList(); } else { //Check the cache somehow and return the cache? } return resources; } public static List<Model.Resource> GetAll() { return GetAll(false); }

    Read the article

  • Castle ActiveRecord - schema generation without enforcing referential integrity?

    - by Simon
    Hi all, I've just started playing with Castle active record as it seems like a gentle way into NHibernate. I really like the idea of the database schema being generate from my classes during development. I want to do something similar to the following: [ActiveRecord] public class Camera : ActiveRecordBase<Camera> { [PrimaryKey] public int CameraId {get; set;} [Property] public int CamKitId {get; set;} [Property] public string serialNo {get; set;} } [ActiveRecord] public class Tripod : ActiveRecordBase<Tripod> { [PrimaryKey] public int TripodId {get; set;} [Property] public int CamKitId {get; set;} [Property] public string serialNo {get; set;} } [ActiveRecord] public class CameraKit : ActiveRecordBase<CameraKit> { [PrimaryKey] public int CamKitId {get; set;} [Property] public string description {get; set;} [HasMany(Inverse=true, Table="Cameras", ColumnKey="CamKitId")] public IList<Camera> Cameras {get; set;} [HasMany(Inverse=true, Table="Tripods", ColumnKey="CamKitId")] public IList<Camera> Tripods {get; set;} } A camerakit should contain any number of tripods and cameras. Camera kits exist independently of cameras and tripods, but are sometimes related. The problem is, if I use createschema, this will put foreign key constraints on the Camera and Tripod tables. I don't want this, I want to be able to to set CamKitId to null on the tripod and camera tables to indicate that it is not part of a CameraKit. Is there a way to tell activerecord/nhibernate to still see it as related, without enforcing the integrity? I was thinking I could have a cameraKit record in there to indicate "no camera kit", but it seems like oeverkill. Or is my schema wrong? Am I doing something I shouldn't with an ORM? (I've not really used ORMs much) Thanks!

    Read the article

  • Register an Interceptor with Castle Fluent Interface

    - by Quintin Par
    I am trying to implement nhibernate transaction handling through Interceptors and couldn’t figure out how to register the interface through fluent mechanism. I see a Component.For<ServicesInterceptor>().Interceptors but not sure how to use it. Can someone help me out? This example seemed a little complex.

    Read the article

  • How do I pass dependency to object with Castle Windsor and MS Test?

    - by Nick
    I am trying to use Castle Windsor with MS Test. The test class only seems to use the default constructor. How do I configure Castle to resolve the service in the constructor? Here is the Test Class' constructors: private readonly IWebBrowser _browser; public DepressionSummaryTests() { } public DepressionSummaryTests(IWebBrowser browser) { _browser = browser; } My component in the app config looks like so: <castle> <components> <component id="browser" service="ConversationSummary.IWebBrowser, ConversationSummary" type="ConversationSummary.Browser" /> </components> </castle> Here is my application container: public class ApplicationContainer : WindsorContainer { private static IWindsorContainer container; static ApplicationContainer() { container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle"))); } private static IWindsorContainer Container { get { return container; } } public static IWebBrowser Browser { get { return (IWebBrowser) Container.Resolve("browser"); } } } MS test requires the default constructor. What am I missing? Thanks!

    Read the article

  • NHibernate (3.1.0.4000) NullReferenceException using Query<> and NHibernate Facility

    - by TigerShark
    I have a problem with NHibernate, I can't seem to find any solution for. In my project I have a simple entity (Batch), but whenever I try and run the following test, I get an exception. I've triede a couple of different ways to perform a similar query, but almost identical exception for all (it differs in which LINQ method being executed). The first test: [Test] public void QueryLatestBatch() { using (var session = SessionManager.OpenSession()) { var batch = session.Query<Batch>() .FirstOrDefault(); Assert.That(batch, Is.Not.Null); } } The exception: System.NullReferenceException : Object reference not set to an instance of an object. at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression expression, ref IQuery query, ref NhLinqExpression nhQuery) at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) at System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) The second test: [Test] public void QueryLatestBatch2() { using (var session = SessionManager.OpenSession()) { var batch = session.Query<Batch>() .OrderBy(x => x.Executed) .Take(1) .SingleOrDefault(); Assert.That(batch, Is.Not.Null); } } The exception: System.NullReferenceException : Object reference not set to an instance of an object. at NHibernate.Linq.NhQueryProvider.PrepareQuery(Expression expression, ref IQuery query, ref NhLinqExpression nhQuery) at NHibernate.Linq.NhQueryProvider.Execute(Expression expression) at System.Linq.Queryable.SingleOrDefault(IQueryable`1 source) However, this one is passing (using QueryOver<): [Test] public void QueryOverLatestBatch() { using (var session = SessionManager.OpenSession()) { var batch = session.QueryOver<Batch>() .OrderBy(x => x.Executed).Asc .Take(1) .SingleOrDefault(); Assert.That(batch, Is.Not.Null); Assert.That(batch.Executed, Is.LessThan(DateTime.Now)); } } Using the QueryOver< API is not bad at all, but I'm just kind of baffled that the Query< API isn't working, which is kind of sad, since the First() operation is very concise, and our developers really enjoy LINQ. I really hope there is a solution to this, as it seems strange if these methods are failing such a simple test. EDIT I'm using Oracle 11g, my mappings are done with FluentNHibernate registered through Castle Windsor with the NHibernate Facility. As I wrote, the odd thing is that the query works perfectly with the QueryOver< API, but not through LINQ.

    Read the article

  • Mapping Enums to Database with NHibernate/Castle ActiveRecord

    - by Mike
    There's a few other posts on mapping Enums to the DB with ActiveRecord, but none of them answer my question. I have an enum called OrderState: public enum OrderState {InQueue, Ordered, Error, Cancelled} And I have the following property on the table: [Property(NotNull = true, SqlType = "orderstate", ColumnType = "DB.EnumMapper, WebSite")] public OrderState State { get { return state; } set { state = value; } } And I have the following type class: public class EnumMapper : NHibernate.Type.EnumStringType<OrderState> { public EnumMapper() { } public override NHibernate.SqlTypes.SqlType SqlType { get { return new NHibernate.SqlTypes.SqlType(DbType.Object); } } } Now this actually works the way I want, but the problem is I have tons of enums and I don't want to create a EnumMapper class for each one of them. Isn't there some way to just tell ActiveRecord to use DbType.Object for any enum? It seems to either want to be an integer or a string, but nothing else. This one's been driving me crazy for the last 2 hours.. Mike

    Read the article

  • castle monorail unit test rendertext

    - by MikeWyatt
    I'm doing some maintenance on an older web application written in Monorail v1.0.3. I want to unit test an action that uses RenderText(). How do I extract the content in my test? Reading from controller.Response.OutputStream doesn't work, since the response stream is either not setup properly in PrepareController(), or is closed in RenderText(). Example Action public DeleteFoo( int id ) { var success= false; var foo = Service.Get<Foo>( id ); if( foo != null && CurrentUser.IsInRole( "CanDeleteFoo" ) ) { Service.Delete<Foo>( id ); success = true; } CancelView(); RenderText( "{ success: " + success + " }" ); } Example Test (using Moq) [Test] public void DeleteFoo() { var controller = new MyController (); PrepareController ( controller ); var foo = new Foo { Id = 123 }; var mockService = new Mock < Service > (); mockService.Setup ( s => s.Get<Foo> ( foo.Id ) ).Returns ( foo ); controller.Service = mockService.Object; controller.DeleteTicket ( ticket.Id ); mockService.Verify ( s => s.Delete<Foo> ( foo.Id ) ); Assert.AreEqual ( "{success:true}", GetResponse ( Response ) ); } // response.OutputStream.Seek throws an "System.ObjectDisposedException: Cannot access a closed Stream." exception private static string GetResponse( IResponse response ) { response.OutputStream.Seek ( 0, SeekOrigin.Begin ); var buffer = new byte[response.OutputStream.Length]; response.OutputStream.Read ( buffer, 0, buffer.Length ); return Encoding.ASCII.GetString ( buffer ); }

    Read the article

  • Castle ActiveRecord / NHibernate Linq Querys with ValueTypes

    - by Thomas Schreiner
    Given the following code for our Active Record Entites and ValueTypes Linq is not working for us. [ActiveRecord("Person")] public class PersonEntity : ActiveRecordLinqBase<PersonEntity> { string _name; [Property("Name", Length = 20, ColumnType = "string", Access = PropertyAccess.FieldCamelcaseUnderscore)] public Name Name { get { return NameValue.Create(_name);} set { _name = value.DataBaseValue; } } ... } public abstract class Name : IValueType { string DataBaseValue {get;set;} ... } public class Namevalue : Name { string _name; private NameValue(string name) { _name = name; } public static NameValue Create(string name) { return new NameValue(name); } ... } We tried to use linq in the following way so far with no success: var result = from PersonEntity p in PersonEntity.Queryable where p.Name == "Thomas" select p; return result.First(); // throws exception Cannot convert string into Name We tried and implemented a TypeConverter for Name, but the converter never got called. Is there a way to have linq working with this ValueTypes? Update: Using NHibernate.UserTypes.IUserType it sortof works. I Implemented the Interface as described here: http://stackoverflow.com/questions/1565056/how-to-implement-correctly-iusertype I still had to add a ConversionOperator from string to Name and had to call it Explicitly in the linq Statement, even though it was defined as implicit. var result = from PersonEntity p in PersonEntity.Queryable where p.Name == (Name)"Thomas" select p; return result.First(); //Now works

    Read the article

  • Flush separate Castle ActiveRecord Transaction, and refresh object in another Transaction

    - by eanticev
    I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and move on. The reason is that the request in question hits an API that then chain hits another one of my pages (near-synchronously) to let me know that it processed, and thus double submits a transaction record, because the original request had not yet finished, and thus not committed the transaction record. So I've tried wrapping the insertion code with a new SessionScope, TransactionScope(TransactionMode.New), combination of both, flushing everything manually, etc. However, when I call Refresh on the object I'm still getting the old object state. Here's some code sample for what I'm seeing: Post outsidePost = Post.Find(id); // status of this post is Status.Old using (TransactionScope transaction = new TransactionScope(TransactionMode.New)) { Post p = Post.Find(id); p.Status = Status.New; // new status set here p.Update(); SessionScope.Current.Flush(); transaction.Flush(); transaction.VoteCommit(); } outsidePost.Refresh(); // refresh doesn't get the new status, status is still Status.Old Any suggestions, ideas, and comments are appreciated!

    Read the article

  • Is this ISession handled by the SessionScope - Castle ActiveRecord

    - by oillio
    Can I do this? I have the following in my code: public class ARClass : ActiveRecordBase<ARClass> { ---SNIP--- public void DoStuff() { using (new SessionScope()) { holder.CreateSession(typeof(ARClass)).Lock(this, LockMode.None); ...Do some work... } } } So, as I'm sure you can guess, I am doing this so that I can access lazy loaded references in the object. It works great, however I am worried about creating an ISession like this and just dropping it. Does it get properly registered with the SessionScope and will the scope properly tare my ISession down when it is disposed of? Or do I need to do more to manage it myself?

    Read the article

  • Nhibernate.Bytecode.Castle Trust Level on IIS

    - by jack london
    Trying to deploy the wcf service, depended on nhibernate. And getting the following exception On Reflection activator. [SecurityException: That assembly does not allow partially trusted callers.] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230 System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) +8 NHibernate.Driver.ReflectionBasedDriver.CreateConnection() +28 NHibernate.Connection.DriverConnectionProvider.GetConnection() +56 NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Action`1 scriptAction, Boolean export, Boolean justDrop) +376 in IIS configuration service's trust level is Full-trust also application's web config's trust level is full. how could i make this service in working state?

    Read the article

  • Selecting by ID in Castle ActiveRecord

    - by ripper234
    How can I write a criteria to return all Orders that belong to a specific User? public class User { [PrimaryKey] public virtual int Id { get; set; } } public class Order { [PrimaryKey] public virtual int Id { get; set; } [BelongsTo("UserId")] public virtual User User { get; set; } } return ActiveRecordMediator<Order>.FindAll( // What criteria should I write here ? );

    Read the article

  • How can I have a Windsor IoC container that can be shared amongst my classes but not shared across m

    - by Si Keep
    I am building a set of class libraries that produce office open xml based reports and I am using a static Windsor IoC container. My problem is that one possible entry point to the reporting system is via a web front end which means that the reporting systems static IoC Container is being shared amongst multiple web requests which causes exceptions as for each new request the reporting system is trying re-register components in Windsor that were already registered by an earlier request. I dont want to move the registration into the web app global.asax as my reporting system will no longer be stand-alone. How can I have a Windsor IoC container that can be shared amongst my reporting classes but not shared across multiple web requests?

    Read the article

  • [Castle Dynamic Proxy] What really interceptors do with my c# class?

    - by Pandiya Chendur
    I was asked to implement castle dynamic proxy in my asp.net web application and i was going through couple of articles which i got from Castle Project and Code Project about castle dynamic proxy in asp.net web application.... Both articles delt with creating interceptors but i can't get the idea why interceptors are used with classes.... Why should i intercept my class which is behaving properly?

    Read the article

  • [Castle-DynamicProxy] What really interceptors do with my c# class?

    - by Pandiya Chendur
    I was asked to implement castle dynamic proxy in my asp.net web application and i was going through couple of articles which i got from Castle Project and Code Project about castle dynamic proxy in asp.net web application.... Both articles delt with creating interceptors but i can't get the idea why interceptors are used with classes.... Why should i intercept my class which is behaving properly?

    Read the article

  • Registering IWindsorContainer with ASPNET MVC 2.0 Areas

    - by Bernard Larouche
    I had the following code that was working well before the addition of Areas in MVC 2 : protected override IWindsorContainer CreateContainer(string windsorConfig) { IWindsorContainer container = new WindsorContainer(); container.Register(Component.For<IUnitOfWorkFactory>() .ImplementedBy<NHibernateUnitOfWorkFactory>()); container.Register(AllTypes.Of<IController>() .FromAssembly(typeof(HomeController).Assembly) .Configure(t => t.Named(t.Implementation.Name.ToUpper()) .LifeStyle.Is(LifestyleType.Transient))); return container; } It doesn't work anymore with MVC 2.0 Areas feature. Could you guide me through a possible solution Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >