本文整理汇总了C#中Castle.Core.Resource.CustomUri类的典型用法代码示例。如果您正苦于以下问题:C# CustomUri类的具体用法?C# CustomUri怎么用?C# CustomUri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CustomUri类属于Castle.Core.Resource命名空间,在下文中一共展示了CustomUri类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: File
public static IResource File(string name)
{
var fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XmlFiles/" + name);
var uri = new CustomUri(fullPath);
var resource = new FileResource(uri);
return resource;
}
示例2: AssemblyResource
public AssemblyResource(CustomUri resource, String basePath)
{
CreateStream = delegate
{
return CreateResourceFromUri(resource, basePath);
};
}
示例3: Create
public IResource Create(CustomUri uri, String basePath)
{
if (basePath != null)
return new FileResource(uri, basePath);
else
return new FileResource(uri);
}
示例4: FileResource
public FileResource(CustomUri resource)
{
CreateStream = delegate
{
return CreateStreamFromUri(resource, DefaultBasePath);
};
}
示例5: CreateResourceFromUri
private Stream CreateResourceFromUri(CustomUri resourcex, String path)
{
if (resourcex == null) throw new ArgumentNullException("resourcex");
assemblyName = resourcex.Host;
resourcePath = ConvertToResourceName(assemblyName, resourcex.Path, path);
Assembly assembly = ObtainAssembly(assemblyName);
String[] names = assembly.GetManifestResourceNames();
String nameFound = GetNameFound(names);
if (nameFound == null)
{
resourcePath = resourcex.Path.Replace('/', '.').Substring(1);
nameFound = GetNameFound(names);
}
if (nameFound == null)
{
String message = String.Format(CultureInfo.InvariantCulture, "The assembly resource {0} could not be located", resourcePath);
throw new ResourceException(message);
}
basePath = ConvertToPath(resourcePath);
return assembly.GetManifestResourceStream(nameFound);
}
示例6: Create
public IResource Create(CustomUri uri, String basePath)
{
if (basePath == null)
{
return new AssemblyResource(uri);
}
return new AssemblyResource(uri, basePath);
}
示例7: AssemblyUri
public void AssemblyUri()
{
CustomUri uri1 = new CustomUri("assembly://Assembly.Name/properties.config");
Assert.AreEqual("/properties.config", uri1.Path);
Assert.AreEqual("Assembly.Name", uri1.Host);
Assert.AreEqual("assembly", uri1.Scheme);
Assert.AreEqual(false, uri1.IsFile);
Assert.AreEqual(false, uri1.IsUnc);
}
示例8: FileUris3
public void FileUris3()
{
CustomUri uri1 = new CustomUri("e:\\somedir\\somefile.extension");
Assert.AreEqual("e:/somedir/somefile.extension", uri1.Path);
Assert.AreEqual(null, uri1.Host);
Assert.AreEqual("file", uri1.Scheme);
Assert.AreEqual(true, uri1.IsFile);
Assert.AreEqual(false, uri1.IsUnc);
}
示例9: FileUris2
public void FileUris2()
{
CustomUri uri1 = new CustomUri("file://Config/properties.config");
Assert.AreEqual("Config/properties.config", uri1.Path);
Assert.AreEqual(null, uri1.Host);
Assert.AreEqual("file", uri1.Scheme);
Assert.AreEqual(true, uri1.IsFile);
Assert.AreEqual(false, uri1.IsUnc);
}
示例10: CreateStreamFromUri
private Stream CreateStreamFromUri(CustomUri resource, String rootPath)
{
if (resource == null) throw new ArgumentNullException("resource");
if (rootPath == null) throw new ArgumentNullException("rootPath");
if (!resource.IsFile)
throw new ArgumentException("The specified resource is not a file", "resource");
return CreateStreamFromPath(resource.Path, rootPath);
}
示例11: CreateWithAbsolutePath
public void CreateWithAbsolutePath()
{
CustomUri uri = new CustomUri(@"\\hammet\C$\file.txt");
IResource resource = resFactory.Create(uri, null);
Assert.IsNotNull(resource);
String line = resource.GetStreamReader().ReadLine();
Assert.AreEqual("The long and winding road", line);
}
示例12: CreateWithRelativePathAndContext
public void CreateWithRelativePathAndContext()
{
CustomUri uri = new CustomUri("file://file1.txt");
IResource resource = resFactory.Create( uri, basePath );
Assert.IsNotNull(resource);
String line = resource.GetStreamReader().ReadLine();
Assert.AreEqual("Something", line);
}
示例13: CreateRelative
public void CreateRelative()
{
CustomUri uri = new CustomUri(@"\\hammet\C$\file.txt");
IResource resource = resFactory.Create( uri, null );
resource = resource.CreateRelative("file2.txt");
Assert.IsNotNull(resource);
String line = resource.GetStreamReader().ReadLine();
Assert.AreEqual("Something", line);
}
示例14: UriWithEnvironmentVariable
public void UriWithEnvironmentVariable()
{
string path = Environment.GetEnvironmentVariable("PATH");
Assert.IsNotEmpty(path);
CustomUri uri1 = new CustomUri("file://%PATH%");
Assert.AreEqual(path, uri1.Path);
Assert.AreEqual(null, uri1.Host);
Assert.AreEqual("file", uri1.Scheme);
Assert.AreEqual(true, uri1.IsFile);
Assert.AreEqual(false, uri1.IsUnc);
}
示例15: With_config_section
public void With_config_section()
{
var sectionName = "config://castle/";//trailing slash is required
var uri = new CustomUri(sectionName);
Assert.AreEqual("config", uri.Scheme);
Assert.AreEqual("castle", uri.Host);
var container = new WindsorContainer(sectionName);
container.Resolve<ICalcService>("calcservice");
}