本文整理汇总了C#中Factory.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.Create方法的具体用法?C# Factory.Create怎么用?C# Factory.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory.Create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register2
public void Register2()
{
Factory<string, int> FactoryObject = new Factory<string, int>();
FactoryObject.Register("A", () => 1);
Assert.True(FactoryObject.Exists("A"));
Assert.Equal(1, FactoryObject.Create("A"));
}
示例2: BindAbstractClassToClass
public void BindAbstractClassToClass()
{
var f = new Factory();
f.Bind<AbstractTestClass, TestClass>();
Assert.IsNotNull(f.Create<AbstractTestClass>());
}
示例3: BindInterfaceToClass
public void BindInterfaceToClass()
{
var f = new Factory();
f.Bind<ITestInterface, TestClass>();
Assert.IsNotNull(f.Create<ITestInterface>());
}
示例4: LoadDummy
public static List<Feature> LoadDummy(){
List<Feature> features = new List<Feature>();
Bitmap bitmap = Bitmap.FromFile("../prefab/AdobePreferences.png");
Bitmap feature = Bitmap.Crop(bitmap, 606, 614, 2,2 );
Bitmap feature2 = Bitmap.Crop(bitmap, 681, 614, 2, 2);
Bitmap feature3 = Bitmap.Crop(bitmap, 606, 637, 2, 2);
Bitmap feature4 = Bitmap.Crop(bitmap, 681, 637, 2, 2);
Bitmap feature5 = Bitmap.Crop(bitmap, 219, 318, 12, 12);
Factory factory = new Factory();
Feature dummy = factory.Create(feature);
Feature dummy2 = factory.Create(feature2);
Feature dummy3 = factory.Create(feature3);
Feature dummy4 = factory.Create(feature4);
Feature dummy5 = factory.Create(feature5);
features.Add(dummy);
features.Add(dummy2);
features.Add(dummy3);
features.Add(dummy4);
features.Add(dummy5);
return features;
}
示例5: DatabaseManager
/**
* Singleton methods
*/
public DatabaseManager ()
{
// sqlDB = new SqliteDatabase ("config12.db");
if (DBCallbackDispatcher.Singleton == null )
{
DBCallbackDispatcher.Init();
}
var factory = new Factory();
string DatabaseName = "config.db";
#if UNITY_EDITOR
DatabaseName = "configEditor3.db";
var dbPath = System.IO.Path.Combine(Application.streamingAssetsPath, DatabaseName);
//Debug.Log(dbPath);
//Debug.Log(System.IO.Path.Combine(Application.streamingAssetsPath, DatabaseName));
#else
// check if file exists in Application.persistentDataPath
var filepath = string.Format("{0}/{1}", Application.persistentDataPath, DatabaseName);
if (!File.Exists(filepath))
{
Debug.Log("Database not in Persistent path");
// if it doesn't ->
// open StreamingAssets directory and load the db ->
#if UNITY_ANDROID
var loadDb = new WWW(System.IO.Path.Combine(Application.streamingAssetsPath, DatabaseName)); // this is the path to your StreamingAssets in android
while (!loadDb.isDone) { } // CAREFUL here, for safety reasons you shouldn't let this while loop unattended, place a timer and error check
// then save to Application.persistentDataPath
File.WriteAllBytes(filepath, loadDb.bytes);
#elif UNITY_IOS
var loadDb = Application.dataPath + "/Raw/" + DatabaseName; // this is the path to your StreamingAssets in iOS
// then save to Application.persistentDataPath
// File.Copy(loadDb, filepath);
#elif UNITY_WP8
var loadDb = Application.dataPath + "/StreamingAssets/" + DatabaseName; // this is the path to your StreamingAssets in iOS
// then save to Application.persistentDataPath
// File.Copy(loadDb, filepath);
#elif UNITY_WINRT
var loadDb = Application.dataPath + "/StreamingAssets/" + DatabaseName; // this is the path to your StreamingAssets in iOS
// then save to Application.persistentDataPath
File.Copy(loadDb, filepath);
#endif
Debug.Log("Database written");
}
var dbPath = filepath;
#endif
connection = factory.Create(dbPath);
}