Beispiel #1
0
 private object ConvertActualValueToExpectedType(object actualPropertyValue, object expectedPropertyValue)
 {
     if (actualPropertyValue as string != null && expectedPropertyValue as string == null)
     {
         actualPropertyValue = LanguagePrimitives.ConvertTo(actualPropertyValue, expectedPropertyValue.GetType(), CultureInfo.InvariantCulture);
     }
     if (ClientSideQuery.PropertyValueFilter.IsSameType(actualPropertyValue, expectedPropertyValue))
     {
         return(actualPropertyValue);
     }
     else
     {
         object[] fullName = new object[3];
         fullName[0] = this.propertyName;
         fullName[1] = actualPropertyValue.GetType().FullName;
         fullName[2] = expectedPropertyValue.GetType().FullName;
         string str = string.Format(CultureInfo.InvariantCulture, CmdletizationResources.CimJob_MismatchedTypeOfPropertyReturnedByQuery, fullName);
         throw CimJobException.CreateWithoutJobContext(str, "CimJob_PropertyTypeUnexpectedByClientSideQuery", ErrorCategory.InvalidType, null);
     }
 }
Beispiel #2
0
            private object ConvertActualValueToExpectedType(object actualPropertyValue, object expectedPropertyValue)
            {
                if (actualPropertyValue is string && expectedPropertyValue is not string)
                {
                    actualPropertyValue = LanguagePrimitives.ConvertTo(actualPropertyValue, expectedPropertyValue.GetType(), CultureInfo.InvariantCulture);
                }

                if (!IsSameType(actualPropertyValue, expectedPropertyValue))
                {
                    var errorMessage = string.Format(
                        CultureInfo.InvariantCulture,
                        CmdletizationResources.CimJob_MismatchedTypeOfPropertyReturnedByQuery,
                        PropertyName,
                        actualPropertyValue.GetType().FullName,
                        expectedPropertyValue.GetType().FullName);
                    throw CimJobException.CreateWithoutJobContext(
                              errorMessage,
                              "CimJob_PropertyTypeUnexpectedByClientSideQuery",
                              ErrorCategory.InvalidType);
                }

                return(actualPropertyValue);
            }