public static bool LoadFromFile(string fileName, out part obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an part object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output part object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out part obj, out System.Exception exception) { exception = null; obj = default(part); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
/// <summary> /// Deserializes workflow markup into an part object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output part object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out part obj, out System.Exception exception) { exception = null; obj = default(part); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string xml, out part obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
public override void visit(Component obj) { if (obj.Impl is Tonka.TestComponent) return; var parts = schematic_obj.parts; var instances = schematic_obj.sheets.sheet.FirstOrDefault().instances; var libraries = schematic_obj.libraries; var schObj = obj.Impl.Children.EDAModelCollection.FirstOrDefault(); if (schObj == null) // no schematic model in this component, skip from generating return; var part = new Eagle.part(); part.name = obj.Name; var device = schObj.Attributes.Device; part.device = (device != null) ? device : "device-unknown"; var deviceset = schObj.Attributes.DeviceSet; part.deviceset = (deviceset != null) ? deviceset : "deviceset-unknown"; var libName = schObj.Attributes.Library; part.library = (String.IsNullOrWhiteSpace(libName) == false) ? libName : "library-noname"; var parVal = obj.Parameters.Where(p => p.Name.Equals("value")).FirstOrDefault(); if (parVal != null) part.value = parVal.Value; MergeLibrary(obj, obj.SchematicLib, libraries, libName); var devLib = (obj.SchematicLib != null) ? obj.SchematicLib.drawing.Item as Eagle.library : null; if (devLib != null) { var techs = devLib.devicesets.deviceset.SelectMany(p => p.devices.device).SelectMany(q => q.technologies.technology).Select(t => t.name); part.technology = techs.FirstOrDefault(); } parts.part.Add(part); CodeGenerator.partComponentMap[part] = obj; // add to map CodeGenerator.componentPartMap[obj] = part; // add to reverse map if (devLib != null) { var gates = devLib.devicesets.deviceset.SelectMany(p => p.gates.gate); foreach (var gate in gates) { var instance = new Eagle.instance(); instance.part = part.name; instance.gate = gate.name; double x = float.Parse(gate.x) + obj.CenterX; double y = float.Parse(gate.y) + obj.CenterY; instance.x = x.ToString("F2"); instance.y = y.ToString("F2"); instances.instance.Add(instance); } } }