当前位置: 首页>>代码示例>>C#>>正文


C# IOException.GetType方法代码示例

本文整理汇总了C#中System.IO.IOException.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IOException.GetType方法的具体用法?C# IOException.GetType怎么用?C# IOException.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IOException的用法示例。


在下文中一共展示了IOException.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostEditorStorageException

 private PostEditorStorageException(IOException ex)
     : base(StringId.PostEditorStorageExceptionTitle2,
     StringId.PostEditorStorageExceptionMessage2,
     ex.GetType().Name,
     ex.Message)
 {
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:7,代码来源:PostEditorException.cs

示例2: GetHResult

        static int GetHResult(IOException exception, int defaultValue)
        {
            if (exception == null)
                throw new ArgumentNullException("exception");

            var field = exception.GetType().GetField("_HResult", BindingFlags.NonPublic | BindingFlags.Instance);
            if (field != null)
                return Convert.ToInt32(field.GetValue(exception));

            return defaultValue;
        }
开发者ID:pjlammertyn,项目名称:Cozo-Broker,代码行数:11,代码来源:Utils.cs

示例3: IsSharingViolation

        static bool IsSharingViolation(
            IOException ioEx)
        {
            var field = ioEx
                .GetType().GetField("_HResult", BindingFlags.NonPublic | BindingFlags.Instance);
            if (field == null) return false;

            var hres = (int) field.GetValue(ioEx);
            Debug.WriteLine("Error '{0}' {1}", ioEx.Message, hres);

            return hres == HResultSharingViolation;
        }
开发者ID:MrAntix,项目名称:Folder,代码行数:12,代码来源:IOFileSystemWorker.cs

示例4: GetHResult

        /// <summary>
        /// Gets the HRESULT of the specified exception.
        /// </summary>
        /// <param name="exception">The exception to test. May not be null.</param>
        /// <param name="defaultValue">The default value in case of an error.</param>
        /// <returns>The HRESULT value.</returns>
        private static int GetHResult(IOException exception, int defaultValue)
        {
            if (exception == null)
                throw new ArgumentNullException("exception");

            try
            {
                return (int)exception.GetType().GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(exception, null);
            }
            catch
            {
                return defaultValue;
            }
        }
开发者ID:JmAbuDabi,项目名称:auto-extractor-net,代码行数:20,代码来源:IOUtils.cs

示例5: GetHResult

 static int GetHResult(IOException ioe, int defaultValue)
 {
     if (ioe == null) throw new ArgumentNullException("ioe");
     try
     {
         return (int)ioe.GetType()
                          .GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Instance)
                          .GetValue(ioe, null);
     }
     catch
     {
         return defaultValue;
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:14,代码来源:PersistenceManager.cs

示例6: GetHResult

        public static int GetHResult(IOException exception, int defaultValue)
        {
            if (exception == null)
                throw new ArgumentNullException("exception");

            try
            {
                const string name = "HResult";
                PropertyInfo pi = exception.GetType().GetProperty(name, BindingFlags.NonPublic | BindingFlags.Instance); // CLR2
                if (pi == null)
                {
                    pi = exception.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance); // CL4
                }
                if (pi != null)
                    return (int)pi.GetValue(exception, null);
            }
            catch
            {
            }
            return defaultValue;
        }
开发者ID:newbyca,项目名称:Mixpanel,代码行数:21,代码来源:Utilities.cs

示例7: BlogClientIOException

 public BlogClientIOException(FileInfo file, IOException ioException)
     : base(StringId.BCEFileIOTitle,
             StringId.BCEFileIOMessage,
             file.Name,
             ioException.GetType().Name,
             ioException.Message)
 {
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:8,代码来源:BlogClientException.cs

示例8: NewProperty

 public void NewProperty(string path, string propertyName, string type, object value)
 {
     if (path == null)
     {
         throw PSTraceSource.NewArgumentNullException("path");
     }
     if (this.CheckOperationNotAllowedOnHiveContainer(path))
     {
         IRegistryWrapper regkeyForPathWriteIfError = this.GetRegkeyForPathWriteIfError(path, true);
         if (regkeyForPathWriteIfError != null)
         {
             string newPropertyAction = RegistryProviderStrings.NewPropertyAction;
             string newPropertyResourceTemplate = RegistryProviderStrings.NewPropertyResourceTemplate;
             string target = string.Format(base.Host.CurrentCulture, newPropertyResourceTemplate, new object[] { path, propertyName });
             if (base.ShouldProcess(target, newPropertyAction))
             {
                 RegistryValueKind kind;
                 if (!this.ParseKind(type, out kind))
                 {
                     regkeyForPathWriteIfError.Close();
                     return;
                 }
                 try
                 {
                     if ((base.Force != 0) || (regkeyForPathWriteIfError.GetValue(propertyName) == null))
                     {
                         this.SetRegistryValue(regkeyForPathWriteIfError, propertyName, value, kind, path);
                     }
                     else
                     {
                         IOException exception = new IOException(RegistryProviderStrings.PropertyAlreadyExists);
                         base.WriteError(new ErrorRecord(exception, exception.GetType().FullName, ErrorCategory.ResourceExists, path));
                         regkeyForPathWriteIfError.Close();
                         return;
                     }
                 }
                 catch (ArgumentException exception2)
                 {
                     base.WriteError(new ErrorRecord(exception2, exception2.GetType().FullName, ErrorCategory.WriteError, path));
                 }
                 catch (InvalidCastException exception3)
                 {
                     base.WriteError(new ErrorRecord(exception3, exception3.GetType().FullName, ErrorCategory.WriteError, path));
                 }
                 catch (IOException exception4)
                 {
                     base.WriteError(new ErrorRecord(exception4, exception4.GetType().FullName, ErrorCategory.WriteError, path));
                 }
                 catch (SecurityException exception5)
                 {
                     base.WriteError(new ErrorRecord(exception5, exception5.GetType().FullName, ErrorCategory.PermissionDenied, path));
                 }
                 catch (UnauthorizedAccessException exception6)
                 {
                     base.WriteError(new ErrorRecord(exception6, exception6.GetType().FullName, ErrorCategory.PermissionDenied, path));
                 }
             }
             regkeyForPathWriteIfError.Close();
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:61,代码来源:RegistryProvider.cs

示例9: NewItem

 protected override void NewItem(string path, string type, object newItem)
 {
     if (string.IsNullOrEmpty(path))
     {
         throw PSTraceSource.NewArgumentException("path");
     }
     string newItemAction = RegistryProviderStrings.NewItemAction;
     string newItemResourceTemplate = RegistryProviderStrings.NewItemResourceTemplate;
     string target = string.Format(base.Host.CurrentCulture, newItemResourceTemplate, new object[] { path });
     if (base.ShouldProcess(target, newItemAction))
     {
         IRegistryWrapper regkeyForPath = this.GetRegkeyForPath(path, false);
         if (regkeyForPath != null)
         {
             if (base.Force == 0)
             {
                 Exception exception = new IOException(RegistryProviderStrings.KeyAlreadyExists);
                 base.WriteError(new ErrorRecord(exception, exception.GetType().FullName, ErrorCategory.ResourceExists, regkeyForPath));
                 regkeyForPath.Close();
                 return;
             }
             regkeyForPath.Close();
             this.RemoveItem(path, false);
         }
         if ((base.Force == 0) || this.CreateIntermediateKeys(path))
         {
             string parentPath = this.GetParentPath(path, null);
             string childName = this.GetChildName(path);
             IRegistryWrapper regkeyForPathWriteIfError = this.GetRegkeyForPathWriteIfError(parentPath, true);
             if (regkeyForPathWriteIfError != null)
             {
                 try
                 {
                     IRegistryWrapper key = regkeyForPathWriteIfError.CreateSubKey(childName);
                     regkeyForPathWriteIfError.Close();
                     try
                     {
                         if (newItem != null)
                         {
                             RegistryValueKind kind;
                             if (!this.ParseKind(type, out kind))
                             {
                                 return;
                             }
                             this.SetRegistryValue(key, string.Empty, newItem, kind, path, false);
                         }
                     }
                     catch (Exception exception2)
                     {
                         if (((!(exception2 is ArgumentException) && !(exception2 is InvalidCastException)) && (!(exception2 is IOException) && !(exception2 is SecurityException))) && (!(exception2 is UnauthorizedAccessException) && !(exception2 is NotSupportedException)))
                         {
                             throw;
                         }
                         ErrorRecord errorRecord = new ErrorRecord(exception2, exception2.GetType().FullName, ErrorCategory.WriteError, key) {
                             ErrorDetails = new ErrorDetails(StringUtil.Format(RegistryProviderStrings.KeyCreatedValueFailed, childName))
                         };
                         base.WriteError(errorRecord);
                     }
                     this.WriteRegistryItemObject(key, path);
                 }
                 catch (IOException exception3)
                 {
                     base.WriteError(new ErrorRecord(exception3, exception3.GetType().FullName, ErrorCategory.WriteError, path));
                 }
                 catch (SecurityException exception4)
                 {
                     base.WriteError(new ErrorRecord(exception4, exception4.GetType().FullName, ErrorCategory.PermissionDenied, path));
                 }
                 catch (UnauthorizedAccessException exception5)
                 {
                     base.WriteError(new ErrorRecord(exception5, exception5.GetType().FullName, ErrorCategory.PermissionDenied, path));
                 }
                 catch (ArgumentException exception6)
                 {
                     base.WriteError(new ErrorRecord(exception6, exception6.GetType().FullName, ErrorCategory.InvalidArgument, path));
                 }
                 catch (NotSupportedException exception7)
                 {
                     base.WriteError(new ErrorRecord(exception7, exception7.GetType().FullName, ErrorCategory.InvalidOperation, path));
                 }
             }
         }
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:84,代码来源:RegistryProvider.cs


注:本文中的System.IO.IOException.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。