/// <summary>
        /// Creates an instance of this class and populates its members using reflection on the specified
        /// <see cref="XliffElement"/>
        /// </summary>
        /// <param name="element">The element to reflect upon.</param>
        /// <returns>An instance of this class with information about the elements children and attributes.</returns>
        public static IElementInformation Create(XliffElement element)
        {
            ElementInformationFromReflection result;

            result              = new ElementInformationFromReflection();
            result.ChildMap     = Reflector.GetSchemaChildren(element.GetType());
            result.AttributeMap = Reflector.GetSchemaAttributes(element.GetType(), element as IInheritanceInfoProvider, element as IOutputResolver);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Throws an <see cref="InvalidOperationException"/> exception if the specified value is not null.
        /// </summary>
        /// <param name="host">The element which contains the property to which to assign a new value.</param>
        /// <param name="propertyName">The name of the property trying to be assigned.</param>
        /// <param name="value">The current value of the property.</param>
        internal static void ThrowIfPropertyNotNull(XliffElement host, string propertyName, object value)
        {
            if (value != null)
            {
                string message;

                message = string.Format(
                    Properties.Resources.XliffElement_ChildAlreadyExists_Format,
                    host.GetType().Name,
                    propertyName);
                throw new InvalidOperationException(message);
            }
        }
Пример #3
0
        /// <summary>
        /// Validates that the <see cref="XliffElement"/> is not already used as a child for another
        /// <see cref="XliffElement"/>. If the element is a child, then an <see cref="ElementReuseException"/>
        /// is thrown.
        /// </summary>
        /// <param name="element">The element to check.</param>
        public static void ParentIsNull(XliffElement element)
        {
            if ((element != null) && (element.Parent != null))
            {
                string message;

                message = string.Format(Properties.Resources.ArgValidator_ElementReused_Format, element.GetType().Name);
                throw new ElementReuseException(message);
            }
        }