Ejemplo n.º 1
0
        public void Save()
        {
            string file = this.ContentNode.RealPhysicalPath + "\\.properties.xml";

            cmSite domain = SiteManager.GetSiteByDistinctName(ContentNode.ContentTree.DistinctName);

            ContentTree.EnsureDirectoryExistsForFile(domain, file);

            PropertyFileHelper.Save(file, new { @Controller = this.Controller, @RouteName = this.RouteName, @IsInherited = false });
        }
Ejemplo n.º 2
0
        public void Save()
        {
            string file = this.ContentNode.RealPhysicalPath + "\\.properties.xml";

            cmSite domain = SiteManager.GetSiteByDistinctName(ContentNode.ContentTree.DistinctName);

            ContentTree.EnsureDirectoryExistsForFile(domain, file);

            PropertyFileHelper.Save(file, new {
                @ValidFrom                = this.ValidFrom,
                @ExpiryTime               = this.ExpiryTime,
                @AvailableForUKLicense    = this.AvailableForUKLicense,
                @AvailableForNonUKLicense = this.AvailableForNonUKLicense,
                @IsInherited              = false
            }, true);
        }
Ejemplo n.º 3
0
        public static void EnsureDirectoryExists(cmSite domain, string dirname)
        {
            if (Directory.Exists(dirname))
            {
                return;
            }

            string parentDir = Path.GetDirectoryName(dirname);

            EnsureDirectoryExists(domain, parentDir);

            // create the directory then look up in template dir
            Directory.CreateDirectory(dirname);

            if (!string.IsNullOrWhiteSpace(domain.TemplateDomainDistinctName))
            {
                string replaced    = string.Format(@"\Views\{0}\", domain.TemplateDomainDistinctName);
                string templateDir = Regex.Replace(dirname
                                                   , string.Format(@"\\Views\\{0}\\", domain.DistinctName.Replace("-", "\\-"))
                                                   , replaced
                                                   , RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled
                                                   );
                if (templateDir.Contains(replaced) && Directory.Exists(templateDir))
                {
                    ContentNode.ContentNodeType nodeType = ContentNode.ContentNodeType.Directory;
                    string propertyXml = Path.Combine(templateDir, ".properties.xml");
                    if (File.Exists(propertyXml))
                    {
                        XDocument doc = PropertyFileHelper.OpenReadWithoutLock(propertyXml);
                        if (!Enum.TryParse <ContentNode.ContentNodeType>(doc.Root.GetElementValue("Type"), out nodeType))
                        {
                            nodeType = ContentNode.ContentNodeType.Directory;
                        }
                    }

                    propertyXml = Path.Combine(dirname, ".properties.xml");
                    PropertyFileHelper.Save(propertyXml, new { @IsInherited = true, @Type = nodeType });
                }
            }
        }