本文整理汇总了C#中System.Xml.Serialization.CodeIdentifiers类的典型用法代码示例。如果您正苦于以下问题:C# CodeIdentifiers类的具体用法?C# CodeIdentifiers怎么用?C# CodeIdentifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeIdentifiers类属于System.Xml.Serialization命名空间,在下文中一共展示了CodeIdentifiers类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateBaseSerializer
internal string GenerateBaseSerializer(string baseSerializer, string readerClass, string writerClass, CodeIdentifiers classes)
{
baseSerializer = CodeIdentifier.MakeValid(baseSerializer);
baseSerializer = classes.AddUnique(baseSerializer, baseSerializer);
this.writer.WriteLine();
this.writer.Write("public abstract class ");
this.writer.Write(CodeIdentifier.GetCSharpName(baseSerializer));
this.writer.Write(" : ");
this.writer.Write(typeof(XmlSerializer).FullName);
this.writer.WriteLine(" {");
this.writer.Indent++;
this.writer.Write("protected override ");
this.writer.Write(typeof(XmlSerializationReader).FullName);
this.writer.WriteLine(" CreateReader() {");
this.writer.Indent++;
this.writer.Write("return new ");
this.writer.Write(readerClass);
this.writer.WriteLine("();");
this.writer.Indent--;
this.writer.WriteLine("}");
this.writer.Write("protected override ");
this.writer.Write(typeof(XmlSerializationWriter).FullName);
this.writer.WriteLine(" CreateWriter() {");
this.writer.Indent++;
this.writer.Write("return new ");
this.writer.Write(writerClass);
this.writer.WriteLine("();");
this.writer.Indent--;
this.writer.WriteLine("}");
this.writer.Indent--;
this.writer.WriteLine("}");
return baseSerializer;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:XmlSerializationCodeGen.cs
示例2: MapCodeGenerator
public MapCodeGenerator (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, CodeGenerationOptions options)
{
// this.codeCompileUnit = codeCompileUnit;
this.codeNamespace = codeNamespace;
this.options = options;
this.identifiers = new CodeIdentifiers ();
}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:MapCodeGenerator.cs
示例3: AddReservedIdentifiersForDataBinding
internal void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
{
if ((this.options & CodeGenerationOptions.EnableDataBinding) != CodeGenerationOptions.None)
{
scope.AddReserved(CodeExporter.PropertyChangedEvent.Name);
scope.AddReserved(CodeExporter.RaisePropertyChangedEventMethod.Name);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SchemaImporter.cs
示例4: IgnoreCase
public void IgnoreCase ()
{
CodeIdentifiers c = new CodeIdentifiers (false);
c.Add ("test", "x");
c.Add ("Test", "y");
Assert.IsTrue ("test" != c.AddUnique ("Test", "z"), "#1");
Assert.IsTrue (c.IsInUse ("tEsT"), "#2");
Assert.AreEqual ("camelCase", c.MakeRightCase ("CAMELCASE"), "#3");
}
开发者ID:nobled,项目名称:mono,代码行数:9,代码来源:CodeIdentifiersTests.cs
示例5: MapCodeGenerator
public MapCodeGenerator (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, CodeDomProvider codeProvider, CodeGenerationOptions options, Hashtable mappings)
{
// this.codeCompileUnit = codeCompileUnit;
this.codeNamespace = codeNamespace;
this.options = options;
this.codeProvider = codeProvider;
this.identifiers = new CodeIdentifiers ((codeProvider.LanguageOptions & LanguageOptions.CaseInsensitive) == 0);
// this.mappings = mappings;
}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:MapCodeGenerator.cs
示例6: SoapParameters
internal SoapParameters(XmlMembersMapping request, XmlMembersMapping response, string[] parameterOrder, CodeIdentifiers identifiers) {
ArrayList requestList = new ArrayList();
ArrayList responseList = new ArrayList();
AddMappings(requestList, request);
if (response != null) AddMappings(responseList, response);
if (parameterOrder != null) {
for (int i = 0; i < parameterOrder.Length; i++) {
string elementName = parameterOrder[i];
XmlMemberMapping requestMapping = FindMapping(requestList, elementName);
SoapParameter parameter = new SoapParameter();
if (requestMapping != null) {
if (RemoveByRefMapping(responseList, requestMapping))
parameter.codeFlags = CodeFlags.IsByRef;
parameter.mapping = requestMapping;
requestList.Remove(requestMapping);
AddParameter(parameter);
}
else {
XmlMemberMapping responseMapping = FindMapping(responseList, elementName);
if (responseMapping != null) {
parameter.codeFlags = CodeFlags.IsOut;
parameter.mapping = responseMapping;
responseList.Remove(responseMapping);
AddParameter(parameter);
}
}
}
}
foreach (XmlMemberMapping requestMapping in requestList) {
SoapParameter parameter = new SoapParameter();
if (RemoveByRefMapping(responseList, requestMapping))
parameter.codeFlags = CodeFlags.IsByRef;
parameter.mapping = requestMapping;
AddParameter(parameter);
}
if (responseList.Count > 0) {
if (!((XmlMemberMapping) responseList[0]).CheckSpecified) {
ret = (XmlMemberMapping)responseList[0];
responseList.RemoveAt(0);
}
foreach (XmlMemberMapping responseMapping in responseList) {
SoapParameter parameter = new SoapParameter();
parameter.mapping = responseMapping;
parameter.codeFlags = CodeFlags.IsOut;
AddParameter(parameter);
}
}
foreach (SoapParameter parameter in parameters) {
parameter.name = identifiers.MakeUnique(CodeIdentifier.MakeValid(parameter.mapping.MemberName));
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:56,代码来源:SoapProtocolImporter.cs
示例7: ImportContext
public ImportContext (CodeIdentifiers identifiers, bool shareTypes)
{
_typeIdentifiers = identifiers;
this._shareTypes = shareTypes;
if (shareTypes) {
MappedTypes = new Hashtable ();
DataMappedTypes = new Hashtable ();
SharedAnonymousTypes = new Hashtable ();
}
}
开发者ID:Profit0004,项目名称:mono,代码行数:11,代码来源:ImportContext.cs
示例8: BeginClass
protected override CodeTypeDeclaration BeginClass ()
{
httpBinding = (HttpBinding) Binding.Extensions.Find (typeof(HttpBinding));
CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
string location = null;
if (Port != null) {
HttpAddressBinding sab = (HttpAddressBinding) Port.Extensions.Find (typeof(HttpAddressBinding));
if (sab != null) location = sab.Location;
}
CodeConstructor cc = new CodeConstructor ();
cc.Attributes = MemberAttributes.Public;
GenerateServiceUrl (location, cc.Statements);
codeClass.Members.Add (cc);
memberIds = new CodeIdentifiers ();
return codeClass;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:20,代码来源:HttpSimpleProtocolImporter.cs
示例9: ImportParticleContent
void ImportParticleContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaParticle particle, CodeIdentifiers classIds, bool multiValue, ref bool isMixed)
{
if (particle == null) return;
if (particle is XmlSchemaGroupRef)
particle = GetRefGroupParticle ((XmlSchemaGroupRef)particle);
if (particle.MaxOccurs > 1) multiValue = true;
if (particle is XmlSchemaSequence) {
ImportSequenceContent (typeQName, cmap, ((XmlSchemaSequence)particle).Items, classIds, multiValue, ref isMixed);
}
else if (particle is XmlSchemaChoice) {
if (((XmlSchemaChoice)particle).Items.Count == 1)
ImportSequenceContent (typeQName, cmap, ((XmlSchemaChoice)particle).Items, classIds, multiValue, ref isMixed);
else
ImportChoiceContent (typeQName, cmap, (XmlSchemaChoice)particle, classIds, multiValue);
}
else if (particle is XmlSchemaAll) {
ImportSequenceContent (typeQName, cmap, ((XmlSchemaAll)particle).Items, classIds, multiValue, ref isMixed);
}
}
开发者ID:nestalk,项目名称:mono,代码行数:22,代码来源:XmlSchemaImporter.cs
示例10: AddTextMember
void AddTextMember (XmlQualifiedName typeQName, ClassMap cmap, CodeIdentifiers classIds)
{
if (cmap.XmlTextCollector == null)
{
XmlTypeMapMemberFlatList member = new XmlTypeMapMemberFlatList ();
member.Name = classIds.AddUnique ("Text", member);
member.TypeData = TypeTranslator.GetTypeData (typeof(string[]));
member.ElementInfo.Add (CreateTextElementInfo (typeQName.Namespace, member, member.TypeData.ListItemTypeData));
member.IsXmlTextCollector = true;
member.ListMap = new ListMap ();
member.ListMap.ItemInfo = member.ElementInfo;
cmap.AddMember (member);
}
}
开发者ID:nestalk,项目名称:mono,代码行数:14,代码来源:XmlSchemaImporter.cs
示例11: ImportParticleComplexContent
void ImportParticleComplexContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaParticle particle, CodeIdentifiers classIds, bool isMixed)
{
ImportParticleContent (typeQName, cmap, particle, classIds, false, ref isMixed);
if (isMixed) AddTextMember (typeQName, cmap, classIds);
}
开发者ID:nestalk,项目名称:mono,代码行数:5,代码来源:XmlSchemaImporter.cs
示例12: XmlSchemaImporter
public XmlSchemaImporter (XmlSchemas schemas)
{
this.schemas = schemas;
typeIdentifiers = new CodeIdentifiers ();
InitializeExtensions ();
}
开发者ID:nestalk,项目名称:mono,代码行数:7,代码来源:XmlSchemaImporter.cs
示例13: CreateHeaderMessages
void CreateHeaderMessages(string methodName, SoapBindingUse use, XmlMembersMapping inHeaderMappings, XmlMembersMapping outHeaderMappings, SoapReflectedHeader[] headers, bool rpc) {
//
if (use == SoapBindingUse.Encoded) {
SoapExporter.ExportMembersMapping(inHeaderMappings, false);
if (outHeaderMappings != null)
SoapExporter.ExportMembersMapping(outHeaderMappings, false);
}
else {
SchemaExporter.ExportMembersMapping(inHeaderMappings);
if (outHeaderMappings != null)
SchemaExporter.ExportMembersMapping(outHeaderMappings);
}
CodeIdentifiers identifiers = new CodeIdentifiers();
int inCount = 0, outCount = 0;
for (int i = 0; i < headers.Length; i++) {
SoapReflectedHeader soapHeader = headers[i];
if (!soapHeader.custom) continue;
XmlMemberMapping member;
if ((soapHeader.direction & SoapHeaderDirection.In) != 0) {
member = inHeaderMappings[inCount++];
if (soapHeader.direction != SoapHeaderDirection.In)
outCount++;
}
else {
member = outHeaderMappings[outCount++];
}
MessagePart part = new MessagePart();
part.Name = member.XsdElementName;
if (use == SoapBindingUse.Encoded)
part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace);
else
part.Element = new XmlQualifiedName(member.XsdElementName, member.Namespace);
Message message = new Message();
message.Name = identifiers.AddUnique(methodName + part.Name, message);
message.Parts.Add(part);
HeaderMessages.Add(message);
ServiceDescriptionFormatExtension soapHeaderBinding = CreateSoapHeaderBinding(new XmlQualifiedName(message.Name, Binding.ServiceDescription.TargetNamespace), part.Name, rpc ? member.Namespace : null, use);
if ((soapHeader.direction & SoapHeaderDirection.In) != 0)
OperationBinding.Input.Extensions.Add(soapHeaderBinding);
if ((soapHeader.direction & SoapHeaderDirection.Out) != 0)
OperationBinding.Output.Extensions.Add(soapHeaderBinding);
if ((soapHeader.direction & SoapHeaderDirection.Fault) != 0) {
if (soapMethod.IsClaimsConformance) {
throw new InvalidOperationException(Res.GetString(Res.BPConformanceHeaderFault, soapMethod.methodInfo.ToString(), soapMethod.methodInfo.DeclaringType.FullName, "Direction", typeof(SoapHeaderDirection).Name, SoapHeaderDirection.Fault.ToString()));
}
OperationBinding.Output.Extensions.Add(soapHeaderBinding);
}
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:55,代码来源:SoapProtocolReflector.cs
示例14: GenerateMethod
CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, HttpOperationBinding httpOper, XmlMembersMapping inputMembers, XmlTypeMapping outputMember)
{
CodeIdentifiers pids = new CodeIdentifiers ();
CodeMemberMethod method = new CodeMemberMethod ();
CodeMemberMethod methodBegin = new CodeMemberMethod ();
CodeMemberMethod methodEnd = new CodeMemberMethod ();
method.Attributes = MemberAttributes.Public;
methodBegin.Attributes = MemberAttributes.Public;
methodEnd.Attributes = MemberAttributes.Public;
// Find unique names for temporary variables
for (int n=0; n<inputMembers.Count; n++)
pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);
string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
string varCallback = pids.AddUnique ("callback","callback");
string varAsyncState = pids.AddUnique ("asyncState","asyncState");
string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);
method.Name = Operation.Name;
methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + Operation.Name),method);
methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + Operation.Name),method);
method.ReturnType = new CodeTypeReference (typeof(void));
methodEnd.ReturnType = new CodeTypeReference (typeof(void));
methodEnd.Parameters.Add (new CodeParameterDeclarationExpression (typeof (IAsyncResult),varAsyncResult));
CodeExpression[] paramArray = new CodeExpression [inputMembers.Count];
for (int n=0; n<inputMembers.Count; n++)
{
string ptype = GetSimpleType (inputMembers[n]);
CodeParameterDeclarationExpression param = new CodeParameterDeclarationExpression (ptype, inputMembers[n].MemberName);
param.Direction = FieldDirection.In;
method.Parameters.Add (param);
methodBegin.Parameters.Add (param);
paramArray [n] = new CodeVariableReferenceExpression (param.Name);
}
bool isVoid = true;
if (outputMember != null)
{
method.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
methodEnd.ReturnType = new CodeTypeReference (outputMember.TypeFullName);
xmlExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, outputMember, "");
isVoid = false;
}
methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (AsyncCallback),varCallback));
methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (object),varAsyncState));
methodBegin.ReturnType = new CodeTypeReference (typeof(IAsyncResult));
// Array of input parameters
CodeArrayCreateExpression methodParams;
if (paramArray.Length > 0)
methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
else
methodParams = new CodeArrayCreateExpression (typeof(object), 0);
// Generate method url
CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
CodeExpression thisURlExp = new CodeFieldReferenceExpression (ethis, "Url");
CodePrimitiveExpression metUrl = new CodePrimitiveExpression (httpOper.Location);
CodeBinaryOperatorExpression expMethodLocation = new CodeBinaryOperatorExpression (thisURlExp, CodeBinaryOperatorType.Add, metUrl);
// Invoke call
CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
CodeMethodInvokeExpression inv;
inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, expMethodLocation, methodParams);
if (!isVoid)
method.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (method.ReturnType, inv)));
else
method.Statements.Add (inv);
// Begin Invoke Call
CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, expMethodLocation, methodParams, expCallb, expAsyncs);
methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
// End Invoke call
CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
if (!isVoid)
methodEnd.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (methodEnd.ReturnType, inv)));
else
methodEnd.Statements.Add (inv);
// Attributes
//.........这里部分代码省略.........
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:101,代码来源:HttpSimpleProtocolImporter.cs
示例15: Reflect
internal void Reflect (ServiceDescriptionReflector serviceReflector, Type type, string url, XmlSchemaExporter xxporter, SoapSchemaExporter sxporter)
{
portNames = new CodeIdentifiers ();
this.serviceReflector = serviceReflector;
serviceUrl = url;
serviceType = type;
schemaExporter = xxporter;
soapSchemaExporter = sxporter;
typeInfo = TypeStubManager.GetTypeStub (type, ProtocolName);
ServiceDescription desc = ServiceDescriptions [typeInfo.LogicalType.WebServiceNamespace];
if (desc == null)
{
desc = new ServiceDescription ();
desc.TargetNamespace = typeInfo.LogicalType.WebServiceNamespace;
desc.Name = typeInfo.LogicalType.WebServiceName;
ServiceDescriptions.Add (desc);
}
ImportService (desc, typeInfo, url);
}
开发者ID:Profit0004,项目名称:mono,代码行数:24,代码来源:ProtocolReflector.cs
示例16: ImportDerivedTypeMapping
public XmlTypeMapping ImportDerivedTypeMapping (XmlQualifiedName name, Type baseType, bool baseTypeCanBeIndirect)
{
XmlQualifiedName qname;
XmlSchemaType stype;
if (encodedFormat)
{
qname = name;
stype = schemas.Find (name, typeof (XmlSchemaComplexType)) as XmlSchemaComplexType;
if (stype == null) throw new InvalidOperationException ("Schema type '" + name + "' not found or not valid");
}
else
{
if (!LocateElement (name, out qname, out stype))
return null;
}
XmlTypeMapping map = GetRegisteredTypeMapping (qname, baseType);
if (map != null)
{
// If the type has already been imported, make sure that the map
// has the requested base type
SetMapBaseType (map, baseType);
map.UpdateRoot (name);
return map;
}
map = CreateTypeMapping (qname, SchemaTypes.Class, name);
if (stype != null) {
map.Documentation = GetDocumentation (stype);
RegisterMapFixup (map, qname, (XmlSchemaComplexType)stype);
} else {
ClassMap cmap = new ClassMap ();
CodeIdentifiers classIds = new CodeIdentifiers ();
map.ObjectMap = cmap;
AddTextMember (qname, cmap, classIds);
}
BuildPendingMaps ();
SetMapBaseType (map, baseType);
return map;
}
开发者ID:nestalk,项目名称:mono,代码行数:44,代码来源:XmlSchemaImporter.cs
示例17: ImportAnyType
public XmlMembersMapping ImportAnyType (XmlQualifiedName typeName, string elementName)
{
if (typeName == XmlQualifiedName.Empty)
{
XmlTypeMapMemberAnyElement mapMem = new XmlTypeMapMemberAnyElement ();
mapMem.Name = typeName.Name;
mapMem.TypeData = TypeTranslator.GetTypeData(typeof(XmlNode));
mapMem.ElementInfo.Add (CreateElementInfo (typeName.Namespace, mapMem, typeName.Name, mapMem.TypeData, true, XmlSchemaForm.None, -1));
XmlMemberMapping[] mm = new XmlMemberMapping [1];
mm[0] = new XmlMemberMapping (typeName.Name, typeName.Namespace, mapMem, encodedFormat);
return new XmlMembersMapping (mm);
}
else
{
XmlSchemaComplexType stype = (XmlSchemaComplexType) schemas.Find (typeName, typeof (XmlSchemaComplexType));
if (stype == null)
throw new InvalidOperationException ("Referenced type '" + typeName + "' not found");
if (!CanBeAnyElement (stype))
throw new InvalidOperationException ("The type '" + typeName + "' is not valid for a collection of any elements");
ClassMap cmap = new ClassMap ();
CodeIdentifiers classIds = new CodeIdentifiers ();
bool isMixed = stype.IsMixed;
ImportSequenceContent (typeName, cmap, ((XmlSchemaSequence) stype.Particle).Items, classIds, false, ref isMixed);
XmlTypeMapMemberAnyElement mapMem = (XmlTypeMapMemberAnyElement) cmap.AllMembers[0];
mapMem.Name = typeName.Name;
XmlMemberMapping[] mm = new XmlMemberMapping [1];
mm[0] = new XmlMemberMapping (typeName.Name, typeName.Namespace, mapMem, encodedFormat);
return new XmlMembersMapping (mm);
}
}
开发者ID:nestalk,项目名称:mono,代码行数:34,代码来源:XmlSchemaImporter.cs
示例18: 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;
}
开发者ID:nestalk,项目名称:mono,代码行数:57,代码来源:XmlSchemaImporter.cs
示例19: ImportComplexContent
void ImportComplexContent (XmlQualifiedName typeQName, XmlTypeMapping map, XmlSchemaComplexContent content, CodeIdentifiers classIds, bool isMixed)
{
ClassMap cmap = (ClassMap)map.ObjectMap;
XmlQualifiedName qname;
XmlSchemaComplexContentExtension ext = content.Content as XmlSchemaComplexContentExtension;
if (ext != null) qname = ext.BaseTypeName;
else qname = ((XmlSchemaComplexContentRestriction)content.Content).BaseTypeName;
if (qname == typeQName)
throw new InvalidOperationException ("Cannot import schema for type '" + typeQName.Name + "' from namespace '" + typeQName.Namespace + "'. Redefine not supported");
// Add base map members to this map
XmlTypeMapping baseMap = ImportClass (qname);
BuildPendingMap (baseMap);
ClassMap baseClassMap = (ClassMap)baseMap.ObjectMap;
foreach (XmlTypeMapMember member in baseClassMap.AllMembers)
cmap.AddMember (member);
if (baseClassMap.XmlTextCollector != null) isMixed = false;
else if (content.IsMixed) isMixed = true;
map.BaseMap = baseMap;
baseMap.DerivedTypes.Add (map);
if (ext != null) {
// Add the members of this map
ImportParticleComplexContent (typeQName, cmap, ext.Particle, classIds, isMixed);
ImportAttributes (typeQName, cmap, ext.Attributes, ext.AnyAttribute, classIds);
}
else {
if (isMixed) ImportParticleComplexContent (typeQName, cmap, null, classIds, true);
}
}
开发者ID:nestalk,项目名称:mono,代码行数:36,代码来源:XmlSchemaImporter.cs
示例20: ImportSequenceContent
void ImportSequenceContent (XmlQualifiedName typeQName, ClassMap cmap, XmlSchemaObjectCollection items, CodeIdentifiers classIds, bool multiValue, ref bool isMixed)
{
foreach (XmlSchemaObject item in items)
{
if (item is XmlSchemaElement)
{
string ns;
XmlSchemaElement elem = (XmlSchemaElement) item;
XmlTypeMapping emap;
TypeData typeData = GetElementTypeData (typeQName, elem, null, out emap);
XmlSchemaElement refElem = GetRefElement (typeQName, elem, out ns);
if (elem.MaxOccurs == 1 && !multiValue)
{
XmlTypeMapMemberElement member = null;
if (typeData.SchemaType != SchemaTypes.Array)
{
member = new XmlTypeMapMemberElement ();
if (refElem.DefaultValue != null) member.DefaultValue = ImportDefaultValue (typeData, refElem.DefaultValue);
}
else if (GetTypeMapping (typeData).IsSimpleType)
{
// It is a simple list (space separated list).
// Since this is not supported, map as a single item value
member = new XmlTypeMapMemberElement ();
#if NET_2_0
// In MS.NET those types are mapped to a string
typeData = TypeTranslator.GetTypeData(typeof(string));
#else
typeData = typeData.ListItemTypeData;
#endif
}
else
member = new XmlTypeMapMemberList ();
if (elem.MinOccurs == 0 && typeData.IsValueType)
member.IsOptionalValueType = true;
member.Name = classIds.AddUnique(CodeIdentifier.MakeValid(refElem.Name), member);
member.Documentation = GetDocumentation (elem);
member.TypeData = typeData;
member.ElementInfo.Add (CreateElementInfo (ns, member, refElem.Name, typeData, refElem.IsNillable, refElem.Form, emap, items.IndexOf (item)));
cmap.AddMember (member);
}
else
{
XmlTypeMapMemberFlatList member = new XmlTypeMapMemberFlatList ();
member.ListMap = new ListMap ();
member.Name = classIds.AddUnique(CodeIdentifier.MakeValid(refElem.Name), member);
member.Documentation = GetDocumentation (elem);
member.TypeData = typeData.ListTypeData;
member.ElementInfo.Add (CreateElementInfo (ns, member, refElem.Name, typeData, refElem.IsNillable, refElem.Form, emap, items.IndexOf (item)));
member.ListMap.ItemInfo = member.ElementInfo;
cmap.AddMember (member);
}
}
else if (item is XmlSchemaAny)
{
XmlSchemaAny elem = (XmlSchemaAny) item;
XmlTypeMapMemberAnyElement member = new XmlTypeMapMemberAnyElement ();
member.Name = classIds.AddUnique ("Any", member);
member.Documentation = GetDocumentation (elem);
Type ctype;
if (elem.MaxOccurs != 1 || multiValue)
ctype = isMixed ? typeof(XmlNode[]) : typeof(XmlElement[]);
else
ctype = isMixed ? typeof(XmlNode) : typeof(XmlElement);
member.TypeData = TypeTranslator.GetTypeData (ctype);
XmlTypeMapElementInfo einfo = new XmlTypeMapElementInfo (member, member.TypeData);
einfo.IsUnnamedAnyElement = true;
member.ElementInfo.Add (einfo);
if (isMixed)
{
einfo = CreateTextElementInfo (typeQName.Namespace, member, member.TypeData);
member.ElementInfo.Add (einfo);
member.IsXmlTextCollector = true;
isMixed = false; //Allow only one XmlTextAttribute
}
cmap.AddMember (member);
}
else if (item is XmlSchemaParticle) {
ImportParticleContent (typeQName, cmap, (XmlSchemaParticle)item, classIds, multiValue, ref isMixed);
}
}
}
开发者ID:nestalk,项目名称:mono,代码行数:89,代码来源:XmlSchemaImporter.cs
注:本文中的System.Xml.Serialization.CodeIdentifiers类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论