コード例 #1
0
        /// <summary>
        /// Loads the file.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="policy">The policy.</param>
        /// <returns></returns>
        public static cssCollection LoadFile(String path, cssEntryPolicy policy = cssEntryPolicy.replace)
        {
            cssCollection output = new cssCollection();

            output.Load(path, policy);
            return(output);
        }
コード例 #2
0
        /// <summary>
        /// Loads the file.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="filename">The filename.</param>
        /// <param name="policy">The policy.</param>
        /// <returns></returns>
        public static cssCollection LoadFile(folderNode folder, String filename, cssEntryPolicy policy = cssEntryPolicy.replace)
        {
            cssCollection output = new cssCollection();

            String p = folder.findFile(filename, SearchOption.TopDirectoryOnly);

            output.Load(p, policy);
            return(output);
        }
コード例 #3
0
 /// <summary>
 /// Loads the specified path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="policy">The policy.</param>
 /// <returns></returns>
 public Boolean Load(String path, cssEntryPolicy policy = cssEntryPolicy.replace)
 {
     if (File.Exists(path))
     {
         String s = File.ReadAllText(path);
         FromString(s, policy);
         return(true);
     }
     return(false);
 }
コード例 #4
0
        /// <summary>
        /// Phrases CSS string source code
        /// </summary>
        /// <param name="cssCode">The CSS code.</param>
        /// <param name="policy">The policy.</param>
        public void FromString(String cssCode, cssEntryPolicy policy = cssEntryPolicy.replace)
        {
            var ms = REGEX_ENTRYSELECTOR.Matches(cssCode);

            foreach (Match m in ms)
            {
                foreach (String n in m.Groups[1].Value.SplitSmart(",", "", true, true))
                {
                    cssEntryDefinition entry = new cssEntryDefinition();
                    entry.name = n;
                    entry.fromString(m.Groups[2].Value, cssEntryDefinition.syntaxFormat.cssFileFormat);
                    Set(entry, policy);
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Sets the specified entry.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <param name="policy">The policy.</param>
        public void Set(cssEntryDefinition entry, cssEntryPolicy policy = cssEntryPolicy.replace)
        {
            if (items.ContainsKey(entry.name))
            {
                switch (policy)
                {
                case cssEntryPolicy.replace:
                    items.Remove(entry.name);
                    items.Add(entry.name, entry);
                    break;

                case cssEntryPolicy.setIfNotExisting:
                    break;

                case cssEntryPolicy.merge:
                    items[entry.name].Merge(entry);
                    break;
                }
            }
            else
            {
                items.Add(entry.name, entry);
            }
        }
コード例 #6
0
        public Boolean Load(folderNode folder, String filename, cssEntryPolicy policy = cssEntryPolicy.replace)
        {
            String p = folder.findFile("conceptual.css", SearchOption.TopDirectoryOnly);

            return(Load(p, policy));
        }