本文整理汇总了C#中System.Xml.Serialization.CodeIdentifiers类的典型用法代码示例。如果您正苦于以下问题:C# CodeIdentifiers类的具体用法?C# CodeIdentifiers怎么用?C# CodeIdentifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeIdentifiers类属于System.Xml.Serialization命名空间,在下文中一共展示了CodeIdentifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: MapCodeGenerator
public MapCodeGenerator (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, CodeGenerationOptions options)
{
// this.codeCompileUnit = codeCompileUnit;
this.codeNamespace = codeNamespace;
this.options = options;
this.identifiers = new CodeIdentifiers ();
}
示例3: AddReservedIdentifiersForDataBinding
internal void AddReservedIdentifiersForDataBinding(CodeIdentifiers scope)
{
if ((this.options & CodeGenerationOptions.EnableDataBinding) != CodeGenerationOptions.None)
{
scope.AddReserved(CodeExporter.PropertyChangedEvent.Name);
scope.AddReserved(CodeExporter.RaisePropertyChangedEventMethod.Name);
}
}
示例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");
}
示例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;
}
示例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));
}
}
示例7: ImportContext
public ImportContext (CodeIdentifiers identifiers, bool shareTypes)
{
_typeIdentifiers = identifiers;
this._shareTypes = shareTypes;
if (shareTypes) {
MappedTypes = new Hashtable ();
DataMappedTypes = new Hashtable ();
SharedAnonymousTypes = new Hashtable ();
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例12: XmlSchemaImporter
public XmlSchemaImporter (XmlSchemas schemas)
{
this.schemas = schemas;
typeIdentifiers = new CodeIdentifiers ();
InitializeExtensions ();
}
示例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);
}
}
}
示例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
//.........这里部分代码省略.........
示例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);
}