XsdDataContractImporter.CanImport Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger om scheman kan omvandlas till en CodeCompileUnit.
Överlagringar
| Name | Description |
|---|---|
| CanImport(XmlSchemaSet) |
Hämtar ett värde som anger om scheman som finns i en XmlSchemaSet kan omvandlas till en CodeCompileUnit. |
| CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>) |
Hämtar ett värde som anger om den angivna uppsättningen typer som finns i en XmlSchemaSet kan omvandlas till CLR-typer som genereras till en CodeCompileUnit. |
| CanImport(XmlSchemaSet, XmlSchemaElement) |
Hämtar ett värde som anger om ett specifikt schemaelement som finns i ett XmlSchemaSet kan importeras. |
| CanImport(XmlSchemaSet, XmlQualifiedName) |
Hämtar ett värde som anger om scheman som finns i en XmlSchemaSet kan omvandlas till en CodeCompileUnit. |
Kommentarer
Mer information om typer som kan importeras finns i Typer som stöds av Data Contract Serializer.
CanImport(XmlSchemaSet)
Hämtar ett värde som anger om scheman som finns i en XmlSchemaSet kan omvandlas till en CodeCompileUnit.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas);
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
member this.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
Public Function CanImport (schemas As XmlSchemaSet) As Boolean
Parametrar
- schemas
- XmlSchemaSet
En XmlSchemaSet som innehåller de scheman som ska transformeras.
Returer
trueom scheman kan omvandlas till datakontraktstyper; annars . false
- Attribut
Undantag
Parametern schemas är null.
Ett datakontrakt som ingår i importen är ogiltigt.
Exempel
I följande exempel anropas CanImport metoden för att avgöra om kan CodeCompileUnit genereras.
static CodeCompileUnit Import(XmlSchemaSet schemas)
{
XsdDataContractImporter imp = new XsdDataContractImporter();
// The EnableDataBinding option adds a RaisePropertyChanged method to
// the generated code. The GenerateInternal causes code access to be
// set to internal.
ImportOptions iOptions = new ImportOptions();
iOptions.EnableDataBinding = true;
iOptions.GenerateInternal = true;
imp.Options = iOptions;
if (imp.CanImport(schemas))
{
imp.Import(schemas);
return imp.CodeCompileUnit;
}
else
{
return null;
}
}
Shared Function Import(ByVal schemas As XmlSchemaSet) As CodeCompileUnit
Dim imp As New XsdDataContractImporter()
' The EnableDataBinding option adds a RaisePropertyChanged method to
' the generated code. The GenerateInternal causes code access to be
' set to internal.
Dim iOptions As New ImportOptions()
iOptions.EnableDataBinding = true
iOptions.GenerateInternal = true
imp.Options = IOptions
If imp.CanImport(schemas) Then
imp.Import(schemas)
Return imp.CodeCompileUnit
Else
Return Nothing
End If
End Function
Gäller för
CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)
Hämtar ett värde som anger om den angivna uppsättningen typer som finns i en XmlSchemaSet kan omvandlas till CLR-typer som genereras till en CodeCompileUnit.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Collections::Generic::ICollection<System::Xml::XmlQualifiedName ^> ^ typeNames);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> typeNames);
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> typeNames);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> bool
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Collections.Generic.ICollection<System.Xml.XmlQualifiedName> -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeNames As ICollection(Of XmlQualifiedName)) As Boolean
Parametrar
- schemas
- XmlSchemaSet
De scheman som ska transformeras.
- typeNames
- ICollection<XmlQualifiedName>
Den uppsättning schematyper som ska importeras.
Returer
trueom scheman kan transformeras; annars . false
- Attribut
Undantag
Parametern schemas eller typeNames är null.
Ett datakontrakt som ingår i importen är ogiltigt.
Gäller för
CanImport(XmlSchemaSet, XmlSchemaElement)
Hämtar ett värde som anger om ett specifikt schemaelement som finns i ett XmlSchemaSet kan importeras.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::Schema::XmlSchemaElement ^ element);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.Schema.XmlSchemaElement element);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
Public Function CanImport (schemas As XmlSchemaSet, element As XmlSchemaElement) As Boolean
Parametrar
- schemas
- XmlSchemaSet
En XmlSchemaSet som ska importeras.
- element
- XmlSchemaElement
En specifik XmlSchemaElement för att checka in uppsättningen scheman.
Returer
trueom elementet kan importeras. annars . false
- Attribut
Undantag
Parametern schemas eller element är null.
Ett datakontrakt som ingår i importen är ogiltigt.
Kommentarer
Den här metoden kontrollerar typen och alla schematyper som refereras från den.
Gäller för
CanImport(XmlSchemaSet, XmlQualifiedName)
Hämtar ett värde som anger om scheman som finns i en XmlSchemaSet kan omvandlas till en CodeCompileUnit.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")]
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
public bool CanImport(System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Data Contract Serialization and Deserialization might require types that cannot be statically analyzed. Make sure all of the required types are preserved.")>]
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeName As XmlQualifiedName) As Boolean
Parametrar
- schemas
- XmlSchemaSet
Schemarepresentationerna.
- typeName
- XmlQualifiedName
Namnen på de schematyper som måste importeras från XmlSchemaSet.
Returer
trueom scheman kan omvandlas till datakontraktstyper; annars . false
- Attribut
Undantag
Parametern schemas eller typeName är null.
Ett datakontrakt som ingår i importen är ogiltigt.
Kommentarer
Mer information om typer som kan importeras finns i Typer som stöds av Data Contract Serializer.