예제 #1
0
 public static bool LoadFromFile(string fileName, out Design obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
예제 #2
0
 /// <summary>
 /// Deserializes xml markup from file into an Design object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output Design 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 Design obj, out System.Exception exception) {
     exception = null;
     obj = default(Design);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
예제 #3
0
 public static bool Deserialize(string xml, out Design obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
예제 #4
0
 /// <summary>
 /// Deserializes workflow markup into an Design object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output Design 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 Design obj, out System.Exception exception) {
     exception = null;
     obj = default(Design);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
예제 #5
0
        public static Complexity.Design Design2Complexity(avm.Design dmInput)
        {
            var dMain = new Complexity.Design();

            dMain.ComponentInstances = new List <Complexity.ComponentInstance>();
            dMain.Connections        = new List <Complexity.Connection>();
            dMain.AVMID = dmInput.DesignID;
            dMain.Name  = dmInput.Name;

            var componentInstances = RecursivelyGetAllComponentInstances(dmInput);
            var componentMapping   = new Dictionary <avm.ComponentInstance, Complexity.ComponentInstance>();

            foreach (var ci in componentInstances)
            {
                var cci_new = new Complexity.ComponentInstance
                {
                    AVMID            = ci.ComponentID,
                    Name             = ci.Name,
                    Complexity       = 1,
                    DistributionType = DistributionTypeEnum.None
                };

                ((List <Complexity.ComponentInstance>)dMain.ComponentInstances).Add(cci_new);

                if (!componentMapping.ContainsKey(ci))
                {
                    componentMapping[ci] = cci_new;
                }
            }

            foreach (var ci in componentInstances)
            {
                if (!componentMapping.ContainsKey(ci))
                {
                    continue;
                }

                foreach (var pi in ci.PortInstance)
                {
                    foreach (var portMap in pi.PortMap)
                    {
                        var parentComponent = componentInstances.Where(x => x.PortInstance.Any(y => y.ID == portMap)).FirstOrDefault();

                        if (parentComponent == null)
                        {
                            continue;
                        }
                        if (!componentMapping.ContainsKey(parentComponent))
                        {
                            continue;
                        }

                        Complexity.Connection cc_new = new Complexity.Connection();
                        ((List <Complexity.Connection>)dMain.Connections).Add(cc_new);
                        cc_new.src              = componentMapping[ci];
                        cc_new.dst              = componentMapping[parentComponent];
                        cc_new.Complexity       = 0.1;
                        cc_new.DistributionType = Complexity.DistributionTypeEnum.None;
                    }
                }
            }

            return(dMain);
        }
예제 #6
0
        private static List <avm.ComponentInstance> RecursivelyGetAllComponentInstances(avm.Design dm_root)
        {
            List <avm.ComponentInstance> lci_rtn = new List <avm.ComponentInstance>();

            foreach (Compound c in dm_root.RootContainer.Container1.Where(c => c is Compound))
            {
                lci_rtn.InsertRange(0, RecursivelyGetAllComponentInstances(c));
            }
            return(lci_rtn);
        }