示例#1
0
 internal static void SecureAction(FileSystemTask context, Action action)
 {
     try
     {
         action();
     }
     catch (ResourceAccessException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceAccess, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (VirtualResourceNotFoundException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceNotFound, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (ResourceOverwriteException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceOverwrite, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (Exception e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.Undefined, Message = e.Message
         };
         throw CreateFault(fault, e);
     }
 }
示例#2
0
 internal static T SecureFunc <T>(FileSystemTask context, Func <T> func)
 {
     try
     {
         return(func());
     }
     catch (ResourceAccessException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceAccess, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (VirtualResourceNotFoundException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceNotFound, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (ResourceOverwriteException e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.ResourceOverwrite, Message = e.Message, EventId = e.EventId
         };
         throw CreateFault(fault, e);
     }
     catch (Exception e)
     {
         var fault = new ResourceFault {
             Context = context, FaultType = ResourceFaultType.Undefined, Message = e.Message
         };
         throw CreateFault(fault, e);
     }
 }