Beispiel #1
0
 public static async Task <bool> ExistsAsync(string path)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Exists(path);
     }).ConfigureAwait(false));
 }
Beispiel #2
0
 public static async Task <IEnumerable <string> > EnumerateDirectoriesAsync(string path, string searchPattern, SearchOption searchOption)
 {
     return(await EmcTask <string[]> .Run(() =>
     {
         return EnumerateDirectories(path, searchPattern, searchOption);
     }).ConfigureAwait(false));
 }
Beispiel #3
0
 public static async Task <IEnumerable <string> > EnumerateFilesAsync(string path, string searchPattern)
 {
     return(await EmcTask <IEnumerable <string> > .Run(() =>
     {
         return EnumerateFiles(path, searchPattern);
     }).ConfigureAwait(false));
 }
Beispiel #4
0
 public static async Task <IEnumerable <string> > EnumerateDirectoriesAsync(string path)
 {
     return(await EmcTask <IEnumerable <string> > .Run(() =>
     {
         return EnumerateDirectories(path);
     }).ConfigureAwait(false));
 }
Beispiel #5
0
 public static async Task WriteJsonAsync(string filename, object value, bool formatting = false)
 {
     await EmcTask.Run(() =>
     {
         WriteJson(filename, value, formatting);
     }).ConfigureAwait(false);
 }
Beispiel #6
0
 public static async Task CopyAsync(string sourcePath, string destinationPath, bool overwrite)
 {
     await EmcTask.Run(() =>
     {
         Copy(sourcePath, destinationPath, overwrite);
     }).ConfigureAwait(false);
 }
Beispiel #7
0
        public static bool Ping(string ipAddress, int timeout = 2000, int retries = 5)
        {
            var task = EmcTask <bool> .Run(async() =>
            {
                using (var pingSender = new Ping())
                {
                    var options = new PingOptions
                    {
                        DontFragment = true
                    };

                    string data = "12345678901234567890123456789012";

                    byte[] buffer = Encoding.ASCII.GetBytes(data);
                    try
                    {
                        for (int retry = 0; retry < retries; retry++)
                        {
                            if ((await pingSender.SendPingAsync(ipAddress, timeout, buffer, options).ConfigureAwait(false)).Status == IPStatus.Success)
                            {
                                return(true);
                            }
                        }
                    }
                    catch { }
                    return(false);
                }
            });

            task.Wait();
            return(task.Result);
        }
Beispiel #8
0
 public static async Task DeleteAsync(string path, bool recursive)
 {
     await EmcTask.Run(() =>
     {
         Delete(path, recursive);
     }).ConfigureAwait(false);
 }
Beispiel #9
0
 public static async Task <string> ReadAllTextAsync(string fileName)
 {
     return(await EmcTask.Run <string>(() =>
     {
         return ReadAllText(fileName);
     }).ConfigureAwait(false));
 }
Beispiel #10
0
 public static async Task AppendAllTextAsync(string fileName, string text)
 {
     await EmcTask.Run(() =>
     {
         AppendAllText(fileName, text);
     }).ConfigureAwait(false);
 }
Beispiel #11
0
 public static async Task CopyAsync(string sourceFileName, string destinationFileName, bool overwrite = false)
 {
     await EmcTask.Run(() =>
     {
         Copy(sourceFileName, destinationFileName, overwrite);
     }).ConfigureAwait(false);
 }
Beispiel #12
0
 public static async Task EnsureExistDeleteAsync(string fileName)
 {
     await EmcTask.Run(() =>
     {
         EnsureExistDelete(fileName);
     }).ConfigureAwait(false);
 }
Beispiel #13
0
 public static async Task <bool> ExistAsync(string fileName)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Exist(fileName);
     }).ConfigureAwait(false));
 }
Beispiel #14
0
 public static async Task CreateDirectoryAsync(string path)
 {
     await EmcTask.Run(() =>
     {
         CreateDirectory(path);
     }).ConfigureAwait(false);
 }
Beispiel #15
0
 public static async Task <bool> PingAsync(string ipAddress, int timeout = 2000, int retries = 5)
 {
     return(await EmcTask <bool> .Run(() =>
     {
         return Ping(ipAddress, timeout, retries);
     }).ConfigureAwait(false));
 }
Beispiel #16
0
 public static async Task ClearAsync(string path)
 {
     await EmcTask.Run(() =>
     {
         Clear(path);
     }).ConfigureAwait(false);
 }
Beispiel #17
0
 public static async Task <string> EnsureDirectoryExistsAsync(string path)
 {
     return(await EmcTask <string> .Run(() =>
     {
         return EnsureDirectoryExists(path);
     }).ConfigureAwait(false));
 }
Beispiel #18
0
 public static async Task <T> ReadJsonAsync <T>(string filename)
 {
     return(await EmcTask.Run <T>(() =>
     {
         return ReadJson <T>(filename);
     }).ConfigureAwait(false));
 }
Beispiel #19
0
 public static async Task <bool> CheckPortUsageAsync(int port)
 {
     return(await EmcTask <bool> .Run(() => CheckPortUsage(port)).ConfigureAwait(false));
 }