コード例 #1
0
        private void LoadFile()
        {
            ContainerNode rootNode = null;

            switch (Path.GetExtension(SaveLoc))
            {
            case @".nbtx":
            {
                try {
                    rootNode = ListNode.Deserialize(SaveLoc);
                } catch {
                    rootNode = ObjectNode.Deserialize(SaveLoc);
                }
            }
            break;

            case @".nbt":
            {
                using (var file = File.OpenRead(SaveLoc)) {
                    rootNode = Serializer.Deserialize <ContainerNode>(file);
                }
            }
            break;

            default:
                return;
            }

            if (rootNode == null)
            {
                return;
            }
            Root.Clear();
            Root.Add(rootNode);
        }