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


C# IDataContainer.ToArray方法代码示例

本文整理汇总了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;
        }
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:19,代码来源:SyncFusion.cs

示例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;
        }
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:77,代码来源:HybridSensing.cs

示例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;
        }
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:45,代码来源:BaseProcessor.cs


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