System.Runtime.Serialization.CodeGenerator.Stloc C# (CSharp) Method

Stloc() private method

private Stloc ( LocalBuilder local ) : void
local System.Reflection.Emit.LocalBuilder
return void
        internal void Stloc(LocalBuilder local)
        {
            if (_codeGenTrace != CodeGenTrace.None)
                EmitSourceInstruction("Stloc " + _localNames[local]);
            EmitStackTop(local.LocalType);
            _ilGen.Emit(OpCodes.Stloc, local);
        }

Usage Example

コード例 #1
0
            void InitArgs(Type objType)
            {
                xmlWriterArg    = ilg.GetArg(0);
                contextArg      = ilg.GetArg(2);
                dataContractArg = ilg.GetArg(3);

                objectLocal = ilg.DeclareLocal(objType, "objSerialized");
                ArgBuilder objectArg = ilg.GetArg(1);

                ilg.Load(objectArg);

                // Copy the data from the DataTimeOffset object passed in to the DateTimeOffsetAdapter.
                // DateTimeOffsetAdapter is used here for serialization purposes to bypass the ISerializable implementation
                // on DateTimeOffset; which does not work in partial trust.

                if (objType == Globals.TypeOfDateTimeOffsetAdapter)
                {
                    ilg.ConvertValue(objectArg.ArgType, Globals.TypeOfDateTimeOffset);
                    ilg.Call(XmlFormatGeneratorStatics.GetDateTimeOffsetAdapterMethod);
                }
                else
                {
                    ilg.ConvertValue(objectArg.ArgType, objType);
                }
                ilg.Stloc(objectLocal);
            }
All Usage Examples Of System.Runtime.Serialization.CodeGenerator::Stloc