当前位置: 首页>>代码示例>>C#>>正文


C# Factory.Create方法代码示例

本文整理汇总了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"));
 }
开发者ID:gwilkinson,项目名称:Craig-s-Utility-Library,代码行数:7,代码来源:Factory.cs

示例2: BindAbstractClassToClass

        public void BindAbstractClassToClass()
        {
            var f = new Factory();

            f.Bind<AbstractTestClass, TestClass>();

            Assert.IsNotNull(f.Create<AbstractTestClass>());
        }
开发者ID:melazarus,项目名称:Iniect.io,代码行数:8,代码来源:AbstractTests.cs

示例3: BindInterfaceToClass

        public void BindInterfaceToClass()
        {
            var f = new Factory();

            f.Bind<ITestInterface, TestClass>();

            Assert.IsNotNull(f.Create<ITestInterface>());
        }
开发者ID:melazarus,项目名称:Iniect.io,代码行数:8,代码来源:AbstractTests.cs

示例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;
		}
开发者ID:nunb,项目名称:interpretation,代码行数:23,代码来源:Feature.cs

示例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);
	}
开发者ID:SonGit,项目名称:NailGame,代码行数:53,代码来源:DatabaseManager.cs


注:本文中的Factory.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。