Пример #1
0
        CreateTransformer <
            TSource,
            TSourceStride,
            TTarget,
            TTargetStride,
            TTransformer>(
            this Accelerator accelerator)
            where TSource : unmanaged
            where TSourceStride : struct, IStride1D
            where TTarget : unmanaged
            where TTargetStride : struct, IStride1D
            where TTransformer : struct, ITransformer <TSource, TTarget>
        {
            var rawTransformer = accelerator.CreateRawTransformer <
                TSource,
                TSourceStride,
                TTarget,
                TTargetStride,
                TTransformer>();

            return((stream, source, target, transformer) =>
            {
                if (!source.IsValid)
                {
                    throw new ArgumentNullException(nameof(source));
                }
                if (source.Length < 1)
                {
                    throw new ArgumentOutOfRangeException(nameof(source));
                }
                if (!target.IsValid)
                {
                    throw new ArgumentNullException(nameof(source));
                }
                if (target.Length < source.Length)
                {
                    throw new ArgumentOutOfRangeException(
                        nameof(target),
                        string.Format(
                            ErrorMessages.ViewOutOfRange,
                            nameof(source),
                            nameof(target)));
                }
                rawTransformer(
                    stream,
                    source.Length,
                    new TransformImplementation <
                        TSource,
                        TSourceStride,
                        TTarget,
                        TTargetStride,
                        TTransformer>(
                        source,
                        target,
                        transformer));
            });
        }