Пример #1
0
        public override bool Execute()
        {
            string outputFileName = String.Format("{0}.area-manifest.xml", AreaName);
            string outputFullPath = Path.Combine(ManifestPath, outputFileName);

            AreaInfo info = new AreaInfo()
            {
                Name         = AreaName,
                Path         = AreaPath,
                Type         = (AreaType)Enum.Parse(typeof(AreaType), AreaType),
                ContentFiles = ContentFiles.Select(o => o.ItemSpec).ToArray()
            };

            // ensure output directory exists before file creation
            string outputDir = Path.GetDirectoryName(outputFullPath);

            FileSystem.CreateDirectory(outputDir);

            XmlSerializer serializer = new XmlSerializer(typeof(AreaInfo));

            using (Stream stream = FileSystem.FileOpen(outputFullPath, FileMode.Create)) {
                serializer.Serialize(stream, info);
            }

            // if we got this far, success!
            return(true);
        }
Пример #2
0
        private void Copy(AreaInfo originInfo, AreaInfo destinationInfo, bool doCrossCopy) {
            // need to be careful not to delete existing <content> files, but can overwrite existing non-<content> files

            { // step 1 - copy from origin to destination
                HashSet<string> existingDestinationContentFiles = new HashSet<string>(destinationInfo.ContentFiles, StringComparer.OrdinalIgnoreCase);

                var filesToCopy = from originFileName in originInfo.ContentFiles
                                  let destinationFileName = RewriteViewPath(originInfo.Name, originFileName)
                                  where !existingDestinationContentFiles.Contains(destinationFileName)
                                  select new {
                                      OriginFile = originFileName,
                                      DestinationFile = destinationFileName
                                  };

                foreach (var fileToCopy in filesToCopy) {
                    CopyFile(originInfo.Path, fileToCopy.OriginFile, destinationInfo.Path, fileToCopy.DestinationFile);
                }
            }

            if (doCrossCopy) {
                // step 2 - copy from destination to origin
                var filesToCopy = destinationInfo.ContentFiles.Except(originInfo.ContentFiles);
                foreach (string fileToCopy in filesToCopy) {
                    CopyFile(destinationInfo.Path, fileToCopy, originInfo.Path, fileToCopy);
                }
            }
        }
        public override bool Execute() {
            string outputFileName = String.Format("{0}.area-manifest.xml", AreaName);
            string outputFullPath = Path.Combine(ManifestPath, outputFileName);

            AreaInfo info = new AreaInfo() {
                Name = AreaName,
                Path = AreaPath,
                Type = (AreaType)Enum.Parse(typeof(AreaType), AreaType),
                ContentFiles = ContentFiles.Select(o => o.ItemSpec).ToArray()
            };

            // ensure output directory exists before file creation
            string outputDir = Path.GetDirectoryName(outputFullPath);
            FileSystem.CreateDirectory(outputDir);

            XmlSerializer serializer = new XmlSerializer(typeof(AreaInfo));
            using (Stream stream = FileSystem.FileOpen(outputFullPath, FileMode.Create)) {
                serializer.Serialize(stream, info);
            }

            // if we got this far, success!
            return true;
        }