コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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
                });
            }
        }
コード例 #4
0
 /// <summary>
 /// Set a list of elements for trace
 /// </summary>
 /// <param name="elements"></param>
 public static void SetElementsForTrace(List <Element> elements)
 {
     if (IsEnabled)
     {
         MultipleSerializableId ids = new MultipleSerializableId(elements);
         TraceUtils.SetTraceData(REVIT_TRACE_ID, ids);
     }
 }
コード例 #5
0
 /// <summary>
 /// Raw method for setting data into the trace cache, the user of this method is reponsible for handling
 /// the interpretation of the data
 /// </summary>
 /// <param name="data"></param>
 public static void SetRawDataForTrace(ISerializable data)
 {
     if (!IsEnabled)
     {
         return;
     }
     TraceUtils.SetTraceData(REVIT_TRACE_ID, data);
 }
コード例 #6
0
        public MinimalTracedClass()
        {
            var retVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID);

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

            TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new DummyDataHolder());
        }
コード例 #7
0
        /// <summary>
        /// Set a list of elements for trace
        /// </summary>
        /// <param name="elements"></param>
        public static void SetElementsForTrace(IEnumerable <Element> elements)
        {
            if (!IsEnabled)
            {
                return;
            }

            MultipleSerializableId ids = new MultipleSerializableId(elements);

            TraceUtils.SetTraceData(REVIT_TRACE_ID, ids);
        }
コード例 #8
0
ファイル: PointField.cs プロジェクト: abhicris/Dynamo
 public static void RegisterTraceableObjectForId(int id, object objectToTrace)
 {
     if (traceableObjectManager.ContainsKey(id))
     {
         traceableObjectManager[id] = objectToTrace;
     }
     else
     {
         traceableObjectManager.Add(id, objectToTrace);
         TraceUtils.SetTraceData(REVIT_TRACE_ID, new TraceableId(id));
     }
 }
コード例 #9
0
        /// <summary>
        /// Set the element associated with the current operation from trace
        /// null if there is no object, or it's of the wrong type etc.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static void SetElementForTrace(ElementId elementId, ElementUUID elementUUID)
        {
            if (IsEnabled)
            {
                SerializableId id = new SerializableId();
                id.IntID    = elementId.IntegerValue;
                id.StringID = elementUUID.UUID;

                // if we're mutating the current Element id, that means we need to
                // clean up the old object

                // Set the element ID cached in the callsite
                TraceUtils.SetTraceData(REVIT_TRACE_ID, id);
            }
        }
コード例 #10
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));
        }
コード例 #11
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
                });
            }
        }
コード例 #12
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
                });
            }
        }
コード例 #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
        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);
        }
コード例 #15
0
 /// <summary>
 /// Raw method for setting data into the trace cache, the user of this method is reponsible for handling
 /// the interpretation of the data
 /// </summary>
 /// <param name="data"></param>
 public static void SetRawDataForTrace(ISerializable data)
 {
     TraceUtils.SetTraceData(REVIT_TRACE_ID, data);
 }
コード例 #16
0
 public void SetTraceData(string key, System.Runtime.Serialization.ISerializable value)
 {
     TraceUtils.SetTraceData(key, value);
 }
コード例 #17
0
 public void SetTraceData(string key, ISerializable value)
 {
     TraceUtils.SetTraceData(key, value);
 }
コード例 #18
0
 public static void RegisterTraceableObjectForId(TraceableId id, Element element)
 {
     TraceUtils.SetTraceData(REVIT_TRACE_ID, id);
 }