Example #1
0
        /// <summary>
        /// Registers a tag mapping, an association between a type and a YAML tag, used when
        /// deserializing a YAML document, when a specific .NET type is expected.
        /// </summary>
        /// <param name="tagName">Name of the tag.</param>
        /// <param name="type">The type.</param>
        /// <exception cref="System.ArgumentNullException">
        /// tagName
        /// or
        /// type
        /// </exception>
        public void RegisterTagMapping(string tagName, Type type)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException("tagName");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            yamlSettings.RegisterTagMapping(tagName, type);
#if W8CORE
            attributeRegistry.Register(type.GetTypeInfo(), new YamlTagAttribute(tagName));
#else
            attributeRegistry.Register(type, new YamlTagAttribute(tagName));
#endif
        }