本文整理匯總了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