Exemplo n.º 1
0
        private void ImportKNM(string path, IDictionary <ulong, string> map)
        {
            int        i    = -1;
            KNMPackage knmp = null;

            if (this.mKNMPackages != null)
            {
                for (i = this.mKNMPackages.Length - 1; i >= 0; i--)
                {
                    knmp = this.mKNMPackages[i];
                    if (path.Equals(knmp.Path))
                    {
                        break;
                    }
                }
            }
            if (this.mGenCLIPs == null)
            {
                this.mGenCLIPs = new Dictionary <ulong, GenCLIP>();
            }
            if (i < 0)
            {
                knmp = new KNMPackage(path);
                this.FillKNMP(knmp, map);
                if (knmp.Names.Count > 0)
                {
                    if (this.mKNMPackages == null)
                    {
                        this.mKNMPackages = new KNMPackage[] { knmp };
                    }
                    else
                    {
                        i = this.mKNMPackages.Length;
                        KNMPackage[] pkgs = new KNMPackage[i + 1];
                        Array.Copy(this.mKNMPackages, 0, pkgs, 0, i);
                        pkgs[i]           = knmp;
                        this.mKNMPackages = pkgs;
                    }
                }
            }
            else
            {
                this.FillKNMP(knmp, map);
            }
        }
Exemplo n.º 2
0
 private void ImportKNM(string path, IDictionary<ulong, string> map)
 {
     int i = -1;
     KNMPackage knmp = null;
     if (this.mKNMPackages != null)
     {
         for (i = this.mKNMPackages.Length - 1; i >= 0; i--)
         {
             knmp = this.mKNMPackages[i];
             if (path.Equals(knmp.Path))
             {
                 break;
             }
         }
     }
     if (this.mGenCLIPs == null)
     {
         this.mGenCLIPs = new Dictionary<ulong, GenCLIP>();
     }
     if (i < 0)
     {
         knmp = new KNMPackage(path);
         this.FillKNMP(knmp, map);
         if (knmp.Names.Count > 0)
         {
             if (this.mKNMPackages == null)
             {
                 this.mKNMPackages = new KNMPackage[] { knmp };
             }
             else
             {
                 i = this.mKNMPackages.Length;
                 KNMPackage[] pkgs = new KNMPackage[i + 1];
                 Array.Copy(this.mKNMPackages, 0, pkgs, 0, i);
                 pkgs[i] = knmp;
                 this.mKNMPackages = pkgs;
             }
         }
     }
     else
     {
         this.FillKNMP(knmp, map);
     }
 }
Exemplo n.º 3
0
 private KeyNameMap(List<PathPackageTuple> ppts, string knmName)
 {
     if (ppts == null)
     {
         this.mKNMPackages = null;
         this.mGenCLIPs = null;
         return;
     }
     KNMPackage knmp;
     IResource resource;
     IDictionary<ulong, string> map;
     List<IResourceIndexEntry> rieList;
     List<KNMPackage> knmps = new List<KNMPackage>();
     foreach (PathPackageTuple ppt in ppts)
     {
         if (ppt != null && ppt.Package != null)
         {
             if (StatusMessage != null)
             {
                 StatusMessage("Searching " + knmName +
                     " Package:\n" + ppt.Path);
             }
             rieList = ppt.Package.FindAll(IsNameMapPred);
             if (rieList != null && rieList.Count > 0)
             {
                 if (this.mGenCLIPs == null)
                 {
                     this.mGenCLIPs
                         = new Dictionary<ulong, GenCLIP>();
                 }
                 knmp = new KNMPackage(ppt.Path);
                 foreach (IResourceIndexEntry rie in rieList)
                 {
                     resource = null;
                     try
                     {
                         resource = WrapperDealer.GetResource(
                             0, ppt.Package, rie);
                     }
                     catch { }
                     if (resource != null)
                     {
                         map = resource as IDictionary<ulong, string>;
                         if (map != null && map.Count > 0)
                         {
                             this.FillKNMP(knmp, map);
                         }
                     }
                 }
                 if (knmp.Names.Count > 0)
                 {
                     knmps.Add(knmp);
                 }
             }
         }
     }
     if (knmps.Count == 0)
     {
         this.mKNMPackages = null;
     }
     else
     {
         this.mKNMPackages = knmps.ToArray();
     }
 }
Exemplo n.º 4
0
 private void FillKNMP(KNMPackage knmp, IDictionary<ulong, string> map)
 {
     GenCLIP gc;
     ulong h, ch;
     string s, cs;
     foreach (KeyValuePair<ulong, string> nm in map)
     {
         h = nm.Key;
         s = nm.Value;
         if (FNVHash.HashString64(s) == h ||
             FNVHash.HashString32(s) == h)
         {
             knmp.Names[h] = s;
         }
         else if (FNVCLIP.HashString(s) == h)
         {
             cs = FNVCLIP.GetGenericValue(s);
             ch = FNVHash.HashString64(cs) & 0x7FFFFFFFFFFFFFFF;
             knmp.Generics[ch] = cs;
             if (!this.mGenCLIPs.TryGetValue(ch, out gc))
             {
                 gc = new GenCLIP(cs);
                 this.mGenCLIPs.Add(ch, gc);
             }
             gc.CLIPNames[h] = new CLIP(s, knmp.Path);
         }
         else
         {
             knmp.Labels[h] = s;
         }
     }
     if (knmp.Names.Count > 0)
     {
         List<KeyValuePair<ulong, string>> names
             = new List<KeyValuePair<ulong, string>>(knmp.Names);
         foreach (KeyValuePair<ulong, string> name in names)
         {
             s = name.Value;
             if (name.Key < 0x100000000)
             {
                 h = FNVHash.HashString64(s);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = s;
                 }
             }
             else
             {
                 h = FNVHash.HashString32(s);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = s;
                 }
             }
             cs = FNVCLIP.GetGenericValue(s);
             if (!string.Equals(s, cs,
                 StringComparison.OrdinalIgnoreCase))
             {
                 h = FNVHash.HashString32(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
                 h = FNVHash.HashString64(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
             }
         }
     }
     if (knmp.Generics.Count > 0)
     {
         foreach (KeyValuePair<ulong, string> gen in knmp.Generics)
         {
             s = gen.Value;
             h = FNVHash.HashString32(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             h = FNVHash.HashString64(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             cs = FNVCLIP.GetGenericValue(s);
             h = FNVHash.HashString32(cs);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = cs;
             }
             h = FNVHash.HashString64(cs);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = cs;
             }
             cs = string.Concat(cs, ".ma");
             h = FNVHash.HashString32(cs);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = cs;
             }
             h = FNVHash.HashString64(cs);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = cs;
             }
             s = string.Concat(s, ".ma");
             h = FNVHash.HashString32(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             h = FNVHash.HashString64(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
         }
     }
     if (knmp.Labels.Count > 0)
     {
         foreach (KeyValuePair<ulong, string> label in knmp.Labels)
         {
             s = label.Value;
             h = FNVHash.HashString32(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             h = FNVHash.HashString64(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             cs = FNVCLIP.GetGenericValue(s);
             if (!string.Equals(s, cs,
                 StringComparison.OrdinalIgnoreCase))
             {
                 h = FNVHash.HashString32(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
                 h = FNVHash.HashString64(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
                 cs = string.Concat(cs, ".ma");
                 h = FNVHash.HashString32(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
                 h = FNVHash.HashString64(cs);
                 if (!knmp.Names.ContainsKey(h))
                 {
                     knmp.Names[h] = cs;
                 }
             }
             s = string.Concat(s, ".ma");
             h = FNVHash.HashString32(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
             h = FNVHash.HashString64(s);
             if (!knmp.Names.ContainsKey(h))
             {
                 knmp.Names[h] = s;
             }
         }
     }
 }
Exemplo n.º 5
0
        private KeyNameMap(List <PathPackageTuple> ppts, string knmName)
        {
            if (ppts == null)
            {
                this.mKNMPackages = null;
                this.mGenCLIPs    = null;
                return;
            }
            KNMPackage knmp;
            IResource  resource;
            IDictionary <ulong, string> map;
            List <IResourceIndexEntry>  rieList;
            List <KNMPackage>           knmps = new List <KNMPackage>();

            foreach (PathPackageTuple ppt in ppts)
            {
                if (ppt != null && ppt.Package != null)
                {
                    if (StatusMessage != null)
                    {
                        StatusMessage("Searching " + knmName +
                                      " Package:\n" + ppt.Path);
                    }
                    rieList = ppt.Package.FindAll(IsNameMapPred);
                    if (rieList != null && rieList.Count > 0)
                    {
                        if (this.mGenCLIPs == null)
                        {
                            this.mGenCLIPs
                                = new Dictionary <ulong, GenCLIP>();
                        }
                        knmp = new KNMPackage(ppt.Path);
                        foreach (IResourceIndexEntry rie in rieList)
                        {
                            resource = null;
                            try
                            {
                                resource = WrapperDealer.GetResource(
                                    0, ppt.Package, rie);
                            }
                            catch { }
                            if (resource != null)
                            {
                                map = resource as IDictionary <ulong, string>;
                                if (map != null && map.Count > 0)
                                {
                                    this.FillKNMP(knmp, map);
                                }
                            }
                        }
                        if (knmp.Names.Count > 0)
                        {
                            knmps.Add(knmp);
                        }
                    }
                }
            }
            if (knmps.Count == 0)
            {
                this.mKNMPackages = null;
            }
            else
            {
                this.mKNMPackages = knmps.ToArray();
            }
        }
Exemplo n.º 6
0
        private void FillKNMP(KNMPackage knmp, IDictionary <ulong, string> map)
        {
            GenCLIP gc;
            ulong   h, ch;
            string  s, cs;

            foreach (KeyValuePair <ulong, string> nm in map)
            {
                h = nm.Key;
                s = nm.Value;
                if (FNVHash.HashString64(s) == h ||
                    FNVHash.HashString32(s) == h)
                {
                    knmp.Names[h] = s;
                }
                else if (FNVCLIP.HashString(s) == h)
                {
                    cs = FNVCLIP.GetGenericValue(s);
                    ch = FNVHash.HashString64(cs) & 0x7FFFFFFFFFFFFFFF;
                    knmp.Generics[ch] = cs;
                    if (!this.mGenCLIPs.TryGetValue(ch, out gc))
                    {
                        gc = new GenCLIP(cs);
                        this.mGenCLIPs.Add(ch, gc);
                    }
                    gc.CLIPNames[h] = new CLIP(s, knmp.Path);
                }
                else
                {
                    knmp.Labels[h] = s;
                }
            }
            if (knmp.Names.Count > 0)
            {
                List <KeyValuePair <ulong, string> > names
                    = new List <KeyValuePair <ulong, string> >(knmp.Names);
                foreach (KeyValuePair <ulong, string> name in names)
                {
                    s = name.Value;
                    if (name.Key < 0x100000000)
                    {
                        h = FNVHash.HashString64(s);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = s;
                        }
                    }
                    else
                    {
                        h = FNVHash.HashString32(s);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = s;
                        }
                    }
                    cs = FNVCLIP.GetGenericValue(s);
                    if (!string.Equals(s, cs,
                                       StringComparison.OrdinalIgnoreCase))
                    {
                        h = FNVHash.HashString32(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                        h = FNVHash.HashString64(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                    }
                }
            }
            if (knmp.Generics.Count > 0)
            {
                foreach (KeyValuePair <ulong, string> gen in knmp.Generics)
                {
                    s = gen.Value;
                    h = FNVHash.HashString32(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    h = FNVHash.HashString64(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    cs = FNVCLIP.GetGenericValue(s);
                    h  = FNVHash.HashString32(cs);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = cs;
                    }
                    h = FNVHash.HashString64(cs);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = cs;
                    }
                    cs = string.Concat(cs, ".ma");
                    h  = FNVHash.HashString32(cs);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = cs;
                    }
                    h = FNVHash.HashString64(cs);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = cs;
                    }
                    s = string.Concat(s, ".ma");
                    h = FNVHash.HashString32(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    h = FNVHash.HashString64(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                }
            }
            if (knmp.Labels.Count > 0)
            {
                foreach (KeyValuePair <ulong, string> label in knmp.Labels)
                {
                    s = label.Value;
                    h = FNVHash.HashString32(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    h = FNVHash.HashString64(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    cs = FNVCLIP.GetGenericValue(s);
                    if (!string.Equals(s, cs,
                                       StringComparison.OrdinalIgnoreCase))
                    {
                        h = FNVHash.HashString32(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                        h = FNVHash.HashString64(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                        cs = string.Concat(cs, ".ma");
                        h  = FNVHash.HashString32(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                        h = FNVHash.HashString64(cs);
                        if (!knmp.Names.ContainsKey(h))
                        {
                            knmp.Names[h] = cs;
                        }
                    }
                    s = string.Concat(s, ".ma");
                    h = FNVHash.HashString32(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                    h = FNVHash.HashString64(s);
                    if (!knmp.Names.ContainsKey(h))
                    {
                        knmp.Names[h] = s;
                    }
                }
            }
        }