Exemple #1
0
		/// <summary>
		/// Returns a list of all available / existing content matching the specified Type
		/// </summary>
		/// <param name="t"></param>
		/// <param name="baseDirectory">The base directory to search in. Defaults to <see cref="DualityApp.DataDirectory"/> if not specified otherwise.</param>
		/// <returns></returns>
		public static List<IContentRef> GetAvailableContent(Type t, string baseDirectory = null)
		{
			TypeInfo typeInfo = t.GetTypeInfo();
			IEnumerable<string> resFiles = Resource.GetResourceFiles(baseDirectory);
			return resFiles
				.Select(p => new ContentRef<Resource>(null, p) as IContentRef)
				.Where(r => r.Is(t))
				.Concat(defaultContent.Where(r => typeInfo.IsInstanceOfType(r)).Select(r => new ContentRef<Resource>(r) as IContentRef))
				.ToList();
		}
Exemple #2
0
		/// <summary>
		/// Returns a list of all available / existing content matching the specified Type
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="baseDirectory">The base directory to search in. Defaults to <see cref="DualityApp.DataDirectory"/> if not specified otherwise.</param>
		/// <returns></returns>
		public static List<ContentRef<T>> GetAvailableContent<T>(string baseDirectory = null) where T : Resource
		{
			IEnumerable<string> resFiles = Resource.GetResourceFiles(baseDirectory);
			return resFiles
				.Select(p => new ContentRef<Resource>(null, p))
				.Where(r => r.Is<T>())
				.Select(r => r.As<T>())
				.Concat(defaultContent.OfType<T>().Select(r => new ContentRef<T>(r)))
				.ToList();
		}