Ejemplo n.º 1
0
        /// <summary>
        /// Use reflection to get strongly-typed constructor info from <paramref name="element"/>.
        /// </summary>
        /// <param name="element">DICOM element for which constructor info should be obtained.</param>
        /// <param name="parameterTypes">Expected parameter types in the requested constructor.</param>
        /// <returns>Constructor info corresponding to <paramref name="element"/> and <paramref name="parameterTypes"/>.</returns>
        private static ConstructorInfo GetConstructor(DicomElement element, params Type[] parameterTypes)
        {
#if PORTABLE || NETSTANDARD || NETFX_CORE
            return(element.GetType().GetTypeInfo().DeclaredConstructors.Single(
                       ci =>
            {
                var pars = ci.GetParameters().Select(par => par.ParameterType);
                return pars.SequenceEqual(parameterTypes);
            }));
#else
            return(element.GetType().GetConstructor(parameterTypes));
#endif
        }
Ejemplo n.º 2
0
        /// <summary>Evaluates whether an element is of type Other*</summary>
        /// <param name="element">The element to be evaluated</param>
        /// <returns>A boolean flag indicating whether the element is of the expected type, otherwise false</returns>
        private static bool IsOtherElement(DicomElement element)
        {
            var t = element.GetType();

            return(t == typeof(DicomOtherByte) || t == typeof(DicomOtherDouble) || t == typeof(DicomOtherFloat) ||
                   t == typeof(DicomOtherLong) || t == typeof(DicomOtherWord) || t == typeof(DicomUnknown));
        }
Ejemplo n.º 3
0
        /// <summary>Evaluates whether an element has a generic valueType</summary>
        /// <param name="element">The element to be evaluated</param>
        /// <returns>The data type if found, otherwise null</returns>
        private static Type ElementValueType(DicomElement element)
        {
            var t = element.GetType();

            if (t.IsConstructedGenericType && t.GetGenericTypeDefinition() == typeof(DicomValueElement <>))
            {
                return(t.GenericTypeArguments[0]);
            }
            return(null);
        }