本文整理汇总了C#中CodeGenerator.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.Pop方法的具体用法?C# CodeGenerator.Pop怎么用?C# CodeGenerator.Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.Pop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateLiteralMembersElement
string GenerateLiteralMembersElement(XmlMembersMapping xmlMembersMapping) {
ElementAccessor element = xmlMembersMapping.Accessor;
MemberMapping[] mappings = ((MembersMapping)element.Mapping).Members;
bool hasWrapperElement = ((MembersMapping)element.Mapping).HasWrapperElement;
string methodName = NextMethodName(element.Name);
ilg = new CodeGenerator(this.typeBuilder);
ilg.BeginMethod(
typeof(object[]),
methodName,
CodeGenerator.EmptyTypeArray,
CodeGenerator.EmptyStringArray,
CodeGenerator.PublicMethodAttributes
);
ilg.Load(null);
ilg.Stloc(ilg.ReturnLocal);
MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod(
"get_Reader",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod(
"MoveToContent",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_get_Reader);
ilg.Call(XmlReader_MoveToContent);
ilg.Pop();
LocalBuilder localP = ilg.DeclareLocal(typeof(object[]), "p");
ilg.NewArray(typeof(object), mappings.Length);
ilg.Stloc(localP);
InitializeValueTypes("p", mappings);
int wrapperLoopIndex = 0;
if (hasWrapperElement) {
wrapperLoopIndex = WriteWhileNotLoopStart();
WriteIsStartTag(element.Name, element.Form == XmlSchemaForm.Qualified ? element.Namespace : "");
}
Member anyText = null;
Member anyElement = null;
Member anyAttribute = null;
ArrayList membersList = new ArrayList();
ArrayList textOrArrayMembersList = new ArrayList();
ArrayList attributeMembersList = new ArrayList();
for (int i = 0; i < mappings.Length; i++) {
MemberMapping mapping = mappings[i];
string source = "p[" + i.ToString(CultureInfo.InvariantCulture) + "]";
string arraySource = source;
if (mapping.Xmlns != null) {
arraySource = "((" + mapping.TypeDesc.CSharpName + ")" + source + ")";
}
string choiceSource = GetChoiceIdentifierSource(mappings, mapping);
Member member = new Member(this, source, arraySource, "a", i, mapping, choiceSource);
Member anyMember = new Member(this, source, null, "a", i, mapping, choiceSource);
if (!mapping.IsSequence)
member.ParamsReadSource = "paramsRead[" + i.ToString(CultureInfo.InvariantCulture) + "]";
if (mapping.CheckSpecified == SpecifiedAccessor.ReadWrite) {
string nameSpecified = mapping.Name + "Specified";
for (int j = 0; j < mappings.Length; j++) {
if (mappings[j].Name == nameSpecified) {
member.CheckSpecifiedSource = "p[" + j.ToString(CultureInfo.InvariantCulture) + "]";
break;
}
}
}
bool foundAnyElement = false;
if (mapping.Text != null) anyText = anyMember;
if (mapping.Attribute != null && mapping.Attribute.Any)
anyAttribute = anyMember;
if (mapping.Attribute != null || mapping.Xmlns != null)
attributeMembersList.Add(member);
else if (mapping.Text != null)
textOrArrayMembersList.Add(member);
if (!mapping.IsSequence) {
for (int j = 0; j < mapping.Elements.Length; j++) {
if (mapping.Elements[j].Any && mapping.Elements[j].Name.Length == 0) {
anyElement = anyMember;
if (mapping.Attribute == null && mapping.Text == null)
textOrArrayMembersList.Add(anyMember);
foundAnyElement = true;
break;
}
}
}
if (mapping.Attribute != null || mapping.Text != null || foundAnyElement)
membersList.Add(anyMember);
else if (mapping.TypeDesc.IsArrayLike && !(mapping.Elements.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping)) {
membersList.Add(anyMember);
textOrArrayMembersList.Add(anyMember);
}
//.........这里部分代码省略.........
示例2: GenerateTypeElement
string GenerateTypeElement(XmlTypeMapping xmlTypeMapping) {
ElementAccessor element = xmlTypeMapping.Accessor;
TypeMapping mapping = element.Mapping;
string methodName = NextMethodName(element.Name);
ilg = new CodeGenerator(this.typeBuilder);
ilg.BeginMethod(
typeof(object),
methodName,
CodeGenerator.EmptyTypeArray,
CodeGenerator.EmptyStringArray,
CodeGenerator.PublicMethodAttributes
);
LocalBuilder oLoc = ilg.DeclareLocal(typeof(object), "o");
ilg.Load(null);
ilg.Stloc(oLoc);
MemberMapping member = new MemberMapping();
member.TypeDesc = mapping.TypeDesc;
//member.ReadOnly = !mapping.TypeDesc.HasDefaultConstructor;
member.Elements = new ElementAccessor[] { element };
Member[] members = new Member[] { new Member(this, "o", "o", "a", 0, member) };
MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod(
"get_Reader",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
MethodInfo XmlReader_MoveToContent = typeof(XmlReader).GetMethod(
"MoveToContent",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_get_Reader);
ilg.Call(XmlReader_MoveToContent);
ilg.Pop();
string unknownNode = "UnknownNode(null, " + ExpectedElements(members) + ");";
WriteMemberElements(members, "throw CreateUnknownNodeException();", unknownNode, element.Any ? members[0] : null, null);
ilg.Ldloc(oLoc);
// for code compat as compiler does
ilg.Stloc(ilg.ReturnLocal);
ilg.Ldloc(ilg.ReturnLocal);
ilg.EndMethod();
return methodName;
}
示例3: WriteLiteralStructMethod
//.........这里部分代码省略.........
}
}
if (anyElement != null) arraysToSetList.Add(anyElement);
if (anyText != null && anyText != anyElement) arraysToSetList.Add(anyText);
Member[] arraysToDeclare = (Member[])arraysToDeclareList.ToArray(typeof(Member));
Member[] arraysToSet = (Member[])arraysToSetList.ToArray(typeof(Member));
Member[] allMembers = (Member[])allMembersList.ToArray(typeof(Member));
WriteMemberBegin(arraysToDeclare);
WriteParamsRead(mappings.Length);
WriteAttributes(allMembers, anyAttribute, "UnknownNode", oLoc);
if (anyAttribute != null)
WriteMemberEnd(arraysToDeclare);
MethodInfo XmlSerializationReader_get_Reader = typeof(XmlSerializationReader).GetMethod(
"get_Reader",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
MethodInfo XmlReader_MoveToElement = typeof(XmlReader).GetMethod(
"MoveToElement",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_get_Reader);
ilg.Call(XmlReader_MoveToElement);
ilg.Pop();
MethodInfo XmlReader_get_IsEmptyElement = typeof(XmlReader).GetMethod(
"get_IsEmptyElement",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_get_Reader);
ilg.Call(XmlReader_get_IsEmptyElement);
ilg.If();
MethodInfo XmlReader_Skip = typeof(XmlReader).GetMethod(
"Skip",
CodeGenerator.InstanceBindingFlags,
null,
CodeGenerator.EmptyTypeArray,
null
);
ilg.Ldarg(0);
ilg.Call(XmlSerializationReader_get_Reader);
ilg.Call(XmlReader_Skip);
WriteMemberEnd(arraysToSet);
ilg.Ldloc(oLoc);
ilg.Stloc(ilg.ReturnLocal);
ilg.Br(ilg.ReturnLabel);
ilg.EndIf();
MethodInfo XmlReader_ReadStartElement = typeof(XmlReader).GetMethod(
"ReadStartElement",
CodeGenerator.InstanceBindingFlags,
null,