Ejemplo n.º 1
0
        public void ConvertHashType()
        {
            if (!HashList.ContainsKey("Hash"))
            {
                return;
            }
            ProtoHashList = new Dictionary <string, List <KeyInfo> >();

            foreach (var item in HashList?["Hash"])
            {
                try
                {
                    var    type    = (HashType)item.KeyObject.HashType;
                    string typeStr = type.ToString();
                    if (!ProtoHashList.ContainsKey(typeStr))
                    {
                        ProtoHashList.Add(typeStr, new List <KeyInfo>());
                    }
                    ProtoHashList[typeStr].Add(item);
                }
                catch (Exception e)
                {
                    Logger.WriteInfo($"Convert hash key exception: {item}");
                }
            }
        }
Ejemplo n.º 2
0
        public void RemoveExample()
        {
            var whatAnimalEatHashList = new HashList <string, string>
            {
                { "cat", "milk" },
                { "cat", "fish" },
                { "dog", "dog food" },
                { "dog", "bones" },
                { "tiger", "people" }
            };

            // HashList contains "dog"
            Assert.IsTrue(whatAnimalEatHashList.ContainsKey("dog"));

            // Remove "dog"
            whatAnimalEatHashList.Remove("dog");

            // HashList does not contain "dog"
            Assert.IsFalse(whatAnimalEatHashList.ContainsKey("dog"));
        }
Ejemplo n.º 3
0
        public KeyInfo GetKeyInfo(string key)
        {
            var keyInfo = new KeyInfo(key);

            try
            {
                byte[] info = ByteArrayHelpers.FromHexString(key);
                keyInfo.RedisValue = info;
                keyInfo.KeyLength  = info.Length;
                ProtobufSerializer ps = new ProtobufSerializer();
                Key objectKey         = ps.Deserialize <Key>(info);
                keyInfo.KeyObject = objectKey;
                string typeStr = objectKey.Type;
                keyInfo.BasicString = typeStr;
                int valueLength = 0;
                keyInfo.ValueInfo   = ConvertKeyValue(objectKey, out valueLength);
                keyInfo.ValueLength = valueLength;
                if (typeStr == "Hash")
                {
                    var hashType = (HashType)objectKey.HashType;
                    keyInfo.HashString = hashType.ToString();
                }
                else
                {
                    keyInfo.HashString = string.Empty;
                }

                if (!HashList.ContainsKey(typeStr))
                {
                    HashList.Add(typeStr, new List <KeyInfo>());
                }
                HashList[typeStr].Add(keyInfo);
            }
            catch (Exception)
            {
                Logger.WriteError($"Get key info exception: {key}");
            }

            return(keyInfo);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <param name="priority"></param>
        public void AddRenderable(IRenderable item, ushort priority)
        {
            RenderPriorityGroup group = null;

            // see if there is a current queue group for this group id
            if (!priorityGroups.ContainsKey(priority))
            {
                // create a new queue group for this group id
                group = new RenderPriorityGroup(splitPassesByLightingType, splitNoShadowPasses,
                                                splitPassesByLightingType);

                // add the new group to cached render group
                priorityGroups.Add(priority, group);
            }
            else
            {
                // retreive the existing queue group
                group = (RenderPriorityGroup)priorityGroups.GetByKey(priority);
            }

            // add the renderable to the appropriate group
            group.AddRenderable(item);
        }
Ejemplo n.º 5
0
        public void Process(IProgress <int> progress)
        {
            var files = Directory.GetFiles(Program.Dest, "*.*", SearchOption.AllDirectories);
            var cnt   = 0;

            foreach (var item in files)
            {
                // ファイルの相対パスを出す。
                var itemFolder   = Path.GetDirectoryName(item);
                var itemRelative = item.Substring(Program.Dest.Length + 1);

                if (!File.Exists(item))
                {
                    cnt++;
                    progress.Report(cnt);
                    continue;
                }

                if (!itemRelative.Contains("\\"))
                {
                    // ルートのやつなので検索しない。
                    cnt++;
                    progress.Report(cnt);
                    continue;
                }

                // SHA1ハッシュの計算。
                var fileStream = new FileStream(item,
                                                FileMode.Open,
                                                FileAccess.Read,
                                                FileShare.None);
                var md5     = MD5.Create();
                var fileMD5 = md5.ComputeHash(fileStream);
                var hash    = BitConverter.ToString(fileMD5).ToLower().Replace("-", "");

                // 後片付け
                md5.Clear();
                fileStream.Close();

                if (!HashList.ContainsKey(hash))
                {
                    cnt++;
                    progress.Report(cnt);
                    continue;
                }

                // リネームする。
                var result = Path.Combine(Path.GetDirectoryName(itemRelative), Path.GetFileName(HashList[hash]));

                try
                {
                    // note:たまにファイル名が重複しているやつがある?
                    File.Move(item, Path.Combine(Program.Dest, result));
                }
                catch (IOException)
                {
                }
                finally
                {
                    cnt++;
                    progress.Report(cnt);
                }
            }
        }
Ejemplo n.º 6
0
        public void Read(FileReader reader)
        {
            string Signature = reader.ReadString(8, Encoding.ASCII);

            if (Signature != "GFLXPACK")
            {
                throw new Exception($"Invalid signature {Signature}! Expected GFLXPACK.");
            }

            version = reader.ReadInt32();
            uint padding   = reader.ReadUInt32();
            uint FileCount = reader.ReadUInt32();

            FolderCount = reader.ReadInt32();
            ulong FileInfoOffset       = reader.ReadUInt64();
            ulong hashArrayPathsOffset = reader.ReadUInt64();
            ulong FolderArrayOffset    = reader.ReadUInt64();

            reader.Seek((long)FolderArrayOffset, SeekOrigin.Begin);

            List <HashIndex> FolderFiles = new List <HashIndex>();

            for (int i = 0; i < FolderCount; i++)
            {
                Folder folder = new Folder();
                folder.Read(reader);
                folders.Add(folder);

                foreach (var hash in folder.hashes)
                {
                    FolderFiles.Add(hash);
                }
            }

            reader.Seek((long)hashArrayPathsOffset, SeekOrigin.Begin);
            for (int i = 0; i < FileCount; i++)
            {
                ulong hash = reader.ReadUInt64();
                hashes.Add(hash);
            }

            reader.Seek((long)FileInfoOffset, SeekOrigin.Begin);
            for (int i = 0; i < FileCount; i++)
            {
                FileEntry fileEntry = new FileEntry(this);
                fileEntry.Read(reader);
                fileEntry.FolderHash = FolderFiles[i];
                fileEntry.FileName   = GetString(hashes[i], fileEntry.FileData);

                string suffix   = hashes[i].ToString("X").GetLast(6);
                ulong  suffix64 = Convert.ToUInt64(suffix, 16);

                if (HashList.ContainsKey(suffix64))
                {
                    fileEntry.FileName = HashList[suffix64];
                }

                string baseName = Path.GetFileName(fileEntry.FileName.Replace("\r", ""));

                switch (Utils.GetExtension(fileEntry.FileName))
                {
                case ".gfbanm":
                    fileEntry.FileName = $"Animations/{baseName}";
                    break;

                case ".gfbanmcfg":
                    fileEntry.FileName = $"AnimationConfigs/{baseName}";
                    break;

                case ".gfbmdl":
                    fileEntry.FileName = $"Models/{baseName}";
                    break;

                case ".gfbpokecfg":
                    fileEntry.FileName = $"PokeConfigs/{baseName}";
                    break;

                case ".bntx":
                    fileEntry.FileName = $"Textures/{baseName}";
                    break;

                case ".bnsh":
                    fileEntry.FileName = $"Shaders/{baseName}";
                    break;

                case ".ptcl":
                    fileEntry.FileName = $"Effects/{baseName}";
                    break;

                default:
                    fileEntry.FileName = $"OtherFiles/{baseName}";
                    break;
                }



                //     Console.WriteLine($"{fileEntry.FileName} {fileEntry.FolderHash.hash.ToString("X")} {suffix64.ToString("X")}");

                files.Add(fileEntry);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Determines whether or not a particular service dependency exists in the current dependency container.
 /// </summary>
 /// <param name="dependency">The target service dependency.</param>
 /// <returns><c>true</c> if the service exists; otherwise, it will return <c>false</c>.</returns>
 public bool Contains(IDependency dependency)
 {
     return(_entries.ContainsKey(dependency));
 }
Ejemplo n.º 8
0
        public void RemoveExample()
        {
            var whatAnimalEatHashList = new HashList<string, string>
                                            {
                                                {"cat", "milk"},
                                                {"cat", "fish"},
                                                {"dog", "dog food"},
                                                {"dog", "bones"},
                                                {"tiger", "people"}
                                            };

            // HashList contains "dog"
            Assert.IsTrue(whatAnimalEatHashList.ContainsKey("dog"));

            // Remove "dog"
            whatAnimalEatHashList.Remove("dog");

            // HashList does not contain "dog"
            Assert.IsFalse(whatAnimalEatHashList.ContainsKey("dog"));
        }