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); }
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); }
/// <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 }); } }
/// <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); } }
/// <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); }
public MinimalTracedClass() { var retVal = TraceUtils.GetTraceData(__TEMP_REVIT_TRACE_ID); if (retVal != null) { wasTraced = true; } TraceUtils.SetTraceData(__TEMP_REVIT_TRACE_ID, new DummyDataHolder()); }
/// <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); }
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)); } }
/// <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); } }
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)); }
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 }); } }
/// <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 }); } }
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); }
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); }
/// <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); }
public void SetTraceData(string key, System.Runtime.Serialization.ISerializable value) { TraceUtils.SetTraceData(key, value); }
public void SetTraceData(string key, ISerializable value) { TraceUtils.SetTraceData(key, value); }
public static void RegisterTraceableObjectForId(TraceableId id, Element element) { TraceUtils.SetTraceData(REVIT_TRACE_ID, id); }