Пример #1
0
        public static MatFile DeserializeFromString(string matStr)
        {
            var siiParser = new SiiParser
            {
                TupleAttribOpen  = "{",
                TupleAttribClose = "}"
            };
            var sii = siiParser.DeserializeFromString(matStr);

            var mat = new MatFile
            {
                Attributes = sii.Units[0].Attributes,
                Effect     = sii.Units[0].Name.Replace("\"", "")
            };

            return(mat);
        }
Пример #2
0
        public static string Serialize(MatFile mat)
        {
            var siiParser = new SiiParser
            {
                TupleAttribOpen  = "{",
                TupleAttribClose = "}"
            };

            var siiFile = new SiiFile();

            siiFile.GlobalScope = false;
            var unit = new Unit();

            siiFile.Units.Add(unit);
            unit.Class      = "material";
            unit.Name       = $"\"{mat.Effect}\"";
            unit.Attributes = mat.Attributes;

            return(siiParser.Serialize(siiFile));
        }