Exemplo n.º 1
0
        public void TestRoundTripElementSerialisation()
        {
            // Use a BinaryFormatter or SoapFormatter.
            IFormatter formatter = new BinaryFormatter();
            //IFormatter formatter = new SoapFormatter();

            // Create an instance of the type and serialize it.
            var elementId = new SerializableId
            {
                IntID = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            //Serialise to a test memory stream
            var m = new MemoryStream();
            formatter.Serialize(m, elementId);
            m.Flush();

            //Reset the stream
            m.Seek(0, SeekOrigin.Begin);

            //Readback
            var readback = (SerializableId)formatter.Deserialize(m);

            Assert.IsTrue(readback.IntID == 42);
            Assert.IsTrue(readback.StringID.Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
        }
Exemplo n.º 2
0
        public void TestRoundTripElementSerialisation()
        {
            IFormatter formatter = new SoapFormatter();

            // Create an instance of the type and serialize it.
            var elementId = new SerializableId
            {
                IntID    = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            //Serialise to a test memory stream
            var m = new MemoryStream();

            formatter.Serialize(m, elementId);
            m.Flush();

            //Reset the stream
            m.Seek(0, SeekOrigin.Begin);

            //Readback
            var readback = (SerializableId)formatter.Deserialize(m);

            Assert.IsTrue(readback.IntID == 42);
            Assert.IsTrue(readback.StringID.Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
        }
Exemplo n.º 3
0
        public void RawTraceInteractionTest()
        {
            var elementId = new SerializableId
            {
                IntID    = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementId);
            elementId = null;

            //Readback
            elementId = (SerializableId)ElementBinder.GetRawDataFromTrace();
            Assert.IsTrue(elementId.IntID == 42);
            Assert.IsTrue(elementId.StringID == "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}");
        }
Exemplo n.º 4
0
        public void TwoInstancesOfSerializableIdAreEqual()
        {
            var elementID = new SerializableId
            {
                IntID    = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            var elementID2 = new SerializableId
            {
                IntID    = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementID);
            elementID = null;

            //Readback
            var readback = (SerializableId)ElementBinder.GetRawDataFromTrace();

            //verify that the id extracted from trace is equal to the new instance
            Assert.IsTrue(readback.Equals(elementID2));
        }
Exemplo n.º 5
0
        private void RevitServicesUpdater_ElementsDeleted(Document document, IEnumerable <ElementId> deleted)
        {
            if (!deleted.Any())
            {
                return;
            }

            var workspace = this.CurrentWorkspace;

            ProtoCore.Core core   = null;
            var            engine = this.EngineController;

            if (engine != null && (engine.LiveRunnerCore != null))
            {
                core = engine.LiveRunnerCore;
            }

            if (core == null) // No execution yet as of this point.
            {
                return;
            }

            // Selecting all nodes that are either a DSFunction,
            // a DSVarArgFunction or a CodeBlockNodeModel into a list.
            var nodeGuids = workspace.Nodes.Where((n) =>
            {
                return(n is DSFunction ||
                       (n is DSVarArgFunction) ||
                       (n is CodeBlockNodeModel));
            }).Select((n) => n.GUID);

            var nodeTraceDataList = core.GetCallsitesForNodes(nodeGuids);// core.GetTraceDataForNodes(nodeGuids);

            foreach (Guid guid in nodeTraceDataList.Keys)
            {
                foreach (CallSite cs in nodeTraceDataList[guid])
                {
                    foreach (CallSite.SingleRunTraceData srtd in cs.TraceData)
                    {
                        List <ISerializable> traceData = srtd.RecursiveGetNestedData();

                        foreach (ISerializable thingy in traceData)
                        {
                            SerializableId sid = thingy as SerializableId;

                            foreach (ElementId eid in deleted)
                            {
                                if (sid != null)
                                {
                                    if (sid.IntID == eid.IntegerValue)
                                    {
                                        NodeModel inm =
                                            workspace.Nodes.Where((n) => n.GUID == guid).FirstOrDefault();

                                        Validity.Assert(inm != null, "The bound node has disappeared");

                                        inm.RequiresRecalc       = true;
                                        inm.ForceReExecuteOfNode = true;

                                        //FOUND IT!
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void RawTraceInteractionTest()
        {
            var elementId = new SerializableId
            {
                IntID = 42,
                StringID = "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"
            };

            //Raw write
            ElementBinder.SetRawDataForTrace(elementId);
            elementId = null;

            //Readback
            elementId = (SerializableId)ElementBinder.GetRawDataFromTrace();
            Assert.IsTrue(elementId.IntID == 42);
            Assert.IsTrue(elementId.StringID == "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}");
        }