internal static Validation Parse(string xml) { return(XTypedServices.Parse <Validation>(xml)); }
public static T ToXTypedElement <T>(XElement xe, ILinqToXsdTypeManager typeManager) where T : XTypedElement { return((T)(XTypedServices.ToXTypedElement(xe, typeManager, typeof(T)) as T)); }
//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; } } }
public static T Parse <T>(string xml) where T : XTypedElement, new() { return(XTypedServices.ToXTypedElement <T>(XElement.Parse(xml))); }
internal static T GetAnnotation <T>(XElement xe) where T : XTypedElement { return((T)XTypedServices.GetAnnotation(typeof(T), xe)); }
protected override void UpdateElement(XElement oldElement, T value) { oldElement.Value = XTypedServices.GetXmlString(value, schemaDatatype, oldElement); }
public static T Load <T>(TextReader reader) where T : XTypedElement, new() { return(XTypedServices.ToXTypedElement <T>(XDocument.Load(reader).Root)); }
internal static Deanonymize Load(string xmlFile) { return(XTypedServices.Load <Deanonymize>(xmlFile)); }
internal static Deanonymize Load(System.IO.TextReader xmlFile) { return(XTypedServices.Load <Deanonymize>(xmlFile)); }
internal static Transformation Parse(string xml) { return(XTypedServices.Parse <Transformation>(xml)); }
public override XTypedElement Clone() { return(XTypedServices.CloneXTypedElement <Transformation>(this)); }
internal static Transformation Load(System.IO.TextReader xmlFile) { return(XTypedServices.Load <Transformation>(xmlFile)); }
internal static Transformation Load(string xmlFile) { return(XTypedServices.Load <Transformation>(xmlFile)); }
public override XTypedElement Clone() { return(XTypedServices.CloneXTypedElement <Validation>(this)); }
internal static VerifyRequired Parse(string xml) { return(XTypedServices.Parse <VerifyRequired>(xml)); }
internal static Deanonymize Parse(string xml) { return(XTypedServices.Parse <Deanonymize>(xml)); }
public override XTypedElement Clone() { return(XTypedServices.CloneXTypedElement <VerifyRequired>(this)); }
public override XTypedElement Clone() { return(XTypedServices.CloneXTypedElement <Deanonymize>(this)); }
protected override T GetValueForElement(XElement element) { return(XTypedServices.ToXTypedElement <T>(element, typeManager)); }
internal void Save(string xmlFile) { XTypedServices.Save(xmlFile, Untyped); }
public static T Load <T>(string uri) where T : XTypedElement, new() { return(XTypedServices.ToXTypedElement <T>(XDocument.Load(uri).Root)); }
internal void Save(System.IO.TextWriter tw) { XTypedServices.Save(tw, Untyped); }
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)); }
internal void Save(System.Xml.XmlWriter xmlWriter) { XTypedServices.Save(xmlWriter, Untyped); }
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))); }
internal static VerifyRequired Load(string xmlFile) { return(XTypedServices.Load <VerifyRequired>(xmlFile)); }
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); }
internal static VerifyRequired Load(System.IO.TextReader xmlFile) { return(XTypedServices.Load <VerifyRequired>(xmlFile)); }
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(); } }
internal static Validation Load(System.IO.TextReader xmlFile) { return(XTypedServices.Load <Validation>(xmlFile)); }