コード例 #1
0
 private static object CreateInstance(Type type, SimObject objectWrapper)
 {
     if (!ObjectDictionary.ContainsKey(objectWrapper.GetID()))
     {
         SimObject obj = (SimObject)FormatterServices.GetUninitializedObject(type);
         obj.SetPointerFromObject(objectWrapper);
         ObjectDictionary[objectWrapper.GetID()] = obj;
     }
     return(ObjectDictionary[objectWrapper.GetID()]);
 }
コード例 #2
0
        public virtual void scanGroup(SimGroup group, GuiPopUpMenuCtrl list, int indentLevel)
        {
            // Create a display name for the group.
            string text = group.getName();

            if (text == "")
            {
                text = group.getClassName();
            }

            string internalName = group.getInternalName();

            if (internalName != "")
            {
                text = text + "[" + internalName + "]";
            }

            // Indent the name according to the depth in the hierarchy.

            if (indentLevel > 0)
            {
                text = Util.strrepeat(" ", indentLevel, "") + text;
            }

            // Add it to the list.

            list.add(text, group.getId());

            // Recurse into SimSets with at least one child.

            for (uint i = 0; i < group.getCount(); i++)
            {
                SimObject obj = group.getObject(i);
                if (!obj.isMemberOfClass("SimSet") || obj.call("getCount").AsInt() == 0)
                {
                    continue;
                }

                scanGroup(obj.GetID(), list, indentLevel + 1);
            }
        }