I have a project that adds elements to an AutoCad drawing. I noticed that I was starting to write the same ten lines of code in multiple methods (only showing two for simplicity).
Initial Implementation:
You will notice that the only thing that really changes is adding a Line instead of a Circle.
[CommandMethod("Test", CommandFlags....
Hi
Is it possible to use DI in your workflow activities? and if yes, how?
For example if you have an activity like
public sealed class MyActivity : CodeActivity
{
public MyClass Dependency { get; set; }
protected override void Execute(CodeActivityContext context)
{
Dependency.DoSomething();
}
}
how can i set...
I am trying to create a custom resolver for automapper which needs to access one of my data repositories to retreive the logged in users account.
Here is my code so far...
public class FollowingResolver : ValueResolver<Audio, bool>
{
readonly IIdentityTasks identityTasks;
public FollowingResolver(IIdentityTasks ide...
I have the following classes defined:
public interface IShapeView
{
void DoSomethingWithShape(Shape shape);
}
public interface IShapeView<T> where T : Shape
{
void DoSomethingWithShape(T shape);
}
public class CircleView : IShapeView<Circle>, IShapeView
{
public void DoSomethingWithShape(Circle shape)
{
MessageB...
Hi folks,
I'm using StructureMap DI/IoC and I've got is a generic InMemory repository. Works great. I was wondering if it's possible to define the initial data which each repository holds, when it's requested?
Now, the first reaction is to do this in the constructor of the class - but I'm using a Generic Repository .. so i don't know w...
Hi all,
In a short view of the IoC and DI .NET libraries I chose to use Ninject2.
According to DDD style in:
Infrastructure: I have Entity Framework 4.0 .edmx model and the Repository implementation
Domain Layer: I have POCO objects and Repository Interfaces (implemented in Infrastructure)
Application Services: I have WCF services tha...
I edited my whole question, so do not wonder :)
Well, I want to have an ActionResult that takes domain model data and some additional parameters, i.e page index and page size for paging a list. It decide itself if it returns a PartialViewResult or a ViewResult depending on the kind of web request (ajax request or not).
The reffered dat...
I've been doing some reading on the Strategy Pattern, and have a question. I have implemented a very basic Console Application below to explain what I'm asking.
I have read that having 'switch' statements is a red flag when implementing the strategy pattern. However, I can't seem to get away from having a switch statement in this exam...
I have a basic working knowledge of Castle Windsor, but I cannot figure out the DI equivalent of the below code ...
private static DbModel BuildModel()
{
var builder = new ModelBuilder();
var types = Assembly.GetExecutingAssembly().GetTypes();
foreach (var type in types)
{
if (type.Na...
public class MyController : Controller
{
private MyClass _class;
public MyController(MyClass class)
{
this._class = class;
}
}
public class MyClass
{
// stuff
}
My Ninject is hooked up to inject classes that implement IController (Controller class does so). But, I did not bind MyClass to anything, yet Ninject...
i'm trying to find an example in .NET of a class that uses Dependancy Injection (e.g. a class that uses a Builder or Factory in order to create the full object - injecting dependencies as it does)
Browsing through Reflector, i would have thought some of the more complicated ado.net or WebRequest objects would use dependency injection - ...
I got the following service:
IRepository<TEntity, TPrimaryKey>
..for which I've created an implementation defined as:
Repository<TEntity, TPrimaryKey>.
How do I register it in autofac so that I can resolve it as:
IRepository<User, int>
...
I created a class that uses the the Java Executor API to create/manage a pool with fixed number of threads.
Each thread needs a new instance of a particular object, and I would like to inject this object with Guice.
For the moment I'm using a Provider which provides new instances of the object through its get() method.
But now this clas...
I am using an approach similar to the one in this ASP.NET MVC tutorial where you pass a wrapper around a controller's ModelState collection into a validation class so that the controller can access error information.
Here is a cooked up example:
interface IProductValidator {
void Validate(Product item);
}
class ProductValidator {
...
I have a class:
public class SystemQuery<T> : ISystemQuery<T> where T : class, IUIView {
protected ISession session;
protected ICriteria baseCriteria;
public SystemQuery(SessionContext sessionContext) {
this.session = sessionContext.Session;
this.baseCriteria = session.CreateCriteria<T>();
}
publi...
I'm trying to get Property Injection working on a Custom Action Filter Attribute. It is working as it is supposed to, however, I'd like to use DI on the Property itself. My filter looks like this
[AttributeUsage(AttributeTargets.Class)]
public sealed class HeaderFilterAttribute : ActionFilterAttribute
{
public IMarketService MarketS...
A class has a unique constructor taking IMyInterface as its argument. If I define a concrete type of IMyInterface and registers it to StructureMap then there is no issue and my class can be instanciated with this concrete type.
However, in some cases, no concrete type will be registered. In that case, I would like to receive null for th...
We have two singleton objects (declared via in(Scopes.SINGLETON)) in Guice that each uses the other in its constructor. Guice's way to implement this is with proxies - it initializes the object at first with a proxy to the other object, and only when that object is needed it is resolved.
When running this code from several threads, we g...
Hi,
I have a class that extends AbstractGinModule
like:
public class ClientModule extends AbstractGinModule {
public ClientModule() { }
@Override
protected void configure() {
...
...
bind(...class).annotatedWith(...).to(...class).in(Singleton.class);
...
}
}
The idea that I have is to bind one class with ano...
Is it possible to somehow leverage the dependency injection in Asp.net MVC 3 (using the Forms ViewEngine) to inject UserControls from another library? I am already using MEF to load some other stuff into my MvcApplication.
I need this because I want to build a system with an expandable type system. I want the type vendor to be able to ...