コード例 #1
0
ファイル: XObjectsSimpleType.cs プロジェクト: pusp/o2platform
        protected void SetUnionValue(object value,
                                    string propertyName,
                                    XTypedElement container,
                                    SimpleTypeValidator typeDef)
        {
            SetUnionCatchAll(value, propertyName, this, null, typeDef, SchemaOrigin.Text);

        }
コード例 #2
0
	    /**
	     * Writes the schema location(s) to the XML Document
	     * @param doc the XML document to write the schema location(s) to
	     * @param schemaVersion the version of the schema to write in
	     * @param namespaceUri the URI of the namespace to write
	     */
	    public void WriteSchemaLocation(XTypedElement doc, string[] namespaceUri) 
        {
		    if(namespaceUri == null) 
			    return;

		    SdmxSchema schemaVersion;
		    StringBuilder schemaLocation = new StringBuilder();

		    string concat = "";
		    foreach (string currentNamespaceUri in namespaceUri) 
            {
			    schemaVersion = SdmxConstants.GetSchemaVersion(currentNamespaceUri);
			    //Base location of schema for version e.g. http://www.sss.sss/schema/
			    string schemaBaseLocation = GetSchemaLocation(schemaVersion);
			    string schemaName = SdmxConstants.GetSchemaName(currentNamespaceUri);
			    schemaLocation.Append(concat+currentNamespaceUri + " " + concat+schemaBaseLocation+schemaName);
			    concat = "\r\n";// System.getProperty("line.separator");
		    }

            doc.Untyped.SetAttributeValue(XName.Get("http://www.w3.org/2001/XMLSchema-instance","schemaLocation"),schemaLocation.ToString());
	    }
コード例 #3
0
	    protected void WriteSchemaLocation(XTypedElement doc, SdmxSchemaEnumType schemaVersion) 
        {
		    if (schemaLocationWriter != null)
            {
                List<string> schemaUri = new List<string>();
			    switch(schemaVersion) 
                {
			        case SdmxSchemaEnumType.VersionOne :  
                        schemaUri.Add(SdmxConstants.MessageNs10);
			            break;
			        case SdmxSchemaEnumType.VersionTwo:  
                        schemaUri.Add(SdmxConstants.MessageNs20);
			            break;
			        case SdmxSchemaEnumType.VersionTwoPointOne :  
                        schemaUri.Add(SdmxConstants.MessageNs21);
			            break;
			        default : 
                        throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "Schema Version " + schemaVersion);
			    }
			    schemaLocationWriter.WriteSchemaLocation(doc, schemaUri.ToArray());
		    }
	    }
コード例 #4
0
 public XRootNamespace(queryparam root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #5
0
 public XRootNamespace(returndiscriminator root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #6
0
 public XRootNamespace(nestedcompositeelement root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #7
0
 public XRootNamespace(primitivearray root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #8
0
 public XTypedSubstitutedList(XTypedElement container, ILinqToXsdTypeManager typeManager,
                              params XName[] itemXNames) : base(container, itemXNames)
 {
     this.typeManager = typeManager;
 }
コード例 #9
0
 public XRootNamespace(EntityContainer root)
 {
     _xDocument = new XDocument(root.Untyped);
       _rootObject = root;
 }
コード例 #10
0
 public XRoot(global::Xml.Schema.Linq.Deanonymize root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #11
0
 public XRootNamespace(sqlinsert root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #12
0
 public XRoot(global::Xml.Schema.Linq.@Namespace root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #13
0
 public XRoot(global::Xml.Schema.Linq.Transformation root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #14
0
 public XRootNamespace(VerifyRequired root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #15
0
 public XRootNamespace(Deanonymize root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #16
0
 public XRootNamespace(Transformation root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #17
0
 public XRootNamespace(synchronize root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #18
0
 public XRoot(global::Xml.Schema.Linq.VerifyRequired root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #19
0
 public XRootNamespace(version root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #20
0
 public XRootNamespace(Configuration root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #21
0
 protected void SetUnionElement(
     object value,
     string propertyName,
     XTypedElement container,
     XName itemXName,
     SimpleTypeValidator typeDef)
 {
     SetUnionCatchAll(
         value,
         propertyName,
         container,
         itemXName,
         typeDef,
         SchemaOrigin.Element);
 }
コード例 #22
0
 public XRootNamespace(Namespaces root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #23
0
 public XRoot(global::https.www.veracode.com.schema.reports.export.Item1.Item0.detailedreport root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #24
0
        internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj, Type elementBaseType)
        {
            NamedContentModelEntity namedEntity = GetNamedEntity(name);

            if (namedEntity == null)
            {
                // See http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3542
                throw new LinqToXsdException(
                          "Name does not belong in content model. Cannot set value for child " +
                          name.LocalName);
            }

            EditAction editAction    = EditAction.None;
            XElement   elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction);

            XElement newElement = XTypedServices.GetXElement(xObj, name, elementBaseType);

            Debug.Assert(xObj != null);

            switch (editAction)
            {
            case EditAction.Append:
                parentElement.Add(newElement);
                break;

            case EditAction.Update:
                elementMarker.AddBeforeSelf(newElement);
                elementMarker.Remove();
                break;

            case EditAction.AddBefore:
                elementMarker.AddBeforeSelf(newElement);
                break;
            }
        }
コード例 #25
0
 public static XSimpleList <T> CopyFromWithValidation(IEnumerable <T> values, XTypedElement container, XName itemXName, XmlSchemaDatatype dataType, string propertyName, SimpleTypeValidator typeDef)
 {
     return(XSimpleList <T> .Initialize(container, dataType, values, itemXName));
 }
コード例 #26
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 (isTypeT && fsm != null)  //Do not execute FSM if we do not 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;
                }
            }
        }
コード例 #27
0
 public XRootNamespace(onetomany root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #28
0
 internal XTypedElementWrapperAnnotation(XTypedElement typedElement)
 {
     this.typedElement = typedElement;
 }
コード例 #29
0
 public XRootNamespace(property root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #30
0
        private void SetUnionCatchAll(object value,
                                      string propertyName,
                                      XTypedElement container,
                                      XName itemXName,
                                      SimpleTypeValidator typeDef,
                                      SchemaOrigin origin)
        {
            UnionSimpleTypeValidator unionDef = typeDef as UnionSimpleTypeValidator;

            Debug.Assert(unionDef != null);
            SimpleTypeValidator matchingType = null;
            object    typedValue;
            Exception e = unionDef.TryParseValue(value,
                                                 XTypedServices.NameTable,
                                                 new XNamespaceResolver(container.GetUntyped()),
                                                 out matchingType,
                                                 out typedValue);

            if (e != null)
            {
                throw new LinqToXsdException(propertyName, e.Message);
            }
            else
            {
                if (matchingType is ListSimpleTypeValidator)
                {
                    ListSimpleTypeValidator listType = matchingType as ListSimpleTypeValidator;
                    switch (origin)
                    {
                    case SchemaOrigin.Element:
                        SetListElement(itemXName, value, listType.ItemType.DataType);
                        break;

                    case SchemaOrigin.Text:
                        SetListValue(value, listType.ItemType.DataType);
                        break;

                    case SchemaOrigin.Attribute:
                        SetListAttribute(itemXName, value, listType.ItemType.DataType);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (origin)
                    {
                    case SchemaOrigin.Element:
                        SetElement(itemXName, value, matchingType.DataType);
                        break;

                    case SchemaOrigin.Text:
                        SetValue(value, matchingType.DataType);
                        break;

                    case SchemaOrigin.Attribute:
                        SetAttribute(itemXName, value, matchingType.DataType);
                        break;

                    default: break;
                    }
                }
            }
        }
コード例 #31
0
 public XRootNamespace(resultset root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #32
0
 public XTypedList(XTypedElement container, XName itemXName) : this(container, null, itemXName)
 {
 }
コード例 #33
0
 public XRootNamespace(returnscalar root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #34
0
 public XTypedList(XTypedElement container, ILinqToXsdTypeManager typeManager, XName itemXName) : base(container, new XName[] { itemXName })
 {
     this.typeManager = typeManager;
 }
コード例 #35
0
 public XRootNamespace(unionsubclass root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #36
0
 public static XTypedList <T> CopyFromWithValidation(IEnumerable <T> typedObjects, XTypedElement container, XName itemXName, ILinqToXsdTypeManager typeManager, string propertyName, SimpleTypeValidator typeDef)
 {
     return(XTypedList <T> .Initialize(container, typeManager, typedObjects, itemXName));
 }
コード例 #37
0
 public XRootNamespace(sqldeleteall root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #38
0
ファイル: LinqToXsdSource.cs プロジェクト: nickvane/vela
 public XRoot(global::schemas.openehr.org.v1.template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #39
0
ファイル: _Language.cs プロジェクト: mcartoixa/GeoSIK
 public XRootNamespace(animateColor root)
 {
     this.doc=new XDocument(root.Untyped);
     this.rootObject=root;
 }
コード例 #40
0
ファイル: LinqToXsdSource.cs プロジェクト: nickvane/vela
 public XRootNamespace(template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #41
0
        private void SetUnionCatchAll(
            object value,
            string propertyName,
            XTypedElement container,
            XName itemXName,
            SimpleTypeValidator typeDef,
            SchemaOrigin origin)
        {
            UnionSimpleTypeValidator unionDef =
                typeDef as UnionSimpleTypeValidator;

            Debug.Assert(unionDef != null);

            SimpleTypeValidator matchingType = null;
            object typedValue;
            Exception e = unionDef.TryParseValue(
                value,
                XTypedServices.NameTable,
                new XNamespaceResolver(container.GetUntyped()),
                out matchingType,
                out typedValue);

            if (e != null)
            {
                throw new LinqToXsdException(propertyName, e.Message);
            }
            else
            {
                if (matchingType is ListSimpleTypeValidator)
                {
                    ListSimpleTypeValidator listType = matchingType as ListSimpleTypeValidator;
                    switch (origin)
                    {
                        case SchemaOrigin.Element:
                            SetListElement(itemXName, value, listType.ItemType.DataType);
                            break;
                        case SchemaOrigin.Text:
                            SetListValue(value, listType.ItemType.DataType);
                            break;
                        case SchemaOrigin.Attribute:
                            SetListAttribute(itemXName, value, listType.ItemType.DataType);
                            break;
                        default:
                            break;
                    }

                }
                else
                {
                    switch (origin)
                    {
                        case SchemaOrigin.Element: SetElement(itemXName, value, matchingType.DataType); break;
                        case SchemaOrigin.Text: SetValue(value, matchingType.DataType); break;
                        case SchemaOrigin.Attribute: SetAttribute(itemXName, value, matchingType.DataType); break;
                        default: break;
                    }
                }
            }
        }
コード例 #42
0
        public static XTypedElement ToXTypedElement(XElement xe, ILinqToXsdTypeManager typeManager, System.Type t)
        {
            if (xe == null)
            {
                return(null);
            }

            if (!t.IsSubclassOf(typeof(XTypedElement)))
            {
                throw new InvalidOperationException("Type t is not a subtype of XTypedElement");
            }

            if (typeManager == null)
            {
                throw new ArgumentNullException("typeManager");
            }

            //Try getting back as the type first, optimized for the cases where xsi:type cannot appear
            XTypedElement xoSubType = GetAnnotation(t, xe);

            if (xoSubType == null)
            {
                //Try xsi:type and lookup in the typeDictionary
                Type clrType = GetXsiClrType(xe, typeManager);
                if (clrType != null)
                {
                    xoSubType = GetAnnotation(clrType, xe);
                    if (xoSubType != null)
                    {
                        return(xoSubType);
                    }

                    if (!t.IsAssignableFrom(clrType))
                    {
                        //xsi:type is not subtype of schema type
                        clrType = t;
                    }
                }
                else
                {
                    //xsi:type not present or CLRType not found for xsi:type name
                    clrType = t;
                }

                if (clrType.IsAbstract)
                {
                    throw new InvalidOperationException("Cannot cast XElement to an abstract type");
                }

                // get public or instance
                var             exactBinding = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
                ConstructorInfo constrInfo   = clrType.GetConstructor(exactBinding, null, Type.EmptyTypes, null);
                if (constrInfo == null)
                {
                    throw new TypeAccessException($"There is no public/internal parameter-less constructor for type:  {clrType.FullName}");
                }

                xoSubType         = (XTypedElement)constrInfo.Invoke(null);
                xoSubType.Untyped = xe;
                xe.AddAnnotation(new XTypedElementAnnotation(xoSubType));
            }

            return(xoSubType);
        }
コード例 #43
0
ファイル: LinqToXsdSource.cs プロジェクト: nickvane/vela
 public XRoot(global::openEHR.v1.Template.template root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #44
0
 public XRootNamespace(listindex root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #45
0
 public XRootNamespace(detailedreport root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #46
0
 public XRootNamespace(metavalue root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #47
0
ファイル: ContentModel.cs プロジェクト: alcardac/SDMXRI_WS_OF
        internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj) {
            NamedContentModelEntity namedEntity = GetNamedEntity(name);
            if (namedEntity == null) {
                // See http://linqtoxsd.codeplex.com/WorkItem/View.aspx?WorkItemId=3542
                throw new LinqToXsdException(
                    "Name does not belong in content model. Cannot set value for child " +
                    name.LocalName);
            }
            EditAction editAction = EditAction.None;
            XElement elementMarker = FindElementPosition(namedEntity, parentElement, addToExisting, out editAction);

            XElement newElement = XTypedServices.GetXElement(xObj, name);
            Debug.Assert(xObj != null);
            
            switch (editAction) {
                case EditAction.Append:
                    parentElement.Add(newElement);
                break;
                
                case EditAction.Update:
                    elementMarker.AddBeforeSelf(newElement);
                    elementMarker.Remove();
                break;
                
                case EditAction.AddBefore:
                    elementMarker.AddBeforeSelf(newElement);
                break;
            }
        }
コード例 #48
0
 public XRootNamespace(naturalid root)
 {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
コード例 #49
0
 public XRootNamespace(StorageSchema root)
 {
     _xDocument = new XDocument(root.Untyped);
       _rootObject = root;
 }
コード例 #50
0
 public XSimpleList(XTypedElement container, XmlSchemaDatatype dataType, XName itemXName) : base(container, new XName[] { itemXName })
 {
     this.schemaDatatype = dataType;
 }