Ejemplo n.º 1
0
        protected Tuple <SpatialFieldManager, List <int> > GetElementAndPrimitiveIdListFromTrace()
        {
            // This is a provisional implementation until we can store both items in trace
            var id = ElementBinder.GetRawDataFromTrace();

            if (id == null)
            {
                return(null);
            }

            var idPair = id as SpmPrimitiveIdListPair;

            if (idPair == null)
            {
                return(null);
            }

            var primitiveIds = idPair.PrimitiveIDs;
            var sfmId        = idPair.SpatialFieldManagerID;

            SpatialFieldManager sfm = null;

            // if we can't get the sfm, return null
            if (!Document.TryGetElement(new ElementId(sfmId), out sfm))
            {
                return(null);
            }

            return(new Tuple <SpatialFieldManager, List <int> >(sfm, primitiveIds));
        }
Ejemplo n.º 2
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}");
        }
Ejemplo n.º 3
0
        public void RawTraceInteractionTestWithMultipleIDs()
        {
            var elementIDs = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

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

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

            //Verify that the data is correct
            Assert.IsTrue(readback.IntIDs.Count == 2);
            Assert.IsTrue(readback.IntIDs[0] == 42);
            Assert.IsTrue(readback.IntIDs[1] == 20);
            Assert.IsTrue(readback.StringIDs.Count == 2);
            Assert.IsTrue(readback.StringIDs[0].Equals("{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}"));
            Assert.IsTrue(readback.StringIDs[1].Equals("{A79294BF-6D27-4B86-BEE9-D6921C11D495}"));
        }
Ejemplo 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));
        }
Ejemplo n.º 5
0
        public void TwoInstancesOfMultSerializableIdAreEqual()
        {
            var elementIDs = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

            var elementIDs2 = new MultipleSerializableId
            {
                IntIDs    = { 42, 20 },
                StringIDs = { "{BE507CAC-7F23-43D6-A2B4-13F6AF09046F}", "{A79294BF-6D27-4B86-BEE9-D6921C11D495}" }
            };

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

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

            //verify that the id extracted from trace is equal to the new instance
            Assert.IsTrue(readback.Equals(elementIDs2));
        }