Consider the following interface:
public interface IMyCallback
{
void SomeEvent(int someArg);
}
which is the contract for a WCF callback that will be receiving "events" from a WCF service. My implementation for this interface looks like this
public class MyCallback : IMyCallback
{
void IMyCallback.SomeEvent(int someArg)
{
O...
I believe the factory method design pattern is appropriate for what I'm trying to do, but I'm not sure how much responsibility (knowledge of subclasses it creates) to give it. The example of using the factory method pattern at Wikipedia describes the situation I'm in almost exactly:
public class ImageReaderFactory
{
public static ...
Hi All
Any one can please help me how to use the service factory for the VS 2008. What are all the tools need to install.
Thanks in Advance
Sekar
...
My c++ SOA app has a concept of "session" that is used exchange data between services. In example its used for checking legality of some service A operations before executing session B which commits or rollback changes. Whatever.
I have 2 types of session modes: normal and what-if. Going further, I have different session, session for le...
I have code that looks like follows:
public interface BaseDAO{
// marker interface
}
public interface CustomerDAO extends BaseDAO{
public void createCustomer();
public void deleteCustomer();
public Customer getCustomer(int id);
// etc
}
public abstract class DAOFactory {
public BaseDAO getCustomerDAO();
public static DAOFactory getIn...
Let's say I have an abstract class Drink, and a factory method which chooses the type of Drink (Wine, Beer, etc.) to create at runtime.
Each Drink needs some arguments to properly initialize itself. Some of these are common to all Drinks; for example, they might all require a DrinkConfig argument.
But each Drink may have its own unique...
can anyone provide a webform linq to sql and repository pattern sample project link
...
Writing a test app to emulate PIO lines, I have a very simple Python/Tk GUI app. Using the numeric Keys 1 to 8 to simulate PIO pins 1 to 8. Press the key down = PIO High, release the Key = PIO goes low. What I need it for is not the problem. I kind of went down a rabbit hole trying to use a factory to create the key press call back funct...
Good people of stackoverflow,
As always, I am writing a factory in order to dynamically instantiate objects.
To schematize, I have four types:
class CatDescriptor : PetDescriptor
class DogDescriptor : PetDescriptor
class Cat : Pet
class Dog : Pet
I instanciate the two last types from the factory. And here comes the dilemma:
Should ...
Is there a way to map a factory method in Hibernate (as opposed to having Hibernate call a default constructor and reflectively set properties or fields)?
And if it can't be mapped, does Hibernate provide a hook for custom object creation on a class by class basis?
Thanks!
...
When my application starts up it needs to get an instance of the correct DAL class (currently there are 4) based on what user is logged in. Certain users are pulling down from certain databases.
Is it still considered a "factory" pattern if instead of instantiating instances of those DAL classes, I simply return the correct static inst...
Factory Girl is a handy framework in rails for easily creating instances of models for testing.
From the Factory Girl home page:
factory_girl allows you to quickly define prototypes for each of your models and ask for instances with properties that are important to the test at hand.
An example (also from the home page):
Factory....
I'm doing a java application.
This are my files so far:
Person Interface.
has a setName(String aName) method
PersonImpl
Implementation of Person Interface.
PersonFactory Interface
has a createPerson()
PersonFactoryImpl
Implementation of PersonFactory Interface.
The thing is I was willing to add a method getAll() that returns a ...
Is there a way in .NET 2.0 to use a class as a class factory for user controls? In other words, 1 super that sits there and when I want a user control, it creates it and returns it to me. It seems it needs the ASP namespace which I can't seem to get it to reference.
I have a masterpage with a placeholder. Depending upon the user's authe...
I don't know if there is an official name for this, but I have been playing with what I like to call the "self-factory" pattern. Basically, it's when an abstract base class acts as a factory for itself. Let me explain:
I have Foo objects and Bar objects in my system, which are used via interfaces FooInterface and BarInterface. I need...
Update
Answered below. In case the linked site disappears, you can use mocha to stub the initial state and prevent overwriting as in ...
require 'mocha'
class OrderTest < ActiveSupport::TestCase
def setup
Order.any_instance.stubs(:set_initial_state)
@order = Factory(:order, :state => "other_state")
end
...
end
Origina...
So I have a factory class and I'm trying to work out what the unit tests should do. From this question I could verify that the interface returned is of a particular concrete type that I would expect.
What should I check for if the factory is returning concrete types (because there is no need - at the moment - for interfaces to be used)...
I am considering a factory function to create different classes in the same hierarchy. I understand that normally a factory is normally implemented as follows:
Person* Person::Create(string type, ...)
{
// Student, Secretary and Professor are all derived classes of Person
if ( type == "student" ) return new Student(...);
if ...
Hi all,
suppose I have a TModel:
TModelClass = class of TModel;
TModel = class
procedure DoSomeStuff;
end;
and 2 descendants:
TModel_A = class(TModel);
TModel_B = class(TModel);
and a factory :
TModelFactory = class
class function CreateModel_A: TModel_A;
class function CreateModel_B: TModel_B;
end;
Now I want to refactor...
What would be the most efficient way to instanciate an object according to a generic type passed to a Factory class, for instance:
public class LoggerFactory
{
public static ILogger<T> Create<T>()
{
// Switch Statement?
// Generic Dictionary?
// EX.: if "T" is of type "string": return (ILogger<T>)new Stri...