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


C# Resource.CustomUri类代码示例

本文整理汇总了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;
		}
开发者ID:n2cms,项目名称:Castle.Windsor,代码行数:7,代码来源:Xml.cs

示例2: AssemblyResource

		public AssemblyResource(CustomUri resource, String basePath)
		{
			CreateStream = delegate
			{
				return CreateResourceFromUri(resource, basePath);
			};
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:AssemblyResource.cs

示例3: Create

		public IResource Create(CustomUri uri, String basePath)
		{
			if (basePath != null)
				return new FileResource(uri, basePath);
			else
				return new FileResource(uri);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:7,代码来源:FileResourceFactory.cs

示例4: FileResource

		public FileResource(CustomUri resource)
		{
			CreateStream = delegate
			{
				return CreateStreamFromUri(resource, DefaultBasePath);
			};
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:7,代码来源:FileResource.cs

示例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);
		}
开发者ID:ralescano,项目名称:castle,代码行数:29,代码来源:AssemblyResource.cs

示例6: Create

		public IResource Create(CustomUri uri, String basePath)
		{
			if (basePath == null)
			{
				return new AssemblyResource(uri);
			}

			return new AssemblyResource(uri, basePath);
		}
开发者ID:leloulight,项目名称:Core,代码行数:9,代码来源:AssemblyResourceFactory.cs

示例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);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:10,代码来源:CustomUriTestCase.cs

示例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);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:10,代码来源:CustomUriTestCase.cs

示例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);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:10,代码来源:CustomUriTestCase.cs

示例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);
		}
开发者ID:gitter-badger,项目名称:MobileMoq,代码行数:10,代码来源:FileResource.cs

示例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);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:10,代码来源:UncResourceFactoryTestCase.cs

示例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);
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:10,代码来源:FileResourceFactoryTestCase.cs

示例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);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:UncResourceFactoryTestCase.cs

示例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);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:13,代码来源:CustomUriTestCase.cs

示例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");
		}
开发者ID:pmcg,项目名称:Castle.Windsor,代码行数:13,代码来源:CreatingContainerTestCase.cs


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