Ejemplo n.º 1
0
        public static async Task Dds2Spr(string path)
        {
            var file       = File.Open(path, FileMode.Open);
            var serializer = new BinarySerializer();

#if DEBUG
            serializer.MemberDeserialized += OnMemberDeserialized;
#endif
            var tex = await serializer.DeserializeAsync <SpriteFile>(file);

            var ddsFiles = Directory.EnumerateFiles(Path.GetDirectoryName(path)).Where(f => Path.GetExtension(f) == ".dds");
            var counter  = 0;

            foreach (var ddsFile in ddsFiles)
            {
                using (var ddsEdit = new FileStream(ddsFile, FileMode.Open))
                {
                    var dds = await serializer.DeserializeAsync <DdsFile>(ddsEdit);

                    tex.Atlas.Textures[counter++].Mipmaps[0] = dds.ToTxpMip();
                }
            }

            file = new FileStream(path, FileMode.Create);

            await serializer.SerializeAsync(file, tex);
        }
Ejemplo n.º 2
0
        public async Task FromArray()
        {
            var Message = await BinarySerializer.DeserializeAsync <Message>(RequestBytes);

            Assert.AreEqual(Message.ID, 39922);
            Assert.AreEqual(MessageType.Query, Message.MessageType);
            Assert.AreEqual(OperationCode.Query, Message.OperationCode);
            Assert.AreEqual(AuthoritativeAnswer.Cache, Message.AuthoritativeAnswer);
            Assert.AreEqual(false, Message.Truncated);
            Assert.AreEqual(true, Message.RecursionDesired);
            Assert.AreEqual(false, Message.RecursionAvailable);
            Assert.AreEqual(0, Message.Zero);
            Assert.AreEqual(false, Message.AuthenticatedData);
            Assert.AreEqual(false, Message.CheckingDisabled);
            Assert.AreEqual(ResponseCode.NoError, Message.ResponseCode);
            Assert.AreEqual(1, Message.QuestionsCount);
            Assert.AreEqual(0, Message.AnswersCount);
            Assert.AreEqual(0, Message.AuthorityCount);
            Assert.AreEqual(0, Message.AdditionalCount);


            Assert.IsNotNull(Message.Questions);
            var Question = Message.Questions?.First();

            Assert.IsNotNull(Question);
            Assert.AreEqual(RecordType.A, Question.Type);
            Assert.AreEqual(RecordClass.Internet, Question.Class);
            Assert.AreEqual("facebook.com", Question.Domain.Name);
        }
        public static async Task RunAsync()
        {
            // Create a full text index with a custom key type
            var index = new FullTextIndexBuilder <CompositeKey>().Build();

            // Index some sample data
            await index.AddAsync(new CompositeKey(1, 9), "This is some text associated with A: fizz");

            await index.AddAsync(new CompositeKey(2, 9), "Some buzz text for B");

            await index.AddAsync(new CompositeKey(3, 11), "Text associated with C is both fizz and buzz");

            // This would error with: No standard key serializer exists for type CompositeKey -
            //    please provide a custom implementation of IKeySerializer<> when serializing/deserializing.
            // var serializer = new BinarySerializer<int>();

            var serializer = new BinarySerializer <CompositeKey>(new CompositeKeySerializer());

            using var stream = new MemoryStream();

            // Serialize the index
            await serializer.SerializeAsync(index, stream, disposeStream : false);

            // Deserialize the index into a new instance
            stream.Position = 0;
            var newIndex = new FullTextIndexBuilder <CompositeKey>().Build();
            await serializer.DeserializeAsync(newIndex, stream, disposeStream : false);

            // Prove that the new index has the same contents and the keys have round-tripped
            // Emits: only (3, 11) contains Fizz & Buzz
            var match = newIndex.Search("fizz & buzz").Single();

            Console.WriteLine($"Only ({match.Key.UserId}, {match.Key.CompanyId}) contains Fizz & Buzz");
        }
Ejemplo n.º 4
0
        public async Task ResolveAsync(UdpReceiveResult UdpReceiveResult)
        {
            ushort ID = 0;

            try
            {
                var Request = await BinarySerializer.DeserializeAsync <Message>(UdpReceiveResult.Buffer);

                ID = Request.ID;
                var Response = await ResponsibilityChain.Execute(Request);

                var ResponseBytes = await BinarySerializer.SerializeAsync(Response);

                await UdpClient.SendAsync(ResponseBytes, ResponseBytes.Length, UdpReceiveResult.RemoteEndPoint);
            }
            catch (Exception Error)
            {
                var Response = new Message()
                {
                    ID           = ID,
                    MessageType  = MessageType.Response,
                    ResponseCode = ResponseCode.FormatError,
                };

                var ResponseBytes = Response.ToArray();

                await UdpClient.SendAsync(ResponseBytes, ResponseBytes.Length, UdpReceiveResult.RemoteEndPoint);

                //Console.WriteLine(Error);
            }
        }
Ejemplo n.º 5
0
        public async Task DeserializeFromPipeSpeedTest()
        {
            var binarySerializer = new BinarySerializer(new StandartBinarySerializer(), new StandartBinaryDeserializer(), BinarySerializerStuffTest.Converters);

            var mock = RecursiveMock <RecursiveMock <RecursiveMock <RecursiveMock <RecursiveMock <int> > > > > .Create(
                RecursiveMock <RecursiveMock <RecursiveMock <RecursiveMock <int> > > > .Create(
                    RecursiveMock <RecursiveMock <RecursiveMock <int> > > .Create(
                        RecursiveMock <RecursiveMock <int> > .Create(
                            RecursiveMock <int> .Create(int.MaxValue
                                                        )
                            )
                        )
                    )
                );

            var serialize = binarySerializer.Serialize(mock);

            var sw = Stopwatch.StartNew();

            for (var i = 0; i < 10000; i++)
            {
                var pipe = PipeReader.Create(new MemoryStream(serialize.Result.ToArray()));
                sw.Start();
                var data = await binarySerializer.DeserializeAsync <long, RecursiveMock <RecursiveMock <RecursiveMock <RecursiveMock <RecursiveMock <int> > > > > >(pipe, CancellationToken.None);

                sw.Stop();
                Assert.NotNull(data);
            }

            Assert.Less(sw.ElapsedMilliseconds, 300);
            TestContext.WriteLine($"Deserialize: {sw.Elapsed.ToString()}");
        }
Ejemplo n.º 6
0
        public static async Task RunAsync()
        {
            // Create a full text index with default settings
            var index = new FullTextIndexBuilder <int>().Build();

            // Index some sample data
            await index.AddAsync(1, "This is some text associated with A: fizz");

            await index.AddAsync(2, "Some buzz text for B");

            await index.AddAsync(3, "Text associated with C is both fizz and buzz");

            var serializer = new BinarySerializer <int>();

            using var stream = new MemoryStream();

            // Serialize the index
            await serializer.SerializeAsync(index, stream, disposeStream : false);

            // Deserialize the index into a new instance
            stream.Position = 0;
            var newIndex = new FullTextIndexBuilder <int>().Build();
            await serializer.DeserializeAsync(newIndex, stream, disposeStream : false);

            // Prove that the new index has the same contents
            // Emits: 3 items contain text in the new index
            var matches = newIndex.Search("text");

            Console.WriteLine($"{matches.Count()} items contain text in the new index");
        }
Ejemplo n.º 7
0
        public async Task <byte[]> ResolveAsync(byte[] Query)
        {
            var Request = await BinarySerializer.DeserializeAsync <Message>(Query);

            var Response = await ResolveAsync(Request);

            return(await BinarySerializer.SerializeAsync(Response));
        }
Ejemplo n.º 8
0
        public async Task <IMessage> ResolveAsync(IMessage Message)
        {
            var RequestBytes = await BinarySerializer.SerializeAsync(Message);

            var ResponseBytes = await ResolveAsync(RequestBytes);

            return(await BinarySerializer.DeserializeAsync <Message>(ResponseBytes));
        }
Ejemplo n.º 9
0
        public async Task BytesAsync()
        {
            var RequestBytes = await BinarySerializer.SerializeAsync(RequestMessage);

            var ResponseBytes = await Resolver.ResolveAsync(RequestBytes);

            ResponseMessage = await BinarySerializer.DeserializeAsync <Message>(ResponseBytes);

            Assertions();
        }
Ejemplo n.º 10
0
        public virtual async ValueTask <IMessage> ResolveAsync(IMessage Query)
        {
            var SerializedQuery = await BinarySerializer.SerializeAsync(Query);

            var SerializedAnswer = await ResolveAsync(SerializedQuery);

            var AnswerMessage = await BinarySerializer.DeserializeAsync <Message>(SerializedAnswer);

            return(AnswerMessage);
        }
Ejemplo n.º 11
0
        protected T Deserialize <T>(Stream stream, object context = null)
        {
#if TESTASYNC
            var task = Serializer.DeserializeAsync <T>(stream, context);
            task.ConfigureAwait(false);
            task.Wait();
            return(task.Result);
#else
            return(Serializer.Deserialize <T>(stream, context));
#endif
        }
Ejemplo n.º 12
0
        protected T DeserializeBe <T>(Stream stream)
        {
#if TESTASYNC
            var task = SerializerBe.DeserializeAsync <T>(stream);
            task.ConfigureAwait(false);
            task.Wait();
            return(task.Result);
#else
            return(SerializerBe.Deserialize <T>(stream));
#endif
        }
Ejemplo n.º 13
0
        public async Task <Message> Run(Message Message, Func <Message, Task <Message> > Next)
        {
            //Using Binary Format Over HTTPs

            var RequestBytes = await BinarySerializer.SerializeAsync(Message);

            var ResponseBytes = await ResolveAsync(RequestBytes);

            Message = await BinarySerializer.DeserializeAsync <Message>(ResponseBytes);

            return(Next is null ? Message : await Next(Message));
        }
Ejemplo n.º 14
0
        public async Task SerializeWithPoolDeserializeFromPipeRecursiveComposeValueTypeTest()
        {
            var binarySerializer = new BinarySerializer(new ArrayPoolBinarySerializer(), new StandartBinaryDeserializer(), BinarySerializerStuffTest.Converters);

            var mock = RecursiveMock <int> .Create(1337);

            var serialize = binarySerializer.Serialize(mock);
            var pipe      = PipeReader.Create(new MemoryStream(serialize.Result.ToArray()));
            var data      = await binarySerializer.DeserializeAsync <long, RecursiveMock <int> >(pipe, CancellationToken.None);

            Assert.NotNull(data);
        }
Ejemplo n.º 15
0
        public async Task ShouldDeserializeV2Index()
        {
            var index      = new FullTextIndexBuilder <string>().Build();
            var serializer = new BinarySerializer <string>();

            using (var stream = new MemoryStream(TestResources.v2Index))
            {
                await serializer.DeserializeAsync(index, stream);
            }

            index.Search("serialized").Should().HaveCount(1);
            index.Search("亜").Should().HaveCount(1);
        }
Ejemplo n.º 16
0
        public async Task <(Log _log, byte[] _response)> NewMessageAsync(byte[] bytes)
        {
            try
            {
                var serializer = new BinarySerializer();
                var message    = await serializer.DeserializeAsync <SocketMessage>(bytes);

                var log = new Log()
                {
                    CreatedOn      = DateTime.UtcNow,
                    MobileID       = message.OptionsHeader.MobileID.ToHex(),
                    ServiceType    = message.Header.ServiceType.ToString(),
                    MessageType    = message.Header.MessageType.ToString(),
                    SequenceNumber = message.Header.SequenceNumber,

                    RawData = bytes.ToHex(),
                    Decoded = message
                };

                if (message.Contents.GetType().IsAssignableTo <BaseReportContents>())
                {
                    var contents = message.Contents as BaseReportContents;
                    log.UpdateTime = contents.UpdateTime.ToDateTime();
                    log.Latitude   = contents.Latitude;
                    log.Longitude  = contents.Longitude;
                    log.Altitude   = contents.Altitude;
                    log.Speed      = contents.Speed * 0.036; //1cm/s=1/1000000cm/1/3600s=0.036km/h
                    log.Heading    = contents.Heading;
                    if (message.Contents.GetType().IsAssignableTo <EventReportMessage>())
                    {
                        var er        = message.Contents as EventReportMessage;
                        var codevalue = string.Empty;
                        if (!DicEventCode.TryGetValue(er.EventCode, out codevalue))
                        {
                            codevalue = string.Format("No Definition EventCode{0}", er.EventCode);
                        }

                        log.EventCode = codevalue;
                    }
                }

                await _repository.InsertOneAsync(log);

                return(log, Response(message, serializer));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null, null);
            }
        }
Ejemplo n.º 17
0
        public async Task <IMessage> ResolveAsync(IMessage Query)
        {
            var Buffer = await BinarySerializer.SerializeAsync(Query);

            await Client.SendAsync(Buffer, Buffer.Length, IPEndPoint);

            var Task = Client.ReceiveAsync();

            Task.Wait(Timeout);

            var Result = Task.IsCompleted ? Task.Result : throw new TimeoutException();

            return(await BinarySerializer.DeserializeAsync <Message>(Result.Buffer));
        }
Ejemplo n.º 18
0
        public async Task SerializeWithPoolDeserializeFromPipeReaderTest()
        {
            var       binarySerializer    = new BinarySerializer(new ArrayPoolBinarySerializer(), new StandartBinaryDeserializer(), BinarySerializerStuffTest.Converters);
            var       ethalon             = Mock.Default();
            const int ethalonHeaderLength = 270;

            var serialize = binarySerializer.Serialize(ethalon);

            Assert.IsTrue(serialize.Length == ethalon.Size + ethalonHeaderLength);
            var deserialize = await binarySerializer.DeserializeAsync <long, Mock>(PipeReader.Create(new MemoryStream(serialize.Result.ToArray())), CancellationToken.None);

            Assert.IsTrue(ethalon.Equals(deserialize.Result));
            serialize.Dispose();
        }
Ejemplo n.º 19
0
        static async Task Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("DIVAFILE Converter\r\n----------------------------------------------------\r\n" +
                                  "Converts files to DIVAFILE encryption and vice versa.\r\n\r\nUsage:\r\n" +
                                  "    Just drag\'n\'drop\r\n\r\nTested:\r\n    Project Diva F2nd");
                Console.Read();
                return;
            }

            var serializer = new BinarySerializer();

            if (Directory.Exists(args[0]))
            {
            }


            using (var file = new FileStream(args[0], FileMode.Open))
            {
                if (file.Length == 0)
                {
                    throw new IOException("File contains no data");
                }

                if (DivaFile.IsValid(file))
                {
                    var divaFile = await serializer.DeserializeAsync <DivaFile>(file);

                    var decrypt = divaFile.DecryptBytes();
                    file.Close();
                    using (var save = new FileStream(args[0], FileMode.Create))
                    {
                        await serializer.SerializeAsync(save, decrypt);
                    }
                }
                else
                {
                    var divaFile = new DivaFile(file);
                    //divaFile.EncryptedData = new MemoryStream(divaFile.EncryptedData);
                    file.Close();
                    using (var save = new FileStream(args[0], FileMode.Create))
                    {
                        await serializer.SerializeAsync(save, divaFile);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private static async Task <FullTextIndex <string> > SearializeAndDeserializeIndexWithText(string text)
        {
            var stream     = new MemoryStream();
            var serializer = new BinarySerializer <string>();
            var index      = new FullTextIndexBuilder <string>().Build();
            await index.AddAsync("A", text);

            await serializer.SerializeAsync(index, stream, false);

            stream.Position = 0;

            var index2 = new FullTextIndexBuilder <string>().Build();
            await serializer.DeserializeAsync(index2, stream);

            return(index2);
        }
Ejemplo n.º 21
0
        public async Task QueryAsync()
        {
            ResponseMessage = await Resolver.ResolveAsync(RequestMessage);

            Assert.AreEqual(ID, ResponseMessage.ID);
            Assert.IsNotNull(ResponseMessage.Questions);
            Assert.IsNotNull(ResponseMessage.Answers);
            Assert.IsInstanceOfType(ResponseMessage.Answers[0].Record, typeof(DNS.Records.TXT));


            var BinarySerializer = new BinarySerializer();

            var Bytes = await BinarySerializer.SerializeAsync(ResponseMessage);

            ResponseMessage = await BinarySerializer.DeserializeAsync <Message>(Bytes);
        }
Ejemplo n.º 22
0
        public async Task <IMessage> ResolveAsync(IMessage Request)
        {
            if (!TcpClient.Connected || !SslStream.CanWrite)
            {
                await InitializeAsync();
            }

            var Bytes = await BinarySerializer.SerializeAsync(Request);

            var Length = BitConverter.GetBytes((ushort)Bytes.Length);

            Array.Reverse(Length);

            await PipeWriter.WriteAsync(Length);

            await PipeWriter.WriteAsync(Bytes);

            PipeWriter.Complete();

            var Task = PipeReader.ReadAsync().AsTask();

            Task.Wait(Options.CurrentValue.Timeout);

            if (Task.IsCompleted)
            {
                var Result = Task.Result;

                var Buffer = Result.Buffer.Length > 14
                    ? Result.Buffer.Slice(2)
                    : throw new OperationCanceledException();

                var Response = await BinarySerializer.DeserializeAsync <Message>(Buffer);

                PipeReader.Complete();

                return(Response);
            }
            else
            {
                PipeReader.CancelPendingRead();

                PipeReader.Complete();

                throw new TimeoutException();
            }
        }
Ejemplo n.º 23
0
        public async Task Test_Diff_Obj_Ctor_Complex()
        {
            var a = createComplexCtorC(1);

            byte[] data = BinarySerializer.Serialize(a);
            var    b    = BinarySerializer.Deserialize <DiffTestCtorC>(data);

            Assert.NotNull(b);

            MemoryStream ms = new MemoryStream();
            await BinarySerializer.SerializeAsync(ms, a);

            ms.Position = 0;

            b = await BinarySerializer.DeserializeAsync <DiffTestCtorC>(ms);

            Assert.NotNull(b);
        }
Ejemplo n.º 24
0
        protected override async ValueTask InitializeAsync()
        {
            var Query = new Message()
            {
                ID               = (ushort)Random.Next(),
                MessageType      = MessageType.Query,
                Truncated        = false,
                CheckingDisabled = true,
                RecursionDesired = true,
                Questions        = new List <IQuestion>()
                {
                    new Question()
                    {
                        Type   = RecordType.TXT,
                        Class  = RecordClass.Internet,
                        Domain = Domain.FromString(Stamp.ProviderName)
                    }
                }
            };

            var SerializedQuery = await BinarySerializer.SerializeAsync(Query);

            await Client.SendAsync(SerializedQuery, SerializedQuery.Length, IPEndPoint);

            var Task = Client.ReceiveAsync();

            Task.Wait(Options.CurrentValue.Timeout);

            var SerializedAnswer = Task.IsCompleted ? Task.Result.Buffer : throw new TimeoutException();

            var AnswerMessage = await BinarySerializer.DeserializeAsync <Message>(SerializedAnswer);

            var IsValid = await VerifyServer(AnswerMessage);

            if (!IsValid)
            {
                throw new CryptographicUnexpectedOperationException("Invalid Server Certificate.");
            }

            SharedKey = MontgomeryCurve25519.KeyExchange(Certificate.PublicKey, ClientPrivateKey);

            IsInitialized = true;
        }
Ejemplo n.º 25
0
        public async Task ShouldRoundTripIndexStructure()
        {
            var serializer = new BinarySerializer <string>();

            var fileName = Guid.NewGuid().ToString() + ".dat";

            using (var stream = File.Open(fileName, FileMode.CreateNew))
            {
                var stopwatch = Stopwatch.StartNew();
                var index     = await CreateWikipediaIndexAsync();

                await serializer.SerializeAsync(index, stream, false);

                this.output.WriteLine($"Serialized in {stopwatch.ElapsedMilliseconds}ms");

                stream.Length.Should().BeGreaterThan(4);

                var newIndex = new FullTextIndexBuilder <string>().Build();

                stream.Position = 0;

                stopwatch.Restart();
                await serializer.DeserializeAsync(newIndex, stream, false);

                this.output.WriteLine($"Deserialized in {stopwatch.ElapsedMilliseconds}ms");

                newIndex.Items.GetIndexedItems().Should().BeEquivalentTo(index.Items.GetIndexedItems());
                newIndex.Count.Should().Be(index.Count);
                newIndex.Root.ToString().Should().Be(index.Root.ToString());

                var oldResults = index.Search("test").ToList();
                var newResults = newIndex.Search("test").ToList();

                oldResults.Should().NotBeEmpty();
                newResults.Should().BeEquivalentTo(oldResults);

                newIndex.Search("🤷‍♀️").Should().HaveCount(1);
            }

            File.Delete(fileName);
        }
Ejemplo n.º 26
0
        public static async Task Spr2Dds(string path)
        {
            var file       = File.Open(path, FileMode.Open);
            var parentPath = Path.GetDirectoryName(path);
            var serializer = new BinarySerializer();

#if DEBUG
            serializer.MemberDeserialized += OnMemberDeserialized;
#endif
            var tex = await serializer.DeserializeAsync <SpriteFile>(file);

            file.Close();
            var tst = 0;

            foreach (var txpTexture in tex.Atlas.Textures)
            {
                using (var save = new FileStream($"{parentPath}\\{tex.Header.TextureNames[tst++]}.dds", FileMode.Create))
                {
                    await serializer.SerializeAsync(save, (DdsFile)txpTexture);
                }
            }
        }
Ejemplo n.º 27
0
        public async Task Test <T>(T input, Action <T> check, BinarySerializerOptions options = null)
        {
            MemoryStream ms = new MemoryStream();
            await BinarySerializer.SerializeAsync <T>(ms, input, options);

            ms.Position = 0;

            T b = await BinarySerializer.DeserializeAsync <T>(ms, options);

            check(b);

            ms.Position = 0;
            object b1 = await BinarySerializer.DeserializeAsync(ms, options);

            check((T)b1);

            byte[] bytes = BinarySerializer.Serialize <T>(input, options);
            T      b2    = BinarySerializer.Deserialize <T>(bytes, options);

            check(b2);

            b1 = BinarySerializer.Deserialize(bytes, options);
            check((T)b1);
        }
Ejemplo n.º 28
0
 public static async ValueTask <T> DeserializeAsync <T>(this BinarySerializer Serializer, ReadOnlySequence <byte> ReadOnlySequence)
 {
     return(await Serializer.DeserializeAsync <T>(ReadOnlySequence.AsStream()));
 }
Ejemplo n.º 29
0
        static async Task Main(string[] args)
        {
#if DEBUG
            //using (var file = File.Open(@"D:\Emulators\RPSC3\dev_hdd0\game\NPJB00134\USRDIR\rom\script\pv_007_extreme.dsc", FileMode.Open))
            //using (var file = File.Open(@"D:\Emulators\RPSC3\dev_hdd0\disc\BLJM60527\PS3_GAME\USRDIR\rom\script\pv600\pv_600_extreme.dsc", FileMode.Open))
            var path = @"D:\dsc\pv_611_extreme.dsc";
            path = @"D:\DIVATools\test_files\dsc\pv_717_normal.dsc";
            using (var file = File.Open(path, FileMode.Open))
            {
                var serial = new BinarySerializer();
                //serial.Endianness = Endianness.Big;
                serial.MemberDeserialized += OnMemberDeserialized;
                //file.Position = 68;
                var dsc = await serial.DeserializeAsync <DscFile2>(file);


                var notesWrapper = dsc.Functions.Where(func => func.Function.GetType() == typeof(FTarget)).ToList();
                var indices      = notesWrapper.Select(note => dsc.Functions.FindIndex(elem => elem == note)).ToList();
                var timesWrapper = indices.Select(i => dsc.Functions[i - 1]).ToList();

                var times = timesWrapper.Select(wrapper => wrapper.Function).Where(time => time.GetType() == typeof(FTime)).ToList();
                var notes = notesWrapper.Select(wrapper => wrapper.Function).ToList();

                /*
                 *      using (var save = new StreamWriter(Path.ChangeExtension(path, ".xml")))
                 *      {
                 *          save.WriteLine(@",timestamp,type,holdLength,bIsHoldEnd,posX,posY,entryAngle,oscillationFrequency,oscillationAngle,oscillationAmplitude,timeout");
                 *          for (var i = 0; i < times.Count; ++i)
                 *          {
                 *              var time = (FTime)times[i];
                 *              var note = (FTarget) notes[i];
                 *              save.WriteLine($"{i},{(time.TimeStamp > 0 ? time.TimeStamp/1000 : -1)},{note.Type},{note.HoldLength},{note.IsHoldEnd},{note.Position.x/10000},{note.Position.y / 10000}," +
                 *                             $"{note.EntryAngle},{note.OscillationFrequency},{note.OscillationAngle},{note.OscillationAmplitude},{note.TimeOut/1000}");
                 *          }
                 *      }
                 */
                return;
            }
            return;
#endif
            if (args.Length < 1)
            {
                Console.WriteLine("FDSC Tool");
                Console.WriteLine("=========");
                Console.WriteLine("Converter for all Project Diva DSC(Diva Script Container) files.\n");
                Console.WriteLine("Currently Supports:");
                Console.WriteLine("	- All DT games");
                Console.WriteLine("	- F");
                Console.WriteLine("	- F2nd\n");
                Console.WriteLine("Usage:");
                Console.WriteLine("	Drag'n'Drop the file onto the application\n");
                Console.WriteLine("	or\n");
                Console.WriteLine("	Run from command line:");
                Console.WriteLine("	");
                Console.WriteLine("	FDSC [source] ");
                Console.WriteLine("	Source is a URI to your dsc file");
                Console.ReadLine();
            }

            if (!File.Exists(args[0]))
            {
                throw new IOException("file doesn't exist.");
            }

            if (File.GetAttributes(args[0]).HasFlag(FileAttributes.Directory))
            {
                throw new NotImplementedException("FDSC doesn't support batch conversion currently.");
            }

            switch (Path.GetExtension(args[0]))
            {
            case ".dsc": DscConvert(args[0]); break;

            case ".xml": XmlConvert(args[0]); break;
            }

            Console.Write("Conversion Complete!\n");
            Console.ReadLine();
        }
Ejemplo n.º 30
0
        public static async Task <Question> FromArrayAsync(byte[] Bytes)
        {
            var Serializer = new BinarySerializer();

            return(await Serializer.DeserializeAsync <Question>(Bytes));
        }