public static NativeTypes.FABRIC_ERROR_CODE HandleException(Action action) { Task <NativeTypes.FABRIC_ERROR_CODE> task = FabricClientState.HandleExceptionAsync(delegate { action(); return(TaskUtility.CreateCompletedTask()); }); return(task.Result); }
public OperationResult <WinFabricNameEnumerationResult> ConvertToWinFabricNameEnumerationResult(NameEnumerationResult enumerationResult, uint errorCode) { OperationResult <WinFabricNameEnumerationResult> actualResult = new OperationResult <WinFabricNameEnumerationResult>(errorCode); if (enumerationResult != null) { WinFabricNameEnumerationResult testProperty = this.Convert(enumerationResult); actualResult = FabricClientState.CreateOperationResultFromNativeErrorCode <WinFabricNameEnumerationResult>(testProperty); } return(actualResult); }
public OperationResult <TestServicePartitionInfo[]> ConvertToServicePartitionResult(NativeTypes.FABRIC_ERROR_CODE errorCode, ResolvedServicePartition resolvedPartition) { OperationResult <TestServicePartitionInfo[]> result = FabricClientState.CreateOperationResultFromNativeErrorCode <TestServicePartitionInfo[]>(errorCode); if (resolvedPartition != null) { // Store ResolvedServicePartition object when the users need to call apis on this object int id = this.PartitionHolder.StoreObject(resolvedPartition); result = FabricClientState.Convert(resolvedPartition, id); } return(result); }
public static OperationResult <TestServicePartitionInfo[]> Convert(ResolvedServicePartition resolvedServicePartition, int partitionIdentifierNumber) { OperationResult <TestServicePartitionInfo[]> result = null; if (resolvedServicePartition != null) { List <TestServicePartitionInfo> partitionInfos = new List <TestServicePartitionInfo>(); foreach (ResolvedServiceEndpoint resolvedEndpoint in resolvedServicePartition.Endpoints) { partitionInfos.Add(FabricClientState.Convert(resolvedServicePartition, resolvedEndpoint, partitionIdentifierNumber)); } result = FabricClientState.CreateOperationResultFromNativeErrorCode <TestServicePartitionInfo[]>(partitionInfos.ToArray()); } return(result); }
public static OperationResult <WinFabricRepairTask[]> ConvertToWinFabricRepairTaskList(IList <RepairTask> repairTaskList, NativeTypes.FABRIC_ERROR_CODE errorCode) { OperationResult <WinFabricRepairTask[]> actualResult = FabricClientState.CreateOperationResultFromNativeErrorCode <WinFabricRepairTask[]>(errorCode); if (repairTaskList != null) { IList <WinFabricRepairTask> winFabricRepairTasks = new List <WinFabricRepairTask>(repairTaskList.Count); foreach (RepairTask repairTask in repairTaskList) { WinFabricRepairTask winFabricRepairTask = Convert(repairTask); winFabricRepairTasks.Add(winFabricRepairTask); } actualResult = FabricClientState.CreateOperationResultFromNativeErrorCode <WinFabricRepairTask[]>(winFabricRepairTasks.ToArray()); } return(actualResult); }
public OperationResult <WinFabricPropertyBatchResult> ConvertToWinFabricPropertyBatchResult(uint errorCode, PropertyBatchResult batchResult) { var result = new OperationResult <WinFabricPropertyBatchResult>(errorCode); if (batchResult != null) { int id = this.BatchResultHolder.StoreObject(batchResult); FabricErrorCode indexErrorCode = 0; if (batchResult.FailedOperationException != null) { if (batchResult.FailedOperationException is OperationCanceledException || batchResult.FailedOperationException is TimeoutException) { throw batchResult.FailedOperationException; } FabricException exception = batchResult.FailedOperationException as FabricException; if (exception == null) { throw new ArgumentException("batchResult.FailedOperationException {0} should be a FabricException", batchResult.FailedOperationException); } indexErrorCode = exception.ErrorCode; } WinFabricPropertyBatchResult testBatch = new WinFabricPropertyBatchResult(id) { Result = batchResult, FailedOperationErrorCode = indexErrorCode, }; result = FabricClientState.CreateOperationResultFromNativeErrorCode <WinFabricPropertyBatchResult>(testBatch); } return(result); }
internal static OperationResult <TResult[]> GetOperationResultArray(NativeTypes.FABRIC_ERROR_CODE errorCode, IEnumerable <TResult> resultList) { TResult[] resultArray = resultList == null ? null : resultList.ToArray(); return(FabricClientState.CreateOperationResultFromNativeErrorCode <TResult[]>(errorCode, resultArray)); }