Exemple #1
0
        /// <summary>
        /// Adds Component to Danu. Adds its name and all its interfaces if they are not present.
        /// </summary>
        public void AddComponent(Component component)
        {
            DanuComponent newComponent = new DanuComponent(component.Name);

            components.Add(newComponent.Name, newComponent);

            foreach (InterfaceObject io in component.Interfaces)
            {
                if (!interfaces.ContainsKey(io.Name))
                {
                    AddInterface(io);
                }

                newComponent.Interfaces.Add(interfaces[io.Name]);
            }

            EshuClass     mainClass = new EshuClass(component.Name);
            EshuComponent comp      = new EshuComponent(component.Name);

            foreach (DanuInterfaceObject io in newComponent.Interfaces)
            {
                if (io.Eshu == null)
                {
                    EshuInterface newIo = new EshuInterface(io.Name);
                    io.Eshu = newIo;
                }
                mainClass.AddInterface(io.Eshu);
                mainClass.Parent = comp;
                comp.Interfaces.Add(io.Eshu);
                io.Eshu.Parent = mainClass;
            }

            comp.Classes.Add(mainClass);
            newComponent.Specification = comp;
        }
Exemple #2
0
        public void ReadXmlComponents(System.Xml.XmlReader reader)
        {
            reader.Read();
            try
            {
                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        System.Xml.XmlReader implementsReader;
                        System.Xml.XmlReader availableInterfaceReader;

                        DanuComponent comp = new DanuComponent(reader["Name"]);
                        comp.EshuPath = reader["FileLocation"];

                        XmlSerializer eshuSerializer = new XmlSerializer(typeof(EshuComponent));

                        //removed comp.EshuPath -> impossible to store location :( dããã...

                        TextReader eshuReader = new StreamReader(Environment.CurrentDirectory + "/Cache/" + reader["Name"] + ".eshu");
                        comp.Specification = (EshuComponent)eshuSerializer.Deserialize(eshuReader);

                        this.components.Add(comp.Name, comp);

                        reader.Read();
                        implementsReader = reader.ReadSubtree();
                        ReadXmlComponentImplements(implementsReader, comp);
                        implementsReader.Close();

                        reader.Read();
                        availableInterfaceReader = reader.ReadSubtree();
                        ReadXmlComponentAvailableInterfaces(availableInterfaceReader, comp);
                        availableInterfaceReader.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                reader.Close();

                throw ex;
            }
            reader.Close();
        }
Exemple #3
0
        public void ReadXmlComponentAvailableInterfaces(System.Xml.XmlReader reader, DanuComponent comp)
        {
            reader.Read();

            while (reader.Read())
            {
                if (!reader.Name.Equals("Interface") && !reader.Name.Equals("Available_Interfaces"))
                {
                    DanuInterfaceObject io = GetInterface(reader.ReadContentAsString());
                    foreach (EshuInterface ioEshu in comp.Specification.Interfaces)
                    {
                        if (ioEshu.Name.Equals(io.Name))
                        {
                            io.Eshu = ioEshu;
                        }
                    }
                    comp.Interfaces.Add(io);
                }
            }

            reader.Close();
        }
Exemple #4
0
        public void ReadXmlComponentImplements(System.Xml.XmlReader reader, DanuComponent comp)
        {
            reader.Read();

            while (reader.Read())
            {
                if (reader.Name.Equals("Interface"))
                {
                    DanuInterfaceObject io = GetInterface(reader.ReadElementString());
                    DanuSocket          so = new DanuSocket(comp, io);
                    AddSocket(so);
                    foreach (DanuComponent checkComp in Components)
                    {
                        if (checkComp.Interfaces.Contains(io))
                        {
                            io.Eshu.Parent = checkComp.Specification.Classes.FirstOrDefault();
                            io.Eshu.ImplementingParents.Add(checkComp.Specification.Classes.FirstOrDefault());
                        }
                    }
                }
            }

            reader.Close();
        }
Exemple #5
0
 public void RemoveRelationship(DanuComponent parent)
 {
     relatedSockets.Remove(parent);
 }
Exemple #6
0
 public void AddRelationship(DanuComponent parent, DanuSocket socket)
 {
     relatedSockets.Add(parent, socket);
 }
Exemple #7
0
 public DanuConstraint GetConstraint(DanuComponent source, DanuComponent target)
 {
     return(constraints[source.Name + target.Name]);
 }
 public DanuSocket(DanuComponent parent, DanuInterfaceObject interfaceUsed)
 {
     this.parent        = parent;
     this.interfaceUsed = interfaceUsed;
 }
Exemple #9
0
 public DanuConstraint(DanuComponent point1, DanuComponent point2, DanuConstraintTypes constraintType)
 {
     this.point1         = point1;
     this.point2         = point2;
     this.constraintType = constraintType;
 }