/** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.Crypt.OnCryptCoroutine_CallBackInterface a_callback_interface, byte[] a_binary, string a_pass, string a_salt)
        {
            //result
            this.result = new ResultType();

            //taskprogress
            this.taskprogress = 0.0f;

            //キャンセルトークン。
            Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

            //result
            Task_EncryptPass.ResultType t_result;

            //タスク起動。
            using (Fee.TaskW.Task <Task_EncryptPass.ResultType> t_task = Task_EncryptPass.Run(this, a_binary, a_pass, a_salt, t_cancel_token)){
                //終了待ち。
                do
                {
                    //キャンセル。
                    if (a_callback_interface != null)
                    {
                        if (a_callback_interface.OnCryptCoroutine(this.taskprogress) == false)
                        {
                            t_cancel_token.Cancel();
                        }
                    }
                    yield return(null);
                }while(t_task.IsEnd() == false);

                //結果。
                t_result = t_task.GetResult();

                //成功。
                if (t_task.IsSuccess() == true)
                {
                    if (t_result.binary != null)
                    {
                        this.result.binary = t_result.binary;
                        yield break;
                    }
                }
            }

            //失敗。
            if (t_result.errorstring != null)
            {
                this.result.errorstring = t_result.errorstring;
                yield break;
            }
            else
            {
                this.result.errorstring = "Coroutine_EncryptPass : null";
                yield break;
            }
        }
Exemplo n.º 2
0
        /** TaskMain_SpriteList
         */
        private int TaskMain_SpriteList(Fee.TaskW.CancelToken a_cancel_token)
        {
            try{
                //削除。
                if ((this.frame % this.frame_max) == 0)
                {
                    if (this.spritelist.delete_request_flag == true)
                    {
                        this.spritelist.delete_request_flag     = false;
                        this.spritelist.calc_index_request_flag = true;
                        this.spritelist.Task_Update();
                    }
                }

                //キャンセル処理。
                if (a_cancel_token.IsCancellationRequested() == true)
                {
                    a_cancel_token.ThrowIfCancellationRequested();
                    return(-1);
                }

                //ソート。
                if (this.spritelist.sort_request_flag == true)
                {
                    this.spritelist.sort_request_flag       = false;
                    this.spritelist.calc_index_request_flag = true;
                    this.spritelist.Sort();
                }

                //キャンセル処理。
                if (a_cancel_token.IsCancellationRequested() == true)
                {
                    a_cancel_token.ThrowIfCancellationRequested();
                    return(-1);
                }

                //インデックス計算。
                if (this.spritelist.calc_index_request_flag == true)
                {
                    this.spritelist.calc_index_request_flag = false;
                    this.layerlist.CalcSpriteIndex(this.spritelist);

                    //全行程完了。
                    this.spritelist.sortend_flag = true;
                }
            }catch (System.OperationCanceledException) {
            }catch (System.Exception t_exception) {
                Tool.DebugReThrow(t_exception);
            }

            return(0);
        }
Exemplo n.º 3
0
        /** constructor
         */
        public Task_SortList(Render2D a_render2d)
        {
            //render2d
            this.render2d = a_render2d;

            //layerlist
            this.layerlist = a_render2d.GetLayerList();

            //spritelist
            this.spritelist = a_render2d.GetSpriteList();

            //textlist
            this.textlist = a_render2d.GetTextList();

            //inputfieldlist
            this.inputfieldlist = a_render2d.GetInputFieldList();

            //canceltoken
            this.canceltoken = new Fee.TaskW.CancelToken();

            //frame
            this.frame     = 0;
            this.frame_max = 120;

            //関数登録。
            this.task_list = new Fee.TaskW.Task <int> [3];
            for (int ii = 0; ii < this.task_list.Length; ii++)
            {
                this.task_list[ii] = new Fee.TaskW.Task <int>(Fee.TaskW.Mode.InstanceMode_Function);
            }
            this.task_list[0].SetFunction(() => {
                return(this.TaskMain_SpriteList(this.canceltoken));
            });
            this.task_list[1].SetFunction(() => {
                return(this.TaskMain_TextList(this.canceltoken));
            });
            this.task_list[2].SetFunction(() => {
                return(this.TaskMain_InputFieldList(this.canceltoken));
            });
        }
 /** TaskMain
  */
         #if ((UNITY_5) || (UNITY_WEBGL))
 private static ResultType TaskMain(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, string a_key, Fee.TaskW.CancelToken a_cancel)
        private static async System.Threading.Tasks.Task <ResultType> TaskMain(Fee.File.OnFileTask_CallBackInterface a_callback_interface, Path a_path, Fee.TaskW.CancelToken a_cancel)
                #endif
        {
            ResultType t_ret;

            {
                t_ret.binary      = null;
                t_ret.errorstring = null;
            }

            Fee.TaskW.TaskW.GetInstance().Post((a_state) => {
                a_callback_interface.OnFileTask(0.1f);
            }, null);

            System.IO.FileStream t_filestream = null;

            try{
                //ファイルパス。
                System.IO.FileInfo t_fileinfo = new System.IO.FileInfo(a_path.GetPath());

                //開く。
                t_filestream = t_fileinfo.OpenRead();

                //読み込み。
                if (t_filestream != null)
                {
                    t_ret.binary = new byte[t_filestream.Length];
                    if (Config.USE_ASYNC == true)
                    {
                                                #if ((UNITY_5) || (UNITY_WEBGL))
                        Tool.Assert(false);
                                                #else
                        await t_filestream.ReadAsync(t_ret.binary, 0, t_ret.binary.Length, a_cancel.GetToken());

                        await t_filestream.FlushAsync(a_cancel.GetToken());
                                                #endif
                    }
                    else
                    {
                        t_filestream.Read(t_ret.binary, 0, t_ret.binary.Length);
                    }
                }
            }catch (System.Exception t_exception) {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_LoadLocalBinaryFile : " + t_exception.Message;
            }

            //閉じる。
            if (t_filestream != null)
            {
                t_filestream.Close();
            }

            if (a_cancel.IsCancellationRequested() == true)
            {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_LoadLocalBinaryFile : Cancel";

                a_cancel.ThrowIfCancellationRequested();
            }

            if (t_ret.binary == null)
            {
                if (t_ret.errorstring == null)
                {
                    t_ret.errorstring = "Task_LoadLocalBinaryFile : null";
                }
            }

            return(t_ret);
        }
 /** TaskMain
  */
         #if ((UNITY_5) || (UNITY_WEBGL))
 private static ResultType TaskMain(Fee.File.OnFileTask_CallBackInterface a_callback_interface, Path a_path, Fee.TaskW.CancelToken a_cancel)
 /** 実行。
  */
 public static Fee.TaskW.Task <ResultType> Run(Fee.File.OnFileTask_CallBackInterface a_callback_interface, Path a_path, Fee.TaskW.CancelToken a_cancel)
 {
     return(new Fee.TaskW.Task <ResultType>(() => {
         return Task_LoadLocalBinaryFile.TaskMain(a_callback_interface, a_path, a_cancel);
     }));
 }
Exemplo n.º 8
0
 /** 実行。
  */
 public static Fee.TaskW.Task <ResultType> Run(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, int a_index, int a_length, string a_pass, string a_salt, Fee.TaskW.CancelToken a_cancel)
 {
     return(new Fee.TaskW.Task <ResultType>(() => {
         return Task_DecryptPass.TaskMain(a_callback_interface, a_binary, a_index, a_length, a_pass, a_salt, a_cancel);
     }));
 }
Exemplo n.º 9
0
        private static async System.Threading.Tasks.Task <ResultType> TaskMain(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, int a_index, int a_length, string a_pass, string a_salt, Fee.TaskW.CancelToken a_cancel)
                #endif
        {
            ResultType t_ret;

            {
                t_ret.binary      = null;
                t_ret.errorstring = null;
            }

            try{
                //RijndaelManaged
                System.Security.Cryptography.RijndaelManaged t_rijndael = new System.Security.Cryptography.RijndaelManaged();
                t_rijndael.KeySize   = 256;
                t_rijndael.BlockSize = 128;
                t_rijndael.Mode      = System.Security.Cryptography.CipherMode.CBC;

                {
                    byte[] t_salt = System.Text.Encoding.UTF8.GetBytes(a_salt);
                    System.Security.Cryptography.Rfc2898DeriveBytes t_derivebyte = new System.Security.Cryptography.Rfc2898DeriveBytes(a_pass, t_salt);
                    t_derivebyte.IterationCount = 1000;

                    t_rijndael.Key = t_derivebyte.GetBytes(t_rijndael.KeySize / 8);
                    t_rijndael.IV  = t_derivebyte.GetBytes(t_rijndael.BlockSize / 8);

                    Tool.Log("Key", System.BitConverter.ToString(t_rijndael.Key));
                    Tool.Log("IV", System.BitConverter.ToString(t_rijndael.IV));
                }

                //TransformFinalBlock
                using (System.Security.Cryptography.ICryptoTransform t_decryptor = t_rijndael.CreateDecryptor()){
                    t_ret.binary = t_decryptor.TransformFinalBlock(a_binary, a_index, a_length);
                }
            }catch (System.Exception t_exception) {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_DecryptPass : "******"Task_DecryptPass : Cancel";

                a_cancel.ThrowIfCancellationRequested();
            }

            if (t_ret.binary == null)
            {
                if (t_ret.errorstring == null)
                {
                    t_ret.errorstring = "Task_DecryptPass : null";
                }
            }

            return(t_ret);
        }
Exemplo n.º 10
0
        private static async System.Threading.Tasks.Task <ResultType> TaskMain(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, string a_key, Fee.TaskW.CancelToken a_cancel)
                #endif
        {
            ResultType t_ret;

            {
                t_ret.binary      = null;
                t_ret.errorstring = null;
            }

            try{
                using (System.Security.Cryptography.RSACryptoServiceProvider t_rsa = new System.Security.Cryptography.RSACryptoServiceProvider()){
                    t_rsa.FromXmlString(a_key);
                    t_ret.binary = t_rsa.Decrypt(a_binary, false);
                }
            }catch (System.Exception t_exception) {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_DecryptPrivateKey : " + t_exception.Message;
            }

            if (a_cancel.IsCancellationRequested() == true)
            {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_DecryptPrivateKey : Cancel";

                a_cancel.ThrowIfCancellationRequested();
            }

            if (t_ret.binary == null)
            {
                if (t_ret.errorstring == null)
                {
                    t_ret.errorstring = "Task_DecryptPrivateKey : null";
                }
            }

            return(t_ret);
        }
Exemplo n.º 11
0
        /** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //ロード。
            byte[] t_result_binary = null;
            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_LoadLocalBinaryFile.ResultType> t_task = Task_LoadLocalBinaryFile.Run(this, a_path, t_cancel_token)){
                    //終了待ち。
                    do
                    {
                        //キャンセルチェック。
                        {
                            if (a_callback_interface != null)
                            {
                                if (a_callback_interface.OnFileCoroutine(this.taskprogress) == false)
                                {
                                    t_cancel_token.Cancel();
                                }
                            }
                        }

                        yield return(null);
                    }while(t_task.IsEnd() == false);

                    //結果。
                    Task_LoadLocalBinaryFile.ResultType t_result = t_task.GetResult();

                    if (t_result.errorstring != null)
                    {
                        //エラー。
                        this.result = new ResultType(null, t_result.errorstring);
                        yield break;
                    }

                    if (t_task.IsSuccess() == false)
                    {
                        //エラー。
                        this.result = new ResultType(null, "Task Error : LoadLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    if (t_result.binary == null)
                    {
                        //エラー。
                        this.result = new ResultType(null, "Unknown Error : LoadLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    //成功。
                    t_result_binary = t_result.binary;
                }
            }

            //コンバート。
            UnityEngine.Texture2D t_result_texture = null;
            {
                t_result_texture = BinaryToTexture2D.Convert(t_result_binary);
                if (t_result_texture == null)
                {
                    //エラー。
                    this.result = new ResultType(null, "Convert Error : LoadLocalTextureFile : " + a_path.ToString());
                    yield break;
                }
            }

            //成功。
            this.result = new ResultType(t_result_texture, null);
            yield break;
        }
        /** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, byte[] a_binary)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //チェック。
            if (a_binary == null)
            {
                //エラー。
                this.result = new ResultType(false, "Param Error : SaveLocalBinaryFile : " + a_path.GetPath());
                yield break;
            }

            //セーブ。
            bool t_result_saveend = false;

            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_SaveLocalBinaryFile.ResultType> t_task = Task_SaveLocalBinaryFile.Run(this, a_path, a_binary, t_cancel_token)){
                    //終了待ち。
                    do
                    {
                        //キャンセルチェック。
                        {
                            if (a_callback_interface != null)
                            {
                                if (a_callback_interface.OnFileCoroutine(this.taskprogress) == false)
                                {
                                    t_cancel_token.Cancel();
                                }
                            }
                        }

                        yield return(null);
                    }while(t_task.IsEnd() == false);

                    //結果。
                    Task_SaveLocalBinaryFile.ResultType t_result = t_task.GetResult();

                    if (t_result.errorstring != null)
                    {
                        //エラー。
                        this.result = new ResultType(false, t_result.errorstring);
                        yield break;
                    }

                    if (t_task.IsSuccess() == false)
                    {
                        //エラー。
                        this.result = new ResultType(false, "Task Error : SaveLocalBinaryFile : " + a_path.GetPath());
                        yield break;
                    }

                    if (t_result.saveend == false)
                    {
                        //エラー。
                        this.result = new ResultType(false, "Unknown Error : SaveLocalBinaryFile : " + a_path.GetPath());
                        yield break;
                    }

                    //成功。
                    t_result_saveend = t_result.saveend;
                }
            }

            this.result = new ResultType(t_result_saveend, null);
            yield break;
        }
        private static async System.Threading.Tasks.Task <ResultType> TaskMain(Fee.File.OnFileTask_CallBackInterface a_callback_interface, Path a_path, byte[] a_binary, Fee.TaskW.CancelToken a_cancel)
                #endif
        {
            ResultType t_ret;

            {
                t_ret.saveend     = false;
                t_ret.errorstring = null;
            }

            System.IO.FileStream t_filestream = null;

            try{
                //ファイルパス。
                System.IO.FileInfo t_fileinfo = new System.IO.FileInfo(a_path.GetPath());

                //開く。
                t_filestream = t_fileinfo.Create();

                //書き込み。
                if (t_filestream != null)
                {
                    if (a_binary != null)
                    {
                        if (Config.USE_ASYNC == true)
                        {
                                                        #if ((UNITY_5) || (UNITY_WEBGL))
                            Tool.Assert(false);
                                                        #else
                            await t_filestream.WriteAsync(a_binary, 0, a_binary.Length, a_cancel.GetToken());

                            await t_filestream.FlushAsync(a_cancel.GetToken());
                                                        #endif
                        }
                        else
                        {
                            t_filestream.Write(a_binary, 0, a_binary.Length);
                            t_filestream.Flush();
                        }
                        t_ret.saveend = true;
                    }
                    else
                    {
                        t_ret.saveend     = false;
                        t_ret.errorstring = "Task_SaveLocalBinaryFile : binary == null";
                    }
                }
            }catch (System.Exception t_exception) {
                t_ret.saveend     = false;
                t_ret.errorstring = "Task_SaveLocalBinaryFile : " + t_exception.Message;
            }

            //閉じる。
            if (t_filestream != null)
            {
                t_filestream.Close();
            }

            Platform.Platform.GetInstance().SyncFs();

            if (a_cancel.IsCancellationRequested() == true)
            {
                t_ret.saveend     = false;
                t_ret.errorstring = "Task_SaveLocalBinaryFile : Cancel";

                a_cancel.ThrowIfCancellationRequested();
            }

            if (t_ret.saveend == false)
            {
                if (t_ret.errorstring == null)
                {
                    t_ret.errorstring = "Task_SaveLocalBinaryFile : null";
                }
            }

            return(t_ret);
        }
Exemplo n.º 14
0
        /** CoroutineMain
         */
        public System.Collections.IEnumerator CoroutineMain(Fee.File.OnFileCoroutine_CallBackInterface a_callback_interface, Fee.File.Path a_path, UnityEngine.Texture2D a_texture)
        {
            //result
            this.result = null;

            //taskprogress_
            this.taskprogress = 0.0f;

            //チェック。
            if (a_texture == null)
            {
                //エラー。
                this.result = new ResultType(false, "Convert Error : SaveLocalTextureFile : " + a_path.GetPath());
                yield break;
            }

            //コンバート。
            byte[] t_result_binary = null;
            {
                try{
                    byte[] t_result = UnityEngine.ImageConversion.EncodeToPNG(a_texture);

                    if (t_result == null)
                    {
                        //エラー。
                        this.result = new ResultType(false, "Convert Error : SaveLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    t_result_binary = t_result;
                }catch (System.Exception t_exception) {
                    //エラー。
                    this.result = new ResultType(false, "Convert Error : SaveLocalTextureFile : " + a_path.GetPath() + " : " + t_exception.Message);
                    yield break;
                }
            }

            //セーブ。
            bool t_result_saveend = false;

            {
                //キャンセルトークン。
                Fee.TaskW.CancelToken t_cancel_token = new Fee.TaskW.CancelToken();

                //タスク起動。
                using (Fee.TaskW.Task <Task_SaveLocalBinaryFile.ResultType> t_task = Task_SaveLocalBinaryFile.Run(this, a_path, t_result_binary, t_cancel_token)){
                    //終了待ち。
                    do
                    {
                        //キャンセルチェック。
                        {
                            if (a_callback_interface != null)
                            {
                                if (a_callback_interface.OnFileCoroutine(this.taskprogress) == false)
                                {
                                    t_cancel_token.Cancel();
                                }
                            }
                        }

                        yield return(null);
                    }while(t_task.IsEnd() == false);

                    //結果。
                    Task_SaveLocalBinaryFile.ResultType t_result = t_task.GetResult();

                    if (t_result.errorstring != null)
                    {
                        //エラー。
                        this.result = new ResultType(false, t_result.errorstring);
                        yield break;
                    }

                    if (t_task.IsSuccess() == false)
                    {
                        //エラー。
                        this.result = new ResultType(false, "Task Error : SaveLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    if (t_result.saveend == false)
                    {
                        //エラー。
                        this.result = new ResultType(false, "Unknown Error : SaveLocalTextureFile : " + a_path.GetPath());
                        yield break;
                    }

                    //成功。
                    t_result_saveend = t_result.saveend;
                }
            }

            this.result = new ResultType(t_result_saveend, null);
            yield break;
        }
        private static async System.Threading.Tasks.Task <ResultType> TaskMain(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, string a_key, Fee.TaskW.CancelToken a_cancel)
                #endif
        {
            ResultType t_ret;

            {
                t_ret.binary      = null;
                t_ret.errorstring = null;
            }

            try{
                //ハッシュの計算。
                byte[] t_hash_binary = null;
                using (System.Security.Cryptography.SHA1Managed t_sha1 = new System.Security.Cryptography.SHA1Managed()){
                    t_hash_binary = t_sha1.ComputeHash(a_binary);
                }

                if (t_hash_binary == null)
                {
                    t_ret.binary      = null;
                    t_ret.errorstring = "Task_CreateSignaturePrivateKey : hash == null";
                }
                else
                {
                    using (System.Security.Cryptography.RSACryptoServiceProvider t_rsa = new System.Security.Cryptography.RSACryptoServiceProvider()){
                        t_rsa.FromXmlString(a_key);

                        //証明書作成。
                        System.Security.Cryptography.RSAPKCS1SignatureFormatter t_formatter = new System.Security.Cryptography.RSAPKCS1SignatureFormatter(t_rsa);
                        t_formatter.SetHashAlgorithm("SHA1");
                        t_ret.binary = t_formatter.CreateSignature(t_hash_binary);
                    }
                }
            }catch (System.Exception t_exception) {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_CreateSignaturePrivateKey : " + t_exception.Message;
            }

            if (a_cancel.IsCancellationRequested() == true)
            {
                t_ret.binary      = null;
                t_ret.errorstring = "Task_CreateSignaturePrivateKey : Cancel";

                a_cancel.ThrowIfCancellationRequested();
            }

            if (t_ret.binary == null)
            {
                if (t_ret.errorstring == null)
                {
                    t_ret.errorstring = "Task_CreateSignaturePrivateKey : null";
                }
            }

            return(t_ret);
        }
 /** 実行。
  */
 public static Fee.TaskW.Task <ResultType> Run(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, string a_key, Fee.TaskW.CancelToken a_cancel)
 {
     return(new Fee.TaskW.Task <ResultType>(() => {
         return Task_CreateSignaturePrivateKey.TaskMain(a_callback_interface, a_binary, a_key, a_cancel);
     }));
 }
Exemplo n.º 17
0
 /** TaskMain
  */
         #if ((UNITY_5) || (UNITY_WEBGL))
 private static ResultType TaskMain(Fee.Crypt.OnCryptTask_CallBackInterface a_callback_interface, byte[] a_binary, int a_index, int a_length, string a_pass, string a_salt, Fee.TaskW.CancelToken a_cancel)