System\Xml\Serialization\XmlSerializationWriter.cs (729)
2250Writer.Write(Access);
2251Writer.Write(" class ");
2252Writer.Write(ClassName);
2253Writer.Write(" : ");
2254Writer.Write(typeof(System.Xml.Serialization.XmlSerializationWriter).FullName);
2255Writer.WriteLine(" {");
2256Writer.Indent++;
2309Writer.Indent--;
2310Writer.WriteLine("}");
2330Writer.WriteLine();
2331Writer.WriteLine("protected override void InitCallbacks() {");
2332Writer.Indent++;
2343Writer.Write("AddWriteCallback(");
2344Writer.Write(RaCodeGen.GetStringForTypeof(typeMapping.TypeDesc.CSharpName, typeMapping.TypeDesc.UseReflection));
2345Writer.Write(", ");
2347Writer.Write(", ");
2349Writer.Write(", new ");
2350Writer.Write(typeof(System.Xml.Serialization.XmlSerializationWriteCallback).FullName);
2351Writer.Write("(this.");
2352Writer.Write(methodName);
2353Writer.WriteLine("));");
2358Writer.Indent--;
2359Writer.WriteLine("}");
2369Writer.WriteLine(" {");
2370Writer.Indent++;
2373Writer.Write(nullable ? ("WriteNullableQualifiedName" + suffix) : "WriteElementQualifiedName");
2374Writer.Write("(");
2378Writer.Write(", ");
2381Writer.Write(", ");
2382Writer.Write(source);
2386Writer.Write(", new System.Xml.XmlQualifiedName(");
2388Writer.Write(", ");
2390Writer.Write(")");
2393Writer.WriteLine(");");
2397Writer.Indent--;
2398Writer.WriteLine("}");
2411Writer.Write(methodName);
2412Writer.Write("(");
2413Writer.Write(source);
2414Writer.Write(")");
2421Writer.Write(source);
2427Writer.Write(typeof(XmlConvert).FullName);
2428Writer.Write(".ToString((");
2429Writer.Write(typeDesc.CSharpName);
2430Writer.Write(")");
2431Writer.Write(source);
2432Writer.Write(")");
2436Writer.Write("From");
2437Writer.Write(typeDesc.FormatterName);
2438Writer.Write("(");
2439Writer.Write(source);
2440Writer.Write(")");
2459Writer.Write("if (");
2461Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue(source, mapping.TypeDesc.UseReflection));
2463Writer.Write(source);
2464Writer.Write(" != ");
2467Writer.Write("(");
2474Writer.WriteLine(" | ");
2475Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, values[i], mapping.TypeDesc.UseReflection));
2477Writer.Write(")");
2481Writer.Write(RaCodeGen.GetStringForEnumCompare((EnumMapping)mapping, (string)defaultValue!, mapping.TypeDesc.UseReflection));
2483Writer.Write(")");
2489Writer.WriteLine(" {");
2490Writer.Indent++;
2493Writer.Write(method);
2494Writer.Write("(");
2498Writer.Write(", ");
2502Writer.Write(", ");
2515Writer.Write(", new System.Xml.XmlQualifiedName(");
2517Writer.Write(", ");
2519Writer.Write(")");
2522Writer.WriteLine(");");
2526Writer.Indent--;
2527Writer.WriteLine("}");
2533Writer.Write(methodName);
2534Writer.Write("(");
2536Writer.Write(", ");
2539Writer.Write("null");
2545Writer.WriteLine(");");
2550Writer.Write(methodName);
2551Writer.Write("(");
2553Writer.Write(", ");
2556Writer.Write("null");
2562Writer.Write(", null, ");
2564Writer.Write("true");
2566Writer.Write("false");
2567Writer.WriteLine(");");
2577Writer.WriteLine("WriteEndElement();");
2581Writer.Write("WriteEndElement(");
2582Writer.Write(source);
2583Writer.WriteLine(");");
2610Writer.WriteLine();
2611Writer.Write("public void ");
2612Writer.Write(methodName);
2613Writer.WriteLine("(object[] p) {");
2614Writer.Indent++;
2616Writer.WriteLine("WriteStartDocument();");
2620Writer.WriteLine("TopLevelElement();");
2626Writer.WriteLine("int pLength = p.Length;");
2637Writer.Write("if (pLength > ");
2638Writer.Write(xmlnsMember.ToString(CultureInfo.InvariantCulture));
2639Writer.WriteLine(") {");
2640Writer.Indent++;
2642Writer.Indent--;
2643Writer.WriteLine("}");
2671Writer.Write("if (pLength > ");
2672Writer.Write(index);
2673Writer.WriteLine(") {");
2674Writer.Indent++;
2678Writer.Write("if (pLength <= ");
2679Writer.Write(specifiedPosition.ToString(CultureInfo.InvariantCulture));
2680Writer.Write(" || ");
2681Writer.Write(specifiedSource);
2682Writer.WriteLine(") {");
2683Writer.Indent++;
2690Writer.Indent--;
2691Writer.WriteLine("}");
2694Writer.Indent--;
2695Writer.WriteLine("}");
2726Writer.Write("if (pLength > ");
2727Writer.Write(index);
2728Writer.WriteLine(") {");
2729Writer.Indent++;
2733Writer.Write("if (pLength <= ");
2734Writer.Write(specifiedPosition.ToString(CultureInfo.InvariantCulture));
2735Writer.Write(" || ");
2736Writer.Write(specifiedSource);
2737Writer.WriteLine(") {");
2738Writer.Indent++;
2765Writer.Write("WriteRpcResult(");
2767Writer.Write(", ");
2769Writer.WriteLine(");");
2777Writer.Indent--;
2778Writer.WriteLine("}");
2781Writer.Indent--;
2782Writer.WriteLine("}");
2794Writer.Write("if (pLength > ");
2795Writer.Write(mapping.Members.Length.ToString(CultureInfo.InvariantCulture));
2796Writer.WriteLine(") {");
2797Writer.Indent++;
2801Writer.Indent--;
2802Writer.WriteLine("}");
2804Writer.WriteLine("WriteReferencedElements();");
2806Writer.Indent--;
2807Writer.WriteLine("}");
2817Writer.WriteLine();
2818Writer.Write("public void ");
2819Writer.Write(methodName);
2820Writer.WriteLine("(object o) {");
2821Writer.Indent++;
2823Writer.WriteLine("WriteStartDocument();");
2825Writer.WriteLine("if (o == null) {");
2826Writer.Indent++;
2836Writer.WriteLine("return;");
2837Writer.Indent--;
2838Writer.WriteLine("}");
2842Writer.WriteLine("TopLevelElement();");
2849Writer.WriteLine("WriteReferencedElements();");
2851Writer.Indent--;
2852Writer.WriteLine("}");
2864Writer.WriteLine();
2868Writer.Write("void ");
2869Writer.Write(methodName);
2870Writer.WriteLine("(object e) {");
2875Writer.Write("string ");
2876Writer.Write(methodName);
2877Writer.Write("(");
2878Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName);
2879Writer.WriteLine(" v) {");
2881Writer.Indent++;
2882Writer.WriteLine("string s = null;");
2889Writer.WriteLine($"switch ({ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection)} ){{");
2891Writer.WriteLine("switch (v) {");
2892Writer.Indent++;
2899Writer.Write("s = ");
2901Writer.WriteLine("; break;");
2909Writer.Write("default: s = FromEnum(");
2910Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection));
2911Writer.Write(", new string[] {");
2912Writer.Indent++;
2917Writer.WriteLine(", ");
2920Writer.Write("}, new ");
2921Writer.Write(typeof(long).FullName);
2922Writer.Write("[] {");
2928Writer.WriteLine(", ");
2929Writer.Write("(long)");
2931Writer.Write(c.Value.ToString(CultureInfo.InvariantCulture));
2934Writer.Write(fullTypeName);
2935Writer.Write(".@");
2937Writer.Write(c.Name);
2940Writer.Indent--;
2941Writer.Write("}, ");
2943Writer.WriteLine("); break;");
2947Writer.Write("default: throw CreateInvalidEnumValueException(");
2948Writer.Write(ReflectionAwareCodeGen.GetStringForEnumLongValue("v", mapping.TypeDesc.UseReflection));
2949Writer.Write(".ToString(System.Globalization.CultureInfo.InvariantCulture), ");
2951Writer.WriteLine(");");
2953Writer.Indent--;
2954Writer.WriteLine("}");
2958Writer.Write("WriteXsiType(");
2960Writer.Write(", ");
2962Writer.WriteLine(");");
2963Writer.WriteLine("Writer.WriteString(s);");
2967Writer.WriteLine("return s;");
2969Writer.Indent--;
2970Writer.WriteLine("}");
2978Writer.Write("if (");
2980Writer.WriteLine(") {");
2981Writer.Indent++;
2990Writer.Write(methodName);
2991Writer.Write("(n, ns,");
2992if (!derived.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})");
2993Writer.Write("o");
2995Writer.Write(", isNullable");
2996Writer.Write(", true");
2997Writer.WriteLine(");");
2998Writer.WriteLine("return;");
2999Writer.Indent--;
3000Writer.WriteLine("}");
3017Writer.Write("if (");
3019Writer.WriteLine(") {");
3020Writer.Indent++;
3028Writer.WriteLine("Writer.WriteStartElement(n, ns);");
3029Writer.Write("WriteXsiType(");
3031Writer.Write(", ");
3033Writer.WriteLine(");");
3034Writer.Write("Writer.WriteString(");
3035Writer.Write(methodName);
3036Writer.Write("(");
3037if (!mapping.TypeDesc.UseReflection) Writer.Write($"({fullTypeName})");
3038Writer.WriteLine("o));");
3039Writer.WriteLine("Writer.WriteEndElement();");
3040Writer.WriteLine("return;");
3041Writer.Indent--;
3042Writer.WriteLine("}");
3049Writer.Write("if (");
3054Writer.WriteLine(") {");
3055Writer.Indent++;
3057Writer.WriteLine("Writer.WriteStartElement(n, ns);");
3058Writer.Write("WriteXsiType(");
3060Writer.Write(", ");
3062Writer.WriteLine(");");
3066Writer.WriteLine("Writer.WriteEndElement();");
3067Writer.WriteLine("return;");
3068Writer.Indent--;
3069Writer.WriteLine("}");
3081Writer.WriteLine();
3082Writer.Write("void ");
3083Writer.Write(methodName);
3089Writer.WriteLine("(object s) {");
3090Writer.Indent++;
3095Writer.Write("(string n, string ns, ");
3096Writer.Write(mapping.TypeDesc.UseReflection ? "object" : fullTypeName);
3097Writer.Write(" o");
3099Writer.Write(", bool isNullable");
3100Writer.WriteLine(", bool needType) {");
3101Writer.Indent++;
3104Writer.WriteLine("if ((object)o == null) {");
3105Writer.Indent++;
3106Writer.WriteLine("if (isNullable) WriteNullTagLiteral(n, ns);");
3107Writer.WriteLine("return;");
3108Writer.Indent--;
3109Writer.WriteLine("}");
3111Writer.WriteLine("if (!needType) {");
3112Writer.Indent++;
3114Writer.Write(typeof(Type).FullName);
3115Writer.WriteLine(" t = o.GetType();");
3116Writer.Write("if (");
3118Writer.WriteLine(") {");
3119Writer.WriteLine("}");
3120Writer.WriteLine("else {");
3121Writer.Indent++;
3128Writer.WriteLine("WriteTypedPrimitive(n, ns, o, true);");
3129Writer.WriteLine("return;");
3133Writer.WriteLine("throw CreateUnknownTypeException(o);");
3135Writer.Indent--;
3136Writer.WriteLine("}");
3137Writer.Indent--;
3138Writer.WriteLine("}");
3145Writer.WriteLine("EscapeName = false;");
3164Writer.Write("WriteStartElement(n, ns, o, false, ");
3166Writer.Write("null");
3168Writer.Write(xmlnsSource);
3170Writer.WriteLine(");");
3173Writer.Write("if (needType) WriteXsiType(");
3175Writer.Write(", ");
3177Writer.WriteLine(");");
3192Writer.Write("if (");
3195Writer.Write(methodInvoke);
3196Writer.WriteLine(") {");
3197Writer.Indent++;
3201Writer.Write("if (");
3204Writer.Write(memberGet);
3205Writer.WriteLine(") {");
3206Writer.Indent++;
3212Writer.Indent--;
3213Writer.WriteLine("}");
3217Writer.Indent--;
3218Writer.WriteLine("}");
3233Writer.Write("if (");
3236Writer.Write(methodInvoke);
3237Writer.WriteLine(") {");
3238Writer.Indent++;
3242Writer.Write("if (");
3245Writer.Write(memberGet);
3246Writer.WriteLine(") {");
3247Writer.Indent++;
3260Writer.Indent--;
3261Writer.WriteLine("}");
3265Writer.Indent--;
3266Writer.WriteLine("}");
3274Writer.Indent--;
3275Writer.WriteLine("}");
3293Writer.WriteLine("{");
3294Writer.Indent++;
3299Writer.WriteLine("if (a != null) {");
3300Writer.Indent++;
3306Writer.Write("Writer.WriteStartAttribute(null, ");
3308Writer.Write(", ");
3316Writer.Write("null");
3318Writer.WriteLine(");");
3322Writer.Write(typeof(StringBuilder).FullName);
3323Writer.Write(" sb = new ");
3324Writer.Write(typeof(StringBuilder).FullName);
3325Writer.WriteLine("();");
3332Writer.Write(" e = ");
3333Writer.Write(typeof(IEnumerator).FullName);
3336Writer.Write("((");
3337Writer.Write(typeof(IEnumerable).FullName);
3338Writer.WriteLine(").GetEnumerator();");
3345Writer.Write("(");
3346Writer.Write(typeof(IEnumerator).FullName);
3347Writer.Write(")");
3348Writer.Write(RaCodeGen.GetReflectionVariable(memberTypeDesc.CSharpName, "System.Collections.Generic.IEnumerable*"));
3349Writer.WriteLine(".Invoke(a, new object[0]);");
3353Writer.Write("((System.Collections.Generic.IEnumerable<");
3354Writer.Write(arrayElementTypeDesc.CSharpName);
3355Writer.WriteLine(">)a).GetEnumerator();");
3362Writer.Write("(");
3363Writer.Write(typeof(IEnumerator).FullName);
3364Writer.Write(")");
3366Writer.Write(RaCodeGen.GetStringForMethodInvoke("a", memberTypeDesc.CSharpName, "GetEnumerator", memberTypeDesc.UseReflection));
3367Writer.WriteLine(";");
3369Writer.WriteLine("if (e != null)");
3370Writer.WriteLine("while (e.MoveNext()) {");
3371Writer.Indent++;
3378Writer.Write("for (int i = 0; i < ");
3381Writer.WriteLine("a.Length; i++) {");
3385Writer.Write("((");
3386Writer.Write(typeof(ICollection).FullName);
3387Writer.WriteLine(")a).Count; i++) {");
3389Writer.Indent++;
3398Writer.WriteLine("if (i != 0) Writer.WriteString(\" \");");
3399Writer.Write("WriteValue(");
3403Writer.WriteLine("if (i != 0) sb.Append(\" \");");
3404Writer.Write("sb.Append(");
3410Writer.WriteLine(");");
3416Writer.Indent--;
3417Writer.WriteLine("}");
3423Writer.WriteLine("Writer.WriteEndAttribute();");
3427Writer.WriteLine("if (sb.Length != 0) {");
3428Writer.Indent++;
3430Writer.Write("WriteAttribute(");
3432Writer.Write(", ");
3437Writer.Write(", ");
3439Writer.WriteLine("sb.ToString());");
3440Writer.Indent--;
3441Writer.WriteLine("}");
3447Writer.Indent--;
3448Writer.WriteLine("}");
3450Writer.Indent--;
3451Writer.WriteLine("}");
3466Writer.Write("WriteXmlAttribute(");
3467Writer.Write(source);
3468Writer.Write(", ");
3469Writer.Write(parent);
3470Writer.WriteLine(");");
3497Writer.WriteLine("{");
3498Writer.Indent++;
3503Writer.WriteLine("if (a != null) {");
3504Writer.Indent++;
3512Writer.WriteLine("if (c == null || c.Length < a.Length) {");
3513Writer.Indent++;
3514Writer.Write("throw CreateInvalidChoiceIdentifierValueException(");
3516Writer.Write(", ");
3518Writer.Write(");");
3519Writer.Indent--;
3520Writer.WriteLine("}");
3526Writer.Indent--;
3527Writer.WriteLine("}");
3529Writer.Indent--;
3530Writer.WriteLine("}");
3540Writer.Write(typeof(IEnumerator).FullName);
3541Writer.Write(" e = ");
3544Writer.Write("((");
3545Writer.Write(typeof(IEnumerable).FullName);
3546Writer.Write(")");
3547Writer.Write(arrayName);
3548Writer.WriteLine(").GetEnumerator();");
3555Writer.Write("(");
3556Writer.Write(typeof(IEnumerator).FullName);
3557Writer.Write(")");
3558Writer.Write(RaCodeGen.GetReflectionVariable(arrayTypeDesc.CSharpName, "System.Collections.Generic.IEnumerable*"));
3559Writer.Write(".Invoke(");
3560Writer.Write(arrayName);
3561Writer.WriteLine(", new object[0]);");
3565Writer.Write("((System.Collections.Generic.IEnumerable<");
3566Writer.Write(arrayElementTypeDesc.CSharpName);
3567Writer.Write(">)");
3568Writer.Write(arrayName);
3569Writer.WriteLine(").GetEnumerator();");
3576Writer.Write("(");
3577Writer.Write(typeof(IEnumerator).FullName);
3578Writer.Write(")");
3580Writer.Write(RaCodeGen.GetStringForMethodInvoke(arrayName, arrayTypeDesc.CSharpName, "GetEnumerator", arrayTypeDesc.UseReflection));
3581Writer.WriteLine(";");
3583Writer.WriteLine("if (e != null)");
3584Writer.WriteLine("while (e.MoveNext()) {");
3585Writer.Indent++;
3592Writer.Write("for (int i");
3593Writer.Write(arrayName);
3594Writer.Write(" = 0; i");
3595Writer.Write(arrayName);
3596Writer.Write(" < ");
3599Writer.Write(arrayName);
3600Writer.Write(".Length");
3604Writer.Write("((");
3605Writer.Write(typeof(ICollection).FullName);
3606Writer.Write(")");
3607Writer.Write(arrayName);
3608Writer.Write(").Count");
3610Writer.Write("; i");
3611Writer.Write(arrayName);
3612Writer.WriteLine("++) {");
3613Writer.Indent++;
3631Writer.Indent--;
3632Writer.WriteLine("}");
3656Writer.Write("if ((object)(");
3657Writer.Write(source);
3658Writer.Write(") != null)");
3660Writer.WriteLine("{");
3661Writer.Indent++;
3691if (wroteFirstIf) Writer.Write("else ");
3693Writer.Write("if (");
3694Writer.Write(enumUseReflection ? ReflectionAwareCodeGen.GetStringForEnumLongValue(enumSource!, enumUseReflection) : enumSource);
3695Writer.Write(" == ");
3696Writer.Write(enumFullName);
3699Writer.Write(" && ((object)(");
3700Writer.Write(source);
3701Writer.Write(") != null)");
3703Writer.WriteLine(") {");
3704Writer.Indent++;
3712Writer.Indent--;
3713Writer.WriteLine("}");
3720if (wroteFirstIf) Writer.Write("else ");
3722Writer.Write("if (");
3724Writer.WriteLine(") {");
3725Writer.Indent++;
3730Writer.Indent--;
3731Writer.WriteLine("}");
3736if (elements.Length - anyCount > 0) Writer.Write("else ");
3740Writer.Write("if (");
3741Writer.Write(source);
3742Writer.Write(" is ");
3743Writer.Write(fullTypeName);
3744Writer.WriteLine(") {");
3745Writer.Indent++;
3747Writer.Write(fullTypeName);
3748Writer.Write(" elem = (");
3749Writer.Write(fullTypeName);
3750Writer.Write(")");
3751Writer.Write(source);
3752Writer.WriteLine(";");
3758if (c++ > 0) Writer.Write("else ");
3766Writer.Write("if (");
3767Writer.Write(enumUseReflection ? ReflectionAwareCodeGen.GetStringForEnumLongValue(enumSource!, enumUseReflection) : enumSource);
3768Writer.Write(" == ");
3769Writer.Write(enumFullName);
3772Writer.Write(" && ((object)(");
3773Writer.Write(source);
3774Writer.Write(") != null)");
3776Writer.WriteLine(") {");
3777Writer.Indent++;
3779Writer.Write("if (elem.Name == ");
3781Writer.Write(" && elem.NamespaceURI == ");
3783Writer.WriteLine(") {");
3784Writer.Indent++;
3789Writer.Indent--;
3790Writer.WriteLine("}");
3791Writer.WriteLine("else {");
3792Writer.Indent++;
3794Writer.WriteLine("// throw Value '{0}' of the choice identifier '{1}' does not match element '{2}' from namespace '{3}'.");
3796Writer.Write("throw CreateChoiceIdentifierValueException(");
3798Writer.Write(", ");
3800Writer.WriteLine(", elem.Name, elem.NamespaceURI);");
3801Writer.Indent--;
3802Writer.WriteLine("}");
3804Writer.Indent--;
3805Writer.WriteLine("}");
3809Writer.WriteLine("else {");
3810Writer.Indent++;
3818Writer.WriteLine("throw CreateUnknownAnyElementException(elem.Name, elem.NamespaceURI);");
3822Writer.Indent--;
3823Writer.WriteLine("}");
3825Writer.Indent--;
3826Writer.WriteLine("}");
3834Writer.Write("else ");
3835Writer.Write("if (");
3837Writer.WriteLine(") {");
3838Writer.Indent++;
3843Writer.Indent--;
3844Writer.WriteLine("}");
3856Writer.Write("else ");
3860Writer.Write(" if ((object)(");
3861Writer.Write(source);
3862Writer.Write(") != null)");
3865Writer.WriteLine("{");
3866Writer.Indent++;
3868Writer.Write("throw CreateUnknownTypeException(");
3869Writer.Write(source);
3870Writer.WriteLine(");");
3872Writer.Indent--;
3873Writer.WriteLine("}");
3875Writer.Indent--;
3876Writer.WriteLine("}");
3884Writer.Write("WriteValue(");
3893Writer.WriteLine(");");
3900Writer.Write(source);
3901Writer.WriteLine(".WriteTo(Writer);");
3916Writer.Write("if (");
3917Writer.Write(source);
3918Writer.WriteLine(" != null) {");
3919Writer.Indent++;
3927Writer.Indent--;
3928Writer.WriteLine("}");
3931Writer.WriteLine("else {");
3932Writer.Indent++;
3934Writer.Indent--;
3935Writer.WriteLine("}");
3942Writer.Write("WritePotentiallyReferencingElement(");
3944Writer.Write(", ");
3946Writer.Write(", ");
3947Writer.Write(source);
3950Writer.Write(", ");
3951Writer.Write(RaCodeGen.GetStringForTypeof(arrayMapping.TypeDesc!.CSharpName, arrayMapping.TypeDesc.UseReflection));
3952Writer.Write(", true, ");
3956Writer.Write(", null, false, ");
3959Writer.WriteLine(");");
3967Writer.WriteLine("{");
3968Writer.Indent++;
3978Writer.Write("if (");
3979Writer.Write(elementArrayName);
3980Writer.Write(" != null)");
3982Writer.WriteLine("{");
3983Writer.Indent++;
3986Writer.Write("for (int ");
3987Writer.Write(arrayIndex);
3988Writer.Write(" = 0; ");
3989Writer.Write(arrayIndex);
3990Writer.Write(" < ");
3994Writer.Write(elementArrayName);
3995Writer.Write(".Length");
3999Writer.Write("((");
4000Writer.Write(typeof(ICollection).FullName);
4001Writer.Write(")");
4002Writer.Write(elementArrayName);
4003Writer.Write(").Count");
4005Writer.Write("; ");
4006Writer.Write(arrayIndex);
4007Writer.WriteLine("++) {");
4008Writer.Indent++;
4014Writer.Indent--;
4015Writer.WriteLine("}");
4017Writer.Indent--;
4018Writer.WriteLine("}");
4019Writer.Indent--;
4020Writer.WriteLine("}");
4025Writer.WriteLine("{");
4026Writer.Indent++;
4036Writer.Write("if (");
4037Writer.Write(arrayName);
4038Writer.Write(" != null)");
4040Writer.WriteLine("{");
4041Writer.Indent++;
4046Writer.Indent--;
4047Writer.WriteLine("}");
4048Writer.Indent--;
4049Writer.WriteLine("}");
4057Writer.Write("Writer.WriteStartElement(");
4059Writer.Write(", ");
4061Writer.WriteLine(");");
4062Writer.Write(methodName);
4063Writer.Write("(");
4064Writer.Write(source);
4065Writer.WriteLine(");");
4089Writer.Write("WritePotentiallyReferencingElement(");
4091Writer.Write(", ");
4093Writer.Write(", ");
4094Writer.Write(source);
4097Writer.Write(", ");
4098Writer.Write(RaCodeGen.GetStringForTypeof(structMapping.TypeDesc!.CSharpName, structMapping.TypeDesc.UseReflection));
4099Writer.Write(", true, ");
4103Writer.Write(", null, false, ");
4115Writer.Write(methodName);
4116Writer.Write("(");
4118Writer.Write(", ");
4120Writer.Write("null");
4125Writer.Write(", ");
4126Writer.Write(source);
4129Writer.Write(", ");
4132Writer.Write(", false");
4134Writer.WriteLine(");");
4145Writer.Write("if ((");
4146Writer.Write(source);
4147Writer.Write(") is ");
4148Writer.Write(typeof(XmlNode).FullName);
4149Writer.Write(" || ");
4150Writer.Write(source);
4151Writer.Write(" == null");
4152Writer.WriteLine(") {");
4153Writer.Indent++;
4157Writer.Indent--;
4158Writer.WriteLine("}");
4159Writer.WriteLine("else {");
4160Writer.Indent++;
4162Writer.Write("throw CreateInvalidAnyTypeException(");
4163Writer.Write(source);
4164Writer.WriteLine(");");
4166Writer.Indent--;
4167Writer.WriteLine("}");
4178Writer.Write(func);
4179Writer.Write("((");
4180Writer.Write(cast.FullName);
4181Writer.Write(")");
4182Writer.Write(source);
4183Writer.Write(", ");
4185Writer.Write(", ");
4187Writer.Write(", ");
4189Writer.Write(", ");
4191Writer.WriteLine(");");
4197Writer.Write("if (");
4202Writer.Write("(");
4203Writer.Write(source);
4205Writer.Write(" == null) || (");
4207Writer.Write(" != null) && (");
4208Writer.Write(source);
4209Writer.Write(".Length != 0)");
4213Writer.Write("!");
4214Writer.Write(source);
4215Writer.Write(".Equals(");
4218Writer.Write(")");
4222Writer.Write(source);
4223Writer.Write(" != ");
4227Writer.Write(")");
4232Writer.Write("if (((object)");
4233Writer.Write(source);
4234Writer.Write(") != null && !(");
4236Writer.Write(")) throw CreateMismatchChoiceException(");
4238Writer.Write(", ");
4240Writer.Write(", ");
4242Writer.WriteLine(");");
4247Writer.Write("if ((object)(");
4248Writer.Write(source);
4249Writer.WriteLine(") == null) {");
4250Writer.Indent++;
4252Writer.Indent--;
4253Writer.WriteLine("}");
4254Writer.WriteLine("else {");
4255Writer.Indent++;
4262Writer.Write("null");
4275Writer.Write('\'');
4278Writer.Write("\'");
4280Writer.Write(ch);
4281Writer.Write('\'');
4284Writer.Write(((int)value).ToString(null, NumberFormatInfo.InvariantInfo));
4289Writer.Write("System.Double.NaN");
4293Writer.Write("System.Double.PositiveInfinity");
4297Writer.Write("System.Double.NegativeInfinity");
4301Writer.Write(((double)value).ToString("R", NumberFormatInfo.InvariantInfo));
4305Writer.Write((bool)value ? "true" : "false");
4308Writer.Write("(");
4309Writer.Write(type.FullName);
4310Writer.Write(")");
4311Writer.Write("(");
4312Writer.Write(Convert.ToString(value, NumberFormatInfo.InvariantInfo));
4313Writer.Write(")");
4319Writer.Write("System.Single.NaN");
4323Writer.Write("System.Single.PositiveInfinity");
4327Writer.Write("System.Single.NegativeInfinity");
4331Writer.Write(((float)value).ToString("R", NumberFormatInfo.InvariantInfo));
4332Writer.Write("f");
4337Writer.Write(((decimal)value).ToString(null, NumberFormatInfo.InvariantInfo));
4338Writer.Write("m");
4342Writer.Write(" new ");
4343Writer.Write(type.FullName);
4344Writer.Write("(");
4345Writer.Write(((DateTime)value).Ticks.ToString(CultureInfo.InvariantCulture));
4346Writer.Write(")");
4350Writer.Write(" new ");
4351Writer.Write(type.FullName);
4352Writer.Write("(");
4353Writer.Write(((DateTimeOffset)value).Ticks.ToString(CultureInfo.InvariantCulture));
4354Writer.Write(", new ");
4355Writer.Write(((DateTimeOffset)value).Offset.GetType().FullName);
4356Writer.Write("(");
4357Writer.Write(((DateTimeOffset)value).Offset.Ticks.ToString(CultureInfo.InvariantCulture));
4358Writer.Write("))");
4362Writer.Write(" new ");
4363Writer.Write(type.FullName);
4364Writer.Write("(");
4365Writer.Write(((TimeSpan)value).Ticks.ToString(CultureInfo.InvariantCulture));
4366Writer.Write(")");
4372Writer.Write(((int)value).ToString(null, NumberFormatInfo.InvariantInfo));
4385Writer.Write("WriteNamespaceDeclarations(");
4386Writer.Write(source);
4387Writer.WriteLine(");");
4403Writer.Write("for (int i = ");
4404Writer.Write(loopStartSource);
4405Writer.Write("; i < ");
4406Writer.Write(loopEndSource);
4407Writer.WriteLine("; i++) {");
4408Writer.Indent++;
4409Writer.WriteLine("if (p[i] != null) {");
4410Writer.Indent++;
4411Writer.WriteLine("WritePotentiallyReferencingElement(null, null, p[i], p[i].GetType(), true, false);");
4412Writer.Indent--;
4413Writer.WriteLine("}");
4414Writer.Indent--;
4415Writer.WriteLine("}");