コード例 #1
0
ファイル: CastExpression.cs プロジェクト: wasowski/NMF
 public IEnumerator <T> GetEnumerator()
 {
     if (notifyEnumerable != null)
     {
         return(notifyEnumerable.GetEnumerator());
     }
     return(SL.Cast <T>(Source).GetEnumerator());
 }
コード例 #2
0
ファイル: Cast.cs プロジェクト: mnjstwins/FastLinq
        public static IReadOnlyCollection <TResult> Cast <TSource, TResult>(
            this IReadOnlyCollection <TSource> source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            return(new EnumerableWithCount <TResult>(
                       Enumerable.Cast <TResult>(source),
                       source.Count));
        }
コード例 #3
0
    public void BlinqShouldEqualLinqNativeArrayGroupByKey([ArrayValues] int[] sourceArr)
    {
        var source   = new NativeArray <int>(sourceArr, Allocator.Persistent);
        var expected = ExceptionAndValue(() =>
        {
            var groupBy = Linq.GroupBy(source, SelectSelf <int>().Invoke);
            return(Linq.ToArray(groupBy));
        });
        var actual = ExceptionAndValue(() =>
        {
            var groupBy = Linq.Cast <IGrouping <int, int> >(Blinq.GroupBy(source, SelectSelf <int>()));
            return(Linq.ToArray(groupBy));
        });

        AssertAreEqual(expected, actual);
        source.Dispose();
    }
コード例 #4
0
        // api/ocr
        public async Task <IHttpActionResult> Post()
        {
            List <Eitem> returnedEitems = new List <Eitem>();

            var file = HttpContext.Current.Request.Files.Count > 0 ?
                       HttpContext.Current.Request.Files[0] : null;

            if (file.ContentLength > 0)
            {
                //Upload Photo
                OcrService   ocrService       = new OcrService();
                BinaryReader binaryReader     = new BinaryReader(file.InputStream);
                byte[]       imageAsByteArray = binaryReader.ReadBytes(file.ContentLength);
                var          json             = await ocrService.GetOrcServerResponce(imageAsByteArray);

                //Deserialize Json
                var ocrDto = JsonConvert.DeserializeObject <OcrDto>(json);
                if (ocrDto.ErrorMessage != null || String.IsNullOrEmpty(Enumerable.FirstOrDefault(ocrDto.ParsedResults).ParsedText))
                {
                    return(BadRequest(ocrDto.ErrorMessage.ToString()));
                }
                //parse E
                string parsedText = Regex.Replace(ocrDto.ParsedResults[0].ParsedText, @"\s+", "");
                var    eElements  = Enumerable.Cast <Match>(Regex.Matches(parsedText, "(([Е{IsCyrillic}]{1}[0-9]{3,4})|([E{IsCyrillic}-]{2}[0-9]{3,4}))")).Select(m => m.Value.Unidecode()).ToList();

                //Get current E from MemoryCache
                MemoryCasheService memoryCache = new MemoryCasheService();
                var items = memoryCache.GetValue("ALL_EITEMS") as List <Eitem>;
                if (items != null)
                {
                    returnedEitems = items.Where(item => eElements.Contains(item.Ecode)).ToList();
                }
                return(Ok(returnedEitems));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #5
0
 public static IEnumerable <TResult> Cast <TResult>(this IEnumerable source) =>
 LinqEnumerable.Cast <TResult>(source);
コード例 #6
0
 public IEnumerator <T> GetEnumerator()
 {
     return(SL.Cast <T>(Source).GetEnumerator());
 }
コード例 #7
0
 public static IEnumerable <T> Cast <T>(this IEnumerable <T> source) => Enumerable.Cast <T>(source);