public static string ToMgaHyperLink <T>(this T subject, CyPhyCOMInterfaces.IMgaTraceability elaboratedObjects = null, bool useName = false) where T : GME.MGA.IMgaObject { StringBuilder sb = new StringBuilder(); if (elaboratedObjects != null) { string id = string.Empty; if (elaboratedObjects.TryGetMappedObject(subject.ID, out id)) { GME.MGA.MgaFCO fco = subject.Project.GetFCOByID(id); if (fco != null) { // TODO: maybe get it until we reach the original source??? sb.AppendFormat("<a href=\"mga:{0}\">{1}</a>", fco.ID, SecurityElement.Escape(fco.Name)); return(sb.ToString()); } } } if (useName) { sb.AppendFormat("<a href=\"mga:{0}\">{1}</a>", subject.ID, subject.Name); } else { sb.AppendFormat("<a href=\"mga:{0}\">{1}</a>", subject.ID, getPath(subject)); } return(sb.ToString()); }
public static IMgaObject getTracedObjectOrSelf(this IMgaObject obj, CyPhyCOMInterfaces.IMgaTraceability traceability) { string originalID; if (traceability != null && traceability.TryGetMappedObject(obj.ID, out originalID)) { return(obj.Project.GetObjectByID(originalID)); } else { return(obj); } }
public void CopyTo(CyPhyCOMInterfaces.IMgaTraceability copy) { foreach (var item in this.map) { string mapped; if (copy.TryGetMappedObject(item.Value, out mapped)) { copy.AddItem(item.Key, mapped); } else { copy.AddItem(item.Key, item.Value); } } }
public ComponentInfo(GME.MGA.IMgaFCO gmeObject, string modelType = null, CyPhyCOMInterfaces.IMgaTraceability traceability = null) { this.Name = gmeObject.Name; this.AbsPath = gmeObject.AbsPath; this.ID = gmeObject.ID; this.Path = this.GetPath(); this.Kind = gmeObject.Meta.Name; this.ModelType = modelType; if (this.Kind == typeof(CyPhy.Component).Name) { var component = CyPhyClasses.Component.Cast(gmeObject); this.AVMID = component.Attributes.AVMID; } if (traceability != null) { string id = string.Empty; if (traceability.TryGetMappedObject(gmeObject.ID, out id)) { GME.MGA.MgaFCO baseComponent = gmeObject.Project.GetFCOByID(id); if (baseComponent != null) { if (baseComponent.Status == 1) { // object is already deleted // try to get it in a different way. var idChain = gmeObject.RegistryValue["Elaborator/ID_Chain"]; if (string.IsNullOrWhiteSpace(idChain) == false) { id = idChain.Split(new char[] { ',' }).LastOrDefault(); if (id != null) { baseComponent = gmeObject.Project.GetFCOByID(id); if (baseComponent != null) { this.Reference = new ComponentInfo(baseComponent, modelType); } } } } else { this.Reference = new ComponentInfo(baseComponent, modelType); } } } } }