c# - How to locate services base on id (service locator pattern)? -


I have different services that each have different types, for example there are three different types of UpdateService ( Hyffrek, medium frack, minfake).

I have made a deeper example for my services and my type of example:

  public enum UpdateServiceType: byte {UpdateService = 1, SpecialService = 2, byte {Minnetupdate Fraction = 1, Medium Upgrade Frack = 2, High UpgradeFake = 3}  

and

  Public Anonymous MyServices:}  
< P> Then saved on the service and on the terms of the database related to:

  serviceId = 1 service type = 2  

Now I want to make every service But I do not know that Which method is to use: factory pattern, service locator, or even I do not know whether I have done the right thing to use ANM?

What should I use instead of enum? How do I make proper service? What are the best practices? How can I use the IOC like unity in this situation?

Update:

After reading the great post by Mark Simon, I look for my problem right because it clearly describes the class But then I came to another problem again. The suggestion to this factory was something like this:

  Public class UpdatePackageFactory: UpdatePackageFactory {Private Redonly IEnumerable & lt; IUpdatePackage & gt; _Candidate; Public Updates Package Fatter (IINMERABLEL & lt; IUpdatePackage & gt; Candidates) {_candidates = Candidates; } Public IUpdatePackage GetUpdatePackage (UpdateFreq UpdateFreq) {Returns from this method method handled in c.Condidates method = C. GetType (). GetCustomAttribute & lt; HandleUpdateFreqAttribute & gt; () where handledMethod! = Null & amp; amp; HandfordMethod.UpdateFreq == Choose UpdateFreq c) .SingleOrDefault (); }}  

This assumes and like enum

  public enum UpdateFreq: byte {minupdatefake = 1, MediumUpdateFreq = 2, HighUpdateFreq = 3}  

But now I want to make another factory which makes the above factory factory, it is itself dependent on an NAU

  public enum ServiceFactory: byte {UpdateService = 1, Using the above method I can make another factory which creates a factory but the problem is that every factory has its own Mr. Enum is obtained for how to make factories who accept different beliefs. . For example, there will be a method on my factory, which takes two emium in the form of logic, the first one is always a meserve, but the second argument is a proportional change for that factory. Once this update may be fracked, one more special type or .....  
  public IUpdatePackage GetUpdatePackage (MyServices myServices, UpdateFreq updateFreq) {}  

or

But what if every factory has its own empowerment, then for another example here near the factories enum

  enum Manufacturers {NOKIA, SAMSUNG, HTC}}. For example, anonymity accepts an ANIM with different items, one HTC accepts another enumeration with different naming. 

How should I write such a factory?


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -