Search Results

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

Page 13/162 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Active Directory Services: PrincipalContext -- What is the DN of a "container" object?

    - by Ranger Pretzel
    I'm currently trying to authenticate via Active Directory Services using the PrincipalContext class. I would like to have my application authenticate to the Domain using Sealed and SSL contexts. In order to do this, I have to use the following constructor of PrincipalContext (link to MSDN page): public PrincipalContext( ContextType contextType, string name, string container, ContextOptions options ) Specifically, I'm using the constructor as so: PrincipalContext domainContext = new PrincipalContext( ContextType.Domain, domain, container, ContextOptions.Sealing | ContextOptions.SecureSocketLayer); MSDN says about "container": The container on the store to use as the root of the context. All queries are performed under this root, and all inserts are performed into this container. For Domain and ApplicationDirectory context types, this parameter is the distinguished name (DN) of a container object. What is the DN of a container object? How do I find out what my container object is? Can I query the Active Directory (or LDAP) server for this?

    Read the article

  • IoC and dataContext disposing in asp.net mvc 2 application

    - by zerkms
    I have the Global.asax like the code below: public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { // .... } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); ControllerBuilder.Current.SetControllerFactory(typeof(IOCControllerFactory)); } } public class IOCControllerFactory : DefaultControllerFactory { private readonly IKernel kernel; public IOCControllerFactory() { kernel = new StandardKernel(new NanocrmContainer()); } protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType == null) return base.GetControllerInstance(requestContext, controllerType); var controller = kernel.TryGet(controllerType) as IController; if (controller == null) return base.GetControllerInstance(requestContext, controllerType); var standartController = controller as Controller; if (standartController is IIoCController) ((IIoCController)standartController).SetIoc(kernel); return standartController; } class NanocrmContainer : Ninject.Modules.NinjectModule { public override void Load() { // ... Bind<DomainModel.Entities.db>().ToSelf().InRequestScope().WithConstructorArgument("connection", "Data Source=lims;Initial Catalog=nanocrm;Persist Security Info=True;User ID=***;Password=***"); } } } In this case if somewhere it is the class, defined like: public class UserRepository : IUserRepository { private db dataContext; private IUserGroupRepository userGroupRepository; public UserRepository(db dataContext, IUserGroupRepository userGroupRepository) { this.dataContext = dataContext; this.userGroupRepository = userGroupRepository; } } then the dataContext instance is created (if no one was created in this request scope) by Ninject. So the trouble now is - where to invoke dataContext method .Dispose()?

    Read the article

  • allocating extra memory for a container class.

    - by sil3nt
    Hey there, I'm writing a template container class and for the past few hours have been trying to allocate new memory for extra data that comes into the container (...hit a brick wall..:| ) template <typename T> void Container<T>::insert(T item, int index){ if ( index < 0){ cout<<"Invalid location to insert " << index << endl; return; } if (index < sizeC){ //copying original array so that when an item is //placed in the middleeverything else is shifted forward T *arryCpy = 0; int tmpSize = 0; tmpSize = size(); arryCpy = new T[tmpSize]; int i = 0, j = 0; for ( i = 0; i < tmpSize; i++){ for ( j = index; j < tmpSize; j++){ arryCpy[i] = elements[j]; } } //overwriting and placing item and location index elements[index] = item; //copying back everything else after the location at index int k = 0, l = 0; for ( k =(index+1), l=0; k < sizeC || l < (sizeC-index); k++,l++){ elements[k] = arryCpy[l]; } delete[] arryCpy; arryCpy = 0; } //seeing if the location is more than the current capacity //and hence allocating more memory if (index+1 > capacityC){ int new_capacity = 0; int current_size = size(); new_capacity = ((index+1)-capacityC)+capacityC; //variable for new capacity T *tmparry2 = 0; tmparry2 = new T[new_capacity]; int n = 0; for (n = 0; n < current_size;n++){ tmparry2[n] = elements[n]; } delete[] elements; elements = 0; //copying back what we had before elements = new T[new_capacity]; int m = 0; for (m = 0; m < current_size; m++){ elements[m] = tmparry2[m]; } //placing item elements[index] = item; } else{ elements[index] = item; } //increasing the current count sizeC++; my testing condition is Container cnt4(3); and as soon as i hit the fourth element (when I use for egsomething.insert("random",3);) it crashes and the above doesnt work. where have I gone wrong?

    Read the article

  • Content Container Overlaps Menu?

    - by Harold
    I'm currently working on a Joomla template using CSS divs. I have a header set up with our logo image in a div floated to the left, an adspace floated to the right, and the menu bar on the bottom. My content is divided into three div columns that are contained in "container.": the left column is floated left, the center is not floated, and the right is floated to the right. The problem is the "container" for the three content divs is overlapping the menu, as you can see in this image: http://www.ndpstudentcouncil.org/images/shot1.png Here's the HTML code: > <body> <div id="backdrop"> <div > id="wrapper"> <div id="header"> > <div id="topimage"> </div> > <div id="adspace1"><jdoc:include > type="modules" name="Ad Space #1" /> > This will be the location for our > "newsflash" items. </div> > > <div id="ddtopmenubar" > class="mattblackmenu"> > <ul> > <li><a href="http://www.ndpstudentcouncil.org">Home</a></li> > <li><a href="http://www.dynamicdrive.com/new.htm" rel="ddsubmenu1">DHTML</a></li> > <li><a href="http://www.dynamicdrive.com/style/" > rel="ddsubmenu2">CSS</a></li> > <li><a href="http://www.dynamicdrive.com/forums/">Forums</a></li> > <li><a href="http://tools.dynamicdrive.com/" > rel="ddsubmenu3">Web Tools</a></li> > </ul> > <script type="text/javascript" src="js/ddlevelsmenu.js"> > ddlevelsmenu.setup("ddtopmenubar", "topbar") > //ddlevelsmenu.setup("mainmenuid", > "topbar|sidebar") > </script> > <ul id="ddsubmenu1" class="ddsubmenustyle"> > <li><a href="#">Item 1a</a></li> > <li><a href="#">Item 2a</a></li> > <li><a href="#">Item Folder 3a</a> > <ul> > <li><a href="#">Sub Item 3.1a</a></li> > </ul> > </li> > <li><a href="#">Item 4a</a></li> > <li><a href="#">Item Folder 5a</a> > <ul> > <li><a href="#">Sub Item 5.1a</a></li> > <li><a href="#">Item Folder 5.2a</a> > <ul> > <li><a href="#">Sub Item 5.2.1a</a></li> > <li><a href="#">Sub Item 5.2.2a</a></li> > </ul> > </li> > </ul> > </a> > </li> > <li><a href="#">Item 6a</a></li> > </ul> </div> </div> > <div id="container"> <script language="javascript"> > matchHeight=function(){ > var divs,contDivs,maxHeight,divHeight,d; > // get all <div> elements in the document > divs=document.getElementsByTagName('div'); > contDivs=[]; > // initialize maximum height value > maxHeight=0; > // iterate over all <div> elements in the document > for(var i=0;i<divs.length;i++){ > // make collection with <div> elements with class attribute > 'container' > if(/\bcontainer\b/.test(divs[i].className)){ > d=divs[i]; > contDivs[contDivs.length]=d; > // determine height for <div> element > if(d.offsetHeight){ > divHeight=d.offsetHeight; > } > else if(d.style.pixelHeight){ > divHeight=d.style.pixelHeight; > } > // calculate maximum height > maxHeight=Math.max(maxHeight,divHeight); > } > } > // assign maximum height value to all of container <div> elements > for(var i=0;i<contDivs.length;i++){ > contDivs[i].style.height=maxHeight; > } > } > // execute function when page loads > window.onload=function(){ > if(document.getElementsByTagName){ > matchHeight(); > } > } > </script> <div id="left"> > <jdoc:include type="modules" name="left" /> </div> <div > id="middle"> > <jdoc:include type="component" /> </div> <div id="right"> > <jdoc:include type="modules" name="right" /> > </div> > </div> > <div id="footer" class="clear"><jdoc:include > type="modules" name="footer" /> > &copy; 2010 NDP Student Council<br > />Website Development Subcommitee > </div> </div> </div> </body> The CSS: > #backdrop { width:100%; height:100%; background: #FFFFFF > url(../images/gradient.jpg) repeat-x; > } > > #wrapper { margin:auto; width:95%; height:95%; border-right:thick solid > black; border-bottom:thick solid > black; border-top:thick solid black; > border-left:thick solid black; > background-color:white; } > > #header { height:131px; width:100%; background-color: #FFFFFF; > border-bottom:thick solid black; } > > #topimage { float:left; height:131px; width:63%; > background-image: > url("../images/ndps2.png"); > background-repeat:no-repeat; } > > #adspace1 { float:right; width:27%; height:131px; } > > #container { clear:both; } > #left{ width:20%; float:left; padding:5px; text-align:center; } > > #middle{ width:60%; padding:5px; text-align:center; } > > #right{ float:right; width:20%; padding:5px; text-align:right; } > #footer { border-top:thick solid black; width:100%; > text-align:center; } .clear { > clear:both; } Here is the CSS for the menu itself, which is from DynamicDrive.com: > .mattblackmenu ul{ margin: 0; padding: > 0; font: bold 12px Verdana; > list-style-type: none; border-bottom: > 1px solid gray; background: #414141; > overflow: hidden; width: 100%; > clear:both; } > > .mattblackmenu li{ display: inline; > margin: 0; } > > .mattblackmenu li a{ float: left; > display: block; text-decoration: none; > margin: 0; padding: 6px 8px; /*padding > inside each tab*/ border-right: 1px > solid white; /*right divider between > tabs*/ color: white; background: > #414141; Thanks for the help!

    Read the article

  • What would be the safest way to store objects of classes derived from a common interface in a common

    - by Svenstaro
    I'd like to manage a bunch of objects of classes derived from a shared interface class in a common container. To illustrate the problem, let's say I'm building a game which will contain different actors. Let's call the interface IActor and derive Enemy and Civilian from it. Now, the idea is to have my game main loop be able to do this: // somewhere during init std::vector<IActor> ActorList; Enemy EvilGuy; Civilian CoolGuy; ActorList.push_back(EvilGuy); ActorList.push_back(CoolGuy); and // main loop while(!done) { BOOST_FOREACH(IActor CurrentActor, ActorList) { CurrentActor.Update(); CurrentActor.Draw(); } } ... or something along those lines. This example obviously won't work but that is pretty much the reason I'm asking here. I'd like to know: What would be the best, safest, highest-level way to manage those objects in a common heterogeneous container? I know about a variety of approaches (Boost::Any, void*, handler class with boost::shared_ptr, Boost.Pointer Container, dynamic_cast) but I can't decide which would be the way to go here. Also I'd like to emphasize that I want to stay away as far as possible from manual memory management or nested pointers. Help much appreciated :).

    Read the article

  • Did the Unity Team fix that "generics handling" bug back in 2008?

    - by rasx
    At my level of experience with Unity it might be faster to ask whether the "generics handling" bug acknowledged by ctavares back in 2008 was fixed in a public release. Here was the problem (which might be my problem today): Hi, I get an exception when using .... container.RegisterType(typeof(IDictionary<,), typeof(Dictionary<,)); The exception is... "Resolution of the dependency failed, type = \"IDictionary2\", name = \"\". Exception message is: The current build operation (build key Build Key[System.Collections.Generic.Dictionary2[System.String,System.String], null]) failed: The current build operation (build key Build Key[System.Collections.Generic.Dictionary2[System.String,System.String], null]) failed: The type Dictionary2 has multiple constructors of length 2. Unable to disambiguate. When I attempt... IDictionary myExampleDictionary = container.Resolve(); Here was the moderated response: There are no books that'll help, Unity is a little too new for publishers to have caught up yet. Unfortunately, you've run into a bug in our generics handling. This is currently fixed in our internal version, but it'll be a little while before we can get the bits out. In the meantime, as a workaround you could do something like this instead: public class WorkaroundDictionary : Dictionary { public WorkaroundDictionary() { } } container.RegisterType(typeof(IDictionary<,),typeof(WorkaroundDictionary<,)); The WorkaroundDictionary only has the default constructor so it'll inject no problem. Since the rest of your app is written in terms of IDictionary, when we get the fixed version done you can just replace the registration with the real Dictionary class, throw out the workaround, and everything will still just work. Sorry about the bug, it'll be fixed soon!

    Read the article

  • StructureMap and injecting IEnumerable<T>

    - by GiddyUpHorsey
    I'm new to StructureMap and have some existing code that I'm working with that uses StructureMap 2.5.4. There is a class that is constructed using StructureMap that has a constructor that takes IEnumerable<TCar> as a parameter. The registry has the following code. Scan(x => { x.TheCallingAssembly(); x.WithDefaultConventions(); x.AddAllTypesOf<ICar>(); } ); ForRequestedType<IEnumerable<ICar>>().TheDefault.Is.ConstructedBy( x => ObjectFactory.GetAllInstances<ICar>()); I'm writing a unit test and have obtained a nested container off the ObjectFactory and have injected an instance using the Inject method. One of the instances of ICar should receive the injected type in its constructor. However it wasn't working and I tracked that down to the ObjectFactory.GetAllInstances() call which doesn't use my nested container. How can I get this to work? I also read about StructureMap autowiring arrays and IEnumerable instances but I couldn't get it to work. Is there a better way to rewrite the above registry code so that an instance of IEnumerable<TCar> will be created and use the injected type from my nested container?

    Read the article

  • Unity Framework constructor parameters in MVC

    - by ubersteve
    I have an ASP.NET MVC3 site that I want to be able to use different types of email service, depending on how busy the site is. Consider the following: public interface IEmailService { void SendEmail(MailMessage mailMessage); } public class LocalEmailService : IEmailService { public LocalEmailService() { // no setup required } public void SendEmail(MailMessage mailMessage) { // send email via local smtp server, write it to a text file, whatever } } public class BetterEmailService : IEmailService { public BetterEmailService (string smtpServer, string portNumber, string username, string password) { // initialize the object with the parameters } public void SendEmail(MailMessage mailMessage) { //actually send the email } } Whilst the site is in development, all of my controllers will send emails via the LocalEmailService; when the site is in production, they will use the BetterEmailService. My question is twofold: 1) How exactly do I pass the BetterEmailService constructor parameters? Is it something like this (from ~/Bootstrapper.cs): private static IUnityContainer BuildUnityContainer() { var container = new UnityContainer(); container.RegisterType<IEmailService, BetterEmailService>("server name", "port", "username", "password"); return container; } 2) Is there a better way of doing that - i.e. putting those keys in the web.config or another configuration file so that the site would not need to be recompiled to switch which email service it was using? Many thanks!

    Read the article

  • Can't create blob container on Azure Blob Storage

    - by desautelsj
    The following code throws an error on the "CreateIfNotExist" method call. I am attempting to connect to my Azure Blob storage and create a new container called "images" var storageAccount = new CloudStorageAccount( new StorageCredentialsAccountAndKey("my_account_name", "... my shared key ..."), "https://blob.core.windows.net/", "https://queue.core.windows.net/", "https://table.core.windows.net/" ); var blobClient = storageAccount.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference("images"); blobContainer.CreateIfNotExist(); The error is: [StorageClientException: The requested URI does not represent any resource on the server.] The "images" container does not exist but I was expecting it to be created instead of an error to be thrown. What am I doing wrong? I have tried HTTP instead of HTTPS but the result is the same error.

    Read the article

  • wpf manually generate TreeViewItem container

    - by viky
    I am creating a TreeView at runtime. It has several nodes(TreeViewItem), each one having a name. Initially it is collapsed. A separate comboBox displays Names of all TreeViewItem. I have to highlight a TreeViewItem based on the Name selected. I am using a recursive function and gets the TreeViewItem container like this: if (parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) continue; TreeViewItem container = parent.ItemContainerGenerator.ContainerFromItem(child).As<TreeViewItem>(); but it is parent.ItemContainerGenerator.Status = GeneratorStatus.NotStarted for all the collapsed items. How can I generate containers for them manually(Without expanding them)?

    Read the article

  • TileGroup does not fill the container

    - by Luo Yong
    I put a TileGroup in a BorderContainer and set the width to 100%, but the content in the TileGroup did not fill the parent container, it leaves a big chunk of blank on the right part. The code is: <s:BorderContainer width="100%" height="100%"> <s:TileGroup width="100%" requestedColumnCount="2"> <s:Button> button1 </s:Button> <s:Button> button2 </s:Button> <s:Button> button3 </s:Button> </s:TileGroup> </s:BorderContainer> and the result is like this: http://i.minus.com/iN39P7Us4cBm1.png The width is already set to 100% but it does not work. Is there any way to make the TileGroup fill the container like GridLayout does in Java swing? http://www.java2s.com/Code/JavaImages/GridLayoutPane.PNG Thank you very much.

    Read the article

  • User Control as container at design time

    - by Luca
    I'm designing a simple expander control. I've derived from UserControl, drawn inner controls, built, run; all ok. Since an inner Control is a Panel, I'd like to use it as container at design time. Indeed I've used the attributes: [Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] Great I say. But it isn't... The result is that I can use it as container at design time but: The added controls go back the inner controls already embedded in the user control Even if I push to top a control added at design time, at runtime it is back again on controls embedded to the user control I cannot restrict the container area at design time into a Panel area What am I missing? Here is the code for completeness... why this snippet of code is not working? [Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] public partial class ExpanderControl : UserControl { public ExpanderControl() { InitializeComponent(); .... [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] internal class ExpanderControlDesigner : ControlDesigner { private ExpanderControl MyControl; public override void Initialize(IComponent component) { base.Initialize(component); MyControl = (ExpanderControl)component; // Hook up events ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); s.SelectionChanged += new EventHandler(OnSelectionChanged); c.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); } private void OnSelectionChanged(object sender, System.EventArgs e) { } private void OnComponentRemoving(object sender, ComponentEventArgs e) { } protected override void Dispose(bool disposing) { ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // Unhook events s.SelectionChanged -= new EventHandler(OnSelectionChanged); c.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); base.Dispose(disposing); } public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { DesignerVerbCollection v = new DesignerVerbCollection(); v.Add(new DesignerVerb("&asd", new EventHandler(null))); return v; } } } I've found many resources (Interaction, designed, limited area), but nothing was usefull for being operative... Actually there is a trick, since System.Windows.Forms classes can be designed (as usual) and have a correct behavior at runtime (TabControl, for example).

    Read the article

  • 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

  • fixed position of inner div related to its container

    - by Lina
    Hi, if have the following code: <div id="container" style="position:relative; width:300px; height:300px; overflow:scroll;"> <div id="header"> </div> <div> a table of contents </div> </div> how do i make the inner div with the id "header" follows when i scroll down the outer div "container"? TIA Lina

    Read the article

  • Creating OpenSocial container for ASP.NET Site

    - by Admin
    hello, i run a social networking site written in asp.net and would like to open it to developers using the OpenSocial APIs. I have read information on opensocial.org as well as google's opensocial page and have a basic idea what it takes but still there is a lot of info missing to even get started. I know i gotta provide RESTful API as well as JavaScript API, authenticating using OAuth methods. Does my container has to provide all 3: JSON, XML, and AtomPub representations of data? I found Shindig but it runs under Apache, i need something for IIS. Are there any libraries that i could use as a base for my APIs to save time? Is it even recommended to write the entire container from scratch? thanks

    Read the article

  • User Control as container

    - by Luca
    I'm designing a simple expander control. I've derived from UserControl, drawn inner controls, built, run; all ok. Since an inner Control is a Panel, I'd like to use it as container at design time. Indeed I've used the attributes: [Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] Great I say. But it isn't... The result is that I can use it as container at design time but: The added controls go back the inner controls already embedded in the user control Even if I push to top a control added at design time, at runtime it is back again on controls embedded to the user control I cannot restrict the container area at design time into a Panel area What am I missing? Here is the code for completeness... why this snippet of code is not working? [Designer(typeof(ExpanderControlDesigner))] [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] public partial class ExpanderControl : UserControl { public ExpanderControl() { InitializeComponent(); .... [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] internal class ExpanderControlDesigner : ControlDesigner { private ExpanderControl MyControl; public override void Initialize(IComponent component) { base.Initialize(component); MyControl = (ExpanderControl)component; // Hook up events ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); s.SelectionChanged += new EventHandler(OnSelectionChanged); c.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving); } private void OnSelectionChanged(object sender, System.EventArgs e) { } private void OnComponentRemoving(object sender, ComponentEventArgs e) { } protected override void Dispose(bool disposing) { ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService)); IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); // Unhook events s.SelectionChanged -= new EventHandler(OnSelectionChanged); c.ComponentRemoving -= new ComponentEventHandler(OnComponentRemoving); base.Dispose(disposing); } public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { DesignerVerbCollection v = new DesignerVerbCollection(); v.Add(new DesignerVerb("&asd", new EventHandler(null))); return v; } } } I've found many resources (Interaction, designed, limited area), but nothing was usefull for being operative...

    Read the article

  • Container for database-like searches

    - by Milan Babuškov
    I'm looking for some STL, boost, or similar container to use the same way indexes are used in databases to search for record using a query like this: select * from table1 where field1 starting with 'X'; or select * from table1 where field1 like 'X%'; I thought about using std::map, but I cannot because I need to search for fields that "start with" some text, and not those that are "equal to". I could create a sorted vector or list and use binary search (breaking the set in 2 in each step by reading the element in the middle and seeing if it's more or less than 'X'), but I wonder if there is some ready-made container I could use without reinventing the wheel?

    Read the article

  • Multiset container appears to stop sorting

    - by Sarah
    I would appreciate help debugging some strange behavior by a multiset container. Occasionally, the container appears to stop sorting. This is an infrequent error, apparent in only some simulations after a long time, and I'm short on ideas. (I'm an amateur programmer--suggestions of all kinds are welcome.) My container is a std::multiset that holds Event structs: typedef std::multiset< Event, std::less< Event > > EventPQ; with the Event structs sorted by their double time members: struct Event { public: explicit Event(double t) : time(t), eventID(), hostID(), s() {} Event(double t, int eid, int hid, int stype) : time(t), eventID( eid ), hostID( hid ), s(stype) {} bool operator < ( const Event & rhs ) const { return ( time < rhs.time ); } double time; ... }; The program iterates through periods of adding events with unordered times to EventPQ currentEvents and then pulling off events in order. Rarely, after some events have been added (with perfectly 'legal' times), events start getting executed out of order. What could make the events ever not get ordered properly? (Or what could mess up the iterator?) I have checked that all the added event times are legitimate (i.e., all exceed the current simulation time), and I have also confirmed that the error does not occur because two events happen to get scheduled for the same time. I'd love suggestions on how to work through this. The code for executing and adding events is below for the curious: double t = 0.0; double nextTimeStep = t + EPID_DELTA_T; EventPQ::iterator eventIter = currentEvents.begin(); while ( t < EPID_SIM_LENGTH ) { // Add some events to currentEvents while ( ( *eventIter ).time < nextTimeStep ) { Event thisEvent = *eventIter; t = thisEvent.time; executeEvent( thisEvent ); eventCtr++; currentEvents.erase( eventIter ); eventIter = currentEvents.begin(); } t = nextTimeStep; nextTimeStep += EPID_DELTA_T; } void Simulation::addEvent( double et, int eid, int hid, int s ) { assert( currentEvents.find( Event(et) ) == currentEvents.end() ); Event thisEvent( et, eid, hid, s ); currentEvents.insert( thisEvent ); }

    Read the article

  • C++ Add this pointer to a container by calling it in base class constructor

    - by vivekeviv
    class Base { public: Base (int a, int b); private: int a,b; }; class Derived1 { public: Derived1():base(1,2){} }; similarly Derived2, Derived 3 which doesnt contain any data members on its own Now i need to contain these derived objects in a singleton, so i was thinking to call this in base constructor like Base::Base(int a, int b) { CBaseMgr::GetInstance()->AddtoVector(this); } so now if i construct Derived d1, d2, d3 etc. will the Singleton's container contain all derived objects? My doubt is can i do this adding of objects to container in base ctor or should i do in derived ctor.?

    Read the article

  • [C++] Needed: A simple C++ container (stack, linked list) that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none form a consensus on a simple solution.

    Read the article

  • Simple C++ container class that is thread-safe for writing

    - by conradlee
    I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same time. Is there a simple solution that performs well? After some googling, I found that STL containers are not thread-safe. Some stackoverflow threads address this question, but none that forms a consensus on a simple solution.

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >