本文整理汇总了C#中IDataContainer.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContainer.ToArray方法的具体用法?C# IDataContainer.ToArray怎么用?C# IDataContainer.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataContainer
的用法示例。
在下文中一共展示了IDataContainer.ToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreProcess
public override IDataContainer PreProcess(IDataContainer dataContainer)
{
var push = false;
Parallel.ForEach(StagedData, staged =>
{
if (dataContainer.Any(d => d.Source.Equals(staged.Source)))
push = true;
});
if (push)
Push();
//foreach (var data in dataContainer.OfType<BlobData>())
// Stage(data);
Stage(dataContainer.ToArray());
return null;
}
示例2: PreProcess
public override IDataContainer PreProcess(IDataContainer dataContainer)
{
var depthToIds = new Dictionary<long, long>();
var colorToIds = new Dictionary<long, long>();
/* TODO add to IData an originates from another IData because this will be more independent from Source processor.
* E.g., BlobData originates from Senz3D.Color or Senz3D.Depth or Senz3D.Confidence or just Color, Depth, Confidence */
var depthBlobs = dataContainer.ToArray().OfType<BlobData>().Where(b => Equals(b.Key, "DepthBlob")).ToArray();
var colorBlobs = dataContainer.ToArray().OfType<BlobData>().Where(b => Equals(b.Key, "ColorBlob")).ToArray();
foreach (var depthBlob in depthBlobs)
{
long newId;
if (_depthToIds.ContainsKey(depthBlob.Id))
{
newId = _depthToIds[depthBlob.Id];
}
else
{
newId = NextId();
}
depthToIds[depthBlob.Id] = newId;
depthBlob.Id = newId;
Stage(depthBlob);
}
var pushableColorBlobs = colorBlobs.ToList();
foreach (var depthBlob in depthBlobs)
{
foreach (var colorBlob in colorBlobs)
{
//if (colorBlob.Area.IntersectsWith(depthBlob.Area))
// pushableColorBlobs.Remove(colorBlob);
var r = PolygonCollisionUtils.PolygonCollision(depthBlob.Polygon, colorBlob.Polygon, Vector.Empty);
if (r.WillIntersect)
{
if (IsInTolerance(depthBlob, colorBlob, 0.05))
{
depthBlob.Key = "HybridBlob";
depthBlob.Center = colorBlob.Center;
depthBlob.Angle = colorBlob.Angle;
}
pushableColorBlobs.Remove(colorBlob);
}
}
}
foreach (var colorBlob in pushableColorBlobs)
{
long newId;
if (_colorToIds.ContainsKey(colorBlob.Id))
{
newId = _colorToIds[colorBlob.Id];
}
else
{
newId = NextId();
}
colorToIds[colorBlob.Id] = newId;
colorBlob.Id = newId;
Stage(colorBlob);
}
_depthToIds = depthToIds;
_colorToIds = colorToIds;
Push();
return null;
}
示例3: ProcessInternal
private IDataContainer ProcessInternal(IDataContainer dataContainer)
{
var allData = dataContainer.ToArray();
// Set new data to keep data container's meta information.
dataContainer.Clear();
//Parallel.ForEach(allData, data =>
//{
// IData processedData = null;
// try
// {
// processedData = Process(data);
// }
// catch (Exception e)
// {
// Log("Processing error {0}", e.ToString());
// }
// if (processedData == null)
// return;
// dataContainer.Add(processedData);
//});
foreach (var data in allData)
{
IData processedData = null;
try
{
processedData = Process(data);
}
catch (Exception e)
{
LogFormat("Processing error {0}", e.ToString());
}
if (processedData == null)
continue;
dataContainer.Add(processedData);
};
return dataContainer.Any() ? dataContainer : null;
}