示例#1
0
        /// <summary>
        /// Create a TraceExampleItem and store it in a static dictionary.
        /// </summary>
        public static TraceExampleItem ByString(string description)
        {
            // See if there is data for this object is in trace.
            var traceId = TraceableObjectManager.GetObjectIdFromTrace();

            TraceExampleItem item = null;

            int id;

            if (traceId == null)
            {
                // If there's no id stored in trace for this object,
                // then grab the next unused trace id.
                id = TraceableObjectManager.GetNextUnusedID();

                // Create an item
                item = new TraceExampleItem(description);

                // Remember to store the updated object in the trace object manager,
                // so it's available to use the next time around.
                TraceableObjectManager.RegisterTraceableObjectForId(id, item);
            }
            else
            {
                // If there's and id stored in trace, then retrieve the object stored
                // with that id from the trace object manager.
                item = (TraceExampleItem)TraceableObjectManager.GetTracedObjectById(traceId.IntID)
                       ?? new TraceExampleItem(description);

                // Update the item
                item.Description = description;
            }

            return(item);
        }
示例#2
0
        public static PeriodicUpdateExample PointField()
        {
            // See if the data for this object is in trace.
            var traceId = TraceableObjectManager.GetObjectIdFromTrace();

            var t = 0.0;
            int id;

            if (traceId == null)
            {
                // If there's no id stored in trace for this object,
                // then grab the next unused trace id.
                id = TraceableObjectManager.GetNextUnusedID();
            }
            else
            {
                // If there's and id stored in trace, then retrieve the object stored
                // with that id from the trace object manager.
                id = traceId.IntID;
                t  = (double)TraceableObjectManager.GetTracedObjectById(traceId.IntID);
            }

            return(new PeriodicUpdateExample(t, id));
        }