XsdDataContractImporter.CanImport Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che indica se gli schemi possono essere trasformati in una classe CodeCompileUnit.
Overload
CanImport(XmlSchemaSet) |
Ottiene un valore che indica se gli schemi contenuti in una XmlSchemaSet possono essere trasformati in una CodeCompileUnit. |
CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>) |
Ottiene un valore che indica se il set di tipi specificato contenuto in una classe XmlSchemaSet può essere trasformato in tipi CLR generati in una classe CodeCompileUnit. |
CanImport(XmlSchemaSet, XmlSchemaElement) |
Ottiene un valore che indica se è possibile importare un elemento di schema specifico contenuto in una classe XmlSchemaSet. |
CanImport(XmlSchemaSet, XmlQualifiedName) |
Ottiene un valore che indica se gli schemi contenuti in una XmlSchemaSet possono essere trasformati in una CodeCompileUnit. |
Commenti
Per altre informazioni sui tipi che possono essere importati, vedere Tipi supportati dal serializzatore di contratti dati.
CanImport(XmlSchemaSet)
Ottiene un valore che indica se gli schemi contenuti in una XmlSchemaSet possono essere trasformati in una CodeCompileUnit.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas);
member this.CanImport : System.Xml.Schema.XmlSchemaSet -> bool
Public Function CanImport (schemas As XmlSchemaSet) As Boolean
Parametri
- schemas
- XmlSchemaSet
Classe XmlSchemaSet che contiene gli schemi da trasformare.
Restituisce
true
se gli schemi possono essere trasformati in tipi di contratto dati. In caso contrario, false
.
Eccezioni
Il valore del parametro schemas
è null
.
Un contratto dati coinvolto nell'importazione è non valido.
Esempio
Nell'esempio seguente viene eseguita una chiamata al metodo CanImport per determinare se è possibile generare la classe CodeCompileUnit.
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
Si applica a
CanImport(XmlSchemaSet, ICollection<XmlQualifiedName>)
Ottiene un valore che indica se il set di tipi specificato contenuto in una classe XmlSchemaSet può essere trasformato in tipi CLR generati in una classe CodeCompileUnit.
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);
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
Parametri
- schemas
- XmlSchemaSet
Classe XmlSchemaSet che contiene gli schemi da trasformare.
- typeNames
- ICollection<XmlQualifiedName>
Interfaccia ICollection<T> di XmlQualifiedName che rappresenta il set di tipi di schema da importare.
Restituisce
true
se gli schemi possono essere trasformati. In caso contrario, false
.
Eccezioni
Il parametro schemas
o il parametro typeNames
è null
.
Un contratto dati coinvolto nell'importazione è non valido.
Si applica a
CanImport(XmlSchemaSet, XmlSchemaElement)
Ottiene un valore che indica se è possibile importare un elemento di schema specifico contenuto in una classe XmlSchemaSet.
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);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.Schema.XmlSchemaElement -> bool
Public Function CanImport (schemas As XmlSchemaSet, element As XmlSchemaElement) As Boolean
Parametri
- schemas
- XmlSchemaSet
Classe XmlSchemaSet da importare.
- element
- XmlSchemaElement
Classe XmlSchemaElement specifica in cui archiviare il set di schemi.
Restituisce
true
se è possibile importare l'elemento. In caso contrario, false
.
Eccezioni
Il parametro schemas
o il parametro element
è null
.
Un contratto dati coinvolto nell'importazione è non valido.
Commenti
Questo metodo controlla il tipo e tutti i tipi di schema a cui viene fatto riferimento da esso.
Si applica a
CanImport(XmlSchemaSet, XmlQualifiedName)
Ottiene un valore che indica se gli schemi contenuti in una XmlSchemaSet possono essere trasformati in una CodeCompileUnit.
public:
bool CanImport(System::Xml::Schema::XmlSchemaSet ^ schemas, System::Xml::XmlQualifiedName ^ typeName);
public bool CanImport (System.Xml.Schema.XmlSchemaSet schemas, System.Xml.XmlQualifiedName typeName);
member this.CanImport : System.Xml.Schema.XmlSchemaSet * System.Xml.XmlQualifiedName -> bool
Public Function CanImport (schemas As XmlSchemaSet, typeName As XmlQualifiedName) As Boolean
Parametri
- schemas
- XmlSchemaSet
Classe XmlSchemaSet che contiene le rappresentazioni di schema.
- typeName
- XmlQualifiedName
Interfaccia IList di tipo XmlQualifiedName che specifica i nomi dei tipi di schema che devono essere importati dalla classe XmlSchemaSet.
Restituisce
true
se gli schemi possono essere trasformati in tipi di contratto dati. In caso contrario, false
.
Eccezioni
Il parametro schemas
o il parametro typeName
è null
.
Un contratto dati coinvolto nell'importazione è non valido.
Commenti
Per altre informazioni sui tipi che possono essere importati, vedere Tipi supportati dal serializzatore di contratti dati.
Si applica a
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per