本文整理汇总了C#中System.Uri.openStream方法的典型用法代码示例。如果您正苦于以下问题:C# System.Uri.openStream方法的具体用法?C# System.Uri.openStream怎么用?C# System.Uri.openStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了System.Uri.openStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/** <summary>
* Load a template from dir or group file. Group file is given
* precedence over dir with same name. <paramref name="name"/> is
* always fully qualified.
* </summary>
*/
protected override CompiledTemplate Load(string name)
{
if (Verbose)
Console.WriteLine("STGroupDir.load(" + name + ")");
string parent = Utility.GetParent(name); // must have parent; it's fully-qualified
string prefix = Utility.GetPrefix(name);
// if (parent.isEmpty()) {
// // no need to check for a group file as name has no parent
// return loadTemplateFile("/", name+TemplateFileExtension); // load t.st file
// }
if (!Path.IsPathRooted(parent))
throw new ArgumentException();
Uri groupFileURL = null;
try
{
// see if parent of template name is a group file
groupFileURL = new Uri(TemplateName.GetTemplatePath(root.LocalPath, parent) + GroupFileExtension);
}
catch (UriFormatException e)
{
ErrorManager.InternalError(null, "bad URL: " + TemplateName.GetTemplatePath(root.LocalPath, parent) + GroupFileExtension, e);
return null;
}
if (!File.Exists(groupFileURL.LocalPath))
{
string unqualifiedName = Path.GetFileName(name);
return LoadTemplateFile(prefix, unqualifiedName + TemplateFileExtension); // load t.st file
}
#if false
InputStream @is = null;
try
{
@is = groupFileURL.openStream();
}
catch (FileNotFoundException fnfe)
{
// must not be in a group file
return loadTemplateFile(parent, name + TemplateFileExtension); // load t.st file
}
catch (IOException ioe)
{
errMgr.internalError(null, "can't load template file " + name, ioe);
}
try
{
// clean up
if (@is != null)
@is.close();
}
catch (IOException ioe)
{
errMgr.internalError(null, "can't close template file stream " + name, ioe);
}
#endif
LoadGroupFile(prefix, groupFileURL.LocalPath);
return RawGetTemplate(name);
}