Exemplo n.º 1
0
        public void Write(BabylonScene babylonScene, string outputBabylonDirectory, string outputFileName, string outputFormat, bool generateManifest)
        {
            var outputFile = Path.Combine(outputBabylonDirectory, outputFileName);

            RaiseMessage("Saving to output file " + outputFile);

            var jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings());
            var sb             = new StringBuilder();
            var sw             = new StringWriter(sb, CultureInfo.InvariantCulture);

            using (var jsonWriter = new JsonTextWriterOptimized(sw))
            {
                jsonWriter.Formatting = Formatting.None;
                jsonSerializer.Serialize(jsonWriter, babylonScene);
            }
            File.WriteAllText(outputFile, sb.ToString());

            if (generateManifest)
            {
                File.WriteAllText(outputFile + ".manifest",
                                  "{\r\n\"version\" : 1,\r\n\"enableSceneOffline\" : true,\r\n\"enableTexturesOffline\" : true\r\n}");
            }

            // Binary
            if (outputFormat == "binary babylon")
            {
                RaiseMessage("Generating binary files");
                BinaryConverter.Convert(outputFile, outputBabylonDirectory + "\\Binary",
                                        message => RaiseMessage(message, 1),
                                        error => RaiseError(error, 1));
            }
        }
Exemplo n.º 2
0
        public void TestBinaryConverter()
        {
            string answer;

            answer = BinaryConverter.Convert(2);
            Console.WriteLine(answer);
            Assert.AreEqual(10, Int32.Parse(answer));

            answer = BinaryConverter.Convert(3);
            Console.WriteLine(answer);
            Assert.AreEqual(11, Int32.Parse(answer));

            answer = BinaryConverter.Convert(4);
            Console.WriteLine(answer);
            Assert.AreEqual(100, Int32.Parse(answer));

            answer = BinaryConverter.Convert(5);
            Console.WriteLine(answer);
            Assert.AreEqual(101, Int32.Parse(answer));

            answer = BinaryConverter.Convert(15);
            Console.WriteLine(answer);
            Assert.AreEqual(1111, Int32.Parse(answer));

            answer = BinaryConverter.Convert(15);
            Console.WriteLine(answer);
            Assert.AreEqual(1111, Int32.Parse(answer));

            answer = BinaryConverter.Convert(133);
            Console.WriteLine(answer);
            Assert.AreEqual(10000101, Int32.Parse(answer));
        }
Exemplo n.º 3
0
        public void Binary_Converter_Test()
        {
            IConverter binaryConverter = new BinaryConverter(new DecimalNumber("123.456"));
            var        converted       = binaryConverter.Convert();

            converted.IntegerPart.Should().Be("1111011");
            converted.FloatPart.Should().Be("011101");
            converted.Base.Should().Be(2);
            converted.ToString().Should().Be("1111011.011101");

            binaryConverter = new BinaryConverter(new OctalNumber("123.456"));
            converted       = binaryConverter.Convert();
            converted.IntegerPart.Should().Be("1010011");
            converted.FloatPart.Should().Be("100101");
            converted.Base.Should().Be(2);
            converted.ToString().Should().Be("1010011.100101");

            binaryConverter = new BinaryConverter(new HexadecimalNumber("123.456"));
            converted       = binaryConverter.Convert();
            converted.IntegerPart.Should().Be("100100011");
            converted.FloatPart.Should().Be("010001");
            converted.Base.Should().Be(2);
            converted.ToString().Should().Be("100100011.010001");

            binaryConverter = new BinaryConverter(new BinaryNumber("101.111"));
            converted       = binaryConverter.Convert();
            converted.IntegerPart.Should().Be("101");
            converted.FloatPart.Should().Be("111");
            converted.Base.Should().Be(2);
            converted.ToString().Should().Be("101.111");
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var grid = BinaryConverter.Convert(feature.Value);

            if (grid != null)
            {
                var desired   = grid.AsBoolean();
                var available = device.IsGrid;
                return(desired == available);
            }

            return(false);
        }
        public void BinaryConverter_Tests(int N, string expected)
        {
            var bin = BinaryConverter.Convert(N);

            var actual = new StringBuilder(bin.Count);

            while (bin.Count > 0)
            {
                actual.Append(bin.Pop());
            }

            Assert.AreEqual(expected, actual.ToString());
        }
Exemplo n.º 6
0
 public void ConvertThrowsExceptionWhenValueIsNotABool()
 {
     _converter.Convert("-forced_subs_only", 0);
 }