Search Results

Search found 3300 results on 132 pages for 'dependency walker'.

Page 31/132 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • ASP.NET MVC + fluent nNibernate, what IoC tool?

    - by bondehagen
    I'm working on a ASP.NET MVC project where we have decided to use Fluent nHibernate for dataccess. To enable loose coupling we go for a IoC/DI pattern. My questions is what IoC tool to go for. I've tried to find the differences between windsor, ninject, spring, structuremap and unity, but it's difficult to see the benefits each one has to offer. Whats your experience?

    Read the article

  • what is cairo required by GTK 2.9 to compile (on Lucid Lynx)?

    - by A.Rashad
    I have been trying to run configure to prepare the make file for GTK 2,9 on a fresh Linux box (running Ubuntu 10.04 Lucid Lynx). it complained about some dependencies, including: glib-2.0 atk (1.29.2) pango (1.20) cairo (1.6) I managed to find the glib 2.22.0, downloaded the atk but did not compile yet, did not start the pango yet, but when tried to get the cairo package I didn't know where to get it from! nothing on GNU site, not on GTK site! anyone knows where to get it from?

    Read the article

  • How do I manage dependencies for automated builds on my build server?

    - by Tom Pickles
    I'm trying to implement continuous integration into our day to day workings. In our team, we're moving from just building our code in Visual Studio on our workstations and deploying, to using MSBuild.exe and automating on our build server (which is Jenkins) without the use of Visual Studio. We have external dependencies to references such as Automap in our projects. Because the automap (for example) dll isn't on the build server, the msbuild execution fails, for obvious reasons. There are other dll's which I need to be part of the build, I'm just using automap as an example. So what's the best way to get any dependencies onto the build server as part of the automated build? I've seen references to using a 'lib' folder, but I don't really understand where I should be putting it (in my project, filesystem, SVN ...?), and how the build server will get to it. I've also read that NuGet can do something with dependencies, but my build server isn't connected to the internet, and I don't understand how I can get my build to pull a NuGet package I may have created, and how it works together. Edit: I'm using subversion and we cannot use TeamCity as we would have to buy it and there's zero chance of funding.

    Read the article

  • Dynamic domain methods missing from grails service when injected into java service in grails app.

    - by Gordon C
    I had the idea that I would write my GroovyDao as a grails service. Next I would write a MyJavaService in java and locate it in the java sources dir in my grails app. MyJavaService contains a instance reference to groovyDao for spring injection. I would wire up in resources.groovy the MyJavaService with a groovyDao = ref("GroovyDao"). Everything starts up fine. However if I make call to MyJavaService any Domain method like Domain.list() returns a Method not found error. Any help is appreciated.

    Read the article

  • Unable to step into interface implementation configured by unity application block

    - by Rahul
    I have configured a set of interface implementations with EntLib. unity block. The constructor of implementation classes work fine as soon as I run the application: 1. The interface to implement when I run the application the cctor runs fine, which shows that unity resolution was successful: But when I try to call a method of this class, the code just passes through without actually invoking the function of the implemented class: Edit: Added on June 11, 2012 Following is the Unity Configuration I have. (This is all the unity configuration I am doing) public class UnityControllerFactory : DefaultControllerFactory { private static readonly IUnityContainer container; private static UnityControllerFactory factory = null; static UnityControllerFactory() { container = new UnityContainer(); UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); section.Configure(container); factory = new UnityControllerFactory(); } public static UnityControllerFactory GetControllerFactory() { return factory; } protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { return container.Resolve(controllerType) as IController; } } I am unable to step into this code and the implementation simply skips out without executing anything. What is wrong here?

    Read the article

  • If the dependency is a unique snapshot version and install is called, what does maven select?

    - by chrsk
    Imagine two projects. The first is the framework-core project which is in version 1.1.0 and has several snapshot builds. The other is the example-business project which has the following dependency to framework-core on the build-iteration number 9. <dependency> <groupId>org.example</groupId> <artifactId>framework-core</artifactId> <version>1.1.0-20100518.134928-9</version> </dependency> What happens if mvn install is called on the framework-core? I found out that the artifact is copied to the folder and is named to *.1.1.0-SNAPSHOT.jar (as expected). This lead me to the assumption that this version is only used if even this 1.1.0-SNAPSHOT version is defined as dependency and not the precise build. To test something local without deploying it to the maven repository: call mvn install, change the dependency to 1.1.0-SNAPSHOT -- and the artifact just installed is used? Or is it possible to overwrite the specific build (with using the install lifecycle phase)?

    Read the article

  • Custom SessionListener, name is not bound in this context, javax.naming.NameNotFoundException

    - by mehmet6parmak
    Hi, I am trying to implement HttpSessionListener so that users of this listener can register implementation of ISessionEvent interface to session Events.code is below: public class MySessionListener implements HttpSessionListener{ @Resource ISessionEvent sessionEvent; public ISessionEvent getSessionEvent() { return sessionEvent; } public void setSessionEvent(ISessionEvent sessionEvent) { this.sessionEvent = sessionEvent; } @Override public void sessionCreated(HttpSessionEvent arg0) { sessionEvent.SessionCreated(arg0.getSession()); } @Override public void sessionDestroyed(HttpSessionEvent arg0) { sessionEvent.SessionDestroyed(arg0.getSession()); } } When user implement ISessionEvent and add as a bean, SessionCreated and SessionDestroyed functions of implementation will be called when these events occured. You can ask why dont you just write inside listeners methods, i dont i'm just trying. When i try the code above i got the following error message: javax.naming.NameNotFoundException: Name com.mehmet6parmak.sessionlistener.MySessionListener is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.catalina.util.DefaultAnnotationProcessor.lookupFieldResource(DefaultAnnotationProcessor.java:278) at org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:187) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4082) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Resource annotation causes the error but i could not resolve it. Thanks All... Interface and Implementation @Resource public interface ISessionEvent { public void SessionCreated(HttpSession session); public void SessionDestroyed(HttpSession session); } @Resource public class SessionEvent implements ISessionEvent { @Override public void SessionDestroyed(HttpSession session) { System.out.println("From Session Event Callback(Destroy):" + session.getId()); } @Override public void SessionCreated(HttpSession session) { System.out.println("From Session Event Callback(Create):" + session.getId()); } } Bean Definition <context:annotation-config/> <context:component-scan base-package="com.mehmet6parmak"> </context:component-scan> <bean id="sessionEvent" autowire="byName" class="com.mehmet6parmak.sessionlistener.SessionEvent"></bean> Solution:Using the method used in link works.

    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

  • Unity: Replace registered type with another type at runtime

    - by gehho
    We have a scenario where the user can choose between different hardware at runtime. In the background we have several different hardware classes which all implement an IHardware interface. We would like to use Unity to register the currently selected hardware instance for this interface. However, when the user selects another hardware, this would require us to replace this registration at runtime. The following example might make this clearer: public interface IHardware { // some methods... } public class HardwareA : IHardware { // ... } public class HardwareB : IHardware { // ... } container.RegisterInstance<IHardware>(new HardwareA()); // user selects new hardware somewhere in the configuration... // the following is invalid code, but can it be achieved another way? container.ReplaceInstance<IHardware>(new HardwareB()); Can this behavior be achieved somehow? BTW: I am completely aware that instances which have already been resolved from the container will not be replaced with the new instances, of course. We would take care of that ourselves by forcing them to resolve the instance once again.

    Read the article

  • What is the proper way to access datastore in custom Model Binders?

    - by mare
    How should I properly implement data access in my custom model binders? Like in controllers I use IContentRepository and then have it create an instance of its implementing class in constructor. So I have everything ready for incorporating IoC (DI) at a later stage. Now I need something similar in model binder. I need to make some DB lookups in the binder. I'm thinking of doing it the same way I do it in controllers but I am open to suggestion. This is a snippet from one of my controllers so you can imagine how I'm doing it in them: public class WidgetZoneController : BaseController { // BaseController has IContentRepository ContentRepository field public WidgetZoneController() : this(new XmlWidgetZoneRepository()) { } public WidgetZoneController(IContentRepository repository) { ContentRepository = repository; } ...

    Read the article

  • StructureMap: Calling repository constructor based on RouteData

    - by FreshCode
    I'm implementing a multi-tenant ASP.NET MVC application and using StructureMap for DI where my repositories depend on an ITenantContext interface, which depends on RouteData (or a base controller property). How do I tell StructureMap to construct TenantContext(tenantID); where tenantID is derived from my RouteData or some base controller property? Given the following route: {tenant}/{controller}/{action} My base controller retrieves and stores the correct Tenant based on the {tenant} URL parameter. Using Tenant, a repository with an ITenantContext can be constructed to retrieve only data that is relevant to that tenant. Based on the other DI questions, AbstractFactory could be a solution?solution?

    Read the article

  • How to design app to be modular / support plugins

    - by Lee
    I'm currently in the process of refactoring my webplayer so that we'll be more easily able to run it on our other internet radio stations. Much of the setup between these players will be very similar, however, some will need to have different UI plugins / other plugins. Currently in the webplayer I do something like this in it's init(): _this.ui = new UI(); _this.ui.playlist = new Playlist(); _this.ui.channelDropdown = new ChannelDropdown(); _this.ui.timecode = ne Timecode(); etc etc This works fine but that blocks me into requiring those objects at run time. What I'd like to do is be able to add those based on the stations needs. Basically my question is, do I need to add some kind of "addPlugin()" functionality here? And if I do that, do I need to constantly check from my WebPlayer object if that plugin exists before it attempts to use it? Like... if (_hasPlugin('playlist')) this.plugins.playlist.add(track); I apologize if some of this might not be clear... really trying to get my head wrapped around all of this. I feel I'm closer but I'm still stuck. Any advice on how I should proceed with this would be greatly appreciated. Thanks in advance, Lee

    Read the article

  • Timing related crash when unloading a DLL?

    - by fbrereto
    I know I'm reaching for straws here, but this one is a mystery... any pointers or help would be most welcome, so I'm appealing to those more intelligent than I: We have a crash exhibited in our release binaries only. The crash takes place as the binary is bringing itself down and terminating sub-libraries upon which it depends. Its ability to be reproduced is dependent on the machine- some are 100% reliable in reproducing the crash, some don't exhibit the issue at all, and some are in between. The crash is deep within one of the sublibraries, and there is a good likelihood the stack is corrupt by the time the rubble can be brought into a debugger (MSVC 2008 SP1) to be examined. Running the binary under the debugger prevents the bug from happening, as does remote debugging, as does (of all things) connecting to the machine via VNC. We have tried to install the Microsoft Driver Development Kit, and doing so also squelches the bug. What would be the next best place to look? What tools would be best in this circumstance? Does it sound like a race condition, or something else?

    Read the article

  • WPF Binding to variable / DependencyProperty

    - by Peter
    I'm playing around with WPF Binding and variables. Apparently one can only bind DependencyProperties. I have come up with the following, which works perfectly fine: The code-behind file: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public string Test { get { return (string)this.GetValue(TestProperty); } set { this.SetValue(TestProperty, value); } //set { this.SetValue(TestProperty, "BBB"); } } public static readonly DependencyProperty TestProperty = DependencyProperty.Register( "Test", typeof(string), typeof(MainWindow), new PropertyMetadata("CCC")); private void button1_Click(object sender, RoutedEventArgs e) { MessageBox.Show(Test); Test = "AAA"; MessageBox.Show(Test); } } XAML: <Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase" Title="MainWindow" Height="350" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}"> <Grid> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,86,0,0" Name="textBox1" VerticalAlignment="Top" Width="152" Text="{Binding Test, Mode=TwoWay, diag:PresentationTraceSources.TraceLevel=High}"/> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="320,85,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> <TextBox Height="31" HorizontalAlignment="Left" Margin="84,138,0,0" Name="textBox2" Text="{Binding Test, Mode=TwoWay}" VerticalAlignment="Top" Width="152" /> </Grid> The two TextBoxes update one an other. And the Button sets them to "AAA". But now I replaced the Setter function with the one that is commented out (simulating some manipulation of the given value). I would expect that whenever the property value is changed it will be reset to "BBB". It does so when you press the button, that is when you set the property in code. But it does for some reason not affect the WPF Bindings, that is you can change the TextBox contents and thus the property, but apparently the Setter is never called. I wonder why that is so, and how one would go about to achive the expected behaviour.

    Read the article

  • How do the major C# DI/IoC frameworks compare?

    - by Slomojo
    At the risk of stepping into holy war territory, What are the strengths and weaknesses of these popular DI/IoC frameworks, and could one easily be considered the best? ..: Ninject Unity Castle.Windsor Autofac StructureMap Are there any other DI/IoC Frameworks for C# that I haven't listed here? In context of my use case, I'm building a client WPF app, and a WCF/SQL services infrastructure, ease of use (especially in terms of clear and concise syntax), consistent documentation, good community support and performance are all important factors in my choice. Update: The resources and duplicate questions cited appear to be out of date, can someone with knowledge of all these frameworks come forward and provide some real insight? I realise that most opinion on this subject is likely to be biased, but I am hoping that someone has taken the time to study all these frameworks and have at least a generally objective comparison. I am quite willing to make my own investigations if this hasn't been done before, but I assumed this was something at least a few people had done already. Second Update: If you do have experience with more than one DI/IoC container, please rank and summarise the pros and cons of those, thank you. This isn't an exercise in discovering all the obscure little containers that people have made, I'm looking for comparisons between the popular (and active) frameworks.

    Read the article

  • How can I bind to a helper property in Silverlight

    - by Matt
    For the sake of argument, here's a simple person class public class Person : DependencyObject, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public static readonly DependencyProperty FirstNameProperty = DependencyProperty.Register( "FirstName", typeof ( string ), typeof ( Person ), null ); public static readonly DependencyProperty LastNameProperty = DependencyProperty.Register( "LastName", typeof( string ), typeof( Person ), null ); public string FirstName { get { return ( string ) GetValue( FirstNameProperty ); } set { SetValue( FirstNameProperty, value ); if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs( "FirstName" )); } } public string LastName { get { return ( string ) GetValue( LastNameProperty ); } set { SetValue( LastNameProperty, value ); if ( PropertyChanged != null ) PropertyChanged( this, new PropertyChangedEventArgs( "LastName" ) ); } } } I want to go about creating a readonly property like this public string FullName { get { return FirstName + " " + LastName; } } How does binding work in this scenario? I've tried adding a DependancyProperty and raised the PropertyChanged event for the fullname. Basically I just want to have a property that I can bind to that returns the fullname of a user whenever the first or last name changes. Here's the final class I'm using with the modifications. public class Person : DependencyObject, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public static readonly DependencyProperty FirstNameProperty = DependencyProperty.Register( "FirstName", typeof ( string ), typeof ( Person ), null ); public static readonly DependencyProperty LastNameProperty = DependencyProperty.Register( "LastName", typeof( string ), typeof( Person ), null ); public static readonly DependencyProperty FullNameProperty = DependencyProperty.Register( "FullName", typeof( string ), typeof( Person ), null ); public string FirstName { get { return ( string ) GetValue( FirstNameProperty ); } set { SetValue( FirstNameProperty, value ); if ( PropertyChanged != null ) { PropertyChanged( this, new PropertyChangedEventArgs( "FirstName" ) ); PropertyChanged( this, new PropertyChangedEventArgs( "FullName" ) ); } } } public string LastName { get { return ( string ) GetValue( LastNameProperty ); } set { SetValue( LastNameProperty, value ); if ( PropertyChanged != null ) { PropertyChanged( this, new PropertyChangedEventArgs( "LastName" ) ); PropertyChanged( this, new PropertyChangedEventArgs( "FullName" ) ); } } } public string FullName { get { return GetValue( FirstNameProperty ) + " " + GetValue( LastNameProperty ); } } }

    Read the article

  • Inject a EJB into a JSF converter with JEE6

    - by Michael Bavin
    Hi, I have a stateless EJB that acceses my database. I need this bean in a JSF 2 converter to retreive an entity object from the String value parameter. I'm using JEE6 with Glassfish V3 @EJB annotation does not work and gets a NPE, because it's in the faces context and it has not access to the ejb context. My question is: Is it still possible to Inject this bean (With a @Resource or other annotation, a JNDI lookup,...), or do i need a workaround? Thank you Solution Do a JNDI lookup like this: try { ic = new InitialContext(); myejb= (MyEJB) ic .lookup("java:global/xxxx/MyEJB"); } catch (NamingException e) { e.printStackTrace(); }

    Read the article

  • How does Maven find a Artifact in a remote repository?

    - by Thomas
    I'm trying to create a maven plugin to generate a file with the URL to all the dependencies in a project. I have been able to get the dependencies and their artifact, but I'm having trouble getting the download URL. Using ArtifactResolver and ArticateMetadataSource I get some of the artifact information. However I fail to get all the information for all the dependencies. I haven't been able to find documentation on the resolution logic, so that I can call it form my plugin. I can use an ArtifactResolver to download the artifact, but what I really wanted was just the URL. The Maven Artifact API has a a method called getDownloadURL (see http://maven.apache.org/ref/2.0.4/maven-artifact/apidocs/org/apache/maven/artifact/Artifact.html). However I cant seem to find a way to get a real value into it. I always get a null value. Is there a way to have it resolved (downloading or not) and get the URL for where the file came from?

    Read the article

  • What's the difference between DI and factory patterns?

    - by Anthony Short
    I have a class which depends on 3 classes, all 3 of which have other classes they rely on. Currently, I'm using a container class to build up all the required classes, inject them into one another and return the application. The simplified version of the container looks something like this: class Builder { private $_options; public function __construct($options) { $this->_options = $options; } public function build() { $cache = $this->getCache(); $response = $this->getResponse(); $engine = $this->getEngine(); return new Application($cache,$response,$engine); } public function getResponse() { $encoder = $this->getResponseEncoder(); $cache = $this->getResponseCache(); return new Response($encoder,$cache); } // Methods for building each object } I'm not sure if this would be classified as FactoryMethod or a DI Container. They both seem to solve the same problem in the same way - They build objects and inject dependencies. This container has some more complicated building methods, like loading observers and attaching them to observable objects. Should factories be doing all the building (loading extensions etc) and the DI container should use these factories to inject dependencies? That way the sub-packages, like Cache, Response etc, can each have their own specialised factories.

    Read the article

  • Adding and altering multiple text items to a Canvas -- what approach?

    - by philologon
    I am attempting to use a Canvas to create a simple Cad application. I have been able to get lines to draw as I want. For now the only other thing I need is text. The user should be able to edit the text in place. ?Is one of these better to use for this over the others? Rich Text TextBlock TextBox Label A more important question, though, is once I have chosen which class to use for implementation, how do I set and get the text value in code? Since the app is in essence a cad application, text will be added, deleted, and altered often, so I am not attempting to put these in XAML, but code-behind. That is why I am asking about how to do this in code. If the answer is "use X.SetValue()" (or that family of methods), then please tell me what I am supposed to do with the required DependencyProperty reference? TIA. Paul

    Read the article

  • How Do you Declare a Dependancy Property in VB.Net 3.0

    - by discwiz
    My company is stuck on .Net 3.0. The task I am trying to tackle is simple, I need to bind the IsChecked property of the CheckBoxResolvesCEDAR to the CompletesCEDARWork in my Audio class. The more I read about this it appears that I have to declare CompletesCEDARWork as dependancy propert, but I can not find a good example of how this is done. I found this example, but when I pasted into my code I get an "is not defined" error for GetValue and I have not successfully figure out what MyCode is supposed to represent. Any help/examples would be greatly appreciated. Thanks Public Shared ReadOnly IsSpinningProperty As DependencyProperty = DependencyProperty.Register("IsSpinning", GetType(Boolean), GetType(MyCode)) Public Property IsSpinning() As Boolean Get Return CBool(GetValue(IsSpinningProperty)) End Get Set(ByVal value As Boolean) SetValue(IsSpinningProperty, value) End Set End Property Here is my slimed down Audio Class as it stands now. Imports System.Xml Imports System Imports System.IO Imports System.Collections.ObjectModel Imports System.ComponentModel Public Class Audio Private mXMLString As String Private mTarpID As Integer Private mStartTime As Date Private mEndTime As Date Private mAudioArray As Byte() Private mFileXMLInfo As IO.FileInfo Private mFileXMLStream As IO.FileStream Private mFileAudioInfo As IO.FileInfo Private mDisplayText As String Private mCompletesCEDARWork As Boolean Private Property CompletesCEDARWork() As Boolean Get Return mCompletesCEDARWork End Get Set(ByVal value As Boolean) mCompletesCEDARWork = value End Set End Property And here is my XML Datatemplate where I set the binding. <DataTemplate x:Key="UploadLayout" DataType="Audio"> <Border BorderBrush="LightGray" CornerRadius="8" BorderThickness="1" Padding="10" Margin="0,3,0,0"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding Path=DisplayText}"> </TextBlock> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <TextBlock Text="TARP ID" VerticalAlignment="Center"/> <ComboBox x:Name="ListBoxTarpIDs" ItemsSource="{Binding Path=TarpIds}" SelectedValue="{Binding Path=TarpID}" BorderBrush="Transparent" Background="Transparent" > </ComboBox> </StackPanel> <CheckBox x:Name="CheckBoxResolvesCEDAR" Content="Resolves CEDAR Work" IsChecked="{Binding ElementName=Audio,Path=CompletesCEDARWork,Mode=TwoWay}"/> </StackPanel> </Border> </DataTemplate>

    Read the article

  • Are static delegates thread-safe?

    - by leypascua
    Consider this code snippet: public static class ApplicationContext { private static Func<TService> Uninitialized<TService>() { throw new InvalidOperationException(); } public static Func<IAuthenticationProvider> AuthenticationProvider = Uninitialized<IAuthenticationProvider>(); public static Func<IUnitOfWorkFactory> UnitOfWorkFactory = Uninitialized<IUnitOfWorkFactory>(); } //can also be in global.asax if used in a web app. public static void Main(string[] args) { ApplicationContext.AuthenticationProvider = () => new LdapAuthenticationProvider(); ApplicationContext.UnitOfWorkFactory = () => new EFUnitOfWorkFactory(); } //somewhere in the code.. say an ASP.NET MVC controller ApplicationContext.AuthenticationProvider().SignIn(username, true); Are delegates in the static class ApplicationContext thread-safe in the sense that multiple-threads can invoke them? What potential problems will I face if I pursue this approach?

    Read the article

  • Need an advice for unit testing using mock object

    - by Andree
    Hi there, I just recently read about "Mocking objects" for unit testing and currently I'm having a difficulties implementing this approach in my application. Please let me explain my problem. I have a User model class, which is dependent on 2 data sources (database and facebook web service). The controller class simply use this User model as an interface to access data and it doesn't care about where the data came from. Currently I never done any unit test to this User model because it is dependent on an external web service. But just a while ago, I read about object mocking and now I know that it is a common approach to unit test a class that depends on external resources (like in my case). Now I want to create a unit test for the User model, but then I encountered a design issue: In order for the User model to use a mocked Facebook SDK, I have to inject this mocked Facebook SDK to the User object (probably using a setter). Therefore I can't construct the Facebook SDK inside the User object. I have to construct it outside the User object, and inject the SDK into the User object. The real client of my User model is the application's controller. Therefore I have to construct the Facebook SDK inside the controller and inject it to the user object. Well, this is a problem because I want my controller to be as clean as possible. I want my controller to be ignorant about the application's data source. I'm not good at explaining something systematically, so you'll probably sleeping before reading this last paragraph. But anyway, I want to ask if anyone here ever encountered the same problem as mine? How do you solve this problem? Regards, Andree

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >