예제 #1
0
        /// <summary>
        /// Applies fixups to the given item parameters.
        /// </summary>
        /// <param name="parentName">Name of the parent item.</param>
        /// <param name="name">'name' attribute of the item to fixup.</param>
        /// <param name="show">'show' attribute of the item to fixup.</param>
        /// <param name="showname">'showname' attribute of the item to fixup.</param>
        /// <param name="value">'value' attribute of the item to fixup.</param>
        /// <returns>True if a fixup was applied, false otherwise.</returns>
        private bool ApplyTemplateFixups(string parentName, ref string name, ref string show, ref string showname, ref string value)
        {
            if (templateFixups.Count == 0)
            {
                return(false);
            }

            string newName  = null;
            string newValue = null;

            IList <KeyValuePair <string, string> > accumulator = null;

            foreach (TemplateFixup fixup in templateFixups)
            {
                bool matched = true;
                matched &= RegexSupport.CheckMatch(fixup.ParentNameRegex, parentName, ref accumulator);
                matched &= RegexSupport.CheckMatch(fixup.NameRegex, name, ref accumulator);
                matched &= RegexSupport.CheckMatch(fixup.ShowRegex, show, ref accumulator);
                matched &= RegexSupport.CheckMatch(fixup.ShownameRegex, showname, ref accumulator);
                matched &= RegexSupport.CheckMatch(fixup.ValueRegex, value, ref accumulator);

                if (matched)
                {
                    accumulator.Add(new KeyValuePair <string, string>("parentName", parentName));
                    accumulator.Add(new KeyValuePair <string, string>("parentNamePrefix", !string.IsNullOrEmpty(parentName) ? string.Concat(parentName, ".") : string.Empty));
                    accumulator.Add(new KeyValuePair <string, string>("name", name));
                    accumulator.Add(new KeyValuePair <string, string>("show", show));
                    accumulator.Add(new KeyValuePair <string, string>("showname", showname));
                    accumulator.Add(new KeyValuePair <string, string>("value", value));

                    string newNewName  = TemplateValue(fixup.NameFormat, accumulator, true);
                    string newNewValue = TemplateValue(fixup.ValueFormat, accumulator, false);

                    // TODO checking?

                    newName  = newNewName;
                    newValue = newNewValue;
                }

                if (accumulator != null)
                {
                    accumulator.Clear();
                }
            }

            if (newName != null || newValue != null)
            {
                name     = newName;
                showname = newName;
                show     = newValue;
                value    = newValue;
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Filters a column based on its name and the name of the table containing it.
        /// </summary>
        /// <param name="tableName">Table name to filter.</param>
        /// <param name="columnName">Column name to filter.</param>
        /// <returns>The result of the filtering.</returns>
        public DataFilterType FilterColumn(string tableName, string columnName)
        {
            DataFilterType result = DataFilterType.Unknown;

            foreach (ColumnFilterCommand rule in columnFilter)
            {
                if (RegexSupport.CheckMatch(rule.TableNameRegex, tableName) && RegexSupport.CheckMatch(rule.ColumnNameRegex, columnName))
                {
                    result = rule.Type;
                }
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Filters a table based on its name.
        /// </summary>
        /// <param name="tableName">Table name to filter.</param>
        /// <returns>The result of the filtering.</returns>
        public DataFilterType FilterTable(string tableName)
        {
            DataFilterType result = DataFilterType.Unknown;

            foreach (TableFilterRule rule in tableFilter)
            {
                if (RegexSupport.CheckMatch(rule.TableNameRegex, tableName))
                {
                    result = rule.Type;
                }
            }
            return(result);
        }