Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="detachedCriteria">criteria to look for</param>
        /// <param name="options">future query option</param>
        public FutureQueryOf(DetachedCriteria detachedCriteria, FutureQueryOptions options)
        {
            var criteriaBatch = Batcher.Add(detachedCriteria);

            switch (options)
            {
            case FutureQueryOptions.None:
                criteriaBatch.OnRead(delegate(ICollection <TEntity> entities) {
                    _results = entities;
                    IsLoaded = true;
                });
                break;

            case FutureQueryOptions.WithTotalCount:
                criteriaBatch.OnRead(delegate(ICollection <TEntity> entities, int count) {
                    _results    = entities;
                    _totalCount = count;
                    IsLoaded    = true;
                });
                break;

            default:
                throw new NotSupportedException(options.ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FutureValue{TEntity}"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="options">The options.</param>
        public FutureValue(object id, FutureValueOptions options)
        {
            this.id      = id;
            this.options = options;
            CriteriaBatch criteriaBatch = Batcher.Add(DetachedCriteria.For <TEntity>().Add(Restrictions.IdEq(id)));

            criteriaBatch.OnRead <TEntity>(delegate(TEntity entity)
            {
                value     = entity;
                WasLoaded = true;
            });
        }
Ejemplo n.º 3
0
 public Batch<Tuple<FileInfo, string>> Abfrage_beimischen(Batch<FileInfo> dateien)
 {
     var filteraufträge = new Batcher<Tuple<FileInfo, string>>(dateien.Elements.Length);
     dateien.ForEach(t =>
                         {
                             var suchvorgang = _suchvorgänge[dateien.CorrelationId];
                             var filterauftrag = new Tuple<FileInfo, string>(t, suchvorgang.Abfrage);
                             filteraufträge.Add(filterauftrag);
                         });
     if (dateien.GetType() == typeof(EndOfStreamBatch<FileInfo>))
         return filteraufträge.GrabAsEndOfStream(dateien.CorrelationId);
     return filteraufträge.Grab(dateien.CorrelationId);
 }
Ejemplo n.º 4
0
        internal void Dateien_enummerieren(string id, string pfad, Batcher<string> batcher)
        {
            var dir = new DirectoryInfo(pfad);

            try
            {
                foreach (var file in dir.GetFiles(_dateinamenschablone))
                    if (batcher.Add(file.FullName) == BatchStatus.Full)
                        Dateien(batcher.Grab(id));

                foreach (var subdir in dir.GetDirectories())
                    Dateien_enummerieren(id, subdir.FullName, batcher);
            }
            catch(UnauthorizedAccessException ex) {}
        }
Ejemplo n.º 5
0
        public void Laden(Batch<string> dateipfade)
        {
            var dateien = new Batcher<FileInfo>(dateipfade.Elements.Length/5);

            dateipfade.ForEach(t => {
                                        var fi = new FileInfo(t);

                                        if (dateien.Add(fi) == BatchStatus.Full)
                                            Geladen(dateien.Grab(dateipfade.CorrelationId));
                                    });

            if (dateipfade.GetType() == typeof(EndOfStreamBatch<string>))
                Geladen(dateien.GrabAsEndOfStream(dateipfade.CorrelationId));
            else
                Geladen(dateien.Grab(dateipfade.CorrelationId));
        }
Ejemplo n.º 6
0
        Batcher Batch()
        {
            var commands = new Batcher(Tables, Serializers);

            if (null == Unit)
            {
                return(commands);
            }

            foreach (var pair in Unit)
            {
                commands.Add(pair.Item1, pair.Item2);
            }

            Unit.Flush();

            return(commands);
        }