Konstantin Koch 17d0771b03 Placed the importers into different categories for the "importing existing files" dialog in Visual Studio.
Fixed a performance problem in the Visual Studio extension where no importer or processor was selected for an asset.
Fixed that the asset names for Uri encoded in the build output.
Fixed that errors when serializing assets get logged.
Sped up ImporterManager.GuessImporterByFileExtension, which caused performance problems if many assemblies are loaded into the current AppDomain.
Made the AssimpImporter library deploy the binary files again (hopefully just a temporary solution until we've found a better way.)
Provide a extension for TargetPlatform enum for getting the DisplayName of an entry.
Changed that ProcessorManager.GetProcessorDisplayName doesn't throw an exception if no processor with the given name exists, which now mimicks the same behavior as in importerManager.GetImporterDisplayName.
2015-04-26 19:47:26 +02:00

108 lines
3.3 KiB
C#

using ANX.Framework.Content.Pipeline;
using ANX.Framework.VisualStudio.Nodes;
using Microsoft.VisualStudio.Project.Automation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using System.ComponentModel;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
namespace ANX.Framework.VisualStudio
{
class Utilities
{
private static EnvDTE.DTE _dte;
private static Dictionary<string, TargetPlatform> _displayNames;
public static void Initialize(EnvDTE.DTE dte)
{
if (dte == null)
throw new ArgumentNullException("dte");
_dte = dte;
}
public static ContentProjectNode GetCurrentProject()
{
if (AppDomain.CurrentDomain.IsBuildAppDomain())
throw new InvalidOperationException("GetCurrentProject called from the wrong appDomain.");
if (_dte == null)
throw new InvalidOperationException("The converters have not been initialized.");
Array projects = (Array)_dte.ActiveSolutionProjects;
if (projects.Length == 0)
throw new InvalidOperationException("There's currently no ContentProject selected.");
if (projects.Length > 1)
throw new Exception("Test, too many Projects.");
EnvDTE.Project project = (EnvDTE.Project)projects.GetValue(0);
if (project is OAProject)
{
var oaProject = (OAProject)project;
if (oaProject.ProjectNode is ContentProjectNode)
{
return (ContentProjectNode)oaProject.ProjectNode;
}
}
return null;
}
private static void InitializeTargetPlatforms()
{
if (_displayNames == null)
{
_displayNames = new Dictionary<string, TargetPlatform>();
foreach (var enumValue in typeof(TargetPlatform).GetEnumValues())
{
var enumInstance = (TargetPlatform)Enum.ToObject(typeof(TargetPlatform), enumValue);
_displayNames.Add(enumInstance.ToDisplayName(), enumInstance);
}
}
}
public static TargetPlatform ParseTargetPlatform(string displayName)
{
InitializeTargetPlatforms();
TargetPlatform targetPlatform;
if (_displayNames.TryGetValue(displayName, out targetPlatform))
return targetPlatform;
return default(TargetPlatform);
}
public static string[] GetTargetPlatformDisplayNames()
{
InitializeTargetPlatforms();
return _displayNames.Keys.ToArray();
}
public static string GetDisplayName(TargetPlatform platform)
{
return platform.ToDisplayName();
}
public static string GetTargetPlatformName(string displayName)
{
InitializeTargetPlatforms();
TargetPlatform targetPlatform;
if (_displayNames.TryGetValue(displayName, out targetPlatform))
return targetPlatform.ToString();
return displayName;
}
}
}