private void RedirectReference(DocSchema docSchema, DocDefinition docOld, DocDefinition docNew, bool force)
{
// find reference to each source and redirect to target definition
foreach (DocEntity docEntity in docSchema.Entities)
{
if (force || (docEntity.DiagramNumber != docOld.DiagramNumber))
{
foreach (DocAttribute docAttr in docEntity.Attributes)
{
if (docAttr.Definition == docOld)
{
docAttr.Definition = CreateLink(docNew, docAttr.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docEntity);
}
}
foreach (DocLine docLine in docEntity.Tree)
{
if (docLine.Definition == docOld)
{
docLine.Definition = CreateLink(docNew, docLine.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docEntity);
}
foreach (DocLine docNode in docLine.Tree)
{
if (docNode.Definition == docOld)
{
docNode.Definition = CreateLink(docNew, docLine.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docEntity);
}
}
}
}
}
foreach (DocType docType in docSchema.Types)
{
if (force || (docType.DiagramNumber != docOld.DiagramNumber))
{
if (docType is DocDefined)
{
DocDefined docDef = (DocDefined)docType;
if (docDef.Definition == docOld)
{
docDef.Definition = CreateLink(docNew, docDef.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docDef);
}
}
else if (docType is DocSelect)
{
DocSelect docSel = (DocSelect)docType;
foreach (DocLine docLine in docSel.Tree)
{
if (docLine.Definition == docOld)
{
docLine.Definition = CreateLink(docNew, docLine.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docSel);
}
foreach (DocLine docNode in docLine.Tree)
{
if (docNode.Definition == docOld)
{
docNode.Definition = CreateLink(docNew, docLine.DiagramLine[0]);
this.ctlExpressG.LayoutDefinition(docSel);//?...
}
}
}
}
}
}
}