Various fixes and updates
This commit is contained in:
parent
39e1bf28f4
commit
fb3e6b8f61
@ -926,6 +926,33 @@ namespace UniversalEditor.Common
|
||||
public static T GetAvailableObjectModel<T>(string FileName) where T : ObjectModel
|
||||
{
|
||||
ObjectModelReference[] omrs = GetAvailableObjectModels(FileName);
|
||||
if (omrs.Length == 0)
|
||||
{
|
||||
// we failed to find an object model from the file name, so let's try and
|
||||
// force the loading of the object model we're told to load in the first place
|
||||
|
||||
Type type = typeof(T);
|
||||
ObjectModel om = (ObjectModel)type.Assembly.CreateInstance(type.FullName);
|
||||
ObjectModelReference omr = om.MakeReference();
|
||||
|
||||
DataFormatReference[] dfrs = GetAvailableDataFormats(om.MakeReference());
|
||||
|
||||
FileAccessor accessor = new FileAccessor(FileName);
|
||||
foreach (DataFormatReference dfr in dfrs)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataFormat df = dfr.Create();
|
||||
Document.Load(om, df, accessor);
|
||||
}
|
||||
catch
|
||||
{
|
||||
accessor.Close();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return (T)om;
|
||||
}
|
||||
foreach (ObjectModelReference omr in omrs)
|
||||
{
|
||||
if (omr.ObjectModelType == typeof(T))
|
||||
@ -1014,6 +1041,7 @@ namespace UniversalEditor.Common
|
||||
ObjectModelReference[] array = GetAvailableObjectModels();
|
||||
DataFormatReference[] dfs = GetAvailableDataFormats(FileName);
|
||||
List<ObjectModelReference> list = new List<ObjectModelReference>();
|
||||
if (dfs.Length == 0) return list.ToArray();
|
||||
|
||||
foreach (ObjectModelReference om in array)
|
||||
{
|
||||
|
||||
@ -34,6 +34,8 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
if (sol == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
if (base.Accessor.Remaining < 3) throw new InvalidDataFormatException("File must be at least three bytes");
|
||||
|
||||
byte[] signature1 = reader.ReadBytes(3);
|
||||
if (!signature1.Match(new byte[] { 0xEF, 0xBB, 0xBF }))
|
||||
{
|
||||
@ -148,15 +150,12 @@ namespace UniversalEditor.DataFormats.Solution.Microsoft.VisualStudio
|
||||
}
|
||||
*/
|
||||
|
||||
SolutionObjectModel solproj = new SolutionObjectModel();
|
||||
solproj.Projects.Add(project);
|
||||
|
||||
if (!System.IO.Directory.Exists(projdir))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(projdir);
|
||||
}
|
||||
|
||||
Document.Save(solproj, new VisualStudioProjectDataFormat(), new FileAccessor(projdir + "/" + project.Title + ".ueproj", true, true), true);
|
||||
Document.Save(project, new VisualStudioProjectDataFormat(), new FileAccessor(projdir + "/" + project.Title + ".ueproj", true, true), true);
|
||||
}
|
||||
|
||||
writer.WriteLine("Global");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user