本文整理汇总了C#中System.Xml.Serialization.CodeIdentifiers.AddReserved方法的典型用法代码示例。如果您正苦于以下问题:C# CodeIdentifiers.AddReserved方法的具体用法?C# CodeIdentifiers.AddReserved怎么用?C# CodeIdentifiers.AddReserved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.CodeIdentifiers
的用法示例。
在下文中一共展示了CodeIdentifiers.AddReserved方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddReservedIdentifiersForDataBinding
internal void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
{
if ((this.options & CodeGenerationOptions.EnableDataBinding) != CodeGenerationOptions.None)
{
scope.AddReserved(CodeExporter.PropertyChangedEvent.Name);
scope.AddReserved(CodeExporter.RaisePropertyChangedEventMethod.Name);
}
}
示例2: BuildClassMap
void BuildClassMap (XmlTypeMapping map, XmlQualifiedName typeQName, XmlSchemaComplexType stype)
{
CodeIdentifiers classIds = new CodeIdentifiers();
classIds.AddReserved (map.TypeData.TypeName);
ClassMap cmap = new ClassMap ();
map.ObjectMap = cmap;
bool isMixed = stype.IsMixed;
if (stype.Particle != null)
ImportParticleComplexContent (typeQName, cmap, stype.Particle, classIds, isMixed);
else
{
if (stype.ContentModel is XmlSchemaSimpleContent) {
ImportSimpleContent (typeQName, map, (XmlSchemaSimpleContent)stype.ContentModel, classIds, isMixed);
}
else if (stype.ContentModel is XmlSchemaComplexContent) {
ImportComplexContent (typeQName, map, (XmlSchemaComplexContent)stype.ContentModel, classIds, isMixed);
}
}
ImportAttributes (typeQName, cmap, stype.Attributes, stype.AnyAttribute, classIds);
ImportExtensionTypes (typeQName);
if (isMixed) AddTextMember (typeQName, cmap, classIds);
AddObjectDerivedMap (map);
}
示例3: ImportClassSimpleType
XmlTypeMapping ImportClassSimpleType (XmlQualifiedName typeQName, XmlSchemaSimpleType stype, XmlQualifiedName root)
{
if (CanBeEnum (stype))
{
// Create an enum map
CodeIdentifiers codeIdents = new CodeIdentifiers ();
XmlTypeMapping enumMap = CreateTypeMapping (typeQName, SchemaTypes.Enum, root);
enumMap.Documentation = GetDocumentation (stype);
bool isFlags = false;
if (stype.Content is XmlSchemaSimpleTypeList) {
stype = ((XmlSchemaSimpleTypeList)stype.Content).ItemType;
isFlags = true;
}
XmlSchemaSimpleTypeRestriction rest = (XmlSchemaSimpleTypeRestriction)stype.Content;
codeIdents.AddReserved (enumMap.TypeData.TypeName);
EnumMap.EnumMapMember[] members = new EnumMap.EnumMapMember [rest.Facets.Count];
for (int n=0; n<rest.Facets.Count; n++)
{
XmlSchemaEnumerationFacet enu = (XmlSchemaEnumerationFacet) rest.Facets[n];
string enumName = codeIdents.AddUnique(CodeIdentifier.MakeValid (enu.Value), enu);
members [n] = new EnumMap.EnumMapMember (enu.Value, enumName);
members [n].Documentation = GetDocumentation (enu);
}
enumMap.ObjectMap = new EnumMap (members, isFlags);
enumMap.IsSimpleType = true;
return enumMap;
}
if (stype.Content is XmlSchemaSimpleTypeList)
{
XmlSchemaSimpleTypeList slist = (XmlSchemaSimpleTypeList)stype.Content;
TypeData arrayTypeData = FindBuiltInType (slist.ItemTypeName, stype);
ListMap listMap = new ListMap ();
listMap.ItemInfo = new XmlTypeMapElementInfoList ();
listMap.ItemInfo.Add (CreateElementInfo (typeQName.Namespace, null, "Item", arrayTypeData.ListItemTypeData, false, XmlSchemaForm.None, -1));
XmlTypeMapping map = CreateArrayTypeMapping (typeQName, arrayTypeData);
map.ObjectMap = listMap;
map.IsSimpleType = true;
return map;
}
// It is an extension of a primitive or known type
TypeData typeData = FindBuiltInType (typeQName, stype);
XmlTypeMapping rmap = GetTypeMapping (typeData);
// The resulting map must be a simple type. It needs to be explicitely set for arrays
rmap.IsSimpleType = true;
return rmap;
}
示例4: ImportStructType
StructMapping ImportStructType(XmlSchemaComplexType type, string typeNs, bool excludeFromImport) {
if (type.Name == null) {
XmlSchemaElement element = (XmlSchemaElement)type.Parent;
XmlQualifiedName parentType = XmlSchemas.GetParentName(element);
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidSchemaElementType, parentType.Name, parentType.Namespace, element.Name));
}
TypeDesc baseTypeDesc = null;
Mapping baseMapping = null;
if (!type.DerivedFrom.IsEmpty) {
baseMapping = ImportType(type.DerivedFrom, excludeFromImport);
if (baseMapping is StructMapping)
baseTypeDesc = ((StructMapping)baseMapping).TypeDesc;
else
baseMapping = null;
}
if (baseMapping == null) baseMapping = GetRootMapping();
Mapping previousMapping = (Mapping)ImportedMappings[type];
if (previousMapping != null) {
return (StructMapping)previousMapping;
}
string typeName = GenerateUniqueTypeName(Accessor.UnescapeName(type.Name));
StructMapping structMapping = new StructMapping();
structMapping.IsReference = Schemas.IsReference(type);
TypeFlags flags = TypeFlags.Reference;
if (type.IsAbstract) flags |= TypeFlags.Abstract;
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = type.Name;
structMapping.BaseMapping = (StructMapping)baseMapping;
ImportedMappings.Add(type, structMapping);
if (excludeFromImport)
structMapping.IncludeInSchema = false;
CodeIdentifiers members = new CodeIdentifiers();
members.AddReserved(typeName);
AddReservedIdentifiersForDataBinding(members);
structMapping.Members = ImportTypeMembers(type, typeNs, members);
Scope.AddTypeMapping(structMapping);
ImportDerivedTypes(new XmlQualifiedName(type.Name, typeNs));
return structMapping;
}
示例5: ImportStructDataType
StructMapping ImportStructDataType(XmlSchemaSimpleType dataType, string typeNs, string identifier, Type baseType) {
string typeName = GenerateUniqueTypeName(identifier);
StructMapping structMapping = new StructMapping();
TypeFlags flags = TypeFlags.Reference;
TypeDesc baseTypeDesc = scope.GetTypeDesc(baseType);
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = identifier;
CodeIdentifiers members = new CodeIdentifiers();
members.AddReserved(typeName);
ImportTextMember(members, null);
structMapping.Members = (MemberMapping[])members.ToArray(typeof(MemberMapping));
scope.AddTypeMapping(structMapping);
return structMapping;
}
示例6: ImportStructType
private StructMapping ImportStructType(XmlSchemaType type, string typeNs, string identifier, Type baseType, bool arrayLike)
{
TypeDesc baseTypeDesc = null;
TypeMapping baseMapping = null;
bool isRootType = false;
if (!type.DerivedFrom.IsEmpty)
{
baseMapping = ImportType(type.DerivedFrom, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
if (baseMapping is StructMapping)
baseTypeDesc = ((StructMapping)baseMapping).TypeDesc;
else if (baseMapping is ArrayMapping)
{
baseMapping = ((ArrayMapping)baseMapping).TopLevelMapping;
if (baseMapping != null)
{
baseMapping.ReferencedByTopLevelElement = false;
baseMapping.ReferencedByElement = true;
baseTypeDesc = baseMapping.TypeDesc;
}
}
else
baseMapping = null;
}
if (baseTypeDesc == null && baseType != null)
baseTypeDesc = Scope.GetTypeDesc(baseType);
if (baseMapping == null)
{
baseMapping = GetRootMapping();
isRootType = true;
}
Mapping previousMapping = (Mapping)ImportedMappings[type];
if (previousMapping != null)
{
if (previousMapping is StructMapping)
{
return (StructMapping)previousMapping;
}
else if (arrayLike && previousMapping is ArrayMapping)
{
ArrayMapping arrayMapping = (ArrayMapping)previousMapping;
if (arrayMapping.TopLevelMapping != null)
{
return arrayMapping.TopLevelMapping;
}
}
else
{
throw new InvalidOperationException(SR.Format(SR.XmlTypeUsedTwice, type.QualifiedName.Name, type.QualifiedName.Namespace));
}
}
StructMapping structMapping = new StructMapping();
structMapping.IsReference = Schemas.IsReference(type);
TypeFlags flags = TypeFlags.Reference;
if (type is XmlSchemaComplexType)
{
if (((XmlSchemaComplexType)type).IsAbstract)
flags |= TypeFlags.Abstract;
}
identifier = Accessor.UnescapeName(identifier);
string typeName = type.Name == null || type.Name.Length == 0 ? GenerateUniqueTypeName(identifier, typeNs) : GenerateUniqueTypeName(identifier);
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = type.Name == null || type.Name.Length == 0 ? null : identifier;
structMapping.BaseMapping = (StructMapping)baseMapping;
if (!arrayLike)
ImportedMappings.Add(type, structMapping);
CodeIdentifiers members = new CodeIdentifiers();
CodeIdentifiers membersScope = structMapping.BaseMapping.Scope.Clone();
members.AddReserved(typeName);
membersScope.AddReserved(typeName);
AddReservedIdentifiersForDataBinding(members);
if (isRootType)
AddReservedIdentifiersForDataBinding(membersScope);
bool needExplicitOrder = false;
structMapping.Members = ImportTypeMembers(type, typeNs, identifier, members, membersScope, structMapping, ref needExplicitOrder, true, true);
if (!IsAllGroup(type))
{
if (needExplicitOrder && !GenerateOrder)
{
structMapping.SetSequence();
}
else if (GenerateOrder)
{
structMapping.IsSequence = true;
}
}
for (int i = 0; i < structMapping.Members.Length; i++)
{
StructMapping declaringMapping;
MemberMapping baseMember = ((StructMapping)baseMapping).FindDeclaringMapping(structMapping.Members[i], out declaringMapping, structMapping.TypeName);
if (baseMember != null && baseMember.TypeDesc != structMapping.Members[i].TypeDesc)
throw new InvalidOperationException(SR.Format(SR.XmlIllegalOverride, type.Name, baseMember.Name, baseMember.TypeDesc.FullName, structMapping.Members[i].TypeDesc.FullName, declaringMapping.TypeDesc.FullName));
}
structMapping.Scope = membersScope;
Scope.AddTypeMapping(structMapping);
//.........这里部分代码省略.........
示例7: ImportStructType
StructMapping ImportStructType(XmlSchemaType type, string typeNs, string identifier, Type baseType, bool arrayLike) {
TypeDesc baseTypeDesc = null;
Mapping baseMapping = null;
if (!type.DerivedFrom.IsEmpty) {
baseMapping = ImportType(type.DerivedFrom, typeof(TypeMapping), null);
if (baseMapping is StructMapping)
baseTypeDesc = ((StructMapping)baseMapping).TypeDesc;
else
baseMapping = null;
}
if (baseTypeDesc == null && baseType != null)
baseTypeDesc = scope.GetTypeDesc(baseType);
if (baseMapping == null) baseMapping = GetRootMapping();
Mapping previousMapping = (Mapping)mappings[type];
if (previousMapping != null) {
if (previousMapping is StructMapping) {
return (StructMapping)previousMapping;
}
else {
if (!arrayLike) {
throw new InvalidOperationException(Res.GetString(Res.XmlTypeUsedTwice, type.QualifiedName.Name, type.QualifiedName.Namespace));
}
}
}
string typeName = GenerateUniqueTypeName(identifier);
StructMapping structMapping = new StructMapping();
TypeFlags flags = TypeFlags.Reference;
if (type is XmlSchemaComplexType) {
if (((XmlSchemaComplexType)type).IsAbstract) flags |= TypeFlags.Abstract;
}
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = identifier;
structMapping.BaseMapping = (StructMapping)baseMapping;
bool namedType = (type.Name != null && type.Name.Length != 0);
if (!arrayLike)
mappings.Add(type, structMapping);
CodeIdentifiers members = new CodeIdentifiers();
members.AddReserved(typeName);
structMapping.Members = ImportTypeMembers(type, typeNs, identifier, members);
for (int i = 0; i < structMapping.Members.Length; i++) {
StructMapping declaringMapping;
MemberMapping baseMember = ((StructMapping)baseMapping).FindDeclaringMapping(structMapping.Members[i], out declaringMapping, structMapping.TypeName);
if (baseMember != null && baseMember.TypeDesc != structMapping.Members[i].TypeDesc)
throw new InvalidOperationException(Res.GetString(Res.XmlIllegalOverride, type.Name, baseMember.Name, baseMember.TypeDesc.FullName, structMapping.Members[i].TypeDesc.FullName, declaringMapping.TypeDesc.FullName));
}
scope.AddTypeMapping(structMapping);
if (namedType) ImportDerivedTypes(new XmlQualifiedName(identifier, typeNs));
return structMapping;
}
示例8: ReflectBinding
void ReflectBinding(ReflectedBinding reflectedBinding) {
string bindingName = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
string bindingNamespace = reflectedBinding.bindingAttr.Namespace;
if (bindingName.Length == 0) bindingName = Service.Name + ProtocolName;
if (bindingNamespace.Length == 0) bindingNamespace = ServiceDescription.TargetNamespace;
WsiProfiles claims = WsiProfiles.None;
if (reflectedBinding.bindingAttr.Location.Length > 0) {
// If a URL is specified for the WSDL, file, then we just import the
// binding from there instead of generating it in this WSDL file.
portType = null;
binding = null;
}
else {
bindingServiceDescription = GetServiceDescription(bindingNamespace);
CodeIdentifiers bindingNames = new CodeIdentifiers();
foreach (Binding b in bindingServiceDescription.Bindings)
bindingNames.AddReserved(b.Name);
bindingName = bindingNames.AddUnique(bindingName, binding);
portType = new PortType();
binding = new Binding();
portType.Name = bindingName;
binding.Name = bindingName;
binding.Type = new XmlQualifiedName(portType.Name, bindingNamespace);
claims = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
if (reflectedBinding.bindingAttr.EmitConformanceClaims && claims != WsiProfiles.None) {
ServiceDescription.AddConformanceClaims(binding.GetDocumentationElement(), claims);
}
bindingServiceDescription.Bindings.Add(binding);
bindingServiceDescription.PortTypes.Add(portType);
}
if (portNames == null) {
portNames = new CodeIdentifiers();
foreach (Port p in Service.Ports)
portNames.AddReserved(p.Name);
}
port = new Port();
port.Binding = new XmlQualifiedName(bindingName, bindingNamespace);
port.Name = portNames.AddUnique(bindingName, port);
Service.Ports.Add(port);
BeginClass();
if (reflectedBinding.methodList != null && reflectedBinding.methodList.Count > 0) {
foreach (LogicalMethodInfo method in reflectedBinding.methodList) {
MoveToMethod(method);
operation = new Operation();
operation.Name = XmlConvert.EncodeLocalName(method.Name);
if (methodAttr.Description != null && methodAttr.Description.Length > 0)
operation.Documentation = methodAttr.Description;
operationBinding = new OperationBinding();
operationBinding.Name = operation.Name;
inputMessage = null;
outputMessage = null;
headerMessages = null;
if (ReflectMethod()) {
if (inputMessage != null) bindingServiceDescription.Messages.Add(inputMessage);
if (outputMessage != null) bindingServiceDescription.Messages.Add(outputMessage);
if (headerMessages != null) {
foreach (Message headerMessage in headerMessages) {
bindingServiceDescription.Messages.Add(headerMessage);
}
}
binding.Operations.Add(operationBinding);
portType.Operations.Add(operation);
}
}
}
if (binding != null && claims == WsiProfiles.BasicProfile1_1 && ProtocolName == "Soap") {
BasicProfileViolationCollection warnings = new BasicProfileViolationCollection();
WebServicesInteroperability.AnalyzeBinding(binding, bindingServiceDescription, ServiceDescriptions, warnings);
if (warnings.Count > 0) {
throw new InvalidOperationException(Res.GetString(Res.WebWsiViolation, ServiceType.FullName, warnings.ToString()));
}
}
EndClass();
}
示例9: AddReservedIdentifiersForDataBinding
internal void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
{
if ((_options & CodeGenerationOptions.EnableDataBinding) != 0)
{
scope.AddReserved("PropertyChanged");
scope.AddReserved("RaisePropertyChanged");
}
}
示例10: ImportStructType
private StructMapping ImportStructType(XmlSchemaType type, string typeNs, string identifier, Type baseType, bool arrayLike)
{
TypeDesc baseTypeDesc = null;
TypeMapping topLevelMapping = null;
bool flag = false;
if (!type.DerivedFrom.IsEmpty)
{
topLevelMapping = this.ImportType(type.DerivedFrom, typeof(TypeMapping), null, TypeFlags.CanBeElementValue | TypeFlags.CanBeTextValue, false);
if (topLevelMapping is StructMapping)
{
baseTypeDesc = ((StructMapping) topLevelMapping).TypeDesc;
}
else if (topLevelMapping is ArrayMapping)
{
topLevelMapping = ((ArrayMapping) topLevelMapping).TopLevelMapping;
if (topLevelMapping != null)
{
topLevelMapping.ReferencedByTopLevelElement = false;
topLevelMapping.ReferencedByElement = true;
baseTypeDesc = topLevelMapping.TypeDesc;
}
}
else
{
topLevelMapping = null;
}
}
if ((baseTypeDesc == null) && (baseType != null))
{
baseTypeDesc = base.Scope.GetTypeDesc(baseType);
}
if (topLevelMapping == null)
{
topLevelMapping = base.GetRootMapping();
flag = true;
}
Mapping mapping2 = (Mapping) base.ImportedMappings[type];
if (mapping2 != null)
{
if (mapping2 is StructMapping)
{
return (StructMapping) mapping2;
}
if (!arrayLike || !(mapping2 is ArrayMapping))
{
throw new InvalidOperationException(Res.GetString("XmlTypeUsedTwice", new object[] { type.QualifiedName.Name, type.QualifiedName.Namespace }));
}
ArrayMapping mapping3 = (ArrayMapping) mapping2;
if (mapping3.TopLevelMapping != null)
{
return mapping3.TopLevelMapping;
}
}
StructMapping mapping4 = new StructMapping {
IsReference = base.Schemas.IsReference(type)
};
TypeFlags reference = TypeFlags.Reference;
if ((type is XmlSchemaComplexType) && ((XmlSchemaComplexType) type).IsAbstract)
{
reference |= TypeFlags.Abstract;
}
identifier = Accessor.UnescapeName(identifier);
string name = ((type.Name == null) || (type.Name.Length == 0)) ? this.GenerateUniqueTypeName(identifier, typeNs) : base.GenerateUniqueTypeName(identifier);
mapping4.TypeDesc = new TypeDesc(name, name, TypeKind.Struct, baseTypeDesc, reference);
mapping4.Namespace = typeNs;
mapping4.TypeName = ((type.Name == null) || (type.Name.Length == 0)) ? null : identifier;
mapping4.BaseMapping = (StructMapping) topLevelMapping;
if (!arrayLike)
{
base.ImportedMappings.Add(type, mapping4);
}
CodeIdentifiers scope = new CodeIdentifiers();
CodeIdentifiers identifiers2 = mapping4.BaseMapping.Scope.Clone();
scope.AddReserved(name);
identifiers2.AddReserved(name);
base.AddReservedIdentifiersForDataBinding(scope);
if (flag)
{
base.AddReservedIdentifiersForDataBinding(identifiers2);
}
bool needExplicitOrder = false;
mapping4.Members = this.ImportTypeMembers(type, typeNs, identifier, scope, identifiers2, mapping4, ref needExplicitOrder, true, true);
if (!this.IsAllGroup(type))
{
if (needExplicitOrder && !this.GenerateOrder)
{
mapping4.SetSequence();
}
else if (this.GenerateOrder)
{
mapping4.IsSequence = true;
}
}
for (int i = 0; i < mapping4.Members.Length; i++)
{
StructMapping mapping5;
MemberMapping mapping6 = ((StructMapping) topLevelMapping).FindDeclaringMapping(mapping4.Members[i], out mapping5, mapping4.TypeName);
if ((mapping6 != null) && (mapping6.TypeDesc != mapping4.Members[i].TypeDesc))
{
throw new InvalidOperationException(Res.GetString("XmlIllegalOverride", new object[] { type.Name, mapping6.Name, mapping6.TypeDesc.FullName, mapping4.Members[i].TypeDesc.FullName, mapping5.TypeDesc.FullName }));
//.........这里部分代码省略.........
示例11: GenerateMethod
//.........这里部分代码省略.........
parts = this.GetMessageParts(outputMessage, binding2);
if (!this.CheckMessageStyles(base.MethodName, parts, binding2, soapBindingStyle, out flag2))
{
return null;
}
if (flag != flag2)
{
flag = false;
}
}
bool flag3 = ((soapBindingStyle != SoapBindingStyle.Rpc) && flag) || ((soapBodyBinding.Use == SoapBindingUse.Literal) && (soapBindingStyle == SoapBindingStyle.Rpc));
XmlMembersMapping request = this.ImportMessage(str, messageParts, soapBodyBinding, soapBindingStyle, flag);
if (request == null)
{
return null;
}
XmlMembersMapping response = null;
if (outputMessage != null)
{
response = this.ImportMessage(name, parts, binding2, soapBindingStyle, flag);
if (response == null)
{
return null;
}
}
string str3 = CodeIdentifier.MakeValid(XmlConvert.DecodeName(base.Operation.Name));
if (base.ClassName == str3)
{
str3 = "Call" + str3;
}
string identifier = base.MethodNames.AddUnique(CodeIdentifier.MakeValid(XmlConvert.DecodeName(str3)), base.Operation);
bool flag4 = str3 != identifier;
CodeIdentifiers identifiers = new CodeIdentifiers(false);
identifiers.AddReserved(identifier);
SoapParameters parameters = new SoapParameters(request, response, parameterOrder, base.MethodNames);
foreach (SoapParameter parameter in parameters.Parameters)
{
if ((parameter.IsOut || parameter.IsByRef) && !base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.ReferenceParameters))
{
base.UnsupportedOperationWarning(System.Web.Services.Res.GetString("CodeGenSupportReferenceParameters", new object[] { base.ServiceImporter.CodeGenerator.GetType().Name }));
return null;
}
parameter.name = identifiers.AddUnique(parameter.name, null);
if (parameter.mapping.CheckSpecified)
{
parameter.specifiedName = identifiers.AddUnique(parameter.name + "Specified", null);
}
}
if ((base.Style != ServiceDescriptionImportStyle.Client) || flag4)
{
this.BeginMetadata();
if (flag4)
{
this.AddMetadataProperty("MessageName", identifier);
}
this.EndMetadata(metadata, typeof(WebMethodAttribute), null);
}
this.BeginMetadata();
if ((flag3 && (request.ElementName.Length > 0)) && (request.ElementName != identifier))
{
this.AddMetadataProperty("RequestElementName", request.ElementName);
}
if (request.Namespace != null)
{
this.AddMetadataProperty("RequestNamespace", request.Namespace);
}
示例12: ImportStructDataType
private StructMapping ImportStructDataType(XmlSchemaSimpleType dataType, string typeNs, string identifier, Type baseType)
{
identifier = Accessor.UnescapeName(identifier);
string name = base.GenerateUniqueTypeName(identifier);
StructMapping typeMapping = new StructMapping {
IsReference = base.Schemas.IsReference(dataType)
};
TypeFlags reference = TypeFlags.Reference;
TypeDesc typeDesc = base.Scope.GetTypeDesc(baseType);
typeMapping.TypeDesc = new TypeDesc(name, name, TypeKind.Struct, typeDesc, reference);
typeMapping.Namespace = typeNs;
typeMapping.TypeName = identifier;
CodeIdentifiers scope = new CodeIdentifiers();
scope.AddReserved(name);
base.AddReservedIdentifiersForDataBinding(scope);
this.ImportTextMember(scope, new CodeIdentifiers(), null);
typeMapping.Members = (MemberMapping[]) scope.ToArray(typeof(MemberMapping));
typeMapping.Scope = scope;
base.Scope.AddTypeMapping(typeMapping);
return typeMapping;
}
示例13: ImportStructType
StructMapping ImportStructType(XmlSchemaComplexType type, string typeNs, bool excludeFromImport) {
TypeDesc baseTypeDesc = null;
Mapping baseMapping = null;
if (!type.DerivedFrom.IsEmpty) {
baseMapping = ImportType(type.DerivedFrom, excludeFromImport);
if (baseMapping is StructMapping)
baseTypeDesc = ((StructMapping)baseMapping).TypeDesc;
else
baseMapping = null;
}
if (baseMapping == null) baseMapping = GetRootMapping();
Mapping previousMapping = (Mapping)mappings[type];
if (previousMapping != null) {
return (StructMapping)previousMapping;
}
string typeName = GenerateUniqueTypeName(type.Name);
StructMapping structMapping = new StructMapping();
TypeFlags flags = TypeFlags.Reference;
if (type.IsAbstract) flags |= TypeFlags.Abstract;
structMapping.TypeDesc = new TypeDesc(typeName, typeName, TypeKind.Struct, baseTypeDesc, flags);
structMapping.Namespace = typeNs;
structMapping.TypeName = type.Name;
if (!excludeFromImport) {
structMapping.BaseMapping = (StructMapping)baseMapping;
mappings.Add(type, structMapping);
}
CodeIdentifiers members = new CodeIdentifiers();
members.AddReserved(typeName);
structMapping.Members = ImportTypeMembers(type, typeNs, members);
if (!excludeFromImport)
scope.AddTypeMapping(structMapping);
ImportDerivedTypes(new XmlQualifiedName(type.Name, typeNs));
return structMapping;
}
示例14: GenerateMethod
//.........这里部分代码省略.........
MessagePart[] responseParts = null;
if (responseMessage != null) {
responseParts = GetMessageParts(responseMessage, soapResponseBinding);
bool responseHasWrapper;
if (!CheckMessageStyles(MethodName, responseParts, soapResponseBinding, soapBindingStyle, out responseHasWrapper))
return null;
// since we're using a potentially inaccurate heuristic to determine whether there's a wrapper,
// if we disagree about the request and response we should assume there isn't a wrapper.
if (hasWrapper != responseHasWrapper)
hasWrapper = false;
}
bool wrapperNamesMatter = (soapBindingStyle != SoapBindingStyle.Rpc && hasWrapper) || (soapRequestBinding.Use == SoapBindingUse.Literal && soapBindingStyle == SoapBindingStyle.Rpc);
XmlMembersMapping request = ImportMessage(requestMessageName, requestParts, soapRequestBinding, soapBindingStyle, hasWrapper);
if (request == null) return null;
XmlMembersMapping response = null;
if (responseMessage != null) {
response = ImportMessage(responseMessageName, responseParts, soapResponseBinding, soapBindingStyle, hasWrapper);
if (response == null) return null;
}
string methodName = CodeIdentifier.MakeValid(XmlConvert.DecodeName(this.Operation.Name));
if (ClassName == methodName) {
methodName = "Call" + methodName;
}
string uniqueMethodName = MethodNames.AddUnique(CodeIdentifier.MakeValid(XmlConvert.DecodeName(methodName)), this.Operation);
bool differentNames = methodName != uniqueMethodName;
CodeIdentifiers localIdentifiers = new CodeIdentifiers(false);
localIdentifiers.AddReserved(uniqueMethodName);
SoapParameters parameters = new SoapParameters(request, response, parameterOrder, MethodNames);
foreach (SoapParameter param in parameters.Parameters) {
if ((param.IsOut || param.IsByRef) && !ServiceImporter.CodeGenerator.Supports(GeneratorSupport.ReferenceParameters)) {
UnsupportedOperationWarning(Res.GetString(Res.CodeGenSupportReferenceParameters, ServiceImporter.CodeGenerator.GetType().Name));
return null;
}
param.name = localIdentifiers.AddUnique(param.name, null);
if (param.mapping.CheckSpecified)
param.specifiedName = localIdentifiers.AddUnique(param.name + "Specified", null);
}
if (!(Style == ServiceDescriptionImportStyle.Client) || differentNames) {
BeginMetadata();
if (differentNames) AddMetadataProperty("MessageName", uniqueMethodName);
EndMetadata(metadata, typeof(WebMethodAttribute), null);
}
BeginMetadata();
if (wrapperNamesMatter && request.ElementName.Length > 0 && request.ElementName != uniqueMethodName)
AddMetadataProperty("RequestElementName", request.ElementName);
if (request.Namespace != null)
AddMetadataProperty("RequestNamespace", request.Namespace);
if (response == null) {
AddMetadataProperty("OneWay", true);
}
else {
if (wrapperNamesMatter && response.ElementName.Length > 0 && response.ElementName != (uniqueMethodName + "Response"))
AddMetadataProperty("ResponseElementName", response.ElementName);
if (response.Namespace != null)
AddMetadataProperty("ResponseNamespace", response.Namespace);
示例15: ReflectBinding
private void ReflectBinding(ReflectedBinding reflectedBinding)
{
string identifier = XmlConvert.EncodeLocalName(reflectedBinding.bindingAttr.Name);
string ns = reflectedBinding.bindingAttr.Namespace;
if (identifier.Length == 0)
{
identifier = this.Service.Name + this.ProtocolName;
}
if (ns.Length == 0)
{
ns = this.ServiceDescription.TargetNamespace;
}
WsiProfiles none = WsiProfiles.None;
if (reflectedBinding.bindingAttr.Location.Length > 0)
{
this.portType = null;
this.binding = null;
}
else
{
this.bindingServiceDescription = this.GetServiceDescription(ns);
CodeIdentifiers identifiers = new CodeIdentifiers();
foreach (System.Web.Services.Description.Binding binding in this.bindingServiceDescription.Bindings)
{
identifiers.AddReserved(binding.Name);
}
identifier = identifiers.AddUnique(identifier, this.binding);
this.portType = new System.Web.Services.Description.PortType();
this.binding = new System.Web.Services.Description.Binding();
this.portType.Name = identifier;
this.binding.Name = identifier;
this.binding.Type = new XmlQualifiedName(this.portType.Name, ns);
none = reflectedBinding.bindingAttr.ConformsTo & this.ConformsTo;
if (reflectedBinding.bindingAttr.EmitConformanceClaims && (none != WsiProfiles.None))
{
System.Web.Services.Description.ServiceDescription.AddConformanceClaims(this.binding.GetDocumentationElement(), none);
}
this.bindingServiceDescription.Bindings.Add(this.binding);
this.bindingServiceDescription.PortTypes.Add(this.portType);
}
if (this.portNames == null)
{
this.portNames = new CodeIdentifiers();
foreach (System.Web.Services.Description.Port port in this.Service.Ports)
{
this.portNames.AddReserved(port.Name);
}
}
this.port = new System.Web.Services.Description.Port();
this.port.Binding = new XmlQualifiedName(identifier, ns);
this.port.Name = this.portNames.AddUnique(identifier, this.port);
this.Service.Ports.Add(this.port);
this.BeginClass();
if ((reflectedBinding.methodList != null) && (reflectedBinding.methodList.Count > 0))
{
foreach (LogicalMethodInfo info in reflectedBinding.methodList)
{
this.MoveToMethod(info);
this.operation = new System.Web.Services.Description.Operation();
this.operation.Name = XmlConvert.EncodeLocalName(info.Name);
if ((this.methodAttr.Description != null) && (this.methodAttr.Description.Length > 0))
{
this.operation.Documentation = this.methodAttr.Description;
}
this.operationBinding = new System.Web.Services.Description.OperationBinding();
this.operationBinding.Name = this.operation.Name;
this.inputMessage = null;
this.outputMessage = null;
this.headerMessages = null;
if (this.ReflectMethod())
{
if (this.inputMessage != null)
{
this.bindingServiceDescription.Messages.Add(this.inputMessage);
}
if (this.outputMessage != null)
{
this.bindingServiceDescription.Messages.Add(this.outputMessage);
}
if (this.headerMessages != null)
{
foreach (Message message in this.headerMessages)
{
this.bindingServiceDescription.Messages.Add(message);
}
}
this.binding.Operations.Add(this.operationBinding);
this.portType.Operations.Add(this.operation);
}
}
}
if (((this.binding != null) && (none == WsiProfiles.BasicProfile1_1)) && (this.ProtocolName == "Soap"))
{
BasicProfileViolationCollection violations = new BasicProfileViolationCollection();
WebServicesInteroperability.AnalyzeBinding(this.binding, this.bindingServiceDescription, this.ServiceDescriptions, violations);
if (violations.Count > 0)
{
throw new InvalidOperationException(System.Web.Services.Res.GetString("WebWsiViolation", new object[] { this.ServiceType.FullName, violations.ToString() }));
}
}
//.........这里部分代码省略.........