Ejemplo n.º 1
0
        /// <summary>
        /// Enumerates the inline tags of the container and stores a hash of <see cref="Data"/> references
        /// in <paramref name="idDataMap"/>. Also stores a map from Id to the inline tag with that Id.
        /// </summary>
        /// <param name="container">The resource that contains inline tags to enumerate.</param>
        /// <param name="idDataMap">A dictionary whose key is the inline tag Id and the value is a hash composed of
        /// all the <see cref="Data"/> references referenced by the inline tag. If the inline tag doesn't support Data
        /// references then the item will not be included in the dictionary.</param>
        /// <param name="idMap">A dictionary whose key is the inline tag Id and the value is the corresponding
        /// inline tag. This value may be null if the map is not needed by the caller..</param>
        private static void BuildDataReferenceMap(
            IResourceStringContentContainer container,
            Dictionary <string, string> idDataMap,
            Dictionary <string, IIdentifiable> idMap)
        {
            foreach (ResourceStringContent content in container.Text)
            {
                IIdentifiable identifiable;

                identifiable = content as IIdentifiable;
                if ((identifiable != null) && content.SupportsDataReferences)
                {
                    StringBuilder hash;

                    hash = new StringBuilder();
                    foreach (KeyValuePair <string, string> pair in content.AllDataReferences)
                    {
                        hash.AppendFormat("|||{0}:{1}", pair.Key, pair.Value);
                    }

                    idDataMap[identifiable.Id] = hash.ToString();

                    if (idMap != null)
                    {
                        idMap[identifiable.Id] = identifiable;
                    }
                }

                // Some inline tags support nested inline tags.
                if (content is IResourceStringContentContainer)
                {
                    Utilities.BuildDataReferenceMap((IResourceStringContentContainer)content, idDataMap, idMap);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets all the selectable inline tags under a container and stores them in the specified list.
        /// </summary>
        /// <param name="container">The container to search under.</param>
        /// <param name="list">The list to add the selectable inline tags to.</param>
        internal static void AddAllSelectableInlineTags(IResourceStringContentContainer container, List <ISelectable> list)
        {
            if (container != null)
            {
                foreach (ResourceStringContent content in container.Text)
                {
                    ISelectable selectable;

                    selectable = content as ISelectable;
                    if (selectable != null)
                    {
                        list.Add(selectable);
                    }

                    // Some inline tags support nested inline tags.
                    Utilities.AddAllSelectableInlineTags(content as IResourceStringContentContainer, list);
                }
            }
        }