Exemplo n.º 1
0
        /// <summary>
        /// Substitutes the processing path with an alternative processing path.
        /// </summary>
        /// <param name="processingPath">The new processing path.</param>
        /// <returns></returns>
        public ProcessingPath MapProcessingPath(ProcessingPath processingPath)
        {
            // Any processing path lookups ?
            if (this.ProcessingPath == null || processingPath == null || processingPath.Tag == null)
            {
                return(processingPath);
            }

            // Map each processing tag
            List <ProcessingTag> mappedTags = new List <ProcessingTag>();

            for (Int32 i = 0; i < processingPath.Tag.Length; i++)
            {
                ProcessingTag mappedTag = new ProcessingTag();
                mappedTag.Type = processingPath.Tag[i].Type;
                mappedTag.Name = processingPath.Tag[i].Name;

                // Find the longest matching mapping
                Boolean mapped = false;
                for (Int32 j = processingPath.Tag.Length; j > i && !mapped; j--)
                {
                    // Append these processing tags together
                    StringBuilder appendedTags = new StringBuilder();
                    for (Int32 k = i; k < j; k++)
                    {
                        if (appendedTags.Length > 0)
                        {
                            appendedTags.Append(c_mappingSeparator);
                        }
                        if (!String.IsNullOrEmpty(processingPath.Tag[k].Type))
                        {
                            appendedTags.Append(processingPath.Tag[k].Type);
                        }
                    }

                    // Does this appended list of tags types match any mapping ?
                    foreach (Substitution substitution in this.ProcessingPath)
                    {
                        if (!String.IsNullOrEmpty(substitution.Name))
                        {
                            if (String.Equals(appendedTags.ToString(), substitution.Name))
                            {
                                mappedTag.Type = substitution.With;
                                mappedTag.Name = processingPath.Tag[j - 1].Name;
                                mapped         = true;
                                i = j;
                                break;
                            }
                        }
                    }
                }

                mappedTags.Add(mappedTag);
            }

            // Return the mapped processing path
            ProcessingPath mappedPath = new ProcessingPath();

            mappedPath.Id  = processingPath.Id;
            mappedPath.Tag = mappedTags.ToArray();
            return(mappedPath);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Substitutes the processing path with an alternative processing path.
        /// </summary>
        /// <param name="processingPath">The new processing path.</param>
        /// <returns></returns>
        public ProcessingPath MapProcessingPath(ProcessingPath processingPath)
        {
            // Any processing path lookups ? 
            if (this.ProcessingPath == null || processingPath == null || processingPath.Tag == null)
                return processingPath;

            // Map each processing tag
            List<ProcessingTag> mappedTags = new List<ProcessingTag>();
            for (Int32 i = 0; i < processingPath.Tag.Length; i++)
            {
                ProcessingTag mappedTag = new ProcessingTag();
                mappedTag.Type = processingPath.Tag[i].Type;
                mappedTag.Name = processingPath.Tag[i].Name;

                // Find the longest matching mapping
                Boolean mapped = false;
                for (Int32 j = processingPath.Tag.Length; j > i && !mapped; j--)
                {
                    // Append these processing tags together
                    StringBuilder appendedTags = new StringBuilder();
                    for (Int32 k = i; k < j; k++)
                    {
                        if (appendedTags.Length > 0)
                            appendedTags.Append(c_mappingSeparator);
                        if (!String.IsNullOrEmpty(processingPath.Tag[k].Type))
                            appendedTags.Append(processingPath.Tag[k].Type);
                    }

                    // Does this appended list of tags types match any mapping ?
                    foreach (Substitution substitution in this.ProcessingPath)
                        if (!String.IsNullOrEmpty(substitution.Name))
                        {
                            if (String.Equals(appendedTags.ToString(), substitution.Name))
                            {
                                mappedTag.Type = substitution.With;
                                mappedTag.Name = processingPath.Tag[j - 1].Name;
                                mapped = true;
                                i = j;
                                break;
                            }
                        }
                }

                mappedTags.Add(mappedTag);
            }

            // Return the mapped processing path
            ProcessingPath mappedPath = new ProcessingPath();
            mappedPath.Id = processingPath.Id;
            mappedPath.Tag = mappedTags.ToArray();
            return mappedPath;
        }