support complete URIs and schemes in Accessors (e.g. file:///blah/blah/blah
This commit is contained in:
parent
a5ade252f9
commit
7cd5a3fb24
@ -57,11 +57,11 @@ namespace UniversalEditor.Accessors
|
||||
|
||||
public override string GetFileTitle()
|
||||
{
|
||||
return System.IO.Path.GetFileName(mvarFileName);
|
||||
return System.IO.Path.GetFileName(FileName);
|
||||
}
|
||||
public override string GetFileName()
|
||||
{
|
||||
return mvarFileName;
|
||||
return FileName;
|
||||
}
|
||||
protected override long GetPosition()
|
||||
{
|
||||
@ -103,8 +103,19 @@ namespace UniversalEditor.Accessors
|
||||
private bool mvarForceOverwrite = false;
|
||||
public bool ForceOverwrite { get { return mvarForceOverwrite; } set { mvarForceOverwrite = value; } }
|
||||
|
||||
private string mvarFileName = String.Empty;
|
||||
public string FileName { get { return mvarFileName; } set { mvarFileName = value; } }
|
||||
private string mvarFileName = null;
|
||||
public string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mvarFileName == null && OriginalUri != null)
|
||||
{
|
||||
return OriginalUri.LocalPath;
|
||||
}
|
||||
return mvarFileName;
|
||||
}
|
||||
set { mvarFileName = value; }
|
||||
}
|
||||
|
||||
public FileAccessor()
|
||||
{
|
||||
@ -128,7 +139,7 @@ namespace UniversalEditor.Accessors
|
||||
}
|
||||
protected override void OpenInternal()
|
||||
{
|
||||
string filename = mvarFileName;
|
||||
string filename = FileName;
|
||||
if (filename.StartsWith("file://"))
|
||||
{
|
||||
Uri uri = new Uri(filename);
|
||||
@ -157,8 +168,7 @@ namespace UniversalEditor.Accessors
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("file:///");
|
||||
sb.Append(mvarFileName);
|
||||
sb.Append(FileName);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Accessors>
|
||||
<Accessor Title="Local file" TypeName="UniversalEditor.Accessors.File.FileAccessor">
|
||||
<Accessor Title="Local file" TypeName="UniversalEditor.Accessors.FileAccessor">
|
||||
<Schemas>
|
||||
<Schema Title="Local file" Value="file" />
|
||||
</Schemas>
|
||||
|
||||
@ -95,7 +95,6 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
objectModels.Push(new MarkupObjectModel());
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode()]
|
||||
protected override void AfterLoadInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
base.AfterLoadInternal(objectModels);
|
||||
@ -106,6 +105,59 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
MarkupTagElement tagUniversalEditor = (mom.Elements["UniversalEditor"] as MarkupTagElement);
|
||||
if (tagUniversalEditor == null) throw new InvalidDataFormatException("Top-level tag 'UniversalEditor' not found");
|
||||
|
||||
#region Accssors
|
||||
{
|
||||
MarkupTagElement tagAccessors = (tagUniversalEditor.Elements["Accessors"] as MarkupTagElement);
|
||||
if (tagAccessors != null)
|
||||
{
|
||||
foreach (MarkupElement elAccessor in tagAccessors.Elements)
|
||||
{
|
||||
MarkupTagElement tagAccessor = (elAccessor as MarkupTagElement);
|
||||
if (tagAccessor == null) continue;
|
||||
|
||||
AccessorReference accref = null;
|
||||
MarkupAttribute attTypeName = tagAccessor.Attributes["TypeName"];
|
||||
if (attTypeName != null)
|
||||
{
|
||||
Type type = MBS.Framework.Reflection.FindType(attTypeName.Value);
|
||||
if (type != null)
|
||||
{
|
||||
Accessor acc = (type.Assembly.CreateInstance(type.FullName) as Accessor);
|
||||
if (acc != null)
|
||||
{
|
||||
accref = acc.MakeReference();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (accref != null)
|
||||
{
|
||||
MarkupTagElement tagSchemas = tagAccessor.Elements["Schemas"] as MarkupTagElement;
|
||||
if (tagSchemas != null)
|
||||
{
|
||||
foreach (MarkupElement elSchema in tagSchemas.Elements)
|
||||
{
|
||||
MarkupTagElement tagSchema = (elSchema as MarkupTagElement);
|
||||
if (tagSchema == null) continue;
|
||||
|
||||
MarkupAttribute attSchemaValue = tagSchema.Attributes["Value"];
|
||||
if (attSchemaValue == null) continue;
|
||||
|
||||
accref.Schemas.Add(attSchemaValue.Value);
|
||||
|
||||
MarkupAttribute attSchemaTitle = tagSchema.Attributes["Title"];
|
||||
if (attSchemaTitle != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region Data Formats
|
||||
{
|
||||
MarkupTagElement tagDataFormats = (tagUniversalEditor.Elements["DataFormats"] as MarkupTagElement);
|
||||
|
||||
@ -826,6 +826,7 @@ namespace UniversalEditor.UserInterface
|
||||
if (accs.Length > 0)
|
||||
{
|
||||
Accessor fa = accs[0].Create();
|
||||
fa.OriginalUri = new Uri(fileNames[i]);
|
||||
documents[i] = new Document(fa);
|
||||
}
|
||||
else if (System.IO.File.Exists(fileNames[i]))
|
||||
@ -873,6 +874,7 @@ namespace UniversalEditor.UserInterface
|
||||
MessageDialog.ShowDialog(ex.Message, "Error", MessageDialogButtons.OK, MessageDialogIcon.Error);
|
||||
}
|
||||
}
|
||||
Present(DateTime.Now);
|
||||
}
|
||||
|
||||
public ProjectObjectModel ShowOpenProjectDialog()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user