Ejemplo n.º 1
0
 public void loadSrc(DustInfoTray src)
 {
     this.entity       = src.entity;
     this.key          = src.key;
     this.value        = src.value;
     this.dustHint     = src.dustHint;
     this.readerObject = src.readerObject;
 }
Ejemplo n.º 2
0
 public DustInfoTray(DustEntity owner, Object value, params Object[] keys)
 {
     this.entity = owner;
     this.keys   = keys;
     if (0 < keys.Length)
     {
         this.key = keys[0];
     }
     this.value = value;
 }
Ejemplo n.º 3
0
        public static int indexOf(DustEntity entity, params DustKey[] keys)
        {
            int idx = 0;

            foreach (DustKey key in keys)
            {
                if (entity == Dust.resolveKey(key))
                {
                    return(idx);
                }
                ++idx;
            }

            return(-1);
        }
Ejemplo n.º 4
0
        public static VType getValue <VType>(DustEntity entity, VType defVal, params DustKey[] keys)
        {
            var        tray = new DustInfoTray(entity, null);
            DustEntity e    = null;

            foreach (DustKey key in keys)
            {
                tray.key = key;
                if (null != e)
                {
                    tray.entity = e;
                }
                Dust.access(DustAccessCommand.read, tray);

                e = tray.value as DustEntity;
            }

            return((VType)(tray.value ?? defVal));
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            DustSystem.initKernel(args);

            var module   = "GeoTest02";
            var entityId = "23";

            Console.WriteLine("Connecting to server...");

            Task <DustEntity> t = DustCommConnectorHttp.loadRemote("localhost", module, entityId);

            t.Wait();
            DustEntity e = t.Result;

            DustEntity e1 = DustSystem.getSystem().getEntity(module, "16");

            var draw = new DrawVisitor();
            var vt   = new DustVisitTray(e, draw);

//			vt.cmd = VisitCommand.visitAtts | VisitCommand.recEntityOnce;
            vt.cmd = VisitCommand.visitAllData | VisitCommand.recPathOnce;
//			vt.cmd = VisitCommand.visitRefs | VisitCommand.recEntityOnce;
//			Console.WriteLine("heh? {0}", vt.cmd);
            Dust.Dust.access(DustAccessCommand.visit, vt);

            ShapeSource s = draw.getLastObject <ShapeSource>();

            var a  = Assembly.LoadFrom("bin\\csharp\\DustGui.dll");
            var tt = a.GetType("Dust.Gui.MyClass");
            var mc = Activator.CreateInstance(tt);

            var m = tt.GetMethod("testFunction");

            m.Invoke(mc, null);

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Ejemplo n.º 6
0
        public DustKey keyOf(DustEntity e, int defIdx)
        {
            int idx = indexOf(e);

            return(keyOf((-1 < idx) ? idx : defIdx));
        }
Ejemplo n.º 7
0
 public int indexOf(DustEntity e)
 {
     return(Array.IndexOf(entities, e));
 }
Ejemplo n.º 8
0
 public DustInfoTray(DustEntity owner)
     : this(owner, null)
 {
 }
Ejemplo n.º 9
0
 public DustVisitTray(DustEntity eRoot, DustVisitor visitor)
     : base(eRoot)
 {
     this.visitor = visitor;
     value        = visitor;
 }
Ejemplo n.º 10
0
        public void processVisitEvent(VisitEvent visitEvent, DustVisitTray tray)
        {
            int    kfi = kf.indexOf((DustEntity)tray.key);
            object kfk = kf.keyOf(kfi);

//			Console.WriteLine("DrawVisitor processVisitEvent {0} - {1}", visitEvent, tray.value);
//			return;

            switch (visitEvent)
            {
            case VisitEvent.entityStartOpt:
                DustEntity pt = DustUtils.getValue(tray.entity, (DustEntity)null, DataLinks.EntityPrimaryType);
                if (OB_TYPES.ContainsKey(pt))
                {
                    tray.readerObject = Activator.CreateInstance(OB_TYPES[pt]);
                    var geo = tray.readerObject as GeometricData;
                    if (null != geo)
                    {
                        readingGeoData = geo;
                    }
                }
                break;

            case VisitEvent.keyStartOpt:
                if (-1 == kfi)
                {
                    tray.resp = VisitResponse.skip;
                }
                else
                {
                    if (COORDS.Contains(kfk))
                    {
                        readingCoord = (GeometryValues)kfk;
                    }
                    else if (ROLES.Contains(kfk))
                    {
                        readingRole = (GeometryValues)kfk;
                    }

                    Console.WriteLine("Entering {0} ", kf.keyOf(kfi));
                }
                break;

            case VisitEvent.keyEnd:
                if (CollectionLinks.SequenceMembers == kfk)
                {
                    var sp = tray.readerParent as ShapePath;
                    if (null != sp)
                    {
                        sp.Add((GeometricData)tray.readerObject);
                    }

                    var sc = tray.readerParent as ShapeComposite;
                    if (null != sc)
                    {
                        sc.Add((GeometricInclusion)tray.readerObject);
                    }
                }
                else if (GeometryLinks.GeometricInclusionTarget == kfk)
                {
                    var gi = tray.readerParent as GeometricInclusion;
                    if (null != gi)
                    {
                        gi.target = (ShapeSource)tray.readerObject;
                    }
                }
                else if (GeometryLinks.GeometricInclusionParameters == kfk)
                {
                    var gi = tray.readerParent as GeometricInclusion;

                    if ((null != gi) && (readingRole != null))
                    {
                        gi[readingRole] = (GeometricData)tray.readerObject;
                    }
                }

                Console.WriteLine("Leaving {0} ", kf.keyOf(kfi));
                break;

            case VisitEvent.entityEnd:
                if (null != tray.readerObject)
                {
                    lastReadObject = tray.readerObject;
                }
                break;
            }
        }