本文整理汇总了C#中System.Xml.Serialization.StructMapping.FindDeclaringMapping方法的典型用法代码示例。如果您正苦于以下问题:C# StructMapping.FindDeclaringMapping方法的具体用法?C# StructMapping.FindDeclaringMapping怎么用?C# StructMapping.FindDeclaringMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.StructMapping
的用法示例。
在下文中一共展示了StructMapping.FindDeclaringMapping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLiteralStructMethod
//.........这里部分代码省略.........
Member anyElement = null;
Member anyAttribute = null;
bool isSequence = structMapping.HasExplicitSequence();
ArrayList arraysToDeclareList = new ArrayList(mappings.Length);
ArrayList arraysToSetList = new ArrayList(mappings.Length);
ArrayList allMembersList = new ArrayList(mappings.Length);
for (int i = 0; i < mappings.Length; i++) {
MemberMapping mapping = mappings[i];
CodeIdentifier.CheckValidIdentifier(mapping.Name);
string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc);
Member member = new Member(this, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc));
if (!mapping.IsSequence)
member.ParamsReadSource = "paramsRead[" + i.ToString(CultureInfo.InvariantCulture) + "]";
member.IsNullable = mapping.TypeDesc.IsNullable;
if (mapping.CheckSpecified == SpecifiedAccessor.ReadWrite)
member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", mapping.Name + "Specified", structMapping.TypeDesc);
if (mapping.Text != null)
anyText = member;
if (mapping.Attribute != null && mapping.Attribute.Any)
anyAttribute = member;
if (!isSequence) {
// find anyElement if present.
for (int j = 0; j < mapping.Elements.Length; j++) {
if (mapping.Elements[j].Any && (mapping.Elements[j].Name == null || mapping.Elements[j].Name.Length == 0)) {
anyElement = member;
break;
}
}
}
else if (mapping.IsParticle && !mapping.IsSequence) {
StructMapping declaringMapping;
structMapping.FindDeclaringMapping(mapping, out declaringMapping, structMapping.TypeName);
throw new InvalidOperationException(Res.GetString(Res.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping.TypeDesc.FullName, "Order"));
}
if (mapping.Attribute == null && mapping.Elements.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping) {
Member arrayMember = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc));
arrayMember.CheckSpecifiedSource = member.CheckSpecifiedSource;
allMembersList.Add(arrayMember);
}
else {
allMembersList.Add(member);
}
if (mapping.TypeDesc.IsArrayLike) {
arraysToDeclareList.Add(member);
if (mapping.TypeDesc.IsArrayLike && !(mapping.Elements.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping)) {
member.ParamsReadSource = null; // flat arrays -- don't want to count params read.
if (member != anyText && member != anyElement) {
arraysToSetList.Add(member);
}
}
else if (!mapping.TypeDesc.IsArray) {
member.ParamsReadSource = null; // collection
}
}
}
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);
示例2: WriteLiteralStructMethod
//.........这里部分代码省略.........
Member anyElement = null;
Member anyAttribute = null;
bool isSequence = structMapping.HasExplicitSequence();
ArrayList arraysToDeclareList = new ArrayList(mappings.Length);
ArrayList arraysToSetList = new ArrayList(mappings.Length);
ArrayList allMembersList = new ArrayList(mappings.Length);
for (int i = 0; i < mappings.Length; i++) {
MemberMapping mapping = mappings[i];
CodeIdentifier.CheckValidIdentifier(mapping.Name);
string source = RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc);
Member member = new Member(this, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc));
if (!mapping.IsSequence)
member.ParamsReadSource = "paramsRead[" + i.ToString(CultureInfo.InvariantCulture) + "]";
member.IsNullable = mapping.TypeDesc.IsNullable;
if (mapping.CheckSpecified == SpecifiedAccessor.ReadWrite)
member.CheckSpecifiedSource = RaCodeGen.GetStringForMember("o", mapping.Name + "Specified", structMapping.TypeDesc);
if (mapping.Text != null)
anyText = member;
if (mapping.Attribute != null && mapping.Attribute.Any)
anyAttribute = member;
if (!isSequence) {
// find anyElement if present.
for (int j = 0; j < mapping.Elements.Length; j++) {
if (mapping.Elements[j].Any && (mapping.Elements[j].Name == null || mapping.Elements[j].Name.Length == 0)) {
anyElement = member;
break;
}
}
}
else if (mapping.IsParticle && !mapping.IsSequence) {
StructMapping declaringMapping;
structMapping.FindDeclaringMapping(mapping, out declaringMapping, structMapping.TypeName);
throw new InvalidOperationException(Res.GetString(Res.XmlSequenceHierarchy, structMapping.TypeDesc.FullName, mapping.Name, declaringMapping.TypeDesc.FullName, "Order"));
}
if (mapping.Attribute == null && mapping.Elements.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping) {
Member arrayMember = new Member(this, source, source, "a", i, mapping, GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc));
arrayMember.CheckSpecifiedSource = member.CheckSpecifiedSource;
allMembersList.Add(arrayMember);
}
else {
allMembersList.Add(member);
}
if (mapping.TypeDesc.IsArrayLike) {
arraysToDeclareList.Add(member);
if (mapping.TypeDesc.IsArrayLike && !(mapping.Elements.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping)) {
member.ParamsReadSource = null; // flat arrays -- don't want to count params read.
if (member != anyText && member != anyElement) {
arraysToSetList.Add(member);
}
}
else if (!mapping.TypeDesc.IsArray) {
member.ParamsReadSource = null; // collection
}
}
}
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);
示例3: WriteLiteralStructMethod
//.........这里部分代码省略.........
string source = base.RaCodeGen.GetStringForMember("o", mapping.Name, structMapping.TypeDesc);
Member member4 = new Member(this, source, "a", i, mapping, this.GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc));
if (!mapping.IsSequence)
{
member4.ParamsReadSource = "paramsRead[" + i.ToString(CultureInfo.InvariantCulture) + "]";
}
member4.IsNullable = mapping.TypeDesc.IsNullable;
if (mapping.CheckSpecified == SpecifiedAccessor.ReadWrite)
{
member4.CheckSpecifiedSource = base.RaCodeGen.GetStringForMember("o", mapping.Name + "Specified", structMapping.TypeDesc);
}
if (mapping.Text != null)
{
member = member4;
}
if ((mapping.Attribute != null) && mapping.Attribute.Any)
{
anyAttribute = member4;
}
if (!flag2)
{
for (int j = 0; j < mapping.Elements.Length; j++)
{
if (mapping.Elements[j].Any && ((mapping.Elements[j].Name == null) || (mapping.Elements[j].Name.Length == 0)))
{
member2 = member4;
break;
}
}
}
else if (mapping.IsParticle && !mapping.IsSequence)
{
StructMapping mapping2;
structMapping.FindDeclaringMapping(mapping, out mapping2, structMapping.TypeName);
throw new InvalidOperationException(Res.GetString("XmlSequenceHierarchy", new object[] { structMapping.TypeDesc.FullName, mapping.Name, mapping2.TypeDesc.FullName, "Order" }));
}
if (((mapping.Attribute == null) && (mapping.Elements.Length == 1)) && (mapping.Elements[0].Mapping is ArrayMapping))
{
Member member5 = new Member(this, source, source, "a", i, mapping, this.GetChoiceIdentifierSource(mapping, "o", structMapping.TypeDesc)) {
CheckSpecifiedSource = member4.CheckSpecifiedSource
};
list3.Add(member5);
}
else
{
list3.Add(member4);
}
if (mapping.TypeDesc.IsArrayLike)
{
list.Add(member4);
if (mapping.TypeDesc.IsArrayLike && ((mapping.Elements.Length != 1) || !(mapping.Elements[0].Mapping is ArrayMapping)))
{
member4.ParamsReadSource = null;
if ((member4 != member) && (member4 != member2))
{
list2.Add(member4);
}
}
else if (!mapping.TypeDesc.IsArray)
{
member4.ParamsReadSource = null;
}
}
}
if (member2 != null)
{
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:67,代码来源:XmlSerializationReaderCodeGen.cs