Beispiel #1
0
        public virtual void EditStyle(Site site, string themeName, string fileName, string body)
        {
            var theme     = new Theme(site, themeName);
            var themeFile = new StyleFile(theme, fileName);

            themeFile.Save(body);
        }
Beispiel #2
0
        public virtual void DeleteStyle(Site site, string themeName, string fileName)
        {
            var theme     = new Theme(site, themeName);
            var themeFile = new StyleFile(theme, fileName);

            themeFile.Delete();
        }
Beispiel #3
0
        /// <summary>
        /// Opens entity utility functions. This opens an entity translation file
        /// referred to via the Backsight property <see cref="PropertyNaming.EntityFile"/>
        /// (if there is such a definition). It then reads the file into an
        /// <see cref="EntityFile"/> object for later use.
        /// <para/>
        /// Also opens a style file referred to via the property
        /// <see cref="PropertyNaming.StyleFile"/> (if there is such a definition).
        /// It then reads the file into a <see cref="StyleFile"/> object for later use.
        /// </summary>
        /// <returns>True if an entity file and/or style file was loaded.</returns>
        /// <remarks>
        /// This function should be called near the start of the application. To release
        /// the resources, a subsequent call to <see cref="Close"/> should be made.
        /// </remarks>
        internal bool Open()
        {
            // Ensure any files previously loaded have been released.
            Close();

            s_EntityFile = OpenEntityFile();
            s_StyleFile  = OpenStyleFile();

            return(s_EntityFile != null || s_StyleFile != null);
        }
Beispiel #4
0
        public virtual void CreateStyle(Site site, string themeName, string fileName, string body)
        {
            var theme     = new Theme(site, themeName);
            var themeFile = new StyleFile(theme, fileName);

            if (themeFile.Exists())
            {
                throw new ItemAlreadyExistsException();
            }
            themeFile.Save(body);
        }
Beispiel #5
0
        public virtual StyleFile GetStyle(Site site, string themeName, string fileName)
        {
            var theme = new Theme()
            {
                Name = themeName, Site = site
            };
            var themeFile = new StyleFile(theme, fileName);

            themeFile.Body = themeFile.Read();
            return(themeFile);
        }
Beispiel #6
0
        /// <summary>
        /// Also opens a style file referred to via the property
        /// <see cref="PropertyNaming.StyleFile"/> (if there is such a definition).
        /// It then reads the file into a <see cref="StyleFile"/> object for later use.
        /// </summary>
        /// <returns>The loaded style file (or null if no such file, or it could
        /// not be loaded). If the environment variable is undefined, you get back
        /// an object that represents an empty style file.</returns>
        StyleFile OpenStyleFile()
        {
            // Get the translation (if any) of the property
            // that refers to the standard style file.
            IProperty prop    = EnvironmentContainer.FindPropertyByName(PropertyNaming.StyleFile);
            string    stdfile = (prop == null ? null : prop.Value);

            if (String.IsNullOrEmpty(stdfile))
            {
                return(new StyleFile());
            }

            // Create a new style file object, and ask it to load the file.
            StyleFile file   = new StyleFile();
            int       nStyle = file.Create(stdfile);

            // Return the file if it loaded ok
            return(nStyle > 0 ? file : null);
        }
Beispiel #7
0
        public void AddFile(string filename, string fileUrl, string displayName, FileType filetype)
        {
            var file = Files.Where(p => p.FileName == filename).SingleOrDefault();

            if (file == null)
            {
                var f = new StyleFile()
                {
                    StyleId     = StyleId,
                    FileName    = filename,
                    FileUrl     = fileUrl,
                    FileType    = filetype,
                    DisplayName = displayName
                };
                f.SetCreateUser(currentUser.UserName);
                Files.Add(f);
            }
            else
            {
                file.IsDelete = false;
            }
        }
Beispiel #8
0
 public Processor(StyleFile style, IReadOnlyCollection <LocaleFile> locales)
 {
     Style   = style;
     Locales = locales;
 }
Beispiel #9
0
 /// <summary>
 /// Releases any resources that were allocated via a prior
 /// call to <see cref="Open"/>
 /// </summary>
 internal void Close()
 {
     s_EntityFile = null;
     s_StyleFile  = null;
 }