Exemplo n.º 1
0
        public object Execute(IContentQuery<MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;

            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            translator.Translate(query.Expression);

            //translator.Visite(query.Expression);
            IEnumerable<MediaContent> contents;
            switch (translator.CallType)
            {
                case CallType.Count:
                    return RemoteServiceFactory.CreateService<IMediaContentService>().Count(mediaQuery.MediaFolder.Repository.Name,
                        mediaQuery.MediaFolder.FullName, translator.Prefix);
                case CallType.First:
                    contents = Execute(mediaQuery.MediaFolder, translator);
                    return contents.First();
                case CallType.Last:
                    contents = Execute(mediaQuery.MediaFolder, translator);
                    return contents.Last();
                case CallType.LastOrDefault:
                    contents = Execute(mediaQuery.MediaFolder, translator);
                    return contents.LastOrDefault();
                case CallType.FirstOrDefault:
                    contents = Execute(mediaQuery.MediaFolder, translator);
                    return contents.FirstOrDefault();
                case CallType.Unspecified:
                default:
                    contents = Execute(mediaQuery.MediaFolder, translator);
                    return contents;
            }
        }
Exemplo n.º 2
0
        public object Execute(IContentQuery <MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;


            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            translator.Translate(query.Expression);

            //translator.Visite(query.Expression);
            IEnumerable <MediaContent> contents;

            switch (translator.CallType)
            {
            case CallType.Count:
                return(RemoteServiceFactory.CreateService <IMediaContentService>().Count(mediaQuery.MediaFolder.Repository.Name,
                                                                                         mediaQuery.MediaFolder.FullName, translator.Prefix));

            case CallType.First:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.First());

            case CallType.Last:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.Last());

            case CallType.LastOrDefault:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.LastOrDefault());

            case CallType.FirstOrDefault:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.FirstOrDefault());

            case CallType.Unspecified:
            default:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents);
            }
        }
Exemplo n.º 3
0
        private static IEnumerable <MediaContent> Execute(MediaFolder mediaFolder, QueryExpressionTranslator translator)
        {
            var mediaContentService = RemoteServiceFactory.CreateService <IMediaContentService>();

            if (!string.IsNullOrEmpty(translator.FileName))
            {
                return(new[] { mediaContentService.Get(mediaFolder.Repository.Name, mediaFolder.FullName, translator.FileName) });
            }
            else
            {
                var maxResult = 50;
                if (translator.Take.HasValue && translator.Take.Value != 0)
                {
                    maxResult = translator.Take.Value;
                }
                var skip = 0;
                if (translator.Skip.HasValue)
                {
                    skip = translator.Skip.Value;
                }
                return(mediaContentService.All(mediaFolder.Repository.Name, mediaFolder.FullName, skip, maxResult, translator.Prefix));
            }
        }
Exemplo n.º 4
0
 private static IEnumerable<MediaContent> Execute(MediaFolder mediaFolder, QueryExpressionTranslator translator)
 {
     var mediaContentService = RemoteServiceFactory.CreateService<IMediaContentService>();
     if (!string.IsNullOrEmpty(translator.FileName))
     {
         return new[] { mediaContentService.Get(mediaFolder.Repository.Name, mediaFolder.FullName, translator.FileName) };
     }
     else
     {
         var maxResult = 50;
         if (translator.Take.HasValue && translator.Take.Value != 0)
         {
             maxResult = translator.Take.Value;
         }
         var skip = 0;
         if (translator.Skip.HasValue)
         {
             skip = translator.Skip.Value;
         }
         return mediaContentService.All(mediaFolder.Repository.Name, mediaFolder.FullName, skip, maxResult, translator.Prefix);
     }
 }