本文整理匯總了C#中PHP.Core.PhpArray.IsEmpty方法的典型用法代碼示例。如果您正苦於以下問題:C# PhpArray.IsEmpty方法的具體用法?C# PhpArray.IsEmpty怎麽用?C# PhpArray.IsEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHP.Core.PhpArray
的用法示例。
在下文中一共展示了PhpArray.IsEmpty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: imagesetstyle
public static bool imagesetstyle(PhpResource im, PhpArray styles)
{
PhpGdImageResource img = PhpGdImageResource.ValidImage(im);
if (img == null)
return false;
if (styles == null || styles.IsEmpty())
{
return false;
}
Bitmap brushImage = new Bitmap(styles.Count, 1);
int i = 0;
foreach (int value in styles.Values)
{
brushImage.SetPixel(i, 0, PHPColorToNETColor(value));
i++;
}
img.styled = new TextureBrush(brushImage);
return true;
}
示例2: Select
public static int Select(ref PhpArray read, ref PhpArray write, ref PhpArray except, int tv_sec, int tv_usec)
{
if ((read == null || read.IsEmpty()) && (write == null || write.IsEmpty()))
return except == null ? 0 : except.Count;
var readResult = new PhpArray();
var writeResult = new PhpArray();
var i = 0;
var timer = Stopwatch.StartNew();
var waitTime = tv_sec*1000 + tv_usec;
while (true)
{
if (read != null)
{
readResult.Clear();
foreach (var item in read)
{
var stream = item.Value as PhpStream;
if (stream == null)
continue;
if (stream.CanReadWithoutLock())
readResult.Add(item.Key, item.Value);
}
}
if (write != null)
{
writeResult.Clear();
foreach (var item in write)
{
var stream = item.Value as PhpStream;
if (stream == null)
continue;
if (stream.CanWriteWithoutLock())
writeResult.Add(item.Key, item.Value);
}
}
if (readResult.Count > 0 || writeResult.Count > 0 || except.Count > 0)
break;
i++;
if (timer.ElapsedMilliseconds > waitTime)
break;
if (i < 10)
Thread.Yield();
else
Thread.Sleep(Math.Min(i, waitTime));
}
read = readResult;
write = writeResult;
return read.Count + write.Count + (except == null ? 0 : except.Count);
}