Search Results

Search found 4034 results on 162 pages for 'ioc container'.

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

  • How do I programmatically add a widget to a container created from GtkBuilder?

    - by Warner Young
    I've created a window that has some containers and widgets in it, and I want to add a new widget dynamically at run-time to one of the Vboxes in this window. So I have this code, which brings up the window: gtk_builder_add_from_file( g_builder, "window.xml", NULL ); mainwindow = GTK_WIDGET( gtk_builder_get_object( g_builder, "window" )); gtk_widget_show( mainwindow ); Then I create a new label, for example, and add it to one of the existing Vboxes, called "vbox_mid", like this: label = gtk_label_new( "Test label" ); vbox = GTK_WIDGET( gtk_builder_get_object( g_builder, "vbox_mid" )); gtk_box_pack_end( GTK_BOX( vbox ), label, TRUE, TRUE, 0 ); But this doesn't seem to work. I don't see a new label in the vbox. I have a feeling I'm missing something here, but I can't see what it is. I thought perhaps there was a special GtkBuilder call to add a widget dynamically, but I don't see anything that looks like that. I would really appreciate any help on this.

    Read the article

  • Sending Messages to SignalR Hubs from the Outside

    - by Ricardo Peres
    Introduction You are by now probably familiarized with SignalR, Microsoft’s API for real-time web functionality. This is, in my opinion, one of the greatest products Microsoft has released in recent time. Usually, people login to a site and enter some page which is connected to a SignalR hub. Then they can send and receive messages – not just text messages, mind you – to other users in the same hub. Also, the server can also take the initiative to send messages to all or a specified subset of users on its own, this is known as server push. The normal flow is pretty straightforward, Microsoft has done a great job with the API, it’s clean and quite simple to use. And for the latter – the server taking the initiative – it’s also quite simple, just involves a little more work. The Problem The API for sending messages can be achieved from inside a hub – an instance of the Hub class – which is something that we don’t have if we are the server and we want to send a message to some user or group of users: the Hub instance is only instantiated in response to a client message. The Solution It is possible to acquire a hub’s context from outside of an actual Hub instance, by calling GlobalHost.ConnectionManager.GetHubContext<T>(). This API allows us to: Broadcast messages to all connected clients (possibly excluding some); Send messages to a specific client; Send messages to a group of clients. So, we have groups and clients, each is identified by a string. Client strings are called connection ids and group names are free-form, given by us. The problem with client strings is, we do not know how these map to actual users. One way to achieve this mapping is by overriding the Hub’s OnConnected and OnDisconnected methods and managing the association there. Here’s an example: 1: public class MyHub : Hub 2: { 3: private static readonly IDictionary<String, ISet<String>> users = new ConcurrentDictionary<String, ISet<String>>(); 4:  5: public static IEnumerable<String> GetUserConnections(String username) 6: { 7: ISet<String> connections; 8:  9: users.TryGetValue(username, out connections); 10:  11: return (connections ?? Enumerable.Empty<String>()); 12: } 13:  14: private static void AddUser(String username, String connectionId) 15: { 16: ISet<String> connections; 17:  18: if (users.TryGetValue(username, out connections) == false) 19: { 20: connections = users[username] = new HashSet<String>(); 21: } 22:  23: connections.Add(connectionId); 24: } 25:  26: private static void RemoveUser(String username, String connectionId) 27: { 28: users[username].Remove(connectionId); 29: } 30:  31: public override Task OnConnected() 32: { 33: AddUser(this.Context.Request.User.Identity.Name, this.Context.ConnectionId); 34: return (base.OnConnected()); 35: } 36:  37: public override Task OnDisconnected() 38: { 39: RemoveUser(this.Context.Request.User.Identity.Name, this.Context.ConnectionId); 40: return (base.OnDisconnected()); 41: } 42: } As you can see, I am using a static field to store the mapping between a user and its possibly many connections – for example, multiple open browser tabs or even multiple browsers accessing the same page with the same login credentials. The user identity, as is normal in .NET, is obtained from the IPrincipal which in SignalR hubs case is stored in Context.Request.User. Of course, this property will only have a meaningful value if we enforce authentication. Another way to go is by creating a group for each user that connects: 1: public class MyHub : Hub 2: { 3: public override Task OnConnected() 4: { 5: this.Groups.Add(this.Context.ConnectionId, this.Context.Request.User.Identity.Name); 6: return (base.OnConnected()); 7: } 8:  9: public override Task OnDisconnected() 10: { 11: this.Groups.Remove(this.Context.ConnectionId, this.Context.Request.User.Identity.Name); 12: return (base.OnDisconnected()); 13: } 14: } In this case, we will have a one-to-one equivalence between users and groups. All connections belonging to the same user will fall in the same group. So, if we want to send messages to a user from outside an instance of the Hub class, we can do something like this, for the first option – user mappings stored in a static field: 1: public void SendUserMessage(String username, String message) 2: { 3: var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); 4: 5: foreach (String connectionId in HelloHub.GetUserConnections(username)) 6: { 7: context.Clients.Client(connectionId).sendUserMessage(message); 8: } 9: } And for using groups, its even simpler: 1: public void SendUserMessage(String username, String message) 2: { 3: var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); 4:  5: context.Clients.Group(username).sendUserMessage(message); 6: } Using groups has the advantage that the IHubContext interface returned from GetHubContext has direct support for groups, no need to send messages to individual connections. Of course, you can wrap both mapping options in a common API, perhaps exposed through IoC. One example of its interface might be: 1: public interface IUserToConnectionMappingService 2: { 3: //associate and dissociate connections to users 4:  5: void AddUserConnection(String username, String connectionId); 6:  7: void RemoveUserConnection(String username, String connectionId); 8: } SignalR has built-in dependency resolution, by means of the static GlobalHost.DependencyResolver property: 1: //for using groups (in the Global class) 2: GlobalHost.DependencyResolver.Register(typeof(IUserToConnectionMappingService), () => new GroupsMappingService()); 3:  4: //for using a static field (in the Global class) 5: GlobalHost.DependencyResolver.Register(typeof(IUserToConnectionMappingService), () => new StaticMappingService()); 6:  7: //retrieving the current service (in the Hub class) 8: var mapping = GlobalHost.DependencyResolver.Resolve<IUserToConnectionMappingService>(); Now all you have to do is implement GroupsMappingService and StaticMappingService with the code I shown here and change SendUserMessage method to rely in the dependency resolver for the actual implementation. Stay tuned for more SignalR posts!

    Read the article

  • How can I get access to spring container?

    - by Antony
    I have a spring container running, and I have class with which I want to have access to the bean created inside spring container. The class I have is not registered with the spring container. One thing I can do is that I can use MethodInvoker to call a static method, so I will have access to static field (this would be a bean from spring container) in my class always. Do we have class like WebapplicationContextUtils for a application that is not web?

    Read the article

  • db4o getting history of container

    - by jacklondon
    var config = Db4oEmbedded.NewConfiguration (); using (var container = Db4oEmbedded.OpenFile (config, FILE)) { var foo = new Foo ("Test"); container.Store (foo); foo.Name = "NewName"; container.Store (foo); } Any way to resolve the history of container for foo in the format below? Foo created with values "Test" Foo Foo's property "Test" changed to "NewName"

    Read the article

  • Global Address List, Multiple All Address Lists in CN=Address Lists Container

    - by Jonathan
    When my colleges (that was way before my time here) updated Exchange 2000 to 2003 a English All Address Lists appeared in addition to the German variant. The English All Address Lists have German titled GAL below it. This has just been a cosmetic problem for the last few years. Now as we are in the process of rolling out Exchange 2010 this causes some issues. Exchange 2010 picked the wrong i.e. English Address Lists Container to use. In ADSI Editor we see CN=All Address Lists,CN=Address Lists Container,CN=exchange org,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain and CN=Alle Adresslisten,CN=Address Lists Container,CN=exchange org,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain. In the addressBookRoots attribute of CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=domain both address lists were stored as values. We removed the English variant from addressBookRoots and restarted all (old and new) Exchange servers. User with mailboxes on the Exchange 2003 now only sees the German variant. Exchange 2010 is still stuck with the English/Mixed variant as are Users on Exchange 2010. Our goal would be to have Outlook display the German title of All Address Lists and get rid of the wrong Address Lists Container.

    Read the article

  • Running docker in VPC and accessing container from another VPC machine

    - by Bogdan Gaza
    I'm having issues while running docker in AWS VPC. Here is my setup: I've got two machines running in VPC: 10.0.100.150 10.0.100.151 both having an elastic IPs assigned to them, both running in the same internet enabled subnet. Let's say I'm running a web server that serves static files in a container on the 10.0.100.150 machine the container: IP: 172.17.0.2 port 8111 is forwarded on the 8111 port on the machine. I'm trying to access the static files from my local machine (or another non-VPC machine also tried an EC2 instance not running in the VPC) and it work flawlessly. If I try to access the files from the other machine (10.0.100.151) it hangs. I'm using wget to pull the files. Tried to debug it with tcpdump and ngrep and that I have seen is that the request reaches the container. If I ngrep on the host machine I see the requests going in but no response going back. If I ngrep on the container I see the requests going in and the response going back. I've tried multiple iptables setups (with postrouting enabled, with manually forwarding ports etc) but no success. Help in any way - even debugging directions would be much appreciated. Thanks!

    Read the article

  • IoC with AutoMapper Profile using Autofac

    - by DownChapel
    I have been using AutoMapper for some time now. I have a profile setup like so: public class ViewModelAutoMapperConfiguration : Profile { protected override string ProfileName { get { return "ViewModel"; } } protected override void Configure() { AddFormatter<HtmlEncoderFormatter>(); CreateMap<IUser, UserViewModel>(); } } I add this to the mapper using the following call: Mapper.Initialize(x => x.AddProfile<ViewModelAutoMapperConfiguration>()); However, I now want to pass a dependency into the ViewModelAutoMapperConfiguration constructor using IoC. I am using Autofac. I have been reading through the article here: http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/05/11/automapper-and-ioc.aspx but I can't see how this would work with Profiles. Any ideas? Thanks

    Read the article

  • MVVM && IOC && Sub-ViewModels

    - by Lee Treveil
    I have a ViewModel, it takes two parameters in the constructor that are of the same type: public class CustomerComparerViewModel { public CustomerComparerViewModel(CustomerViewModel customerViewModel1, CustomerViewModel customerViewModel2) { } } public class CustomerViewModel { public string FirstName { get; set; } public string LastName { get; set; } } If I wasn't using IOC I could just new up the viewmodel and pass the sub-viewmodels in. I could package the two viewmodels into one class and pass that into the constructor but if I had another viewmodel that only needed one CustomerViewModel I would need to pass in something that the viewmodel does not need. How do I go about dealing with this using IOC? I'm using Ninject btw. Thanks

    Read the article

  • Unity IOC, AOP & Interface Interception

    - by krisg
    I've been playing around with Unity to do some AOP stuff, setting up via IOC like: ioc.RegisterType<ICustomerService, CustomerService>() .Configure<Interception>().SetInterceptorFor<ICustomerService>(new InterfaceInterceptor()); ... and then having an ICallHandler on the ICustomerService interface's methods. For teh time being i want to just get the method called, the class it's in, and the namespace for that class. So... inside the... public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) ...method of the ICallHandler, i can access the method name via input.MethodBase.Name... if i use input.MethodBase.DeclaringType.Name i get the interface ICustomerService... BUT... how would i go about getting the implementing class "CustomerService" rather than the interface? I've been told to use input.Target.. but that just returns "DynamicModule.ns.Wrapped_ICustomerService_4f2242e5e00640ab84e4bc9e05ba0a13" Any help on this folks?

    Read the article

  • Linq to SQL DataContext Windsor IoC memory leak problem

    - by Mr. Flibble
    I have an ASP.NET MVC app that creates a Linq2SQL datacontext on a per-web-request basis using Castler Windsor IoC. For some reason that I do not fully understand, every time a new datacontext is created (on every web request) about 8k of memory is taken up and not released - which inevitably causes an OutOfMemory exception. If I force garbage collection the memory is released OK. My datacontext class is very simple: public class DataContextAccessor : IDataContextAccessor { private readonly DataContext dataContext; public DataContextAccessor(string connectionString) { dataContext = new DataContext(connectionString); } public DataContext DataContext { get { return dataContext; } } } The Windsor IoC webconfig to instantiate this looks like so: <component id="DataContextAccessor" service="DomainModel.Repositories.IDataContextAccessor, DomainModel" type="DomainModel.Repositories.DataContextAccessor, DomainModel" lifestyle="PerWebRequest"> <parameters> <connectionString> ... </connectionString> </parameters> </component> Does anyone know what the problem is, and how to fix it?

    Read the article

  • Which IOC runs in medium trust

    - by Rippo
    Hi I am trying to get a website running with Mosso that has Castle Windsor as my IOC, however I am getting the following error. [SecurityException: That assembly does not allow partially trusted callers.] GoldMine.WindsorControllerFactory..ctor() in WindsorControllerFactory.cs:33 GoldMine.MvcApplication.Application_Start() in Global.asax.cs:70 My questions are Does Castle Windsor run under medium trust? Can I download the DLL's without having to recompile with nant? (as I don't have this set up and don't know nant at all) Or is there another IOC that I can use that I can download and works in Medium Trust? Thanks

    Read the article

  • Null Inner Bean with Spring IoC

    - by bruno conde
    Hi all. I have a singleton bean definition like this: <bean id="exampleBean" class="com.examples.ExampleBean"> <property name="exampleBean2"> <bean class="com.examples.ExampleBean2" /> </property> </bean> where ExampleBean could be: public class ExampleBean { private ExampleBean2 exampleBean2; public ExampleBean() { } public ExampleBean2 getExampleBean2() { return exampleBean2; } public void setExampleBean2(ExampleBean2 exampleBean2) { this.exampleBean2 = exampleBean2; } } The problem is that, in certain conditions, the com.examples.ExampleBean2 class might not exist at runtime witch will cause an error when the IoC tries to instantiate exampleBean. What I need is to ignore this error from IoC and allow the exampleBean to be created but leaving the exampleBean2 property null. So the question is: is this possible in any way? Thanks for all your help.

    Read the article

  • Share java object between two forms using Spring IoC

    - by Vladimir
    I want to share java object between two forms using Spring IoC. It should acts like Registry: Registry.set("key", new Object()); // ... Object o = Registry.get("key"); // ... Registry.set("key", new AnotherObject()); // rewrite old object I tried this code to register bean at runtime: applicationContext.getBeanFactory().registerSingleton("key", object); but it does not allow to rewrite existing object (result code for checking and deleting existing bean is too complicated)... PS I am Java newbie, so mb I am doing it wrong and I should not use IoC at all... any help is appreciated...

    Read the article

  • Best way to order menu items injected by an IoC/plugin Framework

    - by Daver
    One of the common things I've seen done in applications built on IoC/plugin frameworks is to add commands to menus or toolbars from the dynamically loaded plugins. For example, the application's default plugins supply actions like "New, Open, Save" that show up in the context menu for a certain item in the workspace. A new plugin may add "Mail, Post, Encrypt" commands, but where do those commands show up in relation to "New, Open, Save"? How can the application that is loading components through IoC impose order on the items that get injected? Does it require metadata from the plugins that give a hint on how to group or order the items? Does it use a config file of previously known menu names (or ids) to define the order (seems a little weak to me)? Or are "unknown" plugins treated as second class citizens and always get dumped into sub menus? Something I've never even imagined (which I'm hoping to see in the answers)

    Read the article

  • How do I prevent duplicates, in XSL?

    - by LOlliffe
    How do I prevent duplicate entries into a list, and then ideally, sort that list? What I'm doing, is when information at one level is missing, taking the information from a level below it, to building the missing list, in the level above. Currently, I have XML similar to this: <c03 id="ref6488" level="file"> <did> <unittitle>Clinic Building</unittitle> <unitdate era="ce" calendar="gregorian">1947</unitdate> </did> <c04 id="ref34582" level="file"> <did> <container label="Box" type="Box">156</container> <container label="Folder" type="Folder">3</container> </did> </c04> <c04 id="ref6540" level="file"> <did> <container label="Box" type="Box">156</container> <unittitle>Contact prints</unittitle> </did> </c04> <c04 id="ref6606" level="file"> <did> <container label="Box" type="Box">154</container> <unittitle>Negatives</unittitle> </did> </c04> </c03> I then apply the following XSL: <xsl:template match="c03/did"> <xsl:choose> <xsl:when test="not(container)"> <did> <!-- If no c03 container item is found, look in the c04 level for one --> <xsl:if test="../c04/did/container"> <!-- If a c04 container item is found, use the info to build a c03 version --> <!-- Skip c03 container item, if still no c04 items found --> <container label="Box" type="Box"> <!-- Build container list --> <!-- Test for more than one item, and if so, list them, --> <!-- separated by commas and a space --> <xsl:for-each select="../c04/did"> <xsl:if test="position() &gt; 1">, </xsl:if> <xsl:value-of select="container"/> </xsl:for-each> </container> </did> </xsl:when> <!-- If there is a c03 container item(s), list it normally --> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> But I'm getting the "container" result of <container label="Box" type="Box">156, 156, 154</container> when what I want is <container label="Box" type="Box">154, 156</container> Below is the full result that I'm trying to get: <c03 id="ref6488" level="file"> <did> <container label="Box" type="Box">154, 156</container> <unittitle>Clinic Building</unittitle> <unitdate era="ce" calendar="gregorian">1947</unitdate> </did> <c04 id="ref34582" level="file"> <did> <container label="Box" type="Box">156</container> <container label="Folder" type="Folder">3</container> </did> </c04> <c04 id="ref6540" level="file"> <did> <container label="Box" type="Box">156</container> <unittitle>Contact prints</unittitle> </did> </c04> <c04 id="ref6606" level="file"> <did> <container label="Box" type="Box">154</container> <unittitle>Negatives</unittitle> </did> </c04> </c03> Thanks in advance for any help!

    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

  • Increase the height of Flex Container dynamically and introduce scrollbar on the browser

    - by shruti
    Hi, I am trying to increase the height of container with increase in the number of contents inside the container. Like in my case i m using tileList inside tabNavigator , when I put contents inside the tileList, the height of tileList does not increase beyond vertical height of the viewport. It puts scrollbar on the container. I want to increase the height of an flex container with increase in the contents and introduce scrollbar on the browser with increase in contents in the flex container. Could anybody please suggest me how I could achieve this. Thanks in advance.

    Read the article

  • getting the stage from a container in kineticjs

    - by seinecle
    I have this stage associated to a container: html: <div id="container"> script 1: var stageInFirstScript = new Kinetic.Stage({ container: document.getElementById('container'), width: this.SKETCH_WIDTH, height: this.SKETCH_HEIGTH }); In a second script, I need to manipulate the shapes on the stage I just created. Is it possible to retrieve stageInFirstScript with something like this? script 2: var stageInSecondScript = document.getElementById('container').RetrieveExistingStage(); //now I have retrieved stageInFirstScript //I can add shapes to it, etc.... Any help or alternative solution would be appreciated!

    Read the article

  • Simple heart container script for 2D game (Unity)?

    - by N1ghtshade3
    I'm attempting to create a simple mobile game (C#) that involves a simple three-heart life system. After searching for hours online, many of the solutions use OnGUI (which is apparently horrible for performance) and the rest are too complicated for me to understand and add to my code. The other solutions involve using a single texture and just hiding part of it when damage is taken. In my game, however, the player should be able to go over three hearts (for example, every 100 points). Sebastian Lague's Zelda-Style Health is what I'm looking for, but even though it's a tutorial there is way too much going on that I don't need or can't customize to fit in mine. What I have so far is a script called HealthScript.cs which contains a variable lives. I have another script, PlayerPhysics.cs which calls HealthScript and subtracts a life when an enemy is hit. The part I don't get is actually drawing the hearts. I think I understand what needs to happen, I just am not experienced enough with Unity to know how. The Start function should draw three (or whatever lives is set to) hearts in the top right corner. Since the game should be resolution-independent to accommodate the various sizes of Android devices, I'd rather use scaling rather than PixelInset. When the player hits an enemy as detected by PlayerPhysics.cs, it should subtract from lives. I think that I have this working using this.GetComponent<HealthScript>().lives -= 1 but I'm not sure if it actually works. This should trigger a redraw of the hearts so that there are now two hearts. The same principle would apply for adding hearts when a score is reached, except when lives > maxHeartsPerRow, the new hearts should be drawn below the old ones. I realise I don't have much code to show but believe me; I've tried for quite some time to figure this out and have little to show for it. Any help at all would be welcome; it seems like it shouldn't take that much code to put an image on the screen for each life there is, but I haven't found anything yet. Thanks!

    Read the article

  • WPF: How to get the bounds of a control in an automatic layout container, in the container coordinate space

    - by Bart Read
    Googling this the other day, I started to get the impression that this might be annoyingly tricky. You might wonder why this is necessary at all, given that WPF implements layout for you in most cases (except for containers such as Canvas), but trust me, if you're developing custom elements, at some point you're probably going to need it. If you're adding controls to a Canvas you can always use the attached Left, Right, etc., properties to get the bounds. Fortunately it's really no more difficult...(read more)

    Read the article

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