Пример #1
0
        public void ComplexTests()
        {
            TestClass complexTests = new()
            {
                BaseComplex = new Vector2(10, 20),
                Struct      = new Vector2(14.0f, 15.0f),
                Class       = new InClass(16, 17),
            };

            string actual = RronConvert.SerializeObject(complexTests, new[]
            {
                nameof(TestClass.BaseSingle),
                nameof(TestClass.Bool),
                nameof(TestClass.Byte),
                nameof(TestClass.Sbyte),
                nameof(TestClass.Char),
                nameof(TestClass.Decimal),
                nameof(TestClass.Double),
                nameof(TestClass.Float),
                nameof(TestClass.Int),
                nameof(TestClass.Uint),
                nameof(TestClass.Long),
                nameof(TestClass.Ulong),
                nameof(TestClass.Short),
                nameof(TestClass.Ushort),
                nameof(TestClass.Enum),
            });

            Assert.AreEqual(File.ReadAllText("complex.rron"), actual);
        }
Пример #2
0
        public void BasicTests()
        {
            TestClass basicTests = new()
            {
                NullableBool = true,
                BaseSingle   = 0,
                Bool         = true,
                Byte         = 1,
                Sbyte        = 2,
                Char         = '3',
                Decimal      = 4m,
                Double       = 5d,
                Float        = 6f,
                Int          = 7,
                Uint         = 8,
                Long         = 9,
                Ulong        = 10,
                Short        = 11,
                Ushort       = 12,
                String       = "13",
                Enum         = Enum.A,
            };

            string actual = RronConvert.SerializeObject(basicTests, new[]
            {
                nameof(TestClass.BaseComplex),
                nameof(TestClass.Struct),
            });

            Assert.AreEqual(File.ReadAllText("basic.rron"), actual);
        }
Пример #3
0
        public static BeatMapMeta LoadBeatMap(string path)
        {
            string filePath = string.Equals(Path.GetExtension(path), ".rron")
                ? path
                : Directory.GetFiles(path, @"*.rron").First();
            BeatMapMeta prePath = RronConvert.DeserializeObjectFromFile <BeatMapMeta>(filePath);

            prePath.Path = path;
            return(prePath);
        }
Пример #4
0
        private static SavedSettings LoadSettings()
        {
            if (File.Exists(GenericPaths.SettingsPath) && !string.IsNullOrEmpty(File.ReadAllText(GenericPaths.SettingsPath)))
            {
                return(RronConvert.DeserializeObjectFromFile <SavedSettings>(GenericPaths.SettingsPath));
            }

            SavedSettings settings = new SavedSettings("Default");

            RronConvert.SerializeObjectToFile(settings, GenericPaths.SettingsPath);
            return(settings);
        }
Пример #5
0
        public void BasicCollectionTests()
        {
            TestClass collectionTests = new()
            {
                BaseCollection = new[] { 10, 20 },
                IntArray       = new[] { 18, 19 },
                IntList        = new List <int>
                {
                    20,
                    21,
                },
                EnumArray = new[] { Enum.A, Enum.B },
                EnumList  = new List <Enum>
                {
                    Enum.C,
                    Enum.D,
                },
            };

            string actual = RronConvert.SerializeObject(collectionTests, new[]
            {
                nameof(TestClass.BaseSingle),
                nameof(TestClass.Bool),
                nameof(TestClass.Byte),
                nameof(TestClass.Sbyte),
                nameof(TestClass.Char),
                nameof(TestClass.Decimal),
                nameof(TestClass.Double),
                nameof(TestClass.Float),
                nameof(TestClass.Int),
                nameof(TestClass.Uint),
                nameof(TestClass.Long),
                nameof(TestClass.Ulong),
                nameof(TestClass.Short),
                nameof(TestClass.Ushort),
                nameof(TestClass.Enum),
                nameof(TestClass.BaseComplex),
                nameof(TestClass.Struct),
            });

            Assert.AreEqual(File.ReadAllText("basicCollection.rron"), actual);
        }
Пример #6
0
 private void SaveNewBeatMap() =>
 RronConvert.SerializeObjectToFile(this.beatMapMeta, this.beatMapMeta.Path, new[] { nameof(BeatMapMeta.Id), nameof(BeatMapMeta.Path) });
Пример #7
0
 protected override void LeftClick() => RronConvert.SerializeObjectToFile(Assets.Instance.Settings, GenericPaths.SettingsPath);
Пример #8
0
 public void DataRead()
 {
     RronConvert.DeserializeObject <TestClass>(this.text);
 }
Пример #9
0
        public void Setup()
        {
            string text = File.ReadAllText("data.rron");

            this.testClass = RronConvert.DeserializeObject <TestClass>(text);
        }