protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, LocalizedString?notFoundError, LocalizedString?multipleFoundError, ExchangeErrorCategory errorCategory) where TObject : IConfigurable, new() { IConfigurable result = null; LocalizedString? localizedString; IEnumerable <TObject> dataObjects = this.GetDataObjects <TObject>(id, session, rootID, optionalData, out localizedString); Exception ex = null; using (IEnumerator <TObject> enumerator = dataObjects.GetEnumerator()) { if (enumerator.MoveNext()) { result = enumerator.Current; if (enumerator.MoveNext()) { ex = new ManagementObjectAmbiguousException(multipleFoundError ?? Strings.ErrorManagementObjectAmbiguous(id.ToString())); } } else if (notFoundError != null) { LocalizedString message; if (localizedString != null) { LocalizedString?localizedString2 = notFoundError; string notFound = (localizedString2 != null) ? localizedString2.GetValueOrDefault() : null; LocalizedString?localizedString3 = localizedString; message = Strings.ErrorNotFoundWithReason(notFound, (localizedString3 != null) ? localizedString3.GetValueOrDefault() : null); } else { message = notFoundError.Value; } ex = new ManagementObjectNotFoundException(message); } else { ex = new ManagementObjectNotFoundException(localizedString ?? this.GetErrorMessageObjectNotFound(id.ToString(), typeof(TObject).ToString(), (this.DataSession != null) ? this.DataSession.Source : null)); } } if (ex != null) { if (errorCategory != (ExchangeErrorCategory)0) { RecipientTaskHelper.SetExceptionErrorCategory(ex, errorCategory); } throw ex; } return(result); }
protected virtual void WriteResult() { object[] array = new object[1]; object[] array2 = array; int num = 0; TDataObject dataObject = this.DataObject; array2[num] = dataObject.Identity; TaskLogger.LogEnter(array); TDataObject dataObject2 = this.DataObject; base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(dataObject2.Identity, base.DataSession, typeof(TDataObject))); IConfigurable configurable = null; try { using (TaskPerformanceData.ReadResult.StartRequestTimer()) { IConfigDataProvider dataSession = base.DataSession; TDataObject dataObject3 = this.DataObject; configurable = dataSession.Read <TDataObject>(dataObject3.Identity); } } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (configurable == null) { TDataObject dataObject4 = this.DataObject; Exception exception = new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(dataObject4.Identity), typeof(TDataObject).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)); ErrorCategory category = (ErrorCategory)1003; TDataObject dataObject5 = this.DataObject; base.WriteError(exception, category, dataObject5.Identity); } using (TaskPerformanceData.WriteResult.StartRequestTimer()) { this.WriteResult(configurable); } TaskLogger.LogExit(); }