factory

Loki Factory-Singleton throws “dead reference detected” in try-catch-block on ARM

你。 提交于 2019-12-24 07:31:04
问题 I am using Loki SingletonHolder in combination with Loki Factory in my project. The following example basically consists of two lines of code in the try-block to 1.) use the factory 2.) then throw an exception. #include <iostream> #include <loki/Singleton.h> #include <loki/Factory.h> class AbstractBase {}; class ConcreteChild : public AbstractBase {}; class TestFactory: public Loki::SingletonHolder< Loki::Factory<AbstractBase, std::string> > {}; template <class T> T* createNew() { return new

Simple Factory with reflection C#

﹥>﹥吖頭↗ 提交于 2019-12-24 04:19:10
问题 Simple factory using reflection involves storing (registering) various type names with their corresponding class type in a hash table, then using this hash table for generating objects in the factory. interface Product { void foo(); } class ProductFactory { HashTable m_RegisteredProducts = new HashTable(); public void registerProduct(string productID, Type p) { m_RegisteredProducts.add(productID, p); } public Product createProduct(string productID){ return (Product) new m_RegisteredProducts

How to implement a factory class using PHP - Dependancy injection

非 Y 不嫁゛ 提交于 2019-12-24 01:57:37
问题 Take the following code as an example of what i want: class SomethingController extends Factory { private $somethingRepository; public function __Construct( ISomethingRepository $repo ) { $this->somethingRepository = $repo; } } class Factory { public function __Construct() { // The following call to AddBinding would push into SomethingController the new instance of the class denoted in my AddBinding second parameter. $this->AddBinding( ISomethingRepository, MySQLSomethingRepository); // So in

Can I use a variable on the same line it is declared in this factory in C++?

一曲冷凌霜 提交于 2019-12-24 00:55:03
问题 I have a polymorphic hierarchy of classes. While I also support the standard factory approach, where I use only base class pointers, I also want a factory mechanism which gives me derived classes, which is not easy because these functions only differ in their return types. This is why I came up with the idea to overload a function and let the compiler pick the right one. A simple application of this is that I can write functions which create a derived object, "prepare" it and return a base

Builder Factory returning different sub-interfaces

折月煮酒 提交于 2019-12-24 00:15:16
问题 I know there are many variations and related topics to this one here on stack overflow but I haven't found any compelling answers so I'll give it a go myself. I'm trying to design a builder factory that returns different subclasses of a common builder interface. I want to allow all the implementations to share a common abstract class for code re-use. Note that I'm not interested in the return type of the build() method, only what types the builders are. This is what I have so far: Builder

Can Castle.Windsor TypedFactoryFacility construct a type with only some ref arguments passed inline?

此生再无相见时 提交于 2019-12-23 20:07:14
问题 I have hit a problem in my use of Castle.Windsor's TypedFactoryFacility concept, and not sure how to resolve it (or if I can). I have a ViewModel defined like so; public class MyViewModel : IMyViewModel { // constructor which I aim to access through the factory public MyViewModel( ISomeContainerResolvableDependency a, ISomePassedInDependency b) { ... } } And a corresponding factory interface defined like; public interface IMyViewModelFactory { IMyViewModel Create(ISomePassedInDependency a);

AngularJS: Factory is always undefined when injected in controller

早过忘川 提交于 2019-12-23 19:17:23
问题 I am trying a simple example of an AddressBook Angular application. I have a factory that returns an array of records and it it gets displayed in a list view using a List controller angular.module('abModule', ['ngRoute']) .factory('AddressBook', function() { var address_book = [ { "id": 1, "first_name": "John", "last_name": "Doe", "age": 29 }, { "id": 2, "first_name": "Anna", "last_name": " Smith", "age": 24 }, { "id": 3, "first_name": "Peter", "last_name": " Jones", "age": 39 } ]; alert(

How do you create your Factories?

廉价感情. 提交于 2019-12-23 18:43:58
问题 So, coming upon the subject of Factories, I'm wondering how they are set up. From where I stand, I can see 3 types of Factories: All In One A factory that basically contains all of the classes used in an application. It feels like it is just having a factory for the sake of having a factory, and doesn't really feel structured. Example (Where ClassA, Class B, and ClassC have nothing in common except being in the same App) : class Factory { public static function buildClassA() public static

Generic Interface dependency injection into factory

徘徊边缘 提交于 2019-12-23 17:45:52
问题 I'm playing around with DI and Ninject. I'm open for suggestions on how to solve this in another way. I'm trying to make sure the concrete implementations of ICreateOrders can be replaced - if need be. Maybe there's another way or pattern? Solutions like this: C# - Ninject, IoC and factory pattern are fine but I was hoping to inject the possible creators into the factory and making the factory pick one based on OrderRequest. This doesn't work. kernel.Bind(typeof(ICreateOrders<,>)).To(typeof

Why does Spring report a factory method arg as ambiguous?

随声附和 提交于 2019-12-23 16:40:20
问题 I'm trying to create this bean: <bean id="myBean" class="java.lang.String" factory-method="valueOf"> <constructor-arg name="obj" value="a string" type="java.lang.Object"/> </bean> I want Spring to use this method java.lang.String#valueOf(Object obj) when creating the bean. I get: Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myBean' defined in class path resource [META-INF/test-contexts/testManualDependencyBundleResolverContext.xml