Beispiel #1
0
        protected override void Seed(IndirectlyApp.Models.ApplicationDbContext context)
        {
            var mosaics = new List <Mosaic>();

            for (int i = 0; i < 10; i++)
            {
                var mosaic = new Mosaic();
                mosaic.Description = "Description of mosaic " + i;
                mosaic.User        = _userManager.Users.First();
                mosaics.Add(mosaic);
            }

            var comments = new List <Comment>();

            for (int i = 0; i < 10; i++)
            {
                var comment = new Comment();
                comment.Body   = "Test comment " + i;
                comment.User   = _userManager.Users.First();
                comment.Mosaic = mosaics[i];
                comments.Add(comment);
            }

            db.Mosaics.AddRange(mosaics);
            db.Comments.AddRange(comments);
            db.SaveChanges();
        }
        public async Task <Transaction> Transfer(Account from, Address to, Mosaic mosaic, IMessage message, string generationHash)
        {
            var transferTransaction = TransferTransaction.Create(
                Deadline.Create(),
                Recipient.From(to),
                new List <Mosaic>()
            {
                mosaic
            },
                message,
                NetworkType);

            var signedTransaction = from.Sign(transferTransaction, generationHash);

            WatchForFailure(signedTransaction);

            //Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}");

            var tx = SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(from.Address).Take(1);

            await SiriusClient.TransactionHttp.Announce(signedTransaction);

            var result = await tx;

            return(result);
        }
Beispiel #3
0
        public void CreateANewMosaicViaConstructor()
        {
            Mosaic mosaic = new Mosaic(new MosaicId(12), 24);

            Assert.IsTrue(mosaic.MosaicId.Id.Equals(12));
            Assert.IsTrue(mosaic.Amount.Equals(24));
        }
        public void Should_GetDimensionMosaic_When_ExisteRightScreen()
        {
            var mosaic       = new Mosaic();
            var screen1      = new Screen(100, 200, "screen1");
            var screenRight1 = new Screen(100, 200, "screenRight1");
            var screenRight2 = new Screen(100, 200, "screenRight2");

            mosaic.AddNeighbor(screen1);
            mosaic.AddNeighbor(screen1, screenRight1, DirectionEnum.Right);
            mosaic.AddNeighbor(screenRight1, screenRight2, DirectionEnum.Right);


            var maker = new Maker(mosaic.Items);

            maker.Init();

            Assert.NotNull(mosaic);
            Assert.Equal(3, mosaic.Items.Count);

            Assert.Equal(0, mosaic.Items[0].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[0].DimensionMosaic.Y);
            Assert.Equal(screen1.Dimension.Width, mosaic.Items[0].DimensionMosaic.Width);
            Assert.Equal(screen1.Dimension.Height, mosaic.Items[0].DimensionMosaic.Height);

            Assert.Equal(100, mosaic.Items[1].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[1].DimensionMosaic.Y);
            Assert.Equal(screenRight1.Dimension.Width, mosaic.Items[1].DimensionMosaic.Width);
            Assert.Equal(screenRight1.Dimension.Height, mosaic.Items[1].DimensionMosaic.Height);

            Assert.Equal(200, mosaic.Items[2].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[2].DimensionMosaic.Y);
            Assert.Equal(screenRight2.Dimension.Width, mosaic.Items[2].DimensionMosaic.Width);
            Assert.Equal(screenRight2.Dimension.Height, mosaic.Items[2].DimensionMosaic.Height);
        }
        public void Should_GetNodesTreePath_When_ExistNodesTopAndRight()
        {
            var mosaic       = new Mosaic();
            var screen1      = new Screen(100, 200, "screen1");
            var screenTop1   = new Screen(100, 200, "screenTop1");
            var screenTop2   = new Screen(100, 200, "screenTop2");
            var screenRight1 = new Screen(100, 200, "screenRight1");
            var screenRight2 = new Screen(100, 200, "screenRight2");

            mosaic.AddNeighbor(screen1);
            mosaic.AddNeighbor(screen1, screenRight1, DirectionEnum.Right);
            mosaic.AddNeighbor(screenRight1, screenRight2, DirectionEnum.Right);

            mosaic.AddNeighbor(screen1, screenTop1, DirectionEnum.Up);
            mosaic.AddNeighbor(screenTop1, screenTop2, DirectionEnum.Up);


            var maker = new Maker(mosaic.Items);

            maker.Init();

            var nodes = maker.GetNodesTreePath();

            Assert.NotNull(mosaic);
            Assert.Equal(5, mosaic.Items.Count);
            Assert.NotNull(nodes);
            Assert.Equal(screen1, nodes[0].Screen);

            Assert.Equal(screenTop1, nodes[1].Screen);
            Assert.Equal(screenTop2, nodes[2].Screen);

            Assert.Equal(screenRight1, nodes[3].Screen);
            Assert.Equal(screenRight2, nodes[4].Screen);
        }
        public void Should_AddNeighborTwo_When_FormAStar()
        {
            var mosaic   = new Mosaic();
            var screen0  = new Screen(100, 200);
            var screen11 = new Screen(100, 200);
            var screen12 = new Screen(100, 200);
            var screen21 = new Screen(100, 200);
            var screen22 = new Screen(100, 200);
            var screen31 = new Screen(100, 200);
            var screen32 = new Screen(100, 200);
            var screen41 = new Screen(100, 200);
            var screen42 = new Screen(100, 200);

            mosaic.AddNeighbor(screen0);
            mosaic.AddNeighbor(screen0, screen11, DirectionEnum.Up);
            mosaic.AddNeighbor(screen11, screen12, DirectionEnum.Up);
            mosaic.AddNeighbor(screen0, screen21, DirectionEnum.Right);
            mosaic.AddNeighbor(screen21, screen22, DirectionEnum.Right);
            mosaic.AddNeighbor(screen0, screen31, DirectionEnum.Down);
            mosaic.AddNeighbor(screen31, screen32, DirectionEnum.Down);
            mosaic.AddNeighbor(screen0, screen41, DirectionEnum.Left);
            mosaic.AddNeighbor(screen41, screen42, DirectionEnum.Left);

            var maker = new Maker(mosaic.Items);

            maker.Init();


            Assert.NotNull(mosaic);
            Assert.Equal(9, mosaic.Items.Count);
            Assert.Equal(500, maker.Dimension.Width);
            Assert.Equal(1000, maker.Dimension.Height);
        }
        public void Should_AddNeighborOnlyOne_When_FormASquare()
        {
            var mosaic  = new Mosaic();
            var screen0 = new Screen(100, 200);
            var screen1 = new Screen(100, 200);
            var screen2 = new Screen(100, 200);
            var screen3 = new Screen(100, 200);
            var screen4 = new Screen(100, 200);

            mosaic.AddNeighbor(screen0);
            mosaic.AddNeighbor(screen0, screen1, DirectionEnum.Up);
            mosaic.AddNeighbor(screen0, screen2, DirectionEnum.Right);
            mosaic.AddNeighbor(screen0, screen3, DirectionEnum.Down);
            mosaic.AddNeighbor(screen0, screen4, DirectionEnum.Left);

            var maker = new Maker(mosaic.Items);

            maker.Init();


            Assert.NotNull(mosaic);
            Assert.Equal(5, mosaic.Items.Count);
            Assert.Equal(300, maker.Dimension.Width);
            Assert.Equal(600, maker.Dimension.Height);
        }
 protected MosaicDefinitionTransaction ToMosaicDefinitionTransaction(JObject tx, TransactionInfo txInfo)
 {
     return(new MosaicDefinitionTransaction(
                ExtractNetworkType(int.Parse(tx["version"].ToString())),
                ExtractVersion(int.Parse(tx["version"].ToString())),
                new Deadline(int.Parse(tx["deadline"].ToString())),
                ulong.Parse(tx["fee"].ToString()),
                new MosaicProperties(
                    int.Parse(tx["mosaicDefinition"]["properties"].ToList()[0]["value"].ToString()),
                    ulong.Parse(tx["mosaicDefinition"]["properties"].ToList()[1]["value"].ToString()),
                    bool.Parse(tx["mosaicDefinition"]["properties"].ToList()[2]["value"].ToString()),
                    bool.Parse(tx["mosaicDefinition"]["properties"].ToList()[3]["value"].ToString())),
                MosaicId.CreateFromMosaicIdentifier(tx["mosaicDefinition"]["id"]["namespaceId"] + ":" + tx["mosaicDefinition"]["id"]["name"]),
                tx["mosaicDefinition"]["levy"].ToString() == "{}"
             ? null
             : new MosaicLevy(
                    Mosaic.CreateFromIdentifier(
                        (tx["mosaicDefinition"]["levy"]["mosaicId"]["namespaceId"] + ":" + tx["mosaicDefinition"]["levy"]["mosaicId"]["name"]),
                        ulong.Parse(tx["mosaicDefinition"]["levy"]["fee"].ToString())),
                    int.Parse(tx["mosaicDefinition"]["levy"]["type"].ToString()),
                    Address.CreateFromEncoded(tx["mosaicDefinition"]["levy"]["recipient"].ToString())),
                new PublicAccount(tx["mosaicDefinition"]["creator"].ToString(), ExtractNetworkType(int.Parse(tx["version"].ToString()))),
                tx["mosaicDefinition"]["description"].ToString(),
                tx["signature"].ToString(),
                new PublicAccount(tx["signer"].ToString(), ExtractNetworkType(int.Parse(tx["version"].ToString()))),
                txInfo
                ));
 }
Beispiel #9
0
        public void Should_GetDimensionCorrect_When_AddThreeScreeenDistinctHeight()
        {
            var mosaic = new Mosaic();

            var screen1 = new Screen(200, 200);
            var screen2 = new Screen(100, 300);
            var screen3 = new Screen(200, 200);

            mosaic.AddNeighbor(screen1);
            mosaic.AddNeighbor(screen1, screen2, DirectionEnum.Right);
            mosaic.AddNeighbor(screen2, screen3, DirectionEnum.Right);

            Assert.NotNull(mosaic);
            Assert.Equal(3, mosaic.Items.Count);
            Assert.Equal(500, mosaic.Dimension.Width);
            Assert.Equal(300, mosaic.Dimension.Height);

            Assert.Equal(0, mosaic.Items[0].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[0].DimensionMosaic.Y);
            Assert.Equal(screen1.Dimension.Width, mosaic.Items[0].DimensionMosaic.Width);
            Assert.Equal(screen1.Dimension.Height, mosaic.Items[0].DimensionMosaic.Height);

            Assert.Equal(200, mosaic.Items[1].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[1].DimensionMosaic.Y);
            Assert.Equal(screen2.Dimension.Width, mosaic.Items[1].DimensionMosaic.Width);
            Assert.Equal(screen2.Dimension.Height, mosaic.Items[1].DimensionMosaic.Height);

            Assert.Equal(300, mosaic.Items[2].DimensionMosaic.X);
            Assert.Equal(0, mosaic.Items[2].DimensionMosaic.Y);
            Assert.Equal(screen3.Dimension.Width, mosaic.Items[2].DimensionMosaic.Width);
            Assert.Equal(screen3.Dimension.Height, mosaic.Items[2].DimensionMosaic.Height);
        }
        public async Task <Transaction> AggregateTransfer(Account from, Address to, Mosaic mosaic, IMessage message, string GenerationHash)
        {
            var transferTransaction = TransferTransaction.Create(
                Deadline.Create(),
                Recipient.From(to),
                new List <Mosaic>()
            {
                mosaic
            },
                message,
                NetworkType);

            var aggregateTransaction = AggregateTransaction.CreateComplete(
                Deadline.Create(),
                new List <Transaction>
            {
                transferTransaction.ToAggregate(from.PublicAccount)
            }, NetworkType);

            var signedTransaction = from.Sign(aggregateTransaction, GenerationHash);

            WatchForFailure(signedTransaction);

            var tx = SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(from.Address).Take(1);

            await SiriusClient.TransactionHttp.Announce(signedTransaction);

            var result = await tx;

            return(result);
        }
        public async Task AnnounceTransferTransactionWithMultipleMosaicsWithoutMessage()
        {
            var keyPair =
                KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain);

            var transaction = TransferTransaction.Create(
                NetworkType.Types.MIJIN_TEST,
                Deadline.CreateHours(2),
                Address.CreateFromEncoded("SAAA57-DREOPY-KUFX4O-G7IQXK-ITMBWK-D6KXTV-BBQP"),
                new List <Mosaic>()
            {
                Mosaic.CreateFromIdentifier("happy:test2", 10),
                Mosaic.CreateFromIdentifier("nem:xem", 10),
            },
                EmptyMessage.Create()
                ).SignWith(keyPair);

            await new TransactionHttp("http://" + Config.Domain + ":3000").Announce(transaction);

            listener.TransactionStatus(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST))
            .Subscribe(e => Console.WriteLine(e.Status));

            var status = await listener.ConfirmedTransactionsGiven(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST)).Take(1);

            Assert.AreEqual(keyPair.PublicKeyString, status.Signer.PublicKey);
        }
        public async Task AnnounceTransferTransactionWithMosaicWithMessage()
        {
            var keyPair = KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain);

            var account = new Account("E45030D2A22D97FDC4C78923C4BBF7602BBAC3B018FFAD2ED278FB49CD6F218C", NetworkType.Types.MIJIN_TEST);

            var transaction = TransferTransaction.Create(
                NetworkType.Types.MIJIN_TEST,
                Deadline.CreateHours(2),
                account.Address,
                new List <Mosaic> {
                Mosaic.CreateFromIdentifier("nem:xem", 100000000000)
            },
                PlainMessage.Create("hello")
                ).SignWith(keyPair);

            listener.TransactionStatus(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST))
            .Subscribe(e =>
            {
                Console.WriteLine(e.Status);
            });

            await new TransactionHttp("http://" + Config.Domain + ":3000").Announce(transaction);

            var status = await listener.ConfirmedTransactionsGiven(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST)).Take(1);

            Assert.AreEqual(keyPair.PublicKeyString, status.Signer.PublicKey);
        }
Beispiel #13
0
        public void RemoveScreen(string screenId)
        {
            var    id     = Guid.Parse(screenId);
            Mosaic mosaic = null;

            foreach (var m in Apps)
            {
                if (m.ExistItem(screenId))
                {
                    mosaic = m;
                }
            }

            if (mosaic != null)
            {
                var item = mosaic.GetItem(screenId);
                mosaic.Items.Remove(item);

                if (mosaic.Items.Any())
                {
                    Apps.Remove(mosaic);
                }
            }

            return;
        }
        public async Task <object> TestingTransfer(string from, string privateKey, string to, IAsset asset, decimal amount)
        {
            var nodeHttp    = new NodeHttp(_nemUrl);
            var networkType = await nodeHttp.GetNetworkType();

            var networkTime    = (int)(await nodeHttp.GetExtendedNodeInfo()).NisInfo.CurrentTime;
            var toAddressParts = to.Split(AddressSeparator);
            var message        = toAddressParts.Length > 1
                ? PlainMessage.Create(toAddressParts[1]) as IMessage
                : EmptyMessage.Create();
            var mosaic = Mosaic.CreateFromIdentifier(asset.AssetId, (ulong)asset.ToBaseUnit(amount));
            var fee    = await TransferTransaction.CalculateFee(networkType, message, new[] { mosaic }, new NamespaceMosaicHttp(_nemUrl));

            var tx = TransferTransaction.Create(
                networkType,
                new Deadline(networkTime + _expiresInSeconds),
                fee.fee,
                Address.CreateFromEncoded(toAddressParts[0]),
                new List <Mosaic> {
                mosaic
            },
                message,
                networkTime);
            var signed = tx.SignWith(KeyPair.CreateFromPrivateKey(privateKey));
            var result = await new TransactionHttp(_nemUrl).Announce(signed);

            return(result);
        }
Beispiel #15
0
        public ActionResult EditPartial(Mosaic mosaic)
        {
            if (ModelState.IsValid)
            {
                if (!String.IsNullOrEmpty(mosaic.Background))
                {
                    var name  = Path.GetFileName(mosaic.Background).Replace("/eAd.Website", "").Replace("Thumb", "");
                    var media = db.Media.Where(m => m.Location.Contains(name)).Single();
                    mosaic.Background = media.Location;
                }
                mosaic.Updated = DateTime.Now;

                var mosaicToSave = db.Mosaics.Where(m => m.MosaicID == mosaic.MosaicID).SingleOrDefault();
                if (mosaicToSave != null)
                {
                    mosaicToSave.Name       = mosaic.Name;
                    mosaicToSave.Background = mosaic.Background;
                    mosaicToSave.Updated    = mosaic.Updated;
                    mosaicToSave.Width      = mosaic.Width;
                    mosaicToSave.Height     = mosaic.Height;
                }


                //   db.Mosaics.Attach(mosaic);
                //   db.ObjectStateManager.ChangeObjectState(mosaic, EntityState.Modified);
                db.SaveChanges();
                return(Json("Successfully Saved Mosaic"));
            }
            return(Json("Please Check your inputs and save again"));
        }
Beispiel #16
0
        public Mosaic CreateOrUpdate(string screenId, int width, int height, string connectionId)
        {
            var    id     = Guid.Parse(screenId);
            Mosaic mosaic = GetByScreenId(screenId);

            if (mosaic == null)
            {
                //Create new mosaic
                mosaic = Create(screenId, width, height, connectionId);
            }
            else
            {
                //Update screen into mosaic
                foreach (var item in mosaic.Items)
                {
                    if (item.Screen.Id.Equals(id))
                    {
                        var screenNew = new Screen(id, width, height);
                        screenNew.SetConnectionId(connectionId);
                        item.Resize(screenNew);
                        break;
                    }
                }
            }

            return(mosaic);
        }
Beispiel #17
0
        public Mosaic Generate(string image, string srcImageDirectory)
        {
            var imageProcessing = new ProcessImage();
            var imageInfo       = new List <Imageinformation>();
            var _mosaic         = new Mosaic();

            var di    = new DirectoryInfo(srcImageDirectory);
            var files = di.GetFiles("*.jpg", SearchOption.AllDirectories).ToList();

            //Run through images in path and get the average color of the image
            Parallel.ForEach(files, f =>
            {
                using var inputBmp = imageProcessing.Resize(f.FullName);
                var info           = imageProcessing.GetAverageColor(inputBmp, f.FullName);
                if (info != null)
                {
                    imageInfo.Add(info);
                }
            });

            using (var source = new Bitmap(image))
            {
                var _colorMap = imageProcessing.CreateMap(source);
                _mosaic = imageProcessing.Render(source, _colorMap, imageInfo);
            }

            return(_mosaic);
        }
Beispiel #18
0
        //
        // POST: /Default1/Delete/5

        //     [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(long id)
        {
            try
            {
                Mosaic mosaic = db.Mosaics.Single(m => m.MosaicID == id);

                var positions = new List <Position>();
                foreach (var position in db.Positions.Where(p => p.MosaicID == id))
                {
                    positions.Add(position);
                }

                foreach (var position in positions)
                {
                    mosaic.Positions.Remove(position);
                }



                db.Mosaics.DeleteObject(mosaic);
                db.SaveChanges();
                return(Json("Sucessfully Deleted Mosaic", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("Failed To Delete Mosaic", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #19
0
        public void CreateANewMosaicWithIdentifier()
        {
            Mosaic mosaic = Mosaic.CreateFromIdentifier("nem:xem", 24);

            Assert.IsTrue(mosaic.MosaicId.HexId == Xem.Id.HexId);
            Assert.IsTrue(mosaic.Amount.Equals(24));
        }
        public async Task <Mosaic> CreateMosaic(string userId, string galleryId, string name, Stream stream)
        {
            var tempFile = Path.GetTempFileName();

            try
            {
                var mosaicId = name + "-" + Guid.NewGuid().ToString();
                using (var fileStream = File.OpenWrite(tempFile))
                {
                    Utilities.CopyStream(stream, fileStream);
                }

                var putRequest = new PutObjectRequest
                {
                    BucketName = this._appOptions.MosaicStorageBucket,
                    Key        = S3KeyManager.DetermineS3Key(userId, mosaicId, S3KeyManager.ImageType.Original),
                    FilePath   = tempFile
                };
                await this._s3Client.PutObjectAsync(putRequest).ConfigureAwait(false);

                var mosaic = new Mosaic
                {
                    UserId     = userId,
                    MosaicId   = mosaicId,
                    CreateDate = DateTime.UtcNow,
                    Name       = name,
                    Status     = Mosaic.Statuses.Creating
                };

                var input = new ExecutionInput
                {
                    TableGalleryItems = this._appOptions.TableGalleryItems,
                    TableMosaic       = this._appOptions.TableMosaic,
                    Bucket            = this._appOptions.MosaicStorageBucket,
                    SourceKey         = putRequest.Key,
                    GalleryId         = galleryId,
                    MosaicId          = mosaicId,
                    UserId            = userId
                };

                var stepResponse = await this._stepClient.StartExecutionAsync(new StartExecutionRequest
                {
                    StateMachineArn = this._appOptions.StateMachineArn,
                    Name            = $"{Utilities.MakeSafeName(putRequest.Key, 80)}",
                    Input           = JsonConvert.SerializeObject(input)
                }).ConfigureAwait(false);

                mosaic.ExecutionArn = stepResponse.ExecutionArn;
                await this._ddbContext.SaveAsync(mosaic).ConfigureAwait(false);

                return(mosaic);
            }
            finally
            {
                if (File.Exists(tempFile))
                {
                    File.Delete(tempFile);
                }
            }
        }
        public async Task AnnounceMultisigTransaction()
        {
            var cosignatory     = KeyPair.CreateFromPrivateKey("8db858dcc8e2827074498204b3829154ec4c4f24d13738d3f501003b518ef256");
            var multisigAccount = PublicAccount.CreateFromPublicKey("29c4a4aa674953749053c8a35399b37b713dedd5d002cb29b3331e56ff1ea65a", NetworkType.Types.TEST_NET);
            var recipient       = new Account("E45030D2A22D97FDC4C78923C4BBF7602BBAC3B018FFAD2ED278FB49CD6F218C", NetworkType.Types.TEST_NET);

            var transaction = TransferTransaction.Create(
                NetworkType.Types.TEST_NET,
                Deadline.CreateHours(2),
                recipient.Address,
                new List <Mosaic> {
                Mosaic.CreateFromIdentifier("nem:xem", 1000000)
            },
                PlainMessage.Create("hello")
                );

            var multisigTransaction = MultisigTransaction.Create(
                NetworkType.Types.TEST_NET,
                Deadline.CreateHours(1),
                transaction
                ).SignWith(cosignatory, multisigAccount);

            var response = await new TransactionHttp("http://" + Config.Domain + ":7890").Announce(multisigTransaction);

            Assert.AreEqual("SUCCESS", response.Message);
        }
Beispiel #22
0
        public void Should_GetAddScreen_When_AddScreen()
        {
            var element = new Element(20, 20);

            var mosaic = new Mosaic();

            var screens = new List <Screen>();

            for (int i = 1; i < 100; i++)
            {
                screens.Add(new Screen(300, 300));
            }

            mosaic.AddNeighbor(screens[0]); //First screen node
            for (int i = 1; i < screens.Count; i++)
            {
                mosaic.AddNeighbor(screens[i - 1], screens[i], DirectionEnum.Right);
            }



            //Move element Screen 3 > Location > 620:100
            element.Move(620, 100);
            var result = mosaic.WhereAreYou(element, screens[2]);

            Assert.Equal <int>(screens.Count, mosaic.Items.Count);
            Assert.Equal <int>(screens.Count * 300, mosaic.Dimension.Width);

            Assert.Equal <int>(1220, result.X);
            Assert.Equal <int>(100, result.Y);
        }
        public void CreateANewMosaicViaConstructor()
        {
            Mosaic mosaic = new Mosaic("nem", "xem", 24);

            Assert.IsTrue(mosaic.MosaicName.Equals("xem"));
            Assert.IsTrue(mosaic.Amount.Equals(24));
        }
Beispiel #24
0
        public static async Task <bool> SendFromNewAccount(String message, Account newAcc)
        {
            KeyPair keyPair = KeyPair.CreateFromPrivateKey(newAcc.PrivateKey);

            var transaction = TransferTransaction.Create(
                NetworkType.Types.TEST_NET,
                Deadline.CreateHours(2),
                Address.CreateFromEncoded(Config.Address),
                new List <Mosaic> {
                Mosaic.CreateFromIdentifier("nem:xem", 10)
            },
                SecureMessage.Create(message, newAcc.PrivateKey, Config.PublicKey)
                );

            TransactionHttp   transactionHttp   = new TransactionHttp("http://" + Config.Domain + ":7890");
            SignedTransaction signedTransaction = transaction.SignWith(keyPair);

            Thread.Sleep(2000);
            await transactionHttp.Announce(signedTransaction);

            Thread.Sleep(2000);
            Console.WriteLine(signedTransaction.Hash);
            Console.WriteLine(Config.Address + " recve something from : " + newAcc.Address.Plain);

            return(true);
        }
Beispiel #25
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="mosaic"></param>
 /// <param name="cost"></param>
 /// <param name="type"></param>
 /// <param name="duration"></param>
 public AddExchangeOffer(Mosaic mosaic, ulong cost, ExchangeOfferType type, ulong duration)
 {
     MosaicId     = mosaic.Id;
     MosaicAmount = mosaic.Amount;
     Cost         = cost;
     Type         = type;
     Duration     = duration;
 }
 public ExchangeOffer(Mosaic mosaic, ulong cost, ExchangeOfferType type, PublicAccount owner)
 {
     MosaicId     = mosaic.Id;
     MosaicAmount = mosaic.Amount;
     Cost         = cost;
     Type         = type;
     Owner        = owner;
 }
        public void CreateANewMosaicWithIdentifier()
        {
            Mosaic mosaic = Mosaic.CreateFromIdentifier("nem:xem", 24);

            Assert.IsTrue(mosaic.MosaicName == "xem");
            Assert.IsTrue(mosaic.NamespaceName == "nem");
            Assert.IsTrue(mosaic.Amount.Equals(24));
        }
Beispiel #28
0
        public void SetNormalizedSamples(int xWorldLocationMeters, int zWorldLocationMeters, int metersPerSample, float[,] normalizedSamples)
        {
            int sizeXSamples = normalizedSamples.GetLength(0);
            int sizeZSamples = normalizedSamples.GetLength(1);

            float[,] diffArray = new float[sizeXSamples, sizeZSamples];

            bool wasModified = Mosaic.Modified;

            try
            {
                changeNotificationEnabled = false;

                // Calculate the heights and set them
                {
                    int worldZMeters = zWorldLocationMeters;
                    for (int sampleZ = 0; sampleZ < sizeZSamples; sampleZ++)
                    {
                        int worldXMeters = xWorldLocationMeters;
                        for (int sampleX = 0; sampleX < sizeXSamples; sampleX++)
                        {
                            float heightNormalized = normalizedSamples[sampleX, sampleZ];

                            // Make sure the normalized height is within the proper bounds
                            if (heightNormalized < 0)
                            {
                                heightNormalized = 0;
                            }
                            else if (heightNormalized > 1)
                            {
                                heightNormalized = 1;
                            }

                            float heightMM = ConvertNormalizedHeightToMM(heightNormalized);
                            diffArray[sampleX, sampleZ] = heightMM - Mosaic.GetWorldHeightMM(worldXMeters, worldZMeters);

                            worldXMeters += metersPerSample;
                        }

                        worldZMeters += metersPerSample;
                    }

                    Mosaic.AdjustWorldSamplesMM(xWorldLocationMeters, zWorldLocationMeters, metersPerSample, diffArray);
                }
            }
            finally
            {
                changeNotificationEnabled = true;

                if (Modified != wasModified)
                {
                    FireTerrainModificationStateChanged();
                }

                FireTerrainChanged(xWorldLocationMeters, zWorldLocationMeters, sizeXSamples * metersPerSample, sizeZSamples * metersPerSample);
            }
        }
Beispiel #29
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="networkType"></param>
 /// <param name="version"></param>
 /// <param name="deadline"></param>
 /// <param name="maxFee"></param>
 /// <param name="mosaic"></param>
 /// <param name="duration"></param>
 /// <param name="transaction"></param>
 /// <param name="signature"></param>
 /// <param name="signer"></param>
 /// <param name="transactionInfo"></param>
 public LockFundsTransaction(NetworkType networkType, int version, Deadline deadline, ulong?maxFee,
                             Mosaic mosaic, ulong duration, SignedTransaction transaction, string signature = null,
                             PublicAccount signer = null, TransactionInfo transactionInfo = null)
     : base(networkType, version, EntityType.LOCK, deadline, maxFee, signature, signer, transactionInfo)
 {
     Mosaic      = mosaic;
     Duration    = duration;
     Transaction = transaction;
 }
Beispiel #30
0
 // Start is called before the first frame update
 void Start()
 {
     script = GetComponent <Mosaic>();
     script.SetSize(100.0f);
     do
     {
         script.SetSize(script.GetSize() - 1.0f);
     } while (script.GetSize() <= 0);
 }