コード例 #1
0
 internal static Validation Parse(string xml)
 {
     return(XTypedServices.Parse <Validation>(xml));
 }
コード例 #2
0
 public static T ToXTypedElement <T>(XElement xe, ILinqToXsdTypeManager typeManager)
     where T : XTypedElement
 {
     return((T)(XTypedServices.ToXTypedElement(xe, typeManager, typeof(T)) as T));
 }
コード例 #3
0
        //XML Query axes
        IEnumerable <T> IXTyped.Descendants <T>()
        {
            XTypedElement currentObject = this as XTypedElement;
            Type          lookupType    = typeof(T);

            //Metadata
            IXMetaData schemaMetaData = currentObject as IXMetaData;
            Dictionary <XName, System.Type> localElementsDict = null;
            ILinqToXsdTypeManager           typeManager       = schemaMetaData.TypeManager;
            Dictionary <XName, Type>        typeDictionary    = typeManager.GlobalTypeDictionary;

            //FSM
            XName    matchingName     = null;
            WildCard matchingWildCard = null;
            int      currentState     = FSM.InvalidState;

            XElement parentElement             = null;
            Stack <XTypedElement> elementStack = new Stack <XTypedElement>();

            while (true)
            {
                schemaMetaData = currentObject as IXMetaData;
                FSM fsm = currentObject.ValidationStates;
                if (fsm != null)
                {
                    StartFsm();
                    currentState = fsm.Start;
                }

                Debug.Assert(schemaMetaData != null);
                localElementsDict = schemaMetaData.LocalElementsDictionary;
                parentElement     = currentObject.Untyped;

                matchingName     = null;
                matchingWildCard = null;

                XTypedElement childObject  = null;
                bool          validContent = true;

                foreach (XElement childElement in parentElement.Elements())
                {
                    bool isTypeT = IsAnnoatedElemTypeOf <T>(childElement, out childObject);

                    if (fsm != null)
                    {
                        //Always execute FSM no matter whether we find an element of type T
                        currentState = FsmMakeTransition(currentState, childElement.Name, out matchingName,
                                                         out matchingWildCard);
                        if (currentState == FSM.InvalidState)
                        {
                            validContent = false;
                            break;
                        }
                    }

                    if (!isTypeT)
                    {
                        //check dictionary
                        if (fsm != null && matchingWildCard != null)
                        {
                            childObject = XTypedServices.ToXTypedElement(childElement, typeManager); //Auto-typing
                        }
                        else
                        {
                            childObject = TypeChildElement(childElement, localElementsDict, typeManager);
                        }

                        if (childObject != null)
                        {
                            Type runtimeType = childObject.GetType();
                            if (lookupType.IsAssignableFrom(runtimeType))
                            {
                                isTypeT = true;
                            }
                            else
                            {
                                //Check content type
                                Type contentType = null;
                                if (typeManager.RootContentTypeMapping.TryGetValue(runtimeType, out contentType) &&
                                    lookupType.IsAssignableFrom(contentType))
                                {
                                    childObject = GetContentType(childObject);
                                    isTypeT     = true;
                                }
                            }
                        }
                    }

                    if (isTypeT)
                    {
                        yield return((T)childObject);
                    }

                    if (childObject != null)
                    {
                        elementStack.Push(childObject);
                    }
                }

                if (validContent && elementStack.Count > 0)
                {
                    currentObject = elementStack.Pop();
                }
                else
                {
                    break;
                }
            }
        }
コード例 #4
0
 public static T Parse <T>(string xml)
     where T : XTypedElement, new()
 {
     return(XTypedServices.ToXTypedElement <T>(XElement.Parse(xml)));
 }
コード例 #5
0
 internal static T GetAnnotation <T>(XElement xe)
     where T : XTypedElement
 {
     return((T)XTypedServices.GetAnnotation(typeof(T), xe));
 }
コード例 #6
0
 protected override void UpdateElement(XElement oldElement, T value)
 {
     oldElement.Value = XTypedServices.GetXmlString(value, schemaDatatype, oldElement);
 }
コード例 #7
0
 public static T Load <T>(TextReader reader)
     where T : XTypedElement, new()
 {
     return(XTypedServices.ToXTypedElement <T>(XDocument.Load(reader).Root));
 }
コード例 #8
0
 internal static Deanonymize Load(string xmlFile)
 {
     return(XTypedServices.Load <Deanonymize>(xmlFile));
 }
コード例 #9
0
 internal static Deanonymize Load(System.IO.TextReader xmlFile)
 {
     return(XTypedServices.Load <Deanonymize>(xmlFile));
 }
コード例 #10
0
 internal static Transformation Parse(string xml)
 {
     return(XTypedServices.Parse <Transformation>(xml));
 }
コード例 #11
0
 public override XTypedElement Clone()
 {
     return(XTypedServices.CloneXTypedElement <Transformation>(this));
 }
コード例 #12
0
 internal static Transformation Load(System.IO.TextReader xmlFile)
 {
     return(XTypedServices.Load <Transformation>(xmlFile));
 }
コード例 #13
0
 internal static Transformation Load(string xmlFile)
 {
     return(XTypedServices.Load <Transformation>(xmlFile));
 }
コード例 #14
0
 public override XTypedElement Clone()
 {
     return(XTypedServices.CloneXTypedElement <Validation>(this));
 }
コード例 #15
0
 internal static VerifyRequired Parse(string xml)
 {
     return(XTypedServices.Parse <VerifyRequired>(xml));
 }
コード例 #16
0
 internal static Deanonymize Parse(string xml)
 {
     return(XTypedServices.Parse <Deanonymize>(xml));
 }
コード例 #17
0
 public override XTypedElement Clone()
 {
     return(XTypedServices.CloneXTypedElement <VerifyRequired>(this));
 }
コード例 #18
0
 public override XTypedElement Clone()
 {
     return(XTypedServices.CloneXTypedElement <Deanonymize>(this));
 }
コード例 #19
0
 protected override T GetValueForElement(XElement element)
 {
     return(XTypedServices.ToXTypedElement <T>(element, typeManager));
 }
コード例 #20
0
 internal void Save(string xmlFile)
 {
     XTypedServices.Save(xmlFile, Untyped);
 }
コード例 #21
0
 public static T Load <T>(string uri)
     where T : XTypedElement, new()
 {
     return(XTypedServices.ToXTypedElement <T>(XDocument.Load(uri).Root));
 }
コード例 #22
0
 internal void Save(System.IO.TextWriter tw)
 {
     XTypedServices.Save(tw, Untyped);
 }
コード例 #23
0
 public static W Parse <W, T>(string xml, ILinqToXsdTypeManager typeManager)
     where W : XTypedElement
     where T : XTypedElement
 {
     return(XTypedServices.ToXTypedElement <W, T>(XElement.Parse(xml), typeManager));
 }
コード例 #24
0
 internal void Save(System.Xml.XmlWriter xmlWriter)
 {
     XTypedServices.Save(xmlWriter, Untyped);
 }
コード例 #25
0
 public static W ToXTypedElement <W, T>(XElement xe, ILinqToXsdTypeManager typeManager)
     where W : XTypedElement
     where T : XTypedElement
 {
     return((W)XTypedServices.ToXTypedElement(xe, typeManager, typeof(W), typeof(T)));
 }
コード例 #26
0
 internal static VerifyRequired Load(string xmlFile)
 {
     return(XTypedServices.Load <VerifyRequired>(xmlFile));
 }
コード例 #27
0
        public static XTypedElement ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager)
        {
            XTypedElement xTypedElement;

            if (xe != null)
            {
                XName elementName = xe.Name;
                Type  clrType     = null;
                if (!typeManager.GlobalElementDictionary.TryGetValue(elementName, out clrType))
                {
                    Type xsiClrType = XTypedServices.GetXsiClrType(xe, typeManager);
                    if (!(xsiClrType != null))
                    {
                        xTypedElement = null;
                    }
                    else
                    {
                        xTypedElement = XTypedServices.ToXTypedElement(xe, typeManager, xsiClrType);
                    }
                }
                else
                {
                    Type contentType = null;
                    xTypedElement = (!typeManager.RootContentTypeMapping.TryGetValue(clrType, out contentType) ? XTypedServices.ToXTypedElement(xe, typeManager, clrType) : XTypedServices.ToXTypedElement(xe, typeManager, clrType, contentType));
                }
            }
            else
            {
                xTypedElement = null;
            }
            return(xTypedElement);
        }
コード例 #28
0
 internal static VerifyRequired Load(System.IO.TextReader xmlFile)
 {
     return(XTypedServices.Load <VerifyRequired>(xmlFile));
 }
コード例 #29
0
        IEnumerable <T> Xml.Schema.Linq.IXTyped.Descendants <T>()
        {
            bool                     flag;
            bool                     flag1;
            bool                     flag2;
            XTypedElement            xTypedElement           = this;
            Type                     type                    = typeof(T);
            IXMetaData               xMetaDatum              = xTypedElement;
            Dictionary <XName, Type> localElementsDictionary = null;
            ILinqToXsdTypeManager    linqToXsdTypeManager    = xMetaDatum.TypeManager;
            Dictionary <XName, Type> globalTypeDictionary    = linqToXsdTypeManager.GlobalTypeDictionary;
            XName                    xName                   = null;
            WildCard                 wildCard                = null;
            int      invalidState = FSM.InvalidState;
            XElement untyped      = null;
            Stack <XTypedElement> xTypedElements = new Stack <XTypedElement>();

            while (true)
            {
                xMetaDatum = xTypedElement;
                FSM validationStates = xTypedElement.ValidationStates;
                if (validationStates != null)
                {
                    this.StartFsm();
                    invalidState = validationStates.Start;
                }
                Debug.Assert(xMetaDatum != null);
                localElementsDictionary = xMetaDatum.LocalElementsDictionary;
                untyped  = xTypedElement.Untyped;
                xName    = null;
                wildCard = null;
                XTypedElement          xTypedElement1 = null;
                bool                   flag3          = true;
                IEnumerator <XElement> enumerator     = untyped.Elements().GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        XElement current = enumerator.Current;
                        bool     flag4   = this.IsAnnoatedElemTypeOf <T>(current, out xTypedElement1);
                        if (validationStates != null)
                        {
                            invalidState = this.FsmMakeTransition(invalidState, current.Name, out xName, out wildCard);
                            if (invalidState == FSM.InvalidState)
                            {
                                goto Label0;
                            }
                        }
                        if (!flag4)
                        {
                            flag           = (validationStates == null ? true : wildCard == null);
                            xTypedElement1 = (flag ? this.TypeChildElement(current, localElementsDictionary, linqToXsdTypeManager) : XTypedServices.ToXTypedElement(current, linqToXsdTypeManager));
                            if (xTypedElement1 != null)
                            {
                                Type type1 = xTypedElement1.GetType();
                                if (!type.IsAssignableFrom(type1))
                                {
                                    Type type2 = null;
                                    flag1 = (!linqToXsdTypeManager.RootContentTypeMapping.TryGetValue(type1, out type2) ? true : !type.IsAssignableFrom(type2));
                                    if (!flag1)
                                    {
                                        xTypedElement1 = this.GetContentType(xTypedElement1);
                                        flag4          = true;
                                    }
                                }
                                else
                                {
                                    flag4 = true;
                                }
                            }
                        }
                        if (flag4)
                        {
                            yield return((T)xTypedElement1);
                        }
                        if (xTypedElement1 != null)
                        {
                            xTypedElements.Push(xTypedElement1);
                        }
                    }
                    goto Label1;
Label0:
                    flag3 = false;
                }
                finally
                {
                    if (enumerator != null)
                    {
                        enumerator.Dispose();
                    }
                }
Label1:
                flag2 = (!flag3 ? true : xTypedElements.Count <= 0);
                if (flag2)
                {
                    break;
                }
                xTypedElement = xTypedElements.Pop();
            }
        }
コード例 #30
0
 internal static Validation Load(System.IO.TextReader xmlFile)
 {
     return(XTypedServices.Load <Validation>(xmlFile));
 }