コード例 #1
0
        /// <summary>
        /// Get the collection of ElementIDs from Trace
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static List <ElementUUID> GetElementUUIDsFromTrace(Document document)
        {
            //Get the element ID that was cached in the callsite
            ISerializable traceData = TraceUtils.GetTraceData(REVIT_TRACE_ID);

            var multi = traceData as MultipleSerializableId;

            if (multi != null)
            {
                List <ElementUUID> uuids = new List <ElementUUID>();
                foreach (var uuid in multi.StringIDs)
                {
                    uuids.Add(new ElementUUID(uuid));
                }

                return(uuids);
            }

            var single = traceData as SerializableId;

            if (single != null)
            {
                var traceDataUuid        = single.StringID;
                List <ElementUUID> uuids = new List <ElementUUID>()
                {
                    new ElementUUID(traceDataUuid)
                };
                return(uuids);
            }

            //No usable data was found
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Note that x is a dummy var here that is intended to force replicated dispatch
        /// it's not actually used
        /// </summary>
        /// <param name="x">Dummy var used to force replicated dispatch</param>
        /// <param name="failWithException">Fail dispatch with an exception rather than </param>
        public IncrementerTracedClass(int x, bool failWithException)
        {
            if (failWithException)
            {
                throw new ArgumentException("Failure requested");
            }

            var retVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID);

            if (retVal != null)
            {
                wasTraced = true;

                IDHolder idHolder = (IDHolder)retVal;
                ID = idHolder.ID;
            }
            else
            {
                nextID++;
                ID = nextID;
                TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new IDHolder()
                {
                    ID = nextID
                });
            }
        }
コード例 #3
0
        public static void OverwriteTest()
        {
            var key = TraceUtils.TEMP_GetTraceKeys()[0];

            SerializableString testStr1 = new
                                          SerializableString("{0955D962-2936-4FB2-AAB3-635C6FF6E0AD}");

            SerializableString testStr2 = new
                                          SerializableString("{2D7FE0ED-56F3-47A4-9BAA-8DF570170D97}");

            TraceUtils.SetTraceData(key, testStr1);

            //Set complete, readback test

            ISerializable readback = TraceUtils.GetTraceData(key);

            Assert.IsTrue(readback == testStr1);



            TraceUtils.SetTraceData(key, testStr2);

            //Set complete, readback test

            readback = TraceUtils.GetTraceData(key);
            Assert.IsTrue(readback == testStr2);
        }
コード例 #4
0
        public void TestGetSetDataOnDifferentThreads()
        {
            string id         = "TestID-{82AC4E65-CC86-4BF0-95EA-AE4B2B5E4A35}";
            string testString = "This is a test";

            SerializableSring ssString = new SerializableSring(testString);

            TraceUtils.SetTraceData(id, ssString);

            ssString = null;

            bool test = false;

            Thread th = new Thread(
                () =>
            {
                SerializableSring ret = (SerializableSring)TraceUtils.GetTraceData(id);

                test = ret == null;
            }
                );

            th.Start();
            th.Join();

            Assert.IsTrue(test);
        }
コード例 #5
0
        public MinimalTracedClass()
        {
            var retVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID);

            if (retVal != null)
            {
                wasTraced = true;
            }

            TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new DummyDataHolder());
        }
コード例 #6
0
 public bool GetTraceData(string key, out ISerializableId <byte[]> id)
 {
     id = TraceUtils.GetTraceData(key) as ISerializableId <byte[]>;
     if (id != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #7
0
        /// <summary>
        /// Get an Element unique Identifier from trace
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static ElementUUID GetElementUUIDFromTrace(Document document)
        {
            //Get the element ID that was cached in the callsite
            ISerializable traceData = TraceUtils.GetTraceData(REVIT_TRACE_ID);

            SerializableId id = traceData as SerializableId;

            if (id == null)
            {
                return(null); //There was no usable data in the trace cache
            }
            var traceDataUuid = id.StringID;

            return(new ElementUUID(traceDataUuid));
        }
コード例 #8
0
        public static ElementId GetElementIdFromTrace(Document document)
        {
            //Get the element ID that was cached in the callsite
            ISerializable traceData = TraceUtils.GetTraceData(REVIT_TRACE_ID);

            SerializableId id = traceData as SerializableId;

            if (id == null)
            {
                return(null); //There was no usable data in the trace cache
            }
            var traceDataInt = id.IntID;

            return(new Autodesk.Revit.DB.ElementId(traceDataInt));
        }
コード例 #9
0
        public void TestGetSetData()
        {
            string id         = "TestID-{82AC4E65-CC86-4BF0-95EA-AE4B2B5E4A35}";
            string testString = "This is a test";

            SerializableSring ssString = new SerializableSring(testString);

            TraceUtils.SetTraceData(id, ssString);

            ssString = null;

            SerializableSring ret = (SerializableSring)TraceUtils.GetTraceData(id);

            Assert.IsTrue(ret.Payload.Equals(testString));
        }
コード例 #10
0
        public WrapperObject(int x)
        {
            WrapperGuid = Guid.NewGuid();

            var traceVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID);

            if (traceVal != null)
            {
                IDHolder idHolder = (IDHolder)traceVal;
                ID = idHolder.ID;
            }
            else
            {
                nextID++;
                ID = nextID;
                TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new IDHolder()
                {
                    ID = nextID
                });
            }
        }
コード例 #11
0
        /// <summary>
        /// Note that x is a dummy var here that is intended to force replicated dispatch
        /// it's not actually used
        /// </summary>
        /// <param name="x"></param>
        public IncrementerTracedClass(int x)
        {
            var retVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID);

            if (retVal != null)
            {
                wasTraced = true;

                IDHolder idHolder = (IDHolder)retVal;
                ID = idHolder.ID;
            }
            else
            {
                nextID++;
                ID = nextID;
                TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new IDHolder()
                {
                    ID = nextID
                });
            }
        }
コード例 #12
0
        public static void OverwriteNullTest()
        {
            var key = TraceUtils.TEMP_GetTraceKeys()[0];

            SerializableString testStr1 = new
                                          SerializableString("{0955D962-2936-4FB2-AAB3-635C6FF6E0AD}");

            TraceUtils.SetTraceData(key, testStr1);

            //Set complete, readback test

            ISerializable readback = TraceUtils.GetTraceData(key);

            Assert.IsTrue(readback == testStr1);

            TraceUtils.SetTraceData(key, null);

            //Set complete, readback test

            readback = TraceUtils.GetTraceData(key);
            Assert.IsTrue(readback == null);
        }
コード例 #13
0
    public static TracedHog ByPoint(double x, double y)
    {
        TracedHog tHog;

        HogID hid = TraceUtils.GetTraceData(REVIT_TRACE_ID) as HogID;

        if (hid == null)
        {
            // Trace didn't give us a hog, it's a new one.
            tHog = new TracedHog(x, y);
        }
        else
        {
            tHog = TracedHogManager.GetHogByID(hid.IntID);
        }

        // Set the trace data on the return to be this hog.
        TraceUtils.SetTraceData(REVIT_TRACE_ID, new HogID {
            IntID = tHog.ID
        });
        return(tHog);
    }
コード例 #14
0
 /// <summary>
 /// Raw method for getting data from the trace cache, the user is responsible for handling the interpretation
 /// of the data
 /// </summary>
 public static ISerializable GetRawDataFromTrace()
 {
     return(TraceUtils.GetTraceData(REVIT_TRACE_ID));
 }
コード例 #15
0
ファイル: PointField.cs プロジェクト: abhicris/Dynamo
 public static TraceableId GetObjectIdFromTrace()
 {
     return(TraceUtils.GetTraceData(REVIT_TRACE_ID) as TraceableId);
 }