protected void ImportShapes(string path)
        {
            GraphObjectsLibrary library = new GraphObjectsLibrary();
            ShapeSummary shapeSum;
            ConnectionSummary conSum;
            library.Path = path;
            mLibraries.Add(library);

            try
            {
                Assembly ass=Assembly.LoadFrom(path);
                if (ass==null) return;
                Type[] tps=ass.GetTypes();

                if (tps==null) return ;

                object[] objs;
                for(int k=0; k<tps.Length;k++) //loop over modules in assembly
                {

                    if(!tps[k].IsClass) continue;
                    try
                    {
                        objs = tps[k].GetCustomAttributes(typeof(Netron.GraphLib.Attributes.NetronGraphShapeAttribute),false);
                        if(objs.Length>=1)
                        {

                            //now, we are sure to have a shape object

                            NetronGraphShapeAttribute shapeAtts = objs[0] as NetronGraphShapeAttribute;
                            shapeSum = new ShapeSummary(path, shapeAtts.ShapeKey,shapeAtts.ShapeName, shapeAtts.ShapeCategory,shapeAtts.ReflectionName);
                            library.ShapeSummaries.Add(shapeSum);
                            if(this.mEnableContextMenu)
                                AddToContextMenu(shapeSum);

                            continue;//cannot be a connection and a shape at the same time
                        }

                        //try a custom connection

                        objs = tps[k].GetCustomAttributes(typeof(Netron.GraphLib.Attributes.NetronGraphConnectionAttribute),false);
                        if(objs.Length>=1)
                        {
                            //now, we are sure to have a connection object

                            NetronGraphConnectionAttribute conAtts = objs[0] as NetronGraphConnectionAttribute;
                            conSum = new ConnectionSummary(path, conAtts.ConnectionName, conAtts.ReflectionName);
                            library.ConnectionSummaries.Add(conSum);
                            continue;
                        }
                    }
                    catch(Exception exc)
                    {
                        Trace.WriteLine(exc.Message);
                        continue;
                    }

                }

            }
            catch(Exception exc)
            {
                Trace.WriteLine(exc.Message);
            }
        }
 public int Add(ConnectionSummary summary)
 {
     return this.InnerList.Add(summary);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds an item to the collection
 /// </summary>
 /// <param name="summary"></param>
 /// <returns></returns>
 public int Add(ConnectionSummary summary)
 {
     return(this.InnerList.Add(summary));
 }