コード例 #1
0
        public static void WriteNavigation(ObjectDataPath[] path, object root, object newContext)
        {
            // TODO: Fix this method. It breaks things.
            for (int i = path.Length - 1; i > 0; --i)
            {
                object parent = ReadNavigation(path, i - 1, root, false);
                if (parent == null)
                {
                    break;
                }

                ObjectDataPath pathElement = path[i - 1];
                // byType uses the parent element to adjust the type, so we have
                // to go back two elements instead of just one.
                if (path[i].byType != null)
                {
                    if (i - 2 < 0)
                    {
                        break;
                    }
                    pathElement = path[i - 2];
                }
                pathElement.Write(parent, newContext);

                if (i > 0)
                {
                    newContext = ReadNavigation(path, i - 1, root, false);
                }
            }
        }
コード例 #2
0
ファイル: SavedObject.cs プロジェクト: smbss1/fullinspector
        private static                               ObjectDataPath[] CreateNavigation(List <ObjectDataPath> history, ObjectDataPath finalNav)
        {
            var result = new ObjectDataPath[history.Count + 1];

            for (int i = 0; i < history.Count; ++i)
            {
                result[i] = history[i];
            }
            result[result.Length - 1] = finalNav;
            return(result);
        }
コード例 #3
0
        // Return the set of operations needed to make |previousState| look like
        // |currentState|.
        public static void CreateDelta(
            Dictionary <ObjectDataPath[], object> currentState,
            Dictionary <ObjectDataPath[], object> previousState,
            out Dictionary <ObjectDataPath[], object> toAdd,
            out Dictionary <ObjectDataPath[], object> toModify,
            out List <ObjectDataPath[]> toRemove,
            bool dumpString)
        {
            toAdd    = AllocateDict();
            toModify = AllocateDict();
            toRemove = new List <ObjectDataPath[]>();

            foreach (var entry in previousState)
            {
                // End has it, but start doesn't. We need to remove the key.
                if (currentState.ContainsKey(entry.Key) == false)
                {
                    toRemove.Add(entry.Key);
                    continue;
                }

                object startObj = currentState[entry.Key];
                object endObj   = entry.Value;

                // If the objects are the same, do not modify.
                if (ReferenceEquals(startObj, endObj) || startObj.Equals(endObj))
                {
                    continue;
                }

                toModify.Add(entry.Key, startObj);
            }

            // Start has it, but end doesn't.
            foreach (var entry in currentState)
            {
                if (previousState.ContainsKey(entry.Key) == false)
                {
                    toAdd.Add(entry.Key, entry.Value);
                }
            }

            if (dumpString)
            {
                var msg = "Computed delta (click to see):" + Environment.NewLine + Environment.NewLine;
                msg += DumpToString("current", ReadableModel(currentState)) + Environment.NewLine;
                msg += DumpToString("previous", ReadableModel(previousState));
                msg += Environment.NewLine + "----" + Environment.NewLine + Environment.NewLine;
                msg += DumpToString("toAdd", ReadableModel(toAdd)) + Environment.NewLine;
                msg += DumpToString("toModify", ReadableModel(toModify)) + Environment.NewLine;
                msg += DumpToString("toRemove", toRemove.Select(r => ObjectDataPath.ToString(r)).ToList());
                Debug.Log(msg);
            }
        }
コード例 #4
0
        public static Dictionary <string, object> ReadableModel(Dictionary <ObjectDataPath[], object> model)
        {
            var readable = new Dictionary <string, object>();

            foreach (var entry in model)
            {
                string navString = ObjectDataPath.ToString(entry.Key);
                //Debug.Log("Adding " + navString);
                readable.Add(navString, entry.Value);
            }
            return(readable);
        }
コード例 #5
0
ファイル: SavedObject.cs プロジェクト: smbss1/fullinspector
        // TODO: Fix
        //       transform.position.normalized.normalized.normalized.normalized.normalized...
        public static Dictionary <ObjectDataPath[], object> CreateWithPath(List <ObjectDataPath> toUs, ObjectDataPath nav, object obj, HashSet <object> seenObjects)
        {
            toUs.Add(nav);
            var result = Create(toUs, obj, seenObjects);

            toUs.RemoveAt(toUs.Count - 1);
            return(result);
        }
コード例 #6
0
 private static string DumpToString(KeyValuePair <ObjectDataPath[], object> property)
 {
     return(ObjectDataPath.ToString(property.Key) + " => " + property.Value);// + " (" + property.Value.GetType() + ")";
 }