Search Results

Search found 1231 results on 50 pages for 'ioc containers'.

Page 9/50 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Using StructureMap to create classes by a name?

    - by Bevan
    How can I use StructureMap to resolve to an appropriate implementation of an interface based on a name stored in an attribute? In my project, I have many different kinds of widgets, each descending from IWidget, and each decorated with an attribute specifying the kind of associated element. To illustrate: [Configuration("header")] public class HeaderWidget : IWidget { } [Configuration("linegraph")] public class LineGraphWidget : IWidget { } When processing my (XML) configuration file, I want to obtain an instance of the appropriate concrete class based on the name of the element I'm processing. public IWidget CreateWidget(XElement definition) { var kind = definition.Name.LocalName; var widget = // What goes here? widget.Configure(definition); return widget; } Each definition should result in a different widget being created - I don't need or want the instances to be shared. In the past I've written plenty of code to do this kind of thing manually, including writing a custom "roll-your-own" IoC container for one project. However, one of my goals with this project is to become proficient with StructureMap instead of reinventing the wheel. I think I've already managed to set up automatic scanning of assemblies so that StructureMap knows about all my IWidget implementations: public class WidgetRegistration : Registry { public WidgetRegistration() { Scan( scanner => { scanner.AssembliesFromApplicationBaseDirectory(); scanner.AddAllTypesOf<IWidget>(); }); } } However, this isn't registering the names of my widgets with StructureMap. What do I need to add to make my scenario work? (While I am trying to use StructureMap in this project, an answer showing me how to solve this problem with a different DI/IoC tool would still be valuable.)

    Read the article

  • Serializing Configurations for a Dependency Injection / Inversion of Control

    - by Joshua Starner
    I've been researching Dependency Injection and Inversion of Control practices lately in an effort to improve the architecture of our application framework and I can't seem to find a good answer to this question. It's very likely that I have my terminology confused, mixed up, or that I'm just naive to the concept right now, so any links or clarification would be appreciated. Many examples of DI and IoC containers don't illustrate how the container will connect things together when you have a "library" of possible "plugins", or how to "serialize" a given configuration. (From what I've read about MEF, having multiple declarations of [Export] for the same type will not work if your object only requires 1 [Import]). Maybe that's a different pattern or I'm blinded by my current way of thinking. Here's some code for an example reference: public abstract class Engine { } public class FastEngine : Engine { } public class MediumEngine : Engine { } public class SlowEngine : Engine { } public class Car { public Car(Engine e) { engine = e; } private Engine engine; } This post talks about "Fine-grained context" where 2 instances of the same object need different implementations of the "Engine" class: http://stackoverflow.com/questions/2176833/ioc-resolve-vs-constructor-injection Is there a good framework that helps you configure or serialize a configuration to achieve something like this without hard coding it or hand-rolling the code to do this? public class Application { public void Go() { Car c1 = new Car(new FastEngine()); Car c2 = new Car(new SlowEngine()); } } Sample XML: <XML> <Cars> <Car name="c1" engine="FastEngine" /> <Car name="c2" engine="SlowEngine" /> </Cars> </XML>

    Read the article

  • Combining MVVM Light Toolkit and Unity 2.0

    - by Alan Cordner
    This is more of a commentary than a question, though feedback would be nice. I have been tasked to create the user interface for a new project we are doing. We want to use WPF and I wanted to learn all of the modern UI design techniques available. Since I am fairly new to WPF I have been researching what is available. I think I have pretty much settled on using MVVM Light Toolkit (mainly because of its "Blendability" and the EventToCommand behavior!), but I wanted to incorporate IoC also. So, here is what I have come up with. I have modified the default ViewModelLocator class in a MVVM Light project to use a UnityContainer to handle dependency injections. Considering I didn't know what 90% of these terms meant 3 months ago, I think I'm on the right track. // Example of MVVM Light Toolkit ViewModelLocator class that implements Microsoft // Unity 2.0 Inversion of Control container to resolve ViewModel dependencies. using Microsoft.Practices.Unity; namespace MVVMLightUnityExample { public class ViewModelLocator { public static UnityContainer Container { get; set; } #region Constructors static ViewModelLocator() { if (Container == null) { Container = new UnityContainer(); // register all dependencies required by view models Container .RegisterType<IDialogService, ModalDialogService>(new ContainerControlledLifetimeManager()) .RegisterType<ILoggerService, LogFileService>(new ContainerControlledLifetimeManager()) ; } } /// <summary> /// Initializes a new instance of the ViewModelLocator class. /// </summary> public ViewModelLocator() { ////if (ViewModelBase.IsInDesignModeStatic) ////{ //// // Create design time view models ////} ////else ////{ //// // Create run time view models ////} CreateMain(); } #endregion #region MainViewModel private static MainViewModel _main; /// <summary> /// Gets the Main property. /// </summary> public static MainViewModel MainStatic { get { if (_main == null) { CreateMain(); } return _main; } } /// <summary> /// Gets the Main property. /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "This non-static member is needed for data binding purposes.")] public MainViewModel Main { get { return MainStatic; } } /// <summary> /// Provides a deterministic way to delete the Main property. /// </summary> public static void ClearMain() { _main.Cleanup(); _main = null; } /// <summary> /// Provides a deterministic way to create the Main property. /// </summary> public static void CreateMain() { if (_main == null) { // allow Unity to resolve the view model and hold onto reference _main = Container.Resolve<MainViewModel>(); } } #endregion #region OrderViewModel // property to hold the order number (injected into OrderViewModel() constructor when resolved) public static string OrderToView { get; set; } /// <summary> /// Gets the OrderViewModel property. /// </summary> public static OrderViewModel OrderViewModelStatic { get { // allow Unity to resolve the view model // do not keep local reference to the instance resolved because we need a new instance // each time - the corresponding View is a UserControl that can be used multiple times // within a single window/view // pass current value of OrderToView parameter to constructor! return Container.Resolve<OrderViewModel>(new ParameterOverride("orderNumber", OrderToView)); } } /// <summary> /// Gets the OrderViewModel property. /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "This non-static member is needed for data binding purposes.")] public OrderViewModel Order { get { return OrderViewModelStatic; } } #endregion /// <summary> /// Cleans up all the resources. /// </summary> public static void Cleanup() { ClearMain(); Container = null; } } } And the MainViewModel class showing dependency injection usage: using GalaSoft.MvvmLight; using Microsoft.Practices.Unity; namespace MVVMLightUnityExample { public class MainViewModel : ViewModelBase { private IDialogService _dialogs; private ILoggerService _logger; /// <summary> /// Initializes a new instance of the MainViewModel class. This default constructor calls the /// non-default constructor resolving the interfaces used by this view model. /// </summary> public MainViewModel() : this(ViewModelLocator.Container.Resolve<IDialogService>(), ViewModelLocator.Container.Resolve<ILoggerService>()) { if (IsInDesignMode) { // Code runs in Blend --> create design time data. } else { // Code runs "for real" } } /// <summary> /// Initializes a new instance of the MainViewModel class. /// Interfaces are automatically resolved by the IoC container. /// </summary> /// <param name="dialogs">Interface to dialog service</param> /// <param name="logger">Interface to logger service</param> public MainViewModel(IDialogService dialogs, ILoggerService logger) { _dialogs = dialogs; _logger = logger; if (IsInDesignMode) { // Code runs in Blend --> create design time data. _dialogs.ShowMessage("Running in design-time mode!", "Injection Constructor", DialogButton.OK, DialogImage.Information); _logger.WriteLine("Running in design-time mode!"); } else { // Code runs "for real" _dialogs.ShowMessage("Running in run-time mode!", "Injection Constructor", DialogButton.OK, DialogImage.Information); _logger.WriteLine("Running in run-time mode!"); } } public override void Cleanup() { // Clean up if needed _dialogs = null; _logger = null; base.Cleanup(); } } } And the OrderViewModel class: using GalaSoft.MvvmLight; using Microsoft.Practices.Unity; namespace MVVMLightUnityExample { /// <summary> /// This class contains properties that a View can data bind to. /// <para> /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel. /// </para> /// <para> /// You can also use Blend to data bind with the tool's support. /// </para> /// <para> /// See http://www.galasoft.ch/mvvm/getstarted /// </para> /// </summary> public class OrderViewModel : ViewModelBase { private const string testOrderNumber = "123456"; private Order _order; /// <summary> /// Initializes a new instance of the OrderViewModel class. /// </summary> public OrderViewModel() : this(testOrderNumber) { } /// <summary> /// Initializes a new instance of the OrderViewModel class. /// </summary> public OrderViewModel(string orderNumber) { if (IsInDesignMode) { // Code runs in Blend --> create design time data. _order = new Order(orderNumber, "My Company", "Our Address"); } else { _order = GetOrder(orderNumber); } } public override void Cleanup() { // Clean own resources if needed _order = null; base.Cleanup(); } } } And the code that could be used to display an order view for a specific order: public void ShowOrder(string orderNumber) { // pass the order number to show to ViewModelLocator to be injected //into the constructor of the OrderViewModel instance ViewModelLocator.OrderToShow = orderNumber; View.OrderView orderView = new View.OrderView(); } These examples have been stripped down to show only the IoC ideas. It took a lot of trial and error, searching the internet for examples, and finding out that the Unity 2.0 documentation is lacking (at best) to come up with this solution. Let me know if you think it could be improved.

    Read the article

  • Castle Windsor in ASP.NET MVC projet

    - by Kris-I
    Hello, In an ASP.NET MVC project, using Castle Windsor as IoC container. I'd like use the Logger facilities of this package. I read several article about the configuration but I'd find the right configuration to add the logger to the container. Do you have an idea ? Thanks,

    Read the article

  • Unity framework - creating & disposing Entity Framework datacontexts at the appropriate time

    - by TobyEvans
    Hi there, With some kindly help from StackOverflow, I've got Unity Framework to create my chained dependencies, including an Entity Framework datacontext object: using (IUnityContainer container = new UnityContainer()) { container.RegisterType<IMeterView, Meter>(); container.RegisterType<IUnitOfWork, CommunergySQLiteEntities>(new ContainerControlledLifetimeManager()); container.RegisterType<IRepositoryFactory, SQLiteRepositoryFactory>(); container.RegisterType<IRepositoryFactory, WCFRepositoryFactory>("Uploader"); container.Configure<InjectedMembers>() .ConfigureInjectionFor<CommunergySQLiteEntities>( new InjectionConstructor(connectionString)); MeterPresenter meterPresenter = container.Resolve<MeterPresenter>(); this works really well in creating my Presenter object and displaying the related view, I'm really pleased. However, the problem I'm running into now is over the timing of the creation and disposal of the Entity Framework object (and I suspect this will go for any IDisposable object). Using Unity like this, the SQL EF object "CommunergySQLiteEntities" is created straight away, as I've added it to the constructor of the MeterPresenter public MeterPresenter(IMeterView view, IUnitOfWork unitOfWork, IRepositoryFactory cacheRepository) { this.mView = view; this.unitOfWork = unitOfWork; this.cacheRepository = cacheRepository; this.Initialize(); } I felt a bit uneasy about this at the time, as I don't want to be holding open a database connection, but I couldn't see any other way using the Unity dependency injection. Sure enough, when I actually try to use the datacontext, I get this error: ((System.Data.Objects.ObjectContext)(unitOfWork)).Connection '((System.Data.Objects.ObjectContext)(unitOfWork)).Connection' threw an exception of type 'System.ObjectDisposedException' System.Data.Common.DbConnection {System.ObjectDisposedException} My understanding of the principle of IoC is that you set up all your dependencies at the top, resolve your object and away you go. However, in this case, some of the child objects, eg the datacontext, don't need to be initialised at the time the parent Presenter object is created (as you would by passing them in the constructor), but the Presenter does need to know about what type to use for IUnitOfWork when it wants to talk to the database. Ideally, I want something like this inside my resolved Presenter: using(IUnitOfWork unitOfWork = new NewInstanceInjectedUnitOfWorkType()) { //do unitOfWork stuff } so the Presenter knows what IUnitOfWork implementation to use to create and dispose of straight away, preferably from the original RegisterType call. Do I have to put another Unity container inside my Presenter, at the risk of creating a new dependency? This is probably really obvious to a IoC guru, but I'd really appreciate a pointer in the right direction thanks Toby

    Read the article

  • What is the IServiceLocator interface?

    - by stiank81
    From what I understand IServiceLocator is an interface to abstract the actual IoC container away? I'm asking with relation to Prism where I'm trying to replace Unity with Prism, and I see Prism-classes relying on IServiceLocator. Could someone please clarify the role of the interface and when it is used? And also; what is the Common Service Locator, and will this be helpful when working with IServiceLocator?

    Read the article

  • regarding C++ stl container swap function

    - by sm1
    I recently learned that all stl containers have swap function: i.e. c1.swap(c2); will lead to object underlying c1 being assigned to c2 and vice versa. I asked my professor if same is true in case of c1 and c2 being references. he said same mechanism is followed. I wonder how it happens since c++ references cannot be reseted.

    Read the article

  • Is there a concurrent container library for C++

    - by Lirik
    I'm looking for implementations of lock-free containers: Blocking Queue Blocking Stack Hash Map etc... Are there any good libraries out there? I would like to refrain from writing these data structures... I would much rather use something that has been tested by the community.

    Read the article

  • No Internet connectivity to linux container on Debian

    - by kirankumar
    I have created a linux container with debian-wheezy template. I am not able to have internet connectivity from the container. Below is my network configuration. Could some one please help me in figuring out the issue ? I can ping to the eth0 ip address in the container from the host. Similarly, i can ping from container to br0 ip address on the host. /etc/network/interfaces on host =============================== # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 auto eth0 iface eth0 inet dhcp # bridge configuration auto br0 iface br0 inet dhcp bridge_ports eth0 vethCE2 bridge_fd 0 bridge_stp off bridge_maxwait 0 ifconfig -a output on host ========================== ifconfig -a br0 Link encap:Ethernet HWaddr 08:00:27:bd:61:5e inet addr:10.0.0.11 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:febd:615e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:422 errors:0 dropped:0 overruns:0 frame:0 TX packets:266 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:174110 (170.0 KiB) TX bytes:31582 (30.8 KiB) eth0 Link encap:Ethernet HWaddr 08:00:27:bd:61:5e UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13017 errors:0 dropped:0 overruns:0 frame:0 TX packets:6210 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7944745 (7.5 MiB) TX bytes:1368421 (1.3 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:835 errors:0 dropped:0 overruns:0 frame:0 TX packets:835 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:91148 (89.0 KiB) TX bytes:91148 (89.0 KiB) vethCE2 Link encap:Ethernet HWaddr fe:3a:43:52:14:49 inet6 addr: fe80::fc3a:43ff:fe52:1449/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:52 errors:0 dropped:0 overruns:0 frame:0 TX packets:205 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2660 (2.5 KiB) TX bytes:31133 (30.4 KiB) brctl show output on host ========================== bridge name bridge id STP enabled interfaces br0 8000.080027bd615e no eth0 vethCE2 /etc/network/interfaces on container ======================================= auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.0.0.99 netmask 255.255.255.0 network 10.0.0.0 ifconfig -a output on container =============================== root@CE2:~# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:00 inet addr:10.0.0.99 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::211:22ff:fe33:4400/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:198 errors:0 dropped:0 overruns:0 frame:0 TX packets:52 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:30121 (29.4 KiB) TX bytes:2660 (2.5 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:26 errors:0 dropped:0 overruns:0 frame:0 TX packets:26 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2366 (2.3 KiB) TX bytes:2366 (2.3 KiB) Networking content of /var/lib/lxc/CE2/config ============================================== # networking lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 lxc.network.name = eth0 lxc.network.veth.pair = vethCE2 # It is fine to be commented out #lxc.network.ipv4 = 192.168.10.21/24 # Change this lxc.network.hwaddr = 00:11:22:33:44:00 Let me know if you need any other details. Thanks, Kiran Kumar

    Read the article

  • Force an LXC container to use its own IP address

    - by emma sculateur
    Sorry if this question has already been asked. I could not find it, I have this setup : +---------------------------------------------------------------------------------------------+ |HOST | | | | +-------------------------------------------------+ | | | UBUNTU-VM | | | | | | | | +-------------------+ | | | | |UBUNTU-LXC | | +------------------+ | | | | 10.0.0.3/24 | 10.0.0.1/24 | |OTHER VM | | | | | eth0-----lxcbr0----------eth0-----------br0----------eth0 | | | | | | 192.168.100.2/24| 192.168.100.1/24 |192.168.100.3/24 | | | | +-------------------+ | +------------------+ | | +-------------------------------------------------+ | +---------------------------------------------------------------------------------------------+ When I ping 192.168.100.3 from my UBUNTU-LXC, the source IP address is automatically changed to 192.168.100.2 by UBUNTU-VM. It's like having a NAT, whereas I really want my UBUNTU-LXC to talk with it own IP address. Is there any way to do this ? Edit : these info may be relevant : I am using KVM +libvirt to set up my VMs Here is how I create my interface in UBUNTU-VM : <interface type='bridge'> <mac address='52:54:00:cb:aa:74'/> <source bridge='br0'/> <model type='e1000'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </interface>

    Read the article

  • Reinstalling a container in virtuozzo (Parallels Power Panel)

    - by x86shadow
    Hello, I recently bought a VPS with Windows Server 2003 x64 Standard PreInstalled. the reseller gave me the Username and Password for the Parallels Power Panel and also it's address (something like this: https://??.???.???.??:4643/) I've just reinstalled the container using Virtuozzo (first I stopped the container, then reinstalled the container and the last log message was Reinstalling...) now after 2 hours I can't access the ControlPanel. what's wrong? is it normal? how long does it take to reinstall the container? why the ControlPanel is not accessible now? I'm kinda noob. Please help

    Read the article

  • Encryption container for multiple people

    - by Adam M.
    I was just wondering if anyone may have come across a product that would allow for a container based encryption to be used by multiple people, in a Windows Server setup. I wanted to see if there might be something like a truecrypt that could handle being accessed by two accounts? Looking to see if there is a product that would have such properties that would allow only a hand full of users access to the content of the location, but allow for the files to be backed up a normal backup system. That way if a file had to be restored, the container could be redirected to another location for one of the users to get access to it? This would allow for access to be restricted beyond the NTFS and file share permissons

    Read the article

  • Dependency Injection Constructor Madness

    - by JP
    I find that my constructors are starting to look like this: public MyClass(Container con, SomeClass1 obj1, SomeClass2, obj2.... ) with ever increasing parameter list. Since "Container" is my dependency injection container, why can't I just do this: public MyClass(Container con) for every class? What are the downsides? If I do this, it feels like I'm using a glorified static. Please share your thoughts on IoC and Dependency Injection madness. Thanks in advance. -JP

    Read the article

  • GWT Acegi alternative

    - by DroidIn.net
    I'm starting new project. The client interface is based on GWT (and GXT) I have no say it's predetermined. However I can pick and choose as far as server side so I can have some fun and hopefully learn something new in the process. Some requirements are : Exchange with server will be through use of JSON, most if not all of UI will be generated by GWT (JS) on the client, so the client/serve exchange will be limited to data exchange as much as possible No Hibernate (it's not really supported on the proprietary db I will be connecting to). In the past projects people would use JDBC or iBATIS Some sort of IoC (I'm thinking Guice just to stick with Google) Some sort of Security framework based on LDAP. In the past we would use Spring security (Acegi) but it wasn't ideal and we had to customize it a lot So basically should I stick with tried-and-true Spring/Acegi or try something based on Guice? And what that "something" would be and how mature is it?

    Read the article

  • Plugin Framework - can there be too many addin assemblies?

    - by spooner
    Hi, The product I'm working on needs to be built in such a way that we have a quote engine driven by a pluggable framework. We are currently thinking of using MAF, so we can leverage separation of the host and addin interfaces for versioning. However, I'm concerned that we'd have lots of assemblies, it's likely that we'd have one for each quote engine addin - of which there could be 100 going forward, we also need to support multiple versions, so there could be lots of assemblies in total. The quote engine also uses WF to drive it, which means each AppDomain for each addin will need a workflow runtime associated with it. This seems quite heavyweight, however we can unload unfrequently used addins. Does this seem like a good design? We've also looked at a single AppDomain solution using an IOC container to load addin types, but I'm concerned that we won't be able to unload any of the assemblies, given their quantity.

    Read the article

  • Passing an instantiated class to concrete class derived by Castle Windsor

    - by Tr1stan
    I have a system that I'm using to test some new architecture. I have the following setup (In MVC2 .Net - C Sharp): View < Controller < Service < Repository < DB I'm using Castle Windsor as my DI (IoC) controller, and this is working just fine in both the Service and Repo layers. However, I'm now at a point where I would like to pass an Entity Framework (DatabaseNameEntity) to the constructor to the Service, and then to the Repo, so that I have something similar to a Unit of Work pattern per request (This feels like what I'm trying to achieve anyway) - and I'm having trouble working out how this can be done using Castle Windsor. Am I going off on a silly tangent? Any pointers appreciated.

    Read the article

  • How to override the behavior of Spring @Autowired

    - by Mark
    Hi a little background: I am Using Spring 2.5, and specifically spring IOC and annotations. I am using @Autowired in my code (the Autowiring is done by type) and use @Component for exposing Classes to the Automatic wiring. The situation described bellow arose while i tried to test my code. now to the problem: Note: i use a different Spring Context for the Test environment. I have a class FOO which is @Autowired but in the test context i want to use a different class of the same type MockFoo (extends FOO) The Spring Setup of course fails do so automatically due to multiple options for the Dependency Injection of the FOO class (both FOO and MockFOO comply to the Type check) I am looking for a way to inject the test bean instead of the original bean. I expected Spring to allow using the Context configurion file to override a bean injection or to order Spring not to autowire a specific bean BUT All these option seem to exists only for the beans which were originally defined in the Spring Context Configuration file

    Read the article

  • Passing ASP.NET User by Dependency Injection

    - by UpTheCreek
    In my web application I have various components that need to access the currently authenticated user (HttpContext.User). There are two obvious ways a component can access this: 1) Accessing getting the User from HttpContext.Current 2) Passing the user around in constructors Is not ideal because it makes testing difficult and ties application components to web concerns, when they really shouldn't know about it. Is just messy and complicates everything. So I've been thinking about passing in the current user (or perhaps just the name/id) to any component that needs it using an IoC container (via dependency injection). Is anyone using this technique to supply the current ASP.NET user to parts of the application? Or, Does this sound like a sensible approach? I would like know how this has worked out for people. Thanks

    Read the article

  • StructureMap 'conditional singleton' for Lucene.Net IndexReader

    - by Gareth D
    I have a threadsafe object that is expensive to create and needs to be available through my application (a Lucene.Net IndexReader). The object can become invalid, at which point I need to recreate it (IndexReader.IsCurrent is false, need a new instance using IndexReader.Reopen). I'd like to able to use an IoC container (StructureMap) to manage the creation of the object, but I can't work out if this scenario is possible. It feels like some kind of "conditional singleton" lifecycle. Does StructureMap provide such a feature? Any alternative suggestions?

    Read the article

  • C# Container Class

    - by Jamie
    I'm building a game in c# which allows you to script your own level, although I have come across a bit of a thought. I have a base class called "World" as an object. This was made with a simple: class World { However, when the user is scripting their level, all of the game objects will be contained in the world object. I want them to be able to do something on the lines of: World.ParentObjectName.ParentObjectProperty = "abc"; I know that the System.Windows.Forms.Panel and other classes are like containers and can have objects in them and be accessed in that kind of way... my question is how can I make a class which is like a container in which I can add objects to, and then access them with a World.ObjectName I have tried class World : System.Collections.CollectionBase, but with this method, I have to keep typing World.Item("ObjectName") Can anyone help? Thanks!

    Read the article

  • Doesn't Spring really support Interface injection at all?

    - by mrCoder
    Hi I know that Spring doesn't supports Interface injection and I've read that many a times. But today as I came across an article about IOC by Martin Fowler (link), it seems using ApplicationContextAware in Spring is some what similar to the Interface injection. when ever Spring' context reference is required in our Spring bean, we'll implement ApplicationContextAware and will implement the setApplicationContext(ApplicationContext context) method, and we'll include the bean in the config file. Is not this the same as Interface injection, where where telling the Spring to inject (or), say, pass the reference of the context into this bean? Or I m missing something here? Thanks for any information! ManiKanta

    Read the article

  • How to change size of STL container in C++

    - by Jaime Pardos
    I have a piece of performance critical code written with pointers and dynamic memory. I would like to rewrite it with STL containers, but I'm a bit concerned with performance. Is there a way to increase the size of a container without initializing the data? For example, instead of doing ptr = new BYTE[x]; I want to do something like vec.insert(vec.begin(), x, 0); However this initializes every byte to 0. Isn't there a way to just make the vector grow? I know about reserve() but it just allocates memory, it doesn't change the size of the vector, and doesn't allows me to access it until I have inserted valid data. Thank you everyone.

    Read the article

  • Getting no class def found error. Log4J -> Java

    - by Nitesh Panchal
    Hello, I created a simple web application and added log4J's jar in my lib folder and it seems to work fine. Then i created a Ejb module and did the same thing of adding jar file in my classpath, but i am getting this error :- Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.NoClassDefFoundError: org/apache/log4j/Logger at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:4929) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4761) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955) ... 94 more Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger at common.Utils.getRssFeed(Utils.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5243) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:615) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:567) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:157) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:139) at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:858) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:797) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:367) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5215) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5203) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:190) ... 92 more I don't even have any other version of log4j in classpath. Any idea why is this error coming? Actually first i created a Enterprise application and everything seemed to work fine. But then, i copied files from my enterprise application's ejb module to a separate module and since then these errors are coming. This is in my build-impl.xml :- <target depends="compile" name="library-inclusion-in-archive"> <copyfiles files="${libs.Log4J.classpath}" todir="${build.classes.dir}"/> </target> <target depends="compile" name="library-inclusion-in-manifest"> <copyfiles files="${libs.Log4J.classpath}" todir="${dist.ear.dir}/lib"/> <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update"/> </target> Don't know why is this pointing to ear instead of jar. Is there any problem with the above statement? How do i resolve this? I am using Netbeans 6.8 Thanks in advance :)

    Read the article

  • Castle Windsor and its own configuration file

    - by Coppermill
    I am using Castle Windsor for IoC, and have the configuration held in the web.config/app.config, using the following factory: public static TYPE Factory(string component) { var windsorContainer = new WindsorContainer(new XmlInterpreter()); var service = windsorContainer.Resolve<TYPE>(component); if (service == null) throw new ArgumentNullException(string.Format("Unable to find container {0}", component)); return service; } and my web.config looking like this: <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/> </configSections> <castle> <components> <component id="Data" service="Data.IData, Data" type="Data.DataService, Data"/> </components> </castle> <appSettings>....... Which works fine, but I'd like to place the configuration for Castle Windsor in a file called castle.config. How do I do this?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >