コード例 #1
0
        public TempFeature AddFeature(string featTitle, string featDescription)
        {
            var feat = new TempFeature(featTitle, featDescription);

            this.Features.Add(featTitle, feat);
            return(feat);
        }
コード例 #2
0
        public TempFolder(TempFileSystem fileSystem, TempFolder parent, string name, TempFeature feat) : this(fileSystem, parent, name)
        {
            if (feat != null)
            {
                this.Features.Add(feat.Title, feat);
                feat.RegisterFolder(this);
            }

            if (feat == null && !(name == "root" || VariableConverter.VarToWixId.ContainsKey(name)))
            {
                throw new Exception(name + " must have a feature");
            }
        }
コード例 #3
0
 public void Update(string src, TempFeature fsFeat)
 {
     if (this.Source != src)
     {
         throw new Exception("Can't add same file from multiple sources: " + this.Source + " | " + src);
     }
     if (this.Features.ContainsKey(fsFeat.Title))
     {
         return;
     }
     this.Features.Add(fsFeat.Title, fsFeat);
     fsFeat.RegisterFile(this);
 }
コード例 #4
0
        /// <summary>
        /// //////////////////////////////////////////////////////////////////><!--->-->
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="src"></param>
        /// <param name="fsFeat"></param>

        public void AddFileOrUpdateFeatures(string dest, string src, TempFeature fsFeat)
        {
            var objects = dest.CleanAndSplitFilePath().ToList();

            var srcParts = src.CleanAndSplitFilePath().ToList();

            objects.Add(srcParts[srcParts.Count - 1]);


            //first let's deal with the top level, this should either be a shortcut var which will be precreated, or it's a drive letter.
            var        topLevelName   = objects[0];
            TempFolder topLevelFolder = null;

            if (this.Root.ContainsFolder(topLevelName))
            {
                topLevelFolder = this.Root.GetFolder(topLevelName);
            }
            else
            {
                if (!topLevelName.IsDriveLetter())
                {
                    throw new Exception("Attempted to add non drive or shortcut top level folder: " + topLevelName);
                }
                topLevelFolder = this.Root.CreateFolder(topLevelName, fsFeat);
            }


            //after that the middle bits should all be folders.
            TempFolder prevFolder = topLevelFolder;
            TempFolder currFolder = null;

            for (int i = 1; i < objects.Count - 1; i++)
            {
                var name = objects[i];
                //if (name == "\\") continue;
                currFolder = prevFolder.AddOrGetAndRegisterFolder(name, fsFeat);
                prevFolder = currFolder;
            }

            if (currFolder == null)
            {
                throw new Exception("unknown error 112");
            }

            //finally the last object is our file name
            var finalName = objects[objects.Count - 1];

            //it may have been required here by another feature in which case it should just update the feature registration.
            currFolder.CreateFileOrRegisterFeature(finalName, src, fsFeat);
        }
コード例 #5
0
 public TempFile(TempFileSystem fileSystem, TempFolder parent, string name, string src, TempFeature feat)
 {
     this.FileSystem = fileSystem;
     Name            = name;
     this.Source     = src;
     this.Path       = parent?.Path + "\\";
     this.Move(parent);
     this.Features.Add(feat.Title, feat);
     feat.RegisterFile(this);
 }
コード例 #6
0
        private static void AddDirectoryFromSource(TempFileSystem fs, string src, string dest, TempFeature fsFeat, bool includeSubDirectories)
        {
            var files = Directory.GetFiles(src);

            foreach (var fi in files)
            {
                fs.AddFileOrUpdateFeatures(dest, fi, fsFeat);
            }

            if (includeSubDirectories)
            {
                var folders = Directory.GetDirectories(src);
                foreach (var fd in folders)
                {
                    var destname = dest + "\\" + Path.GetFileName(fd);
                    AddDirectoryFromSource(fs, fd, destname, fsFeat, includeSubDirectories);
                }
            }
        }