// returns null on error internal static FormatInfoData CreateInstance(PSObject so, FormatObjectDeserializer deserializer) { if (so == null) { throw PSTraceSource.NewArgumentNullException("so"); } // look for the property that defines the type of object string classId = FormatObjectDeserializer.GetProperty(so, FormatInfoData.classidProperty) as string; if (classId == null) { string msg = StringUtil.Format(FormatAndOut_format_xxx.FOD_InvalidClassidProperty); ErrorRecord errorRecord = new ErrorRecord( PSTraceSource.NewArgumentException("classid"), "FormatObjectDeserializerInvalidClassidProperty", ErrorCategory.InvalidData, so); errorRecord.ErrorDetails = new ErrorDetails(msg); deserializer.TerminatingErrorContext.ThrowTerminatingError(errorRecord); } FormatInfoData fid = CreateInstance(classId, deserializer); return(fid); }
internal static void ReadList(PSObject so, string property, List <T> lst, FormatObjectDeserializer deserializer) { if (lst == null) { throw PSTraceSource.NewArgumentNullException("lst"); } object memberRaw = FormatObjectDeserializer.GetProperty(so, property); ReadListHelper(PSObjectHelper.GetEnumerable(memberRaw), lst, deserializer); }
internal static FormatInfoData CreateInstance(PSObject so, FormatObjectDeserializer deserializer) { if (so == null) { throw PSTraceSource.NewArgumentNullException("so"); } string property = FormatObjectDeserializer.GetProperty(so, "ClassId2e4f51ef21dd47e99d3c952918aff9cd") as string; if (property == null) { string message = StringUtil.Format(FormatAndOut_format_xxx.FOD_InvalidClassidProperty, new object[0]); ErrorRecord errorRecord = new ErrorRecord(PSTraceSource.NewArgumentException("classid"), "FormatObjectDeserializerInvalidClassidProperty", ErrorCategory.InvalidData, so) { ErrorDetails = new ErrorDetails(message) }; deserializer.TerminatingErrorContext.ThrowTerminatingError(errorRecord); } return(CreateInstance(property, deserializer)); }