示例#1
0
        public bool CreateFile(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }

            var uniqueName = name;
            int i          = 1;

            // If file name already exists, append a (1), (2), etc..
            while (ObjectSystemsDict.ContainsKey(uniqueName))
            {
                var dotIndex = name.LastIndexOf('.') - 1;

                if (dotIndex < 0)
                {
                    return(false);
                }

                uniqueName = name.Insert(dotIndex, $" ({i})");
                i++;
            }

            var file = new File(uniqueName, GetFullPath(uniqueName), this);

            return(AddObjectSystem(file));
        }
示例#2
0
        public bool DeleteObject(ObjectSystem objectSystem)
        {
            if (!ObjectSystemsDict.ContainsKey(objectSystem.Name))
            {
                return(false);
            }

            return(ObjectSystemsDict.Remove(objectSystem.Name) && ObjectSystems.Remove(objectSystem));
        }
示例#3
0
        private bool AddObjectSystem(ObjectSystem objectSystem)
        {
            if (ObjectSystemsDict.ContainsKey(objectSystem.Name))
            {
                return(false);
            }

            ObjectSystemsDict.Add(objectSystem.Name, objectSystem);
            ObjectSystems.Add(objectSystem);

            return(true);
        }
示例#4
0
        public bool CreateDirectory(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }

            var uniqueName = name;
            int i          = 1;

            // If file name already exists, append a (1), (2), etc..
            while (ObjectSystemsDict.ContainsKey(uniqueName))
            {
                uniqueName = name.Insert(name.Length - 1, $" ({i})");
                i++;
            }

            var directory = new Directory(uniqueName, GetFullPath(uniqueName), this);

            return(AddObjectSystem(directory));
        }
示例#5
0
 public bool ChildDictNameChanged(string newName, Directory directory)
 {
     ObjectSystemsDict[newName] = directory;
     return(ObjectSystemsDict.Remove(directory.Name));
 }