Esempio n. 1
0
        public bool CanImport(XmlSchemaSet schemas)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            return(InternalCanImport(schemas, null, null));
        }
Esempio n. 2
0
        public void Import(XmlSchemaSet schemas)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            InternalImport(schemas, null, null);
        }
Esempio n. 3
0
 internal HashSet <string> GetMemberNames()
 {
     if (ReferencedTypeExists)
     {
         throw ExceptionUtil.ThrowHelperError(new InvalidOperationException(SR.Format(SR.CannotSetMembersForReferencedType, TypeReference?.BaseType)));
     }
     else
     {
         return(_memberNames ??= new HashSet <string>(StringComparer.OrdinalIgnoreCase));
     }
 }
Esempio n. 4
0
        public bool CanImport(XmlSchemaSet schemas, XmlQualifiedName typeName)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            if (typeName == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeName)));
            }

            return(InternalCanImport(schemas, new XmlQualifiedName[] { typeName }, null));
        }
Esempio n. 5
0
        public bool CanImport(XmlSchemaSet schemas, ICollection <XmlQualifiedName> typeNames)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            if (typeNames == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeNames)));
            }

            return(InternalCanImport(schemas, typeNames, null));
        }
Esempio n. 6
0
        public CodeTypeReference GetCodeTypeReference(XmlQualifiedName typeName, XmlSchemaElement element)
        {
            if (element == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(element)));
            }
            if (typeName == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeName)));
            }
            DataContract dataContract = FindDataContract(typeName);
            CodeExporter codeExporter = new CodeExporter(DataContractSet, Options, CodeCompileUnit);

            return(codeExporter.GetElementTypeReference(dataContract, element.IsNillable));
        }
Esempio n. 7
0
        public bool CanImport(XmlSchemaSet schemas, XmlSchemaElement element)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            if (element == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(element)));
            }

            SingleElementArray[0] = element;
            return(InternalCanImport(schemas, s_emptyTypeNameArray, SingleElementArray));
        }
Esempio n. 8
0
        public void Import(XmlSchemaSet schemas, XmlQualifiedName typeName)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            if (typeName == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeName)));
            }

            SingleTypeNameArray[0] = typeName;
            InternalImport(schemas, SingleTypeNameArray, null);
        }
Esempio n. 9
0
        public XmlQualifiedName?Import(XmlSchemaSet schemas, XmlSchemaElement element)
        {
            if (schemas == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(schemas)));
            }

            if (element == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(element)));
            }

            SingleElementArray[0] = element;
            IList <XmlQualifiedName>?elementNames = InternalImport(schemas, s_emptyTypeNameArray, SingleElementArray);

            Debug.Assert(elementNames != null && elementNames.Count > 0);
            return(elementNames[0]);
        }
Esempio n. 10
0
        internal DataContract FindDataContract(XmlQualifiedName typeName)
        {
            if (typeName == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeName)));
            }

            DataContract?dataContract = DataContract.GetBuiltInDataContract(typeName.Name, typeName.Namespace);

            if (dataContract == null)
            {
                dataContract = DataContractSet.GetDataContract(typeName);
                if (dataContract == null)
                {
                    throw ExceptionUtil.ThrowHelperError(new InvalidOperationException(SR.Format(SR.TypeHasNotBeenImported, typeName.Name, typeName.Namespace)));
                }
            }
            return(dataContract);
        }
Esempio n. 11
0
        public ICollection <CodeTypeReference>?GetKnownTypeReferences(XmlQualifiedName typeName)
        {
            if (typeName == null)
            {
                throw ExceptionUtil.ThrowHelperError(new ArgumentNullException(nameof(typeName)));
            }

            DataContract?dataContract = DataContract.GetBuiltInDataContract(typeName.Name, typeName.Namespace);

            if (dataContract == null)
            {
                dataContract = DataContractSet.GetDataContract(typeName);
                if (dataContract == null)
                {
                    throw ExceptionUtil.ThrowHelperError(new InvalidOperationException(SR.Format(SR.TypeHasNotBeenImported, typeName.Name, typeName.Namespace)));
                }
            }

            CodeExporter codeExporter = new CodeExporter(DataContractSet, Options, CodeCompileUnit);

            return(codeExporter.GetKnownTypeReferences(dataContract));
        }
Esempio n. 12
0
        internal static XmlQualifiedName ImportActualType(XmlSchemaAnnotation?annotation, XmlQualifiedName defaultTypeName, XmlQualifiedName typeName)
        {
            XmlElement?actualTypeElement = ImportAnnotation(annotation, ActualTypeAnnotationName);

            if (actualTypeElement == null)
            {
                return(defaultTypeName);
            }

            XmlNode?nameAttribute = actualTypeElement.Attributes.GetNamedItem(ImportGlobals.ActualTypeNameAttribute);

            if (nameAttribute?.Value == null)
            {
                throw ExceptionUtil.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.AnnotationAttributeNotFound, ActualTypeAnnotationName.Name, typeName.Name, typeName.Namespace, ImportGlobals.ActualTypeNameAttribute)));
            }
            XmlNode?nsAttribute = actualTypeElement.Attributes.GetNamedItem(ImportGlobals.ActualTypeNamespaceAttribute);

            if (nsAttribute?.Value == null)
            {
                throw ExceptionUtil.ThrowHelperError(new InvalidDataContractException(SR.Format(SR.AnnotationAttributeNotFound, ActualTypeAnnotationName.Name, typeName.Name, typeName.Namespace, ImportGlobals.ActualTypeNamespaceAttribute)));
            }
            return(new XmlQualifiedName(nameAttribute.Value, nsAttribute.Value));
        }