我正在创建一个 Direct2D 应用程序,API 概述页面显示第一步是创建一个工厂...我尝试使用此函数
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);
Run Code Online (Sandbox Code Playgroud)
但它给出了错误
Error 62 error LNK2019: unresolved external symbol _D2D1CreateFactory@16 referenced in function "long __cdecl D2D1CreateFactory(enum D2D1_FACTORY_TYPE,struct _GUID const &,void * *)" (?D2D1CreateFactory@@YAJW4D2D1_FACTORY_TYPE@@ABU_GUID@@PAPAX@Z
Run Code Online (Sandbox Code Playgroud)
我从 WinMain 函数中调用 D2D1CreateFactory 函数。
这就是我初始化工厂指针的方式
ID2D1Factory *factory;
Run Code Online (Sandbox Code Playgroud)
这些是包含目录和库目录
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86
Run Code Online (Sandbox Code Playgroud)
我有使用 direct3D 的经验,所以我熟悉设备和渲染目标,但我的印象是对于 direct2D 工厂是第一位的,所以我没有创建任何设备、渲染目标等...
任何帮助表示赞赏。
我使用lazy_attributeand choicewith None,但我认为可以做得更好。
import factory # from factory-boy
from random import choice
class Device(models.Model):
deleted_at = models.DateTimeField(null=True, blank=True)
class DeviceFactory(factory.DjangoModelFactory):
class Meta:
model = Device
@factory.lazy_attribute
def deleted_at(self):
return choice([Faker('date_time').generate(), None])
Run Code Online (Sandbox Code Playgroud) 有没有办法修改构造函数中构造的类?
public class A {
A() {
//if (condition) return object of type B
//else return A itself
}
}
public class B extends A { }
Run Code Online (Sandbox Code Playgroud)
基本上我想使用基类构造函数作为工厂方法.在java中有可能吗?
假设我需要实现工厂函数,它返回继承/具有继承自boost :: noncopyable的成员的对象O.
struct O : boost::noncopyable {};
O factory() { return O(); }
Run Code Online (Sandbox Code Playgroud)
显然返回值无法编译.
您知道或使用哪种方法来实施此类工厂方法?如果可能的话,我真的想避免重写复制构造函数并返回值而不是引用或指针.
经过一些修补和来自codeka的链接我管理了这个(不知道这有多便携,似乎与g ++一起工作):
template<class E>
struct threads_parallel_for_generator
: for_generator<E, threads_parallel_for_generator<E> > {
typedef for_generator<E, threads_parallel_for_generator> base_type;
struct factory_constructor {
explicit factory_constructor(const E &expression)
: expression_(expression) {}
operator const E&() const { return expression_; }
private:
E expression_;
};
threads_parallel_for_generator(const factory_constructor & constructor)
: base_type(constructor, *this) {}
private:
boost::mutex mutex_;
};
template<class E>
static threads_parallel_for_generator<E>
parallel_for(const E &expression) {
typedef threads_parallel_for_generator<E> generator;
return typename generator::factory_constructor(expression);
}
Run Code Online (Sandbox Code Playgroud) 我编写了一个新的FactoryComponentSelector,它能够通过名称解析特定接口的实例.到现在为止还挺好.但是,当涉及到我们应用程序的业务部分中的配置时,我需要一个容器外的给定接口的所有名称的列表.
假设我们有以下注册:
container.AddFacility<TypedFactoryFacility>();
container.Register(Component.For<ITypedFactoryComponentSelector>().ImplementedBy<CreateByNameComponentSelector>());
container.Register(Component.For<IProviderFactory>().AsFactory(c => c.SelectedWith<CreateByNameComponentSelector>()));
container.Register(Component.For<IProvider>().ImplementedBy<FirstProvider>().Named("First"));
container.Register(Component.For<IProvider>().ImplementedBy<SecondProvider>().Named("Second"));
container.Register(Component.For<IProvider>().ImplementedBy<ThirdProvider>().Named("Third"));
Run Code Online (Sandbox Code Playgroud)
有没有办法向容器询问实现接口IProvider的所有已注册组件的名称列表?
我是C#开发人员,我想使用工厂模式来创建表示硬盘上的文件或目录的对象.FileInfo和DirectoryInfo是用于此目的的.NET中的类,但是我想拥有自己的包含它们的IFileInfo和IDirectoryInfo接口而不是它们.使用自定义接口而不是内置类的原因是因为我想添加一些其他属性,如文件shell图标等...
所以我想使用工厂模式为文件/目录路径的给定字符串创建IFileInfo和IDirectoryInfo的实例.
所以工厂类看起来像:
public class MyFileInfoFactory
{
IFileInfo Create(string filePath)
{
System.IO.FileInfo file = new System.IO.FileInfo(filePath);
// turn FileInfo to my IFileInfo etc...
}
}
Run Code Online (Sandbox Code Playgroud)
现在看一下System.IO.FileInfo文档(FileInfo MSDN),我看到有几种可能的异常可以抛出.我的问题是我应该在工厂Create()方法中处理所有这些异常吗?或者我应该让它们向上传播到调用MyFileInfoFactory.Create()的代码?
如果第一个解决方案是可行的,那么下一步将是什么?例如,我应该返回null还是可能抛出一些自定义异常,并将InnerException属性设置为从新FileInfo()构造函数抛出的实际异常?
只是想知道在这个具体情景案例中最佳做法是什么......
我的控制器中有一个巨大的json对象,我想要将其分离到一个单独的文件中.到目前为止我这样做:
myApp.controller('smController', ['$scope', function($scope) {
...
var stadtmobilRates = {
classic: {
A: {
night: 0,
hour: 1.4,
day: 21,
week: 125,
km000: 0.2,
km101: 0.18,
km701: 0.18
},
...
}
};
Run Code Online (Sandbox Code Playgroud)
我已经使用了一个工厂,并承诺如解释在这里#2:
myApp.factory('stadtMobilRates', function($http) {
var promise = null;
return function() {
if (promise) {
// If we've already asked for this data once,
// return the promise that already exists.
return promise;
} else {
promise = $http.get('stadtmobilRates.json');
return promise;
}
};
});
myApp.controller('smController', ['$scope', function($scope, …Run Code Online (Sandbox Code Playgroud) 说我们上课Foo:
class Foo {
public:
...
};
Run Code Online (Sandbox Code Playgroud)
Foo有一个实例方法,它将Foo实例转换为另一个Foo实例,或返回相同的Foo实例:
<some appropriate pointer type to Foo> Foo::tryToTransform() {
if (canBeTransformed()) {
<delete this Foo instance>;
return <new instance of Foo>;
}
else {
return <this instance of Foo>;
}
}
Run Code Online (Sandbox Code Playgroud)
客户代码:
<some appropriate pointer type to Foo> foo = ...;
...
foo = foo->tryToTransform();
Run Code Online (Sandbox Code Playgroud)
使用裸指针很容易做到这一点:
Foo* Foo::tryToTransform() {
if (canBeTransformed()) {
delete this;
return new Foo(...);
}
else {
return this;
}
} …Run Code Online (Sandbox Code Playgroud) 我是Laravel的新手,我正在寻找一种使用工厂种植数据透视表的好方法.我不想使用普通的播种机.我会告诉你这个案子:
我有三个表(用户,技能和user_skill).
users user_skill skills
+----------------+ +----------------------+ +-----------------+
| id | name | | user_id | section_id | | id | skills |
+----------------+ +----------------------+ +-----------------+
| 1 | Alex | | | | | 1 | draw |
|----------------| |----------------------| |-----------------|
| 2 | Lucy | | | | | 2 | program |
|----------------| |----------------------| |-----------------|
| 3 | Max | | | | | 3 | social |
|----------------| …Run Code Online (Sandbox Code Playgroud) 我试图将我的cosmosDB集合中的所有文档下载到本地目录.我想使用python修改所有JSON文档中的一些内容,然后将它们上传到另一个Azure帐户.下载我馆藏中所有文件的最简单,最快捷的方法是什么?我应该使用CosmosDB模拟器吗?我被告知要查看Azure的数据工厂?这有助于在本地下载文件吗?我也被提到了CosmosDB的数据迁移工具,我发现它有助于向CosmosDB导入数据,但我在导出方面找不到多少.我的收藏中有大约6GB的Json文件.
谢谢.
factory ×10
c++ ×3
.net ×1
angularjs ×1
azure ×1
boost ×1
c# ×1
c++11 ×1
direct2d ×1
directx ×1
emulation ×1
factory-boy ×1
faker ×1
fileinfo ×1
java ×1
javascript ×1
json ×1
laravel ×1
migration ×1
nullable ×1
option-type ×1
php ×1
pivot-table ×1
unique-ptr ×1