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


C# OrderedPartCollection.SelectMany方法代码示例

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


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

示例1: DoActualCompilation

		private static Type DoActualCompilation(string source, string name, string queryText, OrderedPartCollection<AbstractDynamicCompilationExtension> extensions,
		                                        string basePath, string indexFilePath)
		{
			var provider = new CSharpCodeProvider(new Dictionary<string, string> {{"CompilerVersion", "v4.0"}});
		    var currentAssembly = typeof(QueryParsingUtils).Assembly;

		    var assembliesToLoad = new Dictionary<string, string>();

			var assemblies = new HashSet<string>
			{
                AssemblyHelper.GetExtractedAssemblyLocationFor(typeof(SystemTime), currentAssembly),
                AssemblyHelper.GetExtractedAssemblyLocationFor(typeof(Field), currentAssembly),
                typeof (AbstractViewGenerator).Assembly.Location,
				typeof (NameValueCollection).Assembly.Location,
				typeof (Enumerable).Assembly.Location,
				typeof (Binder).Assembly.Location,
			};

			foreach (var assembly in extensions.SelectMany(extension => extension.Value.GetAssembliesToReference()))
			    assemblies.Add(assembly);

		    foreach (var assembly in assemblies)
		    {
		        var dll = Path.GetFileNameWithoutExtension(assembly);
		        assembliesToLoad[dll] = assembly;
		    }

			var compilerParameters = new CompilerParameters
			{
				GenerateExecutable = false,
				GenerateInMemory = false,
				IncludeDebugInformation = Debugger.IsAttached,
				OutputAssembly = indexFilePath
			};
			if (basePath != null)
				compilerParameters.TempFiles = new TempFileCollection(basePath, false);

			foreach (var assembly in assembliesToLoad)
			{
				compilerParameters.ReferencedAssemblies.Add(assembly.Value);
			}

			CompilerResults compileAssemblyFromFile;
			if (indexFilePath != null)
			{
				var sourceFileName = indexFilePath + ".cs";
				File.WriteAllText(sourceFileName, source);
				compileAssemblyFromFile = provider.CompileAssemblyFromFile(compilerParameters, sourceFileName);
			}	
			else
			{
				compileAssemblyFromFile = provider.CompileAssemblyFromSource(compilerParameters, source);
			}
			var results = compileAssemblyFromFile;

			if (results.Errors.HasErrors)
			{
			    var sb = new StringBuilder()
                    .AppendLine("Compilation Errors:")
                    .AppendLine();
                
                foreach (CompilerError error in results.Errors)
                {
                    sb.AppendFormat("Line {0}, Position {1}: Error {2} - {3}\n", error.Line, error.Column, error.ErrorNumber, error.ErrorText);
                }

			    sb.AppendLine();

			    sb.AppendLine("Source code:")
			      .AppendLine(queryText)
			      .AppendLine();

				throw new InvalidOperationException(sb.ToString());
			}

			var asm = Assembly.Load(File.ReadAllBytes(indexFilePath)); // avoid locking the file

			CodeVerifier.AssertNoSecurityCriticalCalls(asm);

			Type result = asm.GetType(name);
			if (result == null)
				throw new InvalidOperationException(
					"Could not get compiled index type. This probably means that there is something wrong with the assembly load context.");
			return result;
		}
开发者ID:randacc,项目名称:ravendb,代码行数:85,代码来源:QueryParsingUtils.cs


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