Search Results

Search found 11996 results on 480 pages for 'dependency properties'.

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

  • C++ and Dependency Injection in unit testing

    - by lhumongous
    Suppose I have a C++ class like so: class A { public: A() { } void SetNewB( const B& _b ) { m_B = _b; } private: B m_B; } In order to unit test something like this, I would have to break A's dependency on B. Since class A holds onto an actual object and not a pointer, I would have to refactor this code to take a pointer. Additionally, I would need to create a parent interface class for B so I can pass in my own fake of B when I test SetNewB. In this case, doesn't unit testing with dependency injection further complicate the existing code? If I make B a pointer, I'm now introducing heap allocation, and some piece of code is now responsible for cleaning it up (unless I use ref counted pointers). Additionally, if B is a rather trivial class with only a couple of member variables and functions, why introduce a whole new interface for it instead of just testing with an instance of B? I suppose you could make the argument that it would be easier to refactor A by using an interface. But are there some cases where two classes might need to be tightly coupled?

    Read the article

  • DCI: How to implement Context with Dependency Injection?

    - by ciscoheat
    Most examples of a DCI Context are implemented as a Command pattern. When using Dependency Injection though, it's useful to have the dependencies injected in the constructor and send the parameters into the executing method. Compare the Command pattern class: public class SomeContext { private readonly SomeRole _someRole; private readonly IRepository<User> _userRepository; // Everything goes into the constructor for a true encapsuled command. public SomeContext(SomeRole someRole, IRepository<User> userRepository) { _someRole = someRole; _userRepository = userRepository; } public void Execute() { _someRole.DoStuff(_userRepository); } } With the Dependency injected class: public class SomeContext { private readonly IRepository<User> _userRepository; // Only what can be injected using the DI provider. public SomeContext(IRepository<User> userRepository) { _userRepository = userRepository; } // Parameters from the executing method public void Execute(SomeRole someRole) { someRole.DoStuff(_userRepository); } } The last one seems a bit nicer, but I've never seen it implemented like this so I'm curious if there are any things to consider.

    Read the article

  • Avoiding circular project/assembly references in Visual Studio with statically typed dependency conf

    - by svnpttrssn
    First, I want to say that I am not interested in debating about any non-helpful "answers" to my question, with suggestions to putting everything in one assembly, i.e. there is no need for anyone to provide webpages such as the page titled with "Separate Assemblies != Loose Coupling". Now, my question is if it somehow (maybe with some Visual Studio configuration to allow for circular project dependencies?) is possible to use one project/assembly (I am here calling it the "ServiceLocator" assembly) for retrieving concrete implementation classes, (e.g. with StructureMap) which can be referred to from other projects, while it of course is also necessary for the the ServiceLocator itself to refer to other projects with the interfaces and the implementations ? Visual Studio project example, illustrating the kind of dependency structure I am talking about: http://img10.imageshack.us/img10/8838/testingdependencyinject.png Please note in the above picture, the problem is how to let the classes in "ApplicationLayerServiceImplementations" retrieve and instantiate classes that implement the interfaces in "DomainLayerServiceInterfaces". The goal is here to not refer directly to the classes in "DomainLayerServiceImplementations", but rather to try using the project "ServiceLocator" to retrieve such classes, but then the circular dependency problem occurrs... For example, a "UserInterfaceLayer" project/assembly might contain this kind of code: ContainerBootstrapper.BootstrapStructureMap(); // located in "ServiceLocator" project/assembly MyDomainLayerInterface myDomainLayerInterface = ObjectFactory.GetInstance<MyDomainLayerInterface>(); // refering to project/assembly "DomainLayerServiceInterfaces" myDomainLayerInterface.MyDomainLayerMethod(); MyApplicationLayerInterface myApplicationLayerInterface = ObjectFactory.GetInstance<MyApplicationLayerInterface>(); // refering to project/assembly "ApplicationLayerServiceInterfaces" myApplicationLayerInterface.MyApplicationLayerMethod(); The above code do not refer to the implementation projects/assemblies ApplicationLayerServiceImplementations and DomainLayerServiceImplementations, which contain this kind of code: public class MyApplicationLayerImplementation : MyApplicationLayerInterface and public class MyDomainLayerImplementation : MyDomainLayerInterface The "ServiceLocator" project/assembly might contain this code: using ApplicationLayerServiceImplementations; using ApplicationLayerServiceInterfaces; using DomainLayerServiceImplementations; using DomainLayerServiceInterfaces; using StructureMap; namespace ServiceLocator { public static class ContainerBootstrapper { public static void BootstrapStructureMap() { ObjectFactory.Initialize(x => { // The two interfaces and the two implementations below are located in four different Visual Studio projects x.ForRequestedType<MyDomainLayerInterface>().TheDefaultIsConcreteType<MyDomainLayerImplementation>(); x.ForRequestedType<MyApplicationLayerInterface>().TheDefaultIsConcreteType<MyApplicationLayerImplementation>(); }); } } } So far, no problem, but the problem occurs when I want to let the class "MyApplicationLayerImplementation" in the project/assembly "ApplicationLayerServiceImplementations" use the "ServiceLocator" project/assembly for retrieving an implementation of "MyDomainLayerInterface". When I try to do that, i.e. add a reference from "MyApplicationLayerImplementation" to "ServiceLocator", then Visual Studio complains about circular dependencies between projects. Is there any nice solution to this problem, which does not imply using refactoring-unfriendly string based xml-configuration which breaks whenever an interface or class or its namespace is renamed ? / Sven

    Read the article

  • Dependency Injection wcf

    - by Diego Dias
    I want inject a implementation of my Interface in the WCF but I want initialize my container of Dependency Injection in the Client of the WCF. So I can have a different implementation for each client of the my service. Help me please.

    Read the article

  • Custom Grails plugin dependency

    - by ankimal
    I have a custom grails plugin I m trying to develop and set this def dependsOn = [tomcat: "1.0"] in the Plugin script. Now, my custom plugin loads just fine but I dont see tomcat installed in my application. How does one install a dependency plugin (prompt the user to say yes/no)? Is this even possible?

    Read the article

  • Avoiding dependency carrying

    - by dotnetdev
    When coding, I often come across the following pattern: -A method calls another method (Fine), but the method being called/callee takes parameters, so in the wrapping method, I pass in parameters. Problem is, this dependency carrying can go on and on. How could I avoid this (any sample code appreciated)? Thanks

    Read the article

  • Avoiding dependency injection

    - by dotnetdev
    When coding, I often come across the following pattern: -A method calls another method (Fine), but the method being called/callee takes parameters, so in the wrapping method, I pass in parameters. Problem is, this dependency carrying can go on and on. How could I avoid this (any sample code appreciated)? Thanks

    Read the article

  • Binding one dependency property to another

    - by Gregory Dodd
    I have a custom Tab Control that I have created, but I am having an issue. I have an Editable TextBox as part of the custom TabControl View. <Controls:EditableTextControl x:Name="PageTypeName" Style="{StaticResource ResourceKey={x:Type Controls:EditableTextControl}}" Grid.Row="0" TabIndex="0" Uid="0" AutomationProperties.AutomationId="PageTypeNameTextBox" AutomationProperties.Name="PageTypeName" Visibility="{Binding ElementName=PageTabControl,Path=ShowPageType}"> <Controls:EditableTextControl.ContextMenu> <ContextMenu x:Name="TabContextMenu"> <MenuItem Header="Rename Page Type" Command="{Binding Path=PlacementTarget.EnterEditMode, RelativeSource={RelativeSource AncestorType=ContextMenu}}" AutomationProperties.AutomationId="RenamePageTypeMenuItem" AutomationProperties.Name="RenamePageType"/> <MenuItem Header="Delete Page Type" Command="{Binding Path=PageTypeDeletedCommand}" AutomationProperties.AutomationId="DeletePageTypeMenuItem" AutomationProperties.Name="DeletePageType"/> </ContextMenu> </Controls:EditableTextControl.ContextMenu> <Controls:EditableTextControl.Content> <!--<Binding Path="CurrentPageTypeViewModel.Name" Mode="TwoWay"/>--> <Binding ElementName="PageTabControl" Path="CurrentPageTypeName" Mode ="TwoWay"/> </Controls:EditableTextControl.Content> </Controls:EditableTextControl> In the Content section I am binding to a Dependency Prop called CurrentPageTypeName. This Depedency prop is part of this custom Tab Control. public static DependencyProperty CurrentPageTypeNameProperty = DependencyProperty.Register("CurrentPageTypeName", typeof(object), typeof(TabControlView)); public object CurrentPageTypeName { get { return GetValue(CurrentPageTypeNameProperty) as object; } set { SetValue(CurrentPageTypeNameProperty, value); } } In another view, where I am using the custom TabControl I then bind my property, with the actual name value, to CurrentPageTypeName property as seen below: <Views:TabControlView Grid.Row="0" Name="RunPageTabControl" TabItemsSource="{Binding RunPageTypeViewModels}" SelectedTab="{Binding Converter={StaticResource debugConverter}}" CurrentPageTypeName="{Binding Path=RunPageName, Mode=TwoWay}" TabContentTemplateSelector="{StaticResource tabItemTemplateSelector}" SelectedIndex="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.SelectedTabIndex}" ShowPageType="Hidden" > <!--<Views:TabControlView.TabContentTemplate> <DataTemplate DataType="{x:Type ViewModels:RunPageTypeViewModel}"> <RunViews:RunPageTypeView/> </DataTemplate> </Views:TabControlView.TabContentTemplate>--> </Views:TabControlView> My problem is that nothing seems to be happening. It is grabbing its Content from the Itemsource, and not from my chained Dependency props. Is what I am trying even possible? If so, what have I done wrong. Thanks for looking.

    Read the article

  • Is it possible to use .properties files in web.xml in conjunction with contextConfigLocation paramet

    - by Vladimir
    Here is part of my web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:application-config.xml </param-value> </context-param> application-config.xml uses property placeholder: <context:property-placeholder location="classpath:properties/db.properties"/> Is it possible somehow to define which properties file to use in web.xml rather than in application-config.xml?

    Read the article

  • Are TestContext.Properties read only ?

    - by DBJDBJ
    Using Visual Studio generate Test Unit class. Then comment out class initialization method. Inside it add your property, using the testContext argument. //Use ClassInitialize to run code before running the first test in the class [ClassInitialize()] public static void MyClassInitialize(TestContext testContext) { /* * Any user defined testContext.Properties * added here will be erased upon this method exit */ testContext.Properties.Add("key", 1 ) ; // above works but is lost } After leaving MyClassInitialize, properties defined by user are lost. Only the 10 "official" ones are left. This effectively means TestContext.Properties is read only, for users. Which is not clearly documented in MSDN. Please discuss. --DBJ

    Read the article

  • How to read custom file properties in c#

    - by Randy Gamage
    I'm looking for a way to read document properties in C#. I've heard about dsofile.dll, but it seems like an old COM wrapper, and was wondering if there is something more modern for the .NET framework/C#. What I'm actually reading is not an office document file, but a Solidworks .SLDDRW file, that has Custom properties. You can view and change these in Windows Explorer by right-clicking on the file, and going to the Properties window, Custom tab. Anyone know how to read these custom properties in C# / .NET 3.5? Thanks!

    Read the article

  • C# Custom Control Properties load before Load and arrays are empties

    - by Wildhorn
    Hello, I made a custom control with custom properties. When I modify these properties in the "Form.cs [Design]", I need stuff to happens (it fill some arrays and modify the look of the control), so I call a function within the "set" of the property. All of this works good. My problem is that when I run the program with my custom control, it seems that properties "set" is called, which will call the function, but then, my arrays seems now to have lost all their values and the function use these arrays, but now because they are all empty, it crashes due to NullException blahblahblah. It also seems that properties "set" is called before the control Load (which I guess is called only when it is added to my Form, and not when the Form load). So question is, why does my arrays become empty once I try to run the Form and is there an event that is called before that when the Form load? Thanks

    Read the article

  • Log4j Properties in a Custom Place

    - by Azder
    I'm using Apache Commons Logging and SLF4J with log4j, but I also want to use the log4j.properties in a custom place like conf/log4.properties. Here is the problem: If i use PropertyConfigurator.configure("conf/log4j.properties"); then my app is tied to log4j and defets the purpose of having ACL and SLF4J. What is the best way to configure it withouth the app ever knowing what the logging implementation is?

    Read the article

  • Group properties in custom control

    - by Gunners98
    I want to do a class that have properties like font, which will have other properties, such as name, size, unit,bold.I had tried a solution but it isn't working for me.(http://stackoverflow.com/questions/755391/group-properties-in-a-custom-control) Anyone can help? Any help will be appreciated. <TypeConverter(GetType(ExpandableObjectConverter))> _ Class TestingClass 'Some property here End Class

    Read the article

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