예제 #1
0
        public void InitRootServer()
        {
            string filename = Servers + ".group";

            if (!File.Exists(filename))
            {
                DscServer root = new DscServer();
                root.Save(filename);
            }
        }
예제 #2
0
        // Create new server or server group
        public DscServerNode NewServerNode(string name, DscServerNode.ServerType type, DscServerNode parent)
        {
            if (parent == null || string.IsNullOrWhiteSpace(name))
            {
                return(null);
            }

            string fileFolder = Path.GetDirectoryName(parent.FilePath);

            if (fileFolder == null)
            {
                return(null);
            }

            string fileName;

            if (type == DscServerNode.ServerType.Server)
            {
                fileName = Path.Combine(fileFolder, name + @".json");
            }
            else
            {
                fileName = Path.Combine(fileFolder, name, @".group");
                FileSystem.DirectoryCreateIfNotExists(Path.GetDirectoryName(fileName));
            }

            DscServer server = new DscServer();

            server.Save(fileName);
            DscServerNode serverNode =
                new DscServerNode(type, fileName, parent);

            parent.Nodes.Add(serverNode);

            return(serverNode);
        }