本文整理汇总了C#中System.Management.Path.GetExtension方法的典型用法代码示例。如果您正苦于以下问题:C# Path.GetExtension方法的具体用法?C# Path.GetExtension怎么用?C# Path.GetExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Path
的用法示例。
在下文中一共展示了Path.GetExtension方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFileIntoModule
private void LoadFileIntoModule(PSModuleInfo moduleInfo, Path path)
{
// prevents accidental loops while loading a module
moduleInfo.NestingDepth++;
if (moduleInfo.NestingDepth > 10)
{
var msg = "The module is too deeply nested. A module can be only nested 10 times. Make sure to check" +
" the loading order of your module";
throw new PSInvalidOperationException(msg, "Modules_ModuleTooDeeplyNested",
ErrorCategory.InvalidOperation);
}
moduleInfo.Path = path; // update path for nested modules
var stringComparer = StringComparer.InvariantCultureIgnoreCase;
var ext = path.GetExtension();
if (_scriptExtensions.Contains(ext, stringComparer))
{
moduleInfo.ModuleType = ModuleType.Script;
LoadScriptModule(moduleInfo, path); // actually load the script
}
else if (_binaryExtensions.Contains(ext, stringComparer))
{
moduleInfo.ModuleType = ModuleType.Binary;
LoadBinaryModule(moduleInfo, path);
}
else if (_manifestExtensions.Contains(ext, stringComparer))
{
moduleInfo.ModuleType = ModuleType.Manifest;
LoadManifestModule(moduleInfo, path);
}
else
{
var msg = "The extension '" + ext + "' is currently not supported";
throw new PSInvalidOperationException(msg, "Modules_InvalidFileExtension",
ErrorCategory.InvalidOperation, null, false);
}
moduleInfo.ValidateExportedMembers();
}