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

ConvertValue() private method

private ConvertValue ( Type source, Type target ) : void
source System.Type
target System.Type
return void
        internal void ConvertValue(Type source, Type target)
        {
            InternalConvert(source, target, false);
        }

Usage Example

コード例 #1
0
            private 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);
                }
                //Copy the KeyValuePair<K,T> to a KeyValuePairAdapter<K,T>.
                else if (objType.IsGenericType && objType.GetGenericTypeDefinition() == Globals.TypeOfKeyValuePairAdapter)
                {
                    ClassDataContract dc = (ClassDataContract)DataContract.GetDataContract(objType);
                    _ilg.ConvertValue(objectArg.ArgType, Globals.TypeOfKeyValuePair.MakeGenericType(dc.KeyValuePairGenericArguments !));
                    _ilg.New(dc.KeyValuePairAdapterConstructorInfo !);
                }
                else
                {
                    _ilg.ConvertValue(objectArg.ArgType, objType);
                }
                _ilg.Stloc(_objectLocal);
            }
All Usage Examples Of System.Runtime.Serialization.CodeGenerator::ConvertValue