Пример #1
0
        private void AddTemplateFileReferences(DirectoryInfo parentDir, List <TemplateFileReference> templateFileReferenceList, int pathIndex)
        {
            foreach (FileInfo file in parentDir.GetFiles())
            {
                if (FileProvider.IncludeFile(file))
                {
                    string locationPath = file.FullName.Substring(pathIndex);

                    if (!DoLocationExist(templateFileReferenceList, locationPath))
                    {
                        // Do not include webtemp*.xml file, because they are handle by the SiteDefinitionManifest
                        if (!this.ReservedFiles.ContainsKey(file.FullName))
                        {
                            TemplateFileReference templateFileReference = new TemplateFileReference();
                            templateFileReference.Location = locationPath;

                            templateFileReferenceList.Add(templateFileReference);

                            Log.Verbose("TemplateFile added: " + locationPath);

                            //this.CabFiles.Add(new string[] { file.FullName, locationPath });
                            this.AddToCab(file.FullName, locationPath);
                        }
                    }
                }
            }

            foreach (DirectoryInfo childDir in FileProvider.GetDirectories(parentDir))
            {
                AddTemplateFileReferences(childDir, templateFileReferenceList, pathIndex);
            }
        }
Пример #2
0
        public TemplateFileReference[] BuildTemplateFileReference(DirectoryInfo parentDir, TemplateFileReference[] templateFileReferences)
        {
            List <TemplateFileReference> templateFileReferenceList =
                (templateFileReferences != null) ? new List <TemplateFileReference>(templateFileReferences) : new List <TemplateFileReference>();

            int parentPathIndex = parentDir.FullName.Length + 1; // Plus one for the slash

            // Add features
            string pathFeatures = parentDir.FullName + @"\features";

            if (Directory.Exists(pathFeatures))
            {
                DirectoryInfo featuresDir = new DirectoryInfo(pathFeatures);

                this.Solution.FeatureManifests = BuildFeatureManifestReference(featuresDir, this.Solution.FeatureManifests);

                // Add Features resources files.
                this.Solution.Resources = AppendArray <ResourceDefinition>(this.Solution.Resources, BuildResourceDefinition(featuresDir));
            }

            // Add sitedefinitions
            if (Directory.Exists(parentDir.FullName + @"\sitetemplates"))
            {
                this.Solution.SiteDefinitionManifests = BuildSiteDefinitionManifestFileReference(new DirectoryInfo(parentDir.FullName + @"\sitetemplates"), this.Solution.SiteDefinitionManifests);
            }

            // Every other file gets added to the TemplateFileReference
            foreach (DirectoryInfo childDir in FileProvider.GetDirectories(parentDir))
            {
                switch (childDir.Name.ToLower())
                {
                case "features":  break;     // Do nothing here

                case "sitetemplates": break; // Do nothing here

                default: AddTemplateFileReferences(childDir, templateFileReferenceList, parentPathIndex); break;
                }
            }

            // Find and add files in the TEMPLATE folder
            foreach (FileInfo file in parentDir.GetFiles())
            {
                if (FileProvider.IncludeFile(file))
                {
                    string locationPath = file.FullName.Substring(parentPathIndex);

                    if (!DoLocationExist(templateFileReferenceList, locationPath))
                    {
                        TemplateFileReference templateFileReference = new TemplateFileReference();
                        templateFileReference.Location = locationPath;

                        templateFileReferenceList.Add(templateFileReference);

                        //this.CabFiles.Add(new string[] { file.FullName, locationPath });
                        this.AddToCab(file.FullName, locationPath);
                    }
                }
            }


            // Add the directories in the IncludeTemplateDirectory list
            foreach (DirectoryInfo childDir in IncludeTemplateDirectory)
            {
                AddTemplateFileReferences(childDir, templateFileReferenceList, parentPathIndex);
            }

            if (templateFileReferenceList.Count == 0)
            {
                return(null);
            }
            return(templateFileReferenceList.ToArray());
        }