Exemplo n.º 1
0
 internal static object MethodArgumentConvertTo(
     object valueToConvert,
     bool isParameterByRef,
     int parameterIndex,
     Type resultType,
     IFormatProvider formatProvider)
 {
     using (PSObject.memberResolution.TraceScope("Method argument conversion."))
     {
         if (resultType == null)
         {
             throw Adapter.tracer.NewArgumentNullException(nameof(resultType));
         }
         bool isArgumentByRef;
         valueToConvert = Adapter.UnReference(valueToConvert, out isArgumentByRef);
         if (isParameterByRef && !isArgumentByRef)
         {
             throw new MethodException("NonRefArgumentToRefParameterMsg", (Exception)null, "ExtendedTypeSystem", "NonRefArgumentToRefParameter", new object[3]
             {
                 (object)(parameterIndex + 1),
                 (object)typeof(PSReference).FullName,
                 (object)"[ref]"
             });
         }
         if (isArgumentByRef && !isParameterByRef)
         {
             throw new MethodException("RefArgumentToNonRefParameterMsg", (Exception)null, "ExtendedTypeSystem", "RefArgumentToNonRefParameter", new object[3]
             {
                 (object)(parameterIndex + 1),
                 (object)typeof(PSReference).FullName,
                 (object)"[ref]"
             });
         }
         return(Adapter.PropertySetAndMethodArgumentConvertTo(valueToConvert, resultType, formatProvider));
     }
 }