示例#1
0
        public TypeNode getTypeNode(UnityClass unityClass, UnityVersion unityVersion, bool exact)
        {
            TypeTreeDatabaseEntry entry = getEntry(unityClass, unityVersion, exact);

            if (entry != null)
            {
                return(entry.typeNode);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public void addEntry(TypeTreeDatabaseEntry entry)
        {
            // don't add duplicates
            if (entryMap.ContainsValue(entry))
            {
                return;
            }

            entries.Add(entry);
            string pair = entry.unityClass.name() + "_" + entry.unityVersion.build;

            entryMap[pair] = entry;
        }
示例#3
0
        public TypeTreeDatabaseEntry getEntry(UnityClass unityClass, UnityVersion unityVersion, bool exact)
        {
            // search for exact matches
            string pair = unityClass.name() + "_" + unityVersion.build;
            TypeTreeDatabaseEntry entryA = null;

            if (entryMap.ContainsKey(pair))
            {
                entryA = entryMap[pair];
            }
            if (entryA != null)
            {
                return(entryA);
            }

            // cancel if exact matches are required
            if (exact)
            {
                return(null);
            }

            TypeTreeDatabaseEntry entryB   = null;
            UnityVersion          versionB = null;

            TypeTreeDatabaseEntry entryC   = null;
            UnityVersion          versionC = null;

            foreach (TypeTreeDatabaseEntry entry in entries)
            {
                UnityClass   uclass  = entry.unityClass;
                UnityVersion version = entry.unityVersion;

                if (uclass.equals(unityClass))
                {
                    if (version.major == unityVersion.major)
                    {
                        if (version.minor == unityVersion.minor)
                        {
                            // if major and minor versions match, it will probably work
                            return(entry);
                        }
                        else
                        {
                            // suboptimal choice
                            entryB   = entry;
                            versionB = version;
                        }
                    }

                    // worst choice
                    entryC   = entry;
                    versionC = version;
                }
            }

            // return less perfect match
            if (entryB != null)
            {
                //Logger.Log( "Unprecise match for class {0} (required: {1}, available: {2})"+ new Object[]{unityClass, unityVersion, versionB});
                return(entryB);
            }

            // return field node from any revision as the very last resort
            if (entryC != null)
            {
                //Logger.Log("Bad match for class {0} (required: {1}, available: {2})"+ new Object[]{unityClass, unityVersion, versionC});
                return(entryC);
            }

            // no matches at all
            return(null);
        }