예제 #1
0
        public void Save(string loc, TreeView mapstree)
        {
            Project proj = CurrentProject;

            proj.lMaps = mapstree;
            EncoderUtil.Encode(loc, proj);
        }
예제 #2
0
 private void bExportContainer_Click2(object sender, EventArgs e)
 {
     using (SaveFileDialog dialog = new SaveFileDialog()) {
         dialog.Filter = "PokeSharp Resource Container (*.pcon)|*.pcon";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             try {
                 if (tabs.SelectedIndex == 0)
                 {
                     EncoderUtil.Encode(dialog.FileName, EditorEngine.Instance.World.TilesetContainer);
                 }
                 else if (tabs.SelectedIndex == 1)
                 {
                     EncoderUtil.Encode(dialog.FileName, EditorEngine.Instance.World.EntityContainer);
                 }
             } catch (Exception exc) {
                 MessageBox.Show("Error. Stacktrace: \n\n{0}".WithFormat(exc.Message),
                                 "Exporting Error",
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Exclamation);
             }
         }
     }
     RefreshView();
 }
예제 #3
0
 private void bImportContainer_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fileDialog = new OpenFileDialog()) {
         fileDialog.Filter = "PokeSharp Resource Container (*.pcon)|*.pcon";
         if (fileDialog.ShowDialog() == DialogResult.OK)
         {
             try {
                 if (tabs.SelectedIndex == 0)
                 {
                     TilesetContainer container = EncoderUtil.Decode <TilesetContainer>(fileDialog.FileName, EditorEngine.Instance.GraphicsDevice);
                     EditorEngine.Instance.World.TilesetContainer = container;
                 }
                 else if (tabs.SelectedIndex == 1)
                 {
                     EntityContainer container = EncoderUtil.Decode <EntityContainer>(fileDialog.FileName, EditorEngine.Instance.GraphicsDevice);
                     EditorEngine.Instance.World.EntityContainer = container;
                     EditorEngine.Instance.HasEdit = true;
                 }
             } catch (Exception exc) {
                 MessageBox.Show("Error. Stacktrace: \n\n{0}".WithFormat(exc.Message),
                                 "Importing Error",
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Exclamation);
             }
         }
     }
     RefreshView();
 }
예제 #4
0
        static async Task PerformContractTransactions(LocalTestNet localTestNet, EntryPointContract entryContract, SolcBytecodeInfo contractBytecode, Abi entryFunction)
        {
            // Perform the contract deployment transaction
            var deployParams = new TransactionParams
            {
                From     = localTestNet.Accounts[0],
                Gas      = ArbitraryDefaults.DEFAULT_GAS_LIMIT,
                GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE
            };
            var contractAddress = await ContractFactory.Deploy(localTestNet.RpcClient, HexUtil.HexToBytes(contractBytecode.Bytecode), deployParams);

            var contractInstance = new ContractInstance(
                entryContract.ContractPath, entryContract.ContractName,
                localTestNet.RpcClient, contractAddress, localTestNet.Accounts[0]);


            // If entry function is specified then send transasction to it.
            if (entryFunction != null)
            {
                var callData     = EncoderUtil.GetFunctionCallBytes($"{entryFunction.Name}()");
                var ethFunc      = EthFunc.Create(contractInstance, callData);
                var funcTxParams = new TransactionParams
                {
                    From     = localTestNet.Accounts[0],
                    Gas      = ArbitraryDefaults.DEFAULT_GAS_LIMIT,
                    GasPrice = ArbitraryDefaults.DEFAULT_GAS_PRICE
                };
                await ethFunc.SendTransaction(funcTxParams);
            }
        }
예제 #5
0
 private void bEntitiesImport_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dialog = new OpenFileDialog()) {
         dialog.Filter = "Entity container (*.pcon)|*.pcon";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             using (FrmResourceImport dialog2 = new FrmResourceImport()) {
                 if (dialog2.ShowDialog() == DialogResult.OK)
                 {
                     EntityContainer container = EncoderUtil.Decode <EntityContainer>(dialog.FileName, EditorEngine.Instance.GraphicsDevice);
                     foreach (EntityTemplate template in container.All())
                     {
                         template.ID = EditorEngine.Instance.World.EntityTemplateFactory.AllocateID();
                     }
                     if (dialog2.Mode == 0)
                     {
                         EditorEngine.Instance.World.EntityContainer.Clear();
                     }
                     foreach (EntityTemplate template in container.All())
                     {
                         EditorEngine.Instance.World.EntityContainer.Add(template);
                     }
                     ReloadEntityList();
                 }
             }
         }
     }
 }
        public void SetTypeInfo(AbiTypeInfo info)
        {
            if (info.Category != SolidityTypeCategory.FixedArray)
            {
                throw EncoderUtil.CreateUnsupportedTypeEncodingException(info);
            }

            TypeInfo = info;
        }
예제 #7
0
파일: World.cs 프로젝트: oxysoft/PokeSharp
 public void LoadObjectContainer(string filename)
 {
     if (ViewData != null)
     {
         EntityContainer = EncoderUtil.Decode <EntityContainer>(filename, ViewData.GraphicsDevice);
     }
     else
     {
         EntityContainer = EncoderUtil.Decode <EntityContainer>(filename);
     }
 }
예제 #8
0
파일: World.cs 프로젝트: oxysoft/PokeSharp
 public void LoadTilesheetContainer(string filename)
 {
     if (ViewData != null)
     {
         TilesetContainer = EncoderUtil.Decode <TilesetContainer>(filename, ViewData.GraphicsDevice);
     }
     else
     {
         TilesetContainer = EncoderUtil.Decode <TilesetContainer>(filename);
     }
 }
예제 #9
0
파일: EthFunc.cs 프로젝트: zutobg/Meadow
        public void FunctionDataEncode_MultipleStringParams()
        {
            var funcSig  = "echoMultipleDynamic(string,string,string)";
            var strP1    = "first string";
            var strP2    = "asdf";
            var strP3    = "utf8; 4 bytes: 𠾴; 3 bytes: ⏰ works!";
            var callData = EncoderUtil.GetFunctionCallBytes(
                funcSig,
                EncoderFactory.LoadEncoder("string", strP1),
                EncoderFactory.LoadEncoder("string", strP2),
                EncoderFactory.LoadEncoder("string", strP3));
            var expectedEncode = "0x14d6b8fa000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000c666972737420737472696e670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000461736466000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028757466383b20342062797465733a20f0a0beb43b20332062797465733a20e28fb020776f726b7321000000000000000000000000000000000000000000000000";

            Assert.Equal(expectedEncode, callData.ToHexString(hexPrefix: true));
        }
예제 #10
0
 private void bEntitiesExport_Click(object sender, EventArgs e)
 {
     using (FrmResourceExport dialogs = new FrmResourceExport(EditorEngine.Instance.World.EntityContainer, 1)) {
         if (dialogs.ShowDialog() == DialogResult.OK)
         {
             using (SaveFileDialog dialog = new SaveFileDialog()) {
                 dialog.Filter = "Entity Container (*.pcon)|*.pcon";
                 if (dialog.ShowDialog() != DialogResult.OK)
                 {
                     return;
                 }
                 EncoderUtil.Encode(dialog.FileName, dialogs.EntityContainer);
             }
         }
     }
 }
예제 #11
0
파일: EthFunc.cs 프로젝트: zutobg/Meadow
        public void FunctionDataEncode_MixedParamTypes()
        {
            var p1       = true;
            var p2       = "my string";
            var p3       = (long)-11118;
            var p4       = new Address[] { "0x98E4625b2d7424C403B46366150AB28Df4063408", "0x40515114eEa1497D753659DFF85910F838c6B234", "0xDf0270A6BFf43e7A3Fd92372DfB549292D683D22" };
            var p5       = (byte)99;
            var p6       = new ulong[] { 9, 0, ulong.MaxValue };
            var callData = EncoderUtil.GetFunctionCallBytes(
                "boat(bool,string,int56,address[],uint8,uint64[3])",
                EncoderFactory.LoadEncoder("bool", p1),
                EncoderFactory.LoadEncoder("string", p2),
                EncoderFactory.LoadEncoder("int56", p3),
                EncoderFactory.LoadEncoder("address[]", p4, EncoderFactory.LoadEncoder("address", default(Address))),
                EncoderFactory.LoadEncoder("uint8", p5),
                EncoderFactory.LoadEncoder("uint64[3]", p6, EncoderFactory.LoadEncoder("uint64", default(ulong))));

            var expected = "0x7a4a328f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd4920000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000000000000000000000096d7920737472696e670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000098e4625b2d7424c403b46366150ab28df406340800000000000000000000000040515114eea1497d753659dff85910f838c6b234000000000000000000000000df0270a6bff43e7a3fd92372dfb549292d683d22";
            var result   = callData.ToHexString(hexPrefix: true);

            Assert.Equal(expected, result);
        }
예제 #12
0
        public static string BuildParam(Dictionary <string, string> paramArray, Encoding encode = null)
        {
            string url = "";

            if (encode == null)
            {
                encode = Encoding.UTF8;
            }

            if (paramArray != null && paramArray.Count > 0)
            {
                var parms = "";
                foreach (var item in paramArray)
                {
                    parms += string.Format("{0}={1}&", EncoderUtil.UrlHttpUtilityEncoder(item.Key, encode), EncoderUtil.UrlHttpUtilityEncoder(item.Value, encode));
                }
                if (parms != "")
                {
                    parms = parms.TrimEnd('&');
                }
                url += parms;
            }
            return(url);
        }
예제 #13
0
        /// <summary>
        /// Runs a test based on the input parameters.
        /// </summary>
        /// <param name="inputLength">The length of the input.</param>
        /// <param name="worstCaseOutputCharsPerInputChar">The worst case scenario.</param>
        /// <param name="expectedCapacity">The expected capacity of the string builder created.</param>
        /// <param name="failureMessage">The message to use if the test fails.</param>
        private static void RunGetOutputStringBuilderTest(int inputLength, int worstCaseOutputCharsPerInputChar, int expectedCapacity, string failureMessage)
        {
            StringBuilder builder = EncoderUtil.GetOutputStringBuilder(inputLength, worstCaseOutputCharsPerInputChar);

            Assert.AreEqual(expectedCapacity, builder.Capacity, failureMessage);
        }
예제 #14
0
 public void loadObjectContainer(string objectContainer)
 {
     World.EntityContainer = EncoderUtil.Decode <EntityContainer>(objectContainer, GraphicsDevice);
 }
예제 #15
0
 public void loadTilesheetContainer(string tilesetContainer)
 {
     World.TilesetContainer = EncoderUtil.Decode <TilesetContainer>(tilesetContainer, GraphicsDevice);
 }
예제 #16
0
 public static Project Load(string loc)
 {
     return(EncoderUtil.Decode <Project>(loc));
 }
예제 #17
0
        public IActionResult Export([FromQuery] Bootstrap.BootstrapParams bootstrap)
        {
            var buffer = _materialServices.ExportList(bootstrap);

            if (buffer.IsNull())
            {
                return(File(JsonL((false, PubConst.File8)).ToBytes(), ContentType.ContentTypeJson));
            }
            return(File(buffer, ContentType.ContentTypeFile, DateTimeExt.GetDateTimeS(DateTimeExt.DateTimeFormatString) + "-" + EncoderUtil.UrlHttpUtilityEncoder("物料") + ".xlsx"));
        }