Implement relationships for files other than the base package
This commit is contained in:
parent
4a2c218e29
commit
ccec60e098
@ -46,7 +46,11 @@ namespace UniversalEditor.DataFormats.Package.OpenPackagingConvention
|
||||
RelationshipsObjectModel rels = file.GetObjectModel<RelationshipsObjectModel>(new OPCRelationshipsDataFormat());
|
||||
if (relatedFileName != null)
|
||||
{
|
||||
|
||||
foreach (Relationship rel in rels.Relationships)
|
||||
{
|
||||
rel.Source = relatedFileName;
|
||||
package.Relationships.Add(rel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -41,10 +41,10 @@ namespace UniversalEditor.ObjectModels.Package
|
||||
private FileSystemObjectModel mvarFileSystem = new FileSystemObjectModel();
|
||||
public FileSystemObjectModel FileSystem { get { return mvarFileSystem; } }
|
||||
|
||||
public File[] GetFilesBySchema(string p)
|
||||
public File[] GetFilesBySchema(string schema, string relationshipSource = null)
|
||||
{
|
||||
List<File> files = new List<File>();
|
||||
Relationship[] rels = mvarRelationships.GetBySchema(p);
|
||||
Relationship[] rels = mvarRelationships.GetBySchema(schema, relationshipSource);
|
||||
foreach (Relationship rel in rels)
|
||||
{
|
||||
if (rel.Target.StartsWith("/"))
|
||||
|
||||
@ -15,12 +15,15 @@ namespace UniversalEditor.ObjectModels.Package.Relationships
|
||||
/// </summary>
|
||||
/// <param name="schema">The schema to search for.</param>
|
||||
/// <returns>Array of <see cref="Relationship" /> objects whose Schema property is set to the specified value.</returns>
|
||||
public Relationship[] GetBySchema(string schema)
|
||||
public Relationship[] GetBySchema(string schema, string source = null)
|
||||
{
|
||||
List<Relationship> rels = new List<Relationship>();
|
||||
foreach (Relationship rel in this)
|
||||
{
|
||||
if (rel.Schema == schema) rels.Add(rel);
|
||||
if (rel.Schema == schema && rel.Source == source)
|
||||
{
|
||||
rels.Add(rel);
|
||||
}
|
||||
}
|
||||
return rels.ToArray();
|
||||
}
|
||||
@ -35,11 +38,15 @@ namespace UniversalEditor.ObjectModels.Package.Relationships
|
||||
private string mvarTarget = String.Empty;
|
||||
public string Target { get { return mvarTarget; } set { mvarTarget = value; } }
|
||||
|
||||
private string mvarSource = null;
|
||||
public string Source { get { return mvarSource; } set { mvarSource = value; } }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
Relationship clone = new Relationship();
|
||||
clone.ID = (mvarID.Clone() as string);
|
||||
clone.Schema = (mvarSchema.Clone() as string);
|
||||
clone.Source = (mvarSource.Clone() as string);
|
||||
clone.Target = (mvarTarget.Clone() as string);
|
||||
return clone;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user