Exemplo n.º 1
0
        internal static XTypedElement GetAnnotation(Type t, XElement xe)
        {
            XTypedElementWrapperAnnotation xoWrapperAnnotation = xe.Annotation <XTypedElementWrapperAnnotation>();
            XTypedElement xObj = null;

            if (xoWrapperAnnotation != null)
            {
                //Return the root type if the element is annotated with the root
                xObj = xoWrapperAnnotation.typedElement;
                if (t.IsAssignableFrom(xObj.GetType()))
                {
                    //Check if we are asking for element wrapper
                    return(xObj);
                }
            }

            XTypedElementAnnotation xoAnnotation = xe.Annotation <XTypedElementAnnotation>();

            if (xoAnnotation != null)
            {
                xObj = xoAnnotation.typedElement;
                if (t.IsAssignableFrom(xObj.GetType()))
                {
                    //Check if we are asking for type
                    return(xObj);
                }
            }

            return(null);
        }
Exemplo n.º 2
0
        internal static XTypedElement GetAnnotation(Type t, XElement xe)
        {
            XTypedElement xTypedElement;
            XTypedElementWrapperAnnotation xoWrapperAnnotation = xe.Annotation <XTypedElementWrapperAnnotation>();
            XTypedElement xObj = null;

            if (xoWrapperAnnotation != null)
            {
                xObj = xoWrapperAnnotation.typedElement;
                if (t.IsAssignableFrom(xObj.GetType()))
                {
                    xTypedElement = xObj;
                    return(xTypedElement);
                }
            }
            XTypedElementAnnotation xoAnnotation = xe.Annotation <XTypedElementAnnotation>();

            if (xoAnnotation != null)
            {
                xObj = xoAnnotation.typedElement;
                if (t.IsAssignableFrom(xObj.GetType()))
                {
                    xTypedElement = xObj;
                    return(xTypedElement);
                }
            }
            xTypedElement = null;
            return(xTypedElement);
        }
Exemplo n.º 3
0
        public static XTypedElement GetCloneIfRooted(XTypedElement innerType)
        {
            if (innerType == null)
            {
                throw new ArgumentNullException("Argument innerType should not be null.");
            }

            XElement fragment = innerType.Untyped;
            XTypedElementWrapperAnnotation wrapperAnnotation = fragment.Annotation <XTypedElementWrapperAnnotation>();

            if (wrapperAnnotation != null)
            {
                //Already rooted to a wrapper
                return(innerType.Clone());
            }
            else
            {
                return(innerType);
            }
        }