本文整理汇总了C#中IEnumerable.NotNull方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.NotNull方法的具体用法?C# IEnumerable.NotNull怎么用?C# IEnumerable.NotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.NotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InGac
public static ILookup<IPackageInfo, AssemblyName> InGac(IEnumerable<IPackageInfo> packages, ExecutionEnvironment environment = null)
{
var domain = TempDomain();
try
{
var loader = ((Loader)domain.CreateInstanceFromAndUnwrap(
typeof(Loader).Assembly.Location,
typeof(Loader).FullName));
return (from package in packages.NotNull().Select(x => x.Load()).NotNull()
let export = package.GetExport("bin", environment)
where export != null
from assembly in export.Items.OfType<IAssemblyReferenceExportItem>()
let inGac = loader.InGAC(assembly.AssemblyName)
where inGac
select new { package, assembly.AssemblyName })
.ToLookup(x => (IPackageInfo)x.package, x => x.AssemblyName);
}
catch
{
return (new AssemblyName[0]).ToLookup(x => (IPackageInfo)null);
}
finally
{
AppDomain.Unload(domain);
}
}
示例2: FormValidationResult
/// <summary>
/// 创建 FormValidationResult 对象
/// </summary>
/// <param name="form">所验证的表单</param>
/// <param name="errors">验证错误信息</param>
public FormValidationResult( HtmlForm form, IEnumerable<FormValidationError> errors )
{
if ( form == null )
throw new ArgumentNullException( "form" );
Form = form;
Errors = new FormValidationErrorCollection();
if ( errors != null )
{
errors = errors.NotNull();
if ( errors.Any() )
{
HasError = true;
foreach ( var e in errors )
Errors.Add( e );
}
}
else
HasError = false;
}
示例3: Files
static ILookup<string, string> Files(IEnumerable<ITaskItem> specs)
{
return specs == null
? Lookup<string, string>.Empty
: specs.NotNull()
.Select(x => new { target = GetTarget(x), path = Path.GetFullPath(x.ItemSpec) })
.ToLookup(_ => _.target, _ => _.path);
}
示例4: GetAssemblyReferencesFromPackages
static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferencesFromPackages(IEnumerable<IPackageInfo> packages, ExecutionEnvironment exec)
{
return from package in packages.NotNull()
.GroupBy(x => x.Name)
.Select(x => x.OrderByDescending(y => y.Version).Select(y=>y.Load()).NotNull().First())
from assembly in package.Load().GetExport("bin", exec).Items.Cast<IAssemblyReferenceExportItem>()
where MatchesReferenceSection(package, assembly)
select assembly;
}
示例5: GetAssemblyReferencesFromPackages
static IEnumerable<IAssemblyReferenceExportItem> GetAssemblyReferencesFromPackages(IEnumerable<IPackageInfo> packages, ExecutionEnvironment exec)
{
return packages
.NotNull()
.GroupBy(x=>x.Name)
.Select(x=>x.OrderByDescending(y=>y.Version).First())
.NotNull()
.SelectMany(x => x.Load().GetExport("bin", exec).Items)
.Cast<IAssemblyReferenceExportItem>();
}
示例6: InGac
public static ILookup<IPackageInfo, AssemblyName> InGac(this IPackageExporter exporter, IEnumerable<IPackageInfo> packages)
{
var domain = TempDomain();
try
{
var loader = ((Loader)domain.CreateInstanceFromAndUnwrap(
typeof(Loader).Assembly.Location,
typeof(Loader).FullName));
return (from package in packages.NotNull().Select(x => x.Load()).NotNull()
from assembly in exporter.Assemblies(package, ExecutionEnvironment.Any)
where loader.InGAC(assembly.AssemblyName)
select new { package, assembly.AssemblyName }
).ToLookup(x => (IPackageInfo)x.package, x => x.AssemblyName);
}
catch
{
return (new AssemblyName[0]).ToLookup(x => (IPackageInfo)null);
}
finally
{
AppDomain.Unload(domain);
}
}
示例7: SoundEmitterSourceAction
public SoundEmitterSourceAction(IEnumerable<SoundEmitter.Source> obj)
{
if (obj == null) throw new ArgumentNullException("obj");
this.targetObj = obj.NotNull().ToArray();
}
示例8: MonitorRequest
/// <summary>
/// Constructor
/// </summary>
/// <param name="components">Collection of components to monitor in your system</param>
public MonitorRequest(IEnumerable<ComponentDto> components)
{
components.NotNull(nameof(components));
Components = components.ToList();
}
示例9: RigidBodyShapeAction
public RigidBodyShapeAction(IEnumerable<ShapeInfo> obj)
{
if (obj == null) throw new ArgumentNullException("obj");
this.targetObj = obj.NotNull().ToArray();
}
示例10: CopyPackagesToRepositories
IEnumerable<PackageOperationResult> CopyPackagesToRepositories(IEnumerable<IPackageRepository> sourceRepositories,
DependencyResolutionResult resolvedPackages,
IEnumerable<IPackageRepository> destinationRepositories)
{
var publishingRepos = destinationRepositories.NotNull().OfType<ISupportPublishing>().ToList();
foreach (var foundPackage in resolvedPackages.SuccessfulPackages)
{
foreach (var destinationRepository in publishingRepos)
{
var existingUpToDateVersion = GetExistingPackage(destinationRepository, foundPackage, x => x >= foundPackage.Identifier.Version);
if (existingUpToDateVersion == null)
{
var sourcePackage = GetBestSourcePackage(sourceRepositories, foundPackage.Packages);
_deployer.DeployDependency(sourcePackage, destinationRepository);
var existingVersion = GetExistingPackage(destinationRepository, foundPackage, x => x < foundPackage.Identifier.Version);
yield return existingVersion == null
? new PackageAddedResult(sourcePackage, destinationRepository)
: new PackageUpdatedResult(existingVersion, sourcePackage, destinationRepository);
}
else
{
yield return new PackageUpToDateResult(existingUpToDateVersion, destinationRepository);
}
}
}
foreach (var repo in publishingRepos)
repo.PublishCompleted();
}
示例11: BadRequest
public BadRequest(IEnumerable<SerializableValidationError> validationErrors)
{
validationErrors.NotNull(nameof(validationErrors));
ValidationErrors = validationErrors;
}
示例12: Combine
/// <summary>
/// 合并多个缓存标记
/// </summary>
/// <param name="tokens">要合并的缓存标记列表</param>
/// <returns>合并后的缓存标记</returns>
public static CacheToken Combine( IEnumerable<CacheToken> tokens )
{
if ( tokens.IsNullOrEmpty() )
return null;
tokens = tokens.NotNull();
CacheToken result;
if ( tokens.IsSingle( out result ) )
return result;
return new CacheToken( tokens.SelectMany( t => t._tokens ).ToArray() );
}
示例13: CleanupAfterPlugins
private static void CleanupAfterPlugins(IEnumerable<CorePlugin> oldPlugins)
{
oldPlugins = oldPlugins.NotNull().Distinct();
if (!oldPlugins.Any()) oldPlugins = null;
// Clean globally cached type values
availTypeDict.Clear();
ReflectionHelper.ClearTypeCache();
Component.ClearTypeCache();
Formatter.ClearTypeCache();
CloneProvider.ClearTypeCache();
// Clean input sources that a disposed Assembly forgot to unregister.
if (oldPlugins != null)
{
foreach (CorePlugin plugin in oldPlugins)
CleanInputSources(plugin.PluginAssembly);
}
// Clean event bindings that are still linked to the disposed Assembly.
if (oldPlugins != null)
{
foreach (CorePlugin plugin in oldPlugins)
CleanEventBindings(plugin.PluginAssembly);
}
}
示例14: GeTypes
/// <summary>
/// 获取可用的服务类型。
/// </summary>
/// <param name="types">类型集合。</param>
/// <returns>可用的服务类型。</returns>
public Type[] GeTypes(IEnumerable<Type> types)
{
types = types.NotNull("types").ToArray();
return types.Where(i => i.IsClass && !i.IsAbstract).ToArray();
}
示例15: Files
static List<string> Files(IEnumerable<ITaskItem> specs)
{
return specs == null
? new List<string>(0)
: specs.NotNull()
.Select(x=>System.IO.Path.GetFullPath(x.ItemSpec))
.ToList();
}