本文整理汇总了C#中System.Xml.Serialization.XmlSchemas.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSchemas.Contains方法的具体用法?C# XmlSchemas.Contains怎么用?C# XmlSchemas.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlSchemas
的用法示例。
在下文中一共展示了XmlSchemas.Contains方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SchemaImporter
internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, System.Xml.Serialization.ImportContext context)
{
if (!schemas.Contains("http://www.w3.org/2001/XMLSchema"))
{
schemas.AddReference(XmlSchemas.XsdSchema);
schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
}
if (!schemas.Contains("http://www.w3.org/XML/1998/namespace"))
{
schemas.AddReference(XmlSchemas.XmlSchema);
schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
}
this.schemas = schemas;
this.options = options;
this.codeProvider = codeProvider;
this.context = context;
this.Schemas.SetCache(this.Context.Cache, this.Context.ShareTypes);
SchemaImporterExtensionsSection section = System.Configuration.PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SchemaImporterExtensionsSectionPath) as SchemaImporterExtensionsSection;
if (section != null)
{
this.extensions = section.SchemaImporterExtensionsInternal;
}
else
{
this.extensions = new SchemaImporterExtensionCollection();
}
}
示例2: SchemaImporter
internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context)
{
if (!schemas.Contains(XmlSchema.Namespace))
{
schemas.AddReference(XmlSchemas.XsdSchema);
schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
}
if (!schemas.Contains(XmlReservedNs.NsXml))
{
schemas.AddReference(XmlSchemas.XmlSchema);
schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
}
_schemas = schemas;
_options = options;
_context = context;
Schemas.SetCache(Context.Cache, Context.ShareTypes);
}
示例3: SchemaImporter
internal SchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, CodeDomProvider codeProvider, ImportContext context) {
if (!schemas.Contains(XmlSchema.Namespace)) {
schemas.AddReference(XmlSchemas.XsdSchema);
schemas.SchemaSet.Add(XmlSchemas.XsdSchema);
}
if (!schemas.Contains(XmlReservedNs.NsXml)) {
schemas.AddReference(XmlSchemas.XmlSchema);
schemas.SchemaSet.Add(XmlSchemas.XmlSchema);
}
this.schemas = schemas;
this.options = options;
this.codeProvider = codeProvider;
this.context = context;
Schemas.SetCache(Context.Cache, Context.ShareTypes);
SchemaImporterExtensionsSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SchemaImporterExtensionsSectionPath) as SchemaImporterExtensionsSection;
if (section != null)
extensions = section.SchemaImporterExtensionsInternal;
else
extensions = new SchemaImporterExtensionCollection();
}
示例4: ResolveImportedSchemas
/// <summary>
///
/// Resolve the pointers to included schemas.
///
/// When we generate the schemas from types, and more than one schema is generated,
/// the "master" schema that contains the schema for the type that is the parameter
/// for this method will "include" the other schemas that define the
/// types it inherits from or the types that it returns in it's properties.
/// If we read this schema off the disk, then the XmlSchemaExternal class's Schema property
/// would contain a pointer to the included schema. This is not the case for generated
/// schemas.
///
/// What we do in this method is recurse through the generated schemas, and look for
/// included schemas who's pointers are null. Then we find out what namespoace those
/// include schemas are in, and look for that in the generated schemas collection.
///
/// If we find it, we "fix" the pointer by setting it to the proper generated schema.
///
/// This method modified the schemas in the schema collection
/// </summary>
/// <param name="xmlSchema">The master schema</param>
/// <param name="schemas">the collection of generated schemas</param>
private void ResolveImportedSchemas(XmlSchema xmlSchema, XmlSchemas schemas)
{
string baseSchemaName = GenerateName();
if (string.IsNullOrEmpty(xmlSchema.SourceUri))
{
xmlSchema.Id = Path.GetFileNameWithoutExtension(baseSchemaName);
xmlSchema.SourceUri = baseSchemaName;
}
foreach (XmlSchemaObject externalSchemaObj in xmlSchema.Includes)
{
XmlSchemaExternal externalSchema = externalSchemaObj as XmlSchemaExternal;
if (externalSchema == null) continue;
// if the external schema is not null, we have nothing to worry about
if (externalSchema.Schema != null) continue;
// if the external schema is null, find it in the schema set
XmlSchemaImport importSchema = externalSchemaObj as XmlSchemaImport;
if (importSchema != null)
{
if (schemas.Contains(importSchema.Namespace))
{
XmlSchema referencedSchema = schemas[importSchema.Namespace];
importSchema.Schema = referencedSchema;
string name = GenerateName();
importSchema.Schema.Id = Path.GetFileNameWithoutExtension(name);
importSchema.Schema.SourceUri = name;
importSchema.SchemaLocation = MakeRelative(xmlSchema.SourceUri, name);
}
}
// resolve any included schemas in the external schema
ResolveImportedSchemas(externalSchema.Schema, schemas);
}
}
示例5: AddSchema
private static void AddSchema(XmlSchema schema, bool isEncoded, bool isLiteral, XmlSchemas abstractSchemas, XmlSchemas concreteSchemas, Hashtable references)
{
if (schema != null)
{
if (isEncoded && !abstractSchemas.Contains(schema))
{
if (references.Contains(schema))
{
abstractSchemas.AddReference(schema);
}
else
{
abstractSchemas.Add(schema);
}
}
if (isLiteral && !concreteSchemas.Contains(schema))
{
if (references.Contains(schema))
{
concreteSchemas.AddReference(schema);
}
else
{
concreteSchemas.Add(schema);
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:ServiceDescriptionImporter.cs
示例6: ResolveImportedSchemas
/// <summary>
///
/// Resolve the pointers to included schemas.
///
/// When we generate the schemas from types, and more than one schema is generated,
/// the "master" schema that contains the schema for the type that is the parameter
/// for this method will "include" the other schemas that define the
/// types it inherits from or the types that it returns in it's properties.
/// If we read this schema off the disk, then the XmlSchemaExternal class's Schema property
/// would contain a pointer to the included schema. This is not the case for generated
/// schemas.
///
/// What we do in this method is recurse through the generated schemas, and look for
/// included schemas who's pointers are null. Then we find out what namespoace those
/// include schemas are in, and look for that in the generated schemas collection.
///
/// If we find it, we "fix" the pointer by setting it to the proper generated schema.
///
/// This method modified the schemas in the schema collection
/// </summary>
/// <param name="xmlSchema">The master schema</param>
/// <param name="schemas">the collection of generated schemas</param>
private static void ResolveImportedSchemas(XmlSchema xmlSchema, XmlSchemas schemas)
{
string baseSchemaName = NameGenerator.GenerateName();
if (string.IsNullOrEmpty(xmlSchema.SourceUri))
{
xmlSchema.Id = baseSchemaName;
xmlSchema.SourceUri = "file:///" + baseSchemaName + ".xsd";
}
foreach (XmlSchemaObject externalSchemaObj in xmlSchema.Includes)
{
XmlSchemaExternal externalSchema = externalSchemaObj as XmlSchemaExternal;
if (externalSchema == null) continue;
// if the external schema is not null, we have nothing to worry about
if (externalSchema.Schema != null) continue;
// if the external schema is null, find it in the schema set
XmlSchemaImport importSchema = externalSchemaObj as XmlSchemaImport;
if (importSchema != null)
{
if (schemas.Contains(importSchema.Namespace))
{
XmlSchema referencedSchema = schemas[importSchema.Namespace];
importSchema.Schema = referencedSchema;
string name = NameGenerator.GenerateName();
importSchema.Schema.Id = name;
importSchema.Schema.SourceUri = "file:///" + name + ".xsd";
importSchema.SchemaLocation = name + ".xsd";
}
}
// resolve any included schemas in the external schema
ResolveImportedSchemas(externalSchema.Schema, schemas);
}
}
示例7: CollectEncodedAndLiteralSchemas
// Segregate the schemas containing abstract types from those
// containing regular XML definitions. This is important because
// when you import something returning the ur-type (object), then
// you need to import ALL types/elements within ALL schemas. We
// don't want the RPC-based types leaking over into the XML-based
// element definitions or literal types in the encoded schemas,
// beacase it can cause schema coimpilation falure.
static void CollectEncodedAndLiteralSchemas(WsdlNS.ServiceDescriptionCollection serviceDescriptions, XmlSchemas encodedSchemas, XmlSchemas literalSchemas, XmlSchemaSet allSchemas)
{
XmlSchema wsdl = StockSchemas.CreateWsdl();
XmlSchema soap = StockSchemas.CreateSoap();
XmlSchema soapEncoding = StockSchemas.CreateSoapEncoding();
Hashtable references = new Hashtable();
if (!allSchemas.Contains(wsdl.TargetNamespace))
{
references[soap] = wsdl;
}
if (!allSchemas.Contains(soap.TargetNamespace))
{
references[soap] = soap;
}
if (!allSchemas.Contains(soapEncoding.TargetNamespace))
{
references[soapEncoding] = soapEncoding;
}
foreach (WsdlNS.ServiceDescription description in serviceDescriptions)
{
foreach (WsdlNS.Message message in description.Messages)
{
foreach (WsdlNS.MessagePart part in message.Parts)
{
bool isEncoded;
bool isLiteral;
FindUse(part, out isEncoded, out isLiteral);
if (part.Element != null && !part.Element.IsEmpty)
{
XmlSchemaElement element = FindSchemaElement(allSchemas, part.Element);
if (element != null)
{
AddSchema(element.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
if (element.SchemaTypeName != null && !element.SchemaTypeName.IsEmpty)
{
XmlSchemaType type = FindSchemaType(allSchemas, element.SchemaTypeName);
if (type != null)
{
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
}
}
}
}
if (part.Type != null && !part.Type.IsEmpty)
{
XmlSchemaType type = FindSchemaType(allSchemas, part.Type);
if (type != null)
{
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, encodedSchemas, literalSchemas, references);
}
}
}
}
}
Hashtable imports;
foreach (XmlSchemas schemas in new XmlSchemas[] { encodedSchemas, literalSchemas })
{
// collect all imports
imports = new Hashtable();
foreach (XmlSchema schema in schemas)
{
AddImport(schema, imports, allSchemas);
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys)
{
if (references[schema] == null && !schemas.Contains(schema))
{
schemas.Add(schema);
}
}
}
// If a schema was not referenced by either a literal or an encoded message part,
// add it to both collections. There's no way to tell which it should be.
imports = new Hashtable();
foreach (XmlSchema schema in allSchemas.Schemas())
{
if (!encodedSchemas.Contains(schema) && !literalSchemas.Contains(schema))
{
AddImport(schema, imports, allSchemas);
}
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys)
{
if (references[schema] != null)
continue;
if (!encodedSchemas.Contains(schema))
//.........这里部分代码省略.........
示例8: AddSchema
static void AddSchema(XmlSchema schema, bool isEncoded, bool isLiteral, XmlSchemas encodedSchemas, XmlSchemas literalSchemas, Hashtable references)
{
if (schema != null)
{
if (isEncoded && !encodedSchemas.Contains(schema))
{
if (references.Contains(schema))
{
encodedSchemas.AddReference(schema);
}
else
{
encodedSchemas.Add(schema);
}
}
if (isLiteral && !literalSchemas.Contains(schema))
{
if (references.Contains(schema))
{
literalSchemas.AddReference(schema);
}
else
{
literalSchemas.Add(schema);
}
}
}
}
示例9: AddIncludingSchema
void AddIncludingSchema (XmlSchemas list, string ns)
{
XmlSchema sc = Schemas [ns];
if (sc == null || list.Contains (sc)) return;
list.Add (sc);
foreach (XmlSchemaObject ob in sc.Includes)
{
XmlSchemaImport import = ob as XmlSchemaImport;
if (import != null) AddIncludingSchema (list, import.Namespace);
}
}
示例10: ClasifySchemas
void ClasifySchemas (ArrayList importInfo)
{
// I don't like this, but I could not find any other way of clasifying
// schemas between encoded and literal.
xmlSchemas = new XmlSchemas ();
soapSchemas = new XmlSchemas ();
foreach (ImportInfo info in importInfo)
{
foreach (Service service in info.ServiceDescription.Services)
{
foreach (Port port in service.Ports)
{
this.iinfo = info;
this.port = port;
binding = ServiceDescriptions.GetBinding (port.Binding);
if (binding == null) continue;
portType = ServiceDescriptions.GetPortType (binding.Type);
if (portType == null) continue;
foreach (OperationBinding oper in binding.Operations)
{
operationBinding = oper;
operation = FindPortOperation ();
if (operation == null) continue;
foreach (OperationMessage omsg in operation.Messages)
{
Message msg = ServiceDescriptions.GetMessage (omsg.Message);
if (msg == null) continue;
if (omsg is OperationInput)
inputMessage = msg;
else
outputMessage = msg;
}
if (GetMessageEncoding (oper.Input) == SoapBindingUse.Encoded)
AddMessageSchema (soapSchemas, oper.Input, inputMessage);
else
AddMessageSchema (xmlSchemas, oper.Input, inputMessage);
if (oper.Output != null) {
if (GetMessageEncoding (oper.Output) == SoapBindingUse.Encoded)
AddMessageSchema (soapSchemas, oper.Output, outputMessage);
else
AddMessageSchema (xmlSchemas, oper.Output, outputMessage);
}
}
}
}
}
XmlSchemas defaultList = xmlSchemas;
if (xmlSchemas.Count == 0 && soapSchemas.Count > 0)
defaultList = soapSchemas;
// Schemas not referenced by any message
foreach (XmlSchema sc in Schemas)
{
if (!soapSchemas.Contains (sc) && !xmlSchemas.Contains (sc)) {
if (ImportsEncodedNamespace (sc))
soapSchemas.Add (sc);
else
defaultList.Add (sc);
}
}
}
示例11: Import
private ServiceDescriptionImportWarnings Import(CodeNamespace codeNamespace, ImportContext importContext, Hashtable exportContext, StringCollection warnings) {
allSchemas = new XmlSchemas();
foreach (XmlSchema schema in schemas) {
allSchemas.Add(schema);
}
foreach (ServiceDescription description in serviceDescriptions) {
foreach (XmlSchema schema in description.Types.Schemas) {
allSchemas.Add(schema);
}
}
Hashtable references = new Hashtable();
if (!allSchemas.Contains(ServiceDescription.Namespace)) {
allSchemas.AddReference(ServiceDescription.Schema);
references[ServiceDescription.Schema] = ServiceDescription.Schema;
}
if (!allSchemas.Contains(Soap.Encoding)) {
allSchemas.AddReference(ServiceDescription.SoapEncodingSchema);
references[ServiceDescription.SoapEncodingSchema] = ServiceDescription.SoapEncodingSchema;
}
allSchemas.Compile(null, false);
// Segregate the schemas containing abstract types from those
// containing regular XML definitions. This is important because
// when you import something returning the ur-type (object), then
// you need to import ALL types/elements within ALL schemas. We
// don't want the RPC-based types leaking over into the XML-based
// element definitions. This also occurs when you have derivation:
// we need to search the schemas for derived types: but WHICH schemas
// should we search.
foreach (ServiceDescription description in serviceDescriptions) {
foreach (Message message in description.Messages) {
foreach (MessagePart part in message.Parts) {
bool isEncoded;
bool isLiteral;
FindUse(part, out isEncoded, out isLiteral);
if (part.Element != null && !part.Element.IsEmpty) {
if (isEncoded) throw new InvalidOperationException(Res.GetString(Res.CanTSpecifyElementOnEncodedMessagePartsPart, part.Name, message.Name));
XmlSchemaElement element = (XmlSchemaElement)allSchemas.Find(part.Element, typeof(XmlSchemaElement));
if (element != null) {
AddSchema(element.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
if (element.SchemaTypeName != null && !element.SchemaTypeName.IsEmpty) {
XmlSchemaType type = (XmlSchemaType)allSchemas.Find(element.SchemaTypeName, typeof(XmlSchemaType));
if (type != null) {
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
}
}
}
}
if (part.Type != null && !part.Type.IsEmpty) {
XmlSchemaType type = (XmlSchemaType)allSchemas.Find(part.Type, typeof(XmlSchemaType));
if (type != null) {
AddSchema(type.Parent as XmlSchema, isEncoded, isLiteral, abstractSchemas, concreteSchemas, references);
}
}
}
}
}
Hashtable imports;
foreach (XmlSchemas xmlschemas in new XmlSchemas[] { abstractSchemas, concreteSchemas }) {
// collect all imports
imports = new Hashtable();
foreach (XmlSchema schema in xmlschemas) {
AddImport(schema, imports);
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys) {
if (references[schema] == null && !xmlschemas.Contains(schema)) {
xmlschemas.Add(schema);
}
}
}
// If a schema was not referenced by either a literal or an encoded message part,
// add it to both collections. There's no way to tell which it should be.
imports = new Hashtable();
foreach (XmlSchema schema in allSchemas) {
if (!abstractSchemas.Contains(schema) && !concreteSchemas.Contains(schema)) {
AddImport(schema, imports);
}
}
// make sure we add them to the corresponding schema collections
foreach (XmlSchema schema in imports.Keys) {
if (references[schema] != null)
continue;
if (!abstractSchemas.Contains(schema)) {
abstractSchemas.Add(schema);
}
if (!concreteSchemas.Contains(schema)) {
concreteSchemas.Add(schema);
}
}
if (abstractSchemas.Count > 0) {
foreach (XmlSchema schema in references.Values) {
abstractSchemas.AddReference(schema);
}
StringCollection schemaWarnings = SchemaCompiler.Compile(abstractSchemas);
foreach (string warning in schemaWarnings)
warnings.Add(warning);
//.........这里部分代码省略.........
示例12: AddIncludingSchema
void AddIncludingSchema (XmlSchemas list, string ns)
{
foreach (XmlSchema sc in Schemas) {
if (sc.TargetNamespace == ns && !list.Contains (sc)) {
list.Add (sc);
foreach (XmlSchemaObject ob in sc.Includes) {
XmlSchemaImport import = ob as XmlSchemaImport;
if (import != null) AddIncludingSchema (list, import.Namespace);
}
}
}
}