ThreadWithIndex() public method

public ThreadWithIndex ( int index ) : Thread
index int
return Thread
Beispiel #1
0
        public void WriteJson(SimpleJson.Writer writer)
        {
            writer.WriteObjectStart();

            writer.WriteProperty("callstack", callStack.WriteJson);
            writer.WriteProperty("outputStream", w => Json.WriteListRuntimeObjs(w, outputStream));

            // choiceThreads: optional
            // Has to come BEFORE the choices themselves are written out
            // since the originalThreadIndex of each choice needs to be set
            bool hasChoiceThreads = false;

            foreach (Choice c in currentChoices)
            {
                c.originalThreadIndex = c.threadAtGeneration.threadIndex;

                if (callStack.ThreadWithIndex(c.originalThreadIndex) == null)
                {
                    if (!hasChoiceThreads)
                    {
                        hasChoiceThreads = true;
                        writer.WritePropertyStart("choiceThreads");
                        writer.WriteObjectStart();
                    }

                    writer.WritePropertyStart(c.originalThreadIndex);
                    c.threadAtGeneration.WriteJson(writer);
                    writer.WritePropertyEnd();
                }
            }

            if (hasChoiceThreads)
            {
                writer.WriteObjectEnd();
                writer.WritePropertyEnd();
            }


            writer.WriteProperty("currentChoices", w => {
                w.WriteArrayStart();
                foreach (var c in currentChoices)
                {
                    Json.WriteChoice(w, c);
                }
                w.WriteArrayEnd();
            });


            writer.WriteObjectEnd();
        }
Beispiel #2
0
        public object WriteJson()
        {
            var dict = new Dictionary <string, object>();

            dict["callstack"]    = callStack.WriteJson();
            dict["outputStream"] = Json.WriteListRuntimeObjs(outputStream);

            // choiceThreads: optional
            // Has to come BEFORE the choices themselves are written out
            // since the originalThreadIndex of each choice needs to be set
            bool hasChoiceThreads = false;

            foreach (Choice c in currentChoices)
            {
                c.originalThreadIndex = c.threadAtGeneration.threadIndex;

                if (callStack.ThreadWithIndex(c.originalThreadIndex) == null)
                {
                    if (!hasChoiceThreads)
                    {
                        hasChoiceThreads      = true;
                        dict["choiceThreads"] = new Dictionary <int, object>();
                    }

                    (dict["choiceThreads"] as IDictionary <int, object>)[c.originalThreadIndex] = c.threadAtGeneration.WriteJson();
                }
            }

            if (hasChoiceThreads)
            {
            }

            var lst = new List <object>();

            foreach (var c in currentChoices)
            {
                lst.Add(Json.WriteChoice(c));
            }
            dict["currentChoices"] = lst;

            return(dict);
        }