本文整理汇总了C#中SR.CanBeSeenFrom方法的典型用法代码示例。如果您正苦于以下问题:C# SR.CanBeSeenFrom方法的具体用法?C# SR.CanBeSeenFrom怎么用?C# SR.CanBeSeenFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR
的用法示例。
在下文中一共展示了SR.CanBeSeenFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBeskDiskStorage
/// <summary>
/// returns null if nothing suitable
/// </summary>
private static SR GetBeskDiskStorage(IXenConnection connection, long diskSize, Host affinity, SR suggestion)
{
// try suggestion
if (suggestion != null && suggestion.FreeSpace > diskSize && suggestion.CanBeSeenFrom(affinity))
return suggestion;
// try default sr
SR def_sr = connection.Resolve(Helpers.GetPoolOfOne(connection).default_SR);
if (def_sr != null && def_sr.FreeSpace > diskSize && def_sr.CanBeSeenFrom(affinity))
return def_sr;
// pick an sr
foreach (SR sr in connection.Cache.SRs)
{
if (!sr.CanCreateVmOn())
continue;
if (sr.FreeSpace > diskSize && sr.CanBeSeenFrom(affinity))
return sr;
}
// there is nothing
return null;
}
示例2: GetBeskDiskStorage
/// <summary>
/// Tries to find the best SR for the given VDI considering the suggestedSR which has priority over other SRs in this check.
/// SuggestedSR, default SR, other SRs are checked.
/// Returns first suitable SR or NULL.
/// </summary>
private static SR GetBeskDiskStorage(IXenConnection connection, VDI disk, Host affinity, SR suggestedSR)
{
// try suggestion
if (suggestedSR != null && suggestedSR.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(suggestedSR, disk))
return suggestedSR;
// try default sr
SR defaultSR = connection.Resolve(Helpers.GetPoolOfOne(connection).default_SR);
if (defaultSR != null && defaultSR.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(defaultSR, disk))
return defaultSR;
// pick an sr
foreach (SR sr in connection.Cache.SRs)
{
if (!sr.CanCreateVmOn())
continue;
if (sr.CanBeSeenFrom(affinity) && IsSufficientFreeSpaceAvailableOnSrForVdi(sr, disk))
return sr;
}
// there has been no suitable SR found
return null;
}