예제 #1
0
 public void SetUp()
 {
     fakeReader = A.Fake<ISourceReader>();
     fakeClouder = A.Fake<ICloudMaker>();
     var temp = string.Empty;
     A.CallTo(() => fakeReader.ReadWords(temp, new IFilter[0])).Returns(new List<string>() {"a", "b"});
 }
예제 #2
0
파일: Program.cs 프로젝트: grecoe/CSharpIOC
        static void Main(string[] args)
        {
            // Create a factory and create a web reader, system reader and scribe object.
            Factory fact = new Factory();

            fact.RegisterType(new WebReader("SomeWebLocation"));
            fact.RegisterType(new SystemReader("SomeSystemLocation"));
            fact.RegisterType(new ConsoleScribe());

            // Now create the wrapped versions of different readers. IOC will inject the appropriate
            // class already there based on interface/generic requirements.
            ISourceReader webReader    = (ISourceReader)fact.CreateInstance(typeof(WrappedWebReader <,>));
            ISourceReader systemReader = (ISourceReader)fact.CreateInstance(typeof(WrappedSystemReader <,>));

            Console.WriteLine("Calling both generated interfaces....");
            webReader.ReadContent();
            systemReader.ReadContent();


            // Now, lets say you did some work and passed the factory around instead of the actual objects.
            // You can access them in two ways.
            //  1. Just call create instance again, you will get the type you created earlier
            //  2. Calling GetInstance, then taking the item from the returned list and using it
            Console.WriteLine("Retrieve both interfaces from the factory again....");
            ISourceReader system = (ISourceReader)fact.CreateInstance(typeof(WrappedSystemReader <,>));

            system.ReadContent();

            List <object> wrappedSysReaders = fact.GetInstance(typeof(WrappedWebReader <,>));

            if (wrappedSysReaders.Count > 0)
            {
                (wrappedSysReaders[0] as ISourceReader).ReadContent();
            }
        }
예제 #3
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            object res  = null;
            var    word = reader.LastKeyword;

            foreach (var id in scope.KnownIdentifiers)
            {
                if (!id.StartsWith("cr:"))
                {
                    continue;
                }
                var cr = scope[id] as IConstantReader;
                if (cr.TryRead(word, out res))
                {
                    break;
                }
                res = null;
            }
            if (res == null)
            {
                throw new SyntaxException(reader, string.Format("Unrecognized word : {0}", word));
            }
            reader.ReadNext();
            yield return(res);
        }
예제 #4
0
 public PgmReceiver(string address, int port, ISourceReader reader)
 {
     _socket = new PgmSocket();
     _ip = address;
     _port = port;
     _reader = reader;
 }
예제 #5
0
        private static void CreateBuyerSummeryLists(ISourceReader reader, string base_out_put_folder)
        {
            var buyers       = reader.GetBuyers();
            var reservations = reader.GetReservations();

            var output_folder = base_out_put_folder + "\\BuyerSummeryLists";

            if (!Directory.Exists(output_folder))
            {
                Directory.CreateDirectory(output_folder);
            }

            foreach (var buyer in buyers)
            {
                var new_file_path = output_folder + "\\" + buyer.Id + "-" + buyer.Name + ".xlsx";

                File.Copy("Templates\\ReceiverSummeryTemplate01.xlsx", new_file_path, true);

                var workbook   = new XLWorkbook(new_file_path);
                var work_sheet = workbook.Worksheets.First();

                BuyerSummeryFileCreator.Create(work_sheet, buyer,
                                               reservations.Where(x => x.Buyer.Id == buyer.Id));

                workbook.Save();
            }
        }
예제 #6
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="parent">The source reader to buffer. The current keyword will be the first of the loop.</param>
 public LoopedSourceReader(ISourceReader parent)
 {
     m_Parent  = parent;
     m_Read    = new List <Snapshot>();
     m_Current = 0;
     AddSnapshot();
 }
예제 #7
0
        private static Type ReadType(ISourceReader reader, IExecutionScope scope)
        {
            reader.ReadNext();
            if (reader.ReadingComplete)
            {
                throw new SyntaxException(reader, "Unexpected end of file");
            }
            if (!scope.Contains(reader.LastKeyword) || !scope.IsOfType <Type>(reader.LastKeyword))
            {
                throw new SyntaxException(reader, string.Format("Unknown type {0}", reader.LastKeyword));
            }
            var t = scope[reader.LastKeyword] as Type;

            if (t == null)
            {
                throw new SyntaxException(reader, "Type resolving failed.");
            }
            if (scope.IsGeneric(reader.LastKeyword))
            {
                reader.ReadNext();
                if (!reader.LastKeyword.Equals(DefaultLanguageKeywords.GenericTypeArgumentKeyword))
                {
                    throw new SyntaxException(reader,
                                              "In a Generic declaration, the Generic argument keyword should follow the Type name.");
                }
                Type innerType = ReadType(reader, scope);
                t = t.GetGenericTypeDefinition().MakeGenericType(innerType);
            }

            return(t);
        }
예제 #8
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader.ReadingComplete)
            {
                throw new SyntaxException(reader, "Unexpected end of file");
            }
            if (!reader.LastKeyword.Equals(DefaultLanguageKeywords.InputKeyword))
            {
                throw new SyntaxException(reader, "Input sections should start with the input keyword");
            }
            reader.ReadNext();
            if (reader.ReadingComplete)
            {
                throw new SyntaxException(reader, "Unexpected end of file");
            }
            IDictionary <string, Type> parametersMap = new Dictionary <string, Type>();
            var exec = DefaultLanguageNodes.InputStatement.Execute(reader, scope, skipExec);
            var pmap = exec.ExecuteNext() as IDictionary <string, Type>;

            foreach (var kvp in pmap)
            {
                parametersMap.Add(kvp);
            }
            yield return(parametersMap);
        }
예제 #9
0
        private SourceList <T> GetList <T>(DbCommand cmd, DbTrans dbTran)
            where T : Entity
        {
            try
            {
                using (ISourceReader reader = dbProvider.ExecuteReader(cmd, dbTran))
                {
                    SourceList <T>            list    = new SourceList <T>();
                    FastCreateInstanceHandler creator = DataUtils.GetFastInstanceCreator(typeof(T));

                    while (reader.Read())
                    {
                        T entity = (T)creator();
                        entity.SetAllValues(reader);
                        entity.Attach();
                        list.Add(entity);
                    }

                    reader.Close();

                    return(list);
                }
            }
            catch
            {
                throw;
            }
        }
 public SourceReaderService(ISourceReader sourceReader,
                            IHouseRepository houseRepository
                            )
 {
     _sourceReader    = sourceReader;
     _houseRepository = houseRepository;
 }
예제 #11
0
        /// <summary>
        ///     <see cref="ISyntaxTreeItem.Execute(ISourceReader, IExecutionScope, bool)" />
        /// </summary>
        public IScriptExecution Execute(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader == null)
            {
                return(null);
            }
            var word = reader.LastKeyword;

            if (DefaultLanguageNodes.Assignation.IsStartOfNode(word, scope))
            {
                return(DefaultLanguageNodes.Assignation.Execute(reader, scope, skipExec));
            }

            if (DefaultLanguageNodes.Call.IsStartOfNode(word, scope))
            {
                return(DefaultLanguageNodes.Call.Execute(reader, scope, skipExec));
            }

            if (DefaultLanguageNodes.Variable.IsStartOfNode(word, scope))
            {
                return(DefaultLanguageNodes.Variable.Execute(reader, scope, skipExec));
            }

            if (DefaultLanguageNodes.Constant.IsStartOfNode(word, scope))
            {
                return(DefaultLanguageNodes.Constant.Execute(reader, scope, skipExec));
            }

            throw new SyntaxException(reader, "Not recognized as operation");
        }
예제 #12
0
 private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
 {
     if (reader.ReadingComplete)
     {
         throw new SyntaxException(reader, "Unexpected end of file");
     }
     if (!IsStartOfNode(reader.LastKeyword, scope))
     {
         throw new SyntaxException(reader, "Lists should start with the list begin symbol.");
     }
     reader.ReadNext();
     if (reader.ReadingComplete)
     {
         throw new SyntaxException(reader, "Unexpected end of file");
     }
     while (!reader.LastKeyword.Equals(DefaultLanguageKeywords.ListEndSymbol))
     {
         if (skipExec)
         {
             reader.ReadNext();
             continue;
         }
         var exec = DefaultLanguageNodes.Statement.Execute(reader, scope, skipExec);
         foreach (var o in exec)
         {
             yield return(o);
         }
         if (reader.ReadingComplete)
         {
             throw new SyntaxException(reader, "Unexpected end of file");
         }
     }
     reader.ReadNext();
 }
예제 #13
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader.ReadingComplete)
            {
                throw new SyntaxException(reader, "Unexpected end of file");
            }
            var word = reader.LastKeyword;

            if (!IsStartOfNode(word, scope))
            {
                throw new SyntaxException(reader, "Variable name does not start with $");
            }
            var identifier = word;

            yield return(identifier);

            object value = null;

            if (!skipExec)
            {
                try
                {
                    value = scope[identifier];
                }
                catch (ScopeException se)
                {
                    throw new ScopeException(reader, se.Description);
                }
            }
            reader.ReadNext();
            yield return(value);
        }
예제 #14
0
파일: Concat.cs 프로젝트: vipoo/SuperMFLib
        public static Action<long, long> Concat(ISourceReader reader, ProcessSample transforms, Func<bool> isAborted)
        {
            return (offsetA, offsetV) =>
            {
                reader.SetCurrentPosition(0);

                var stream = FromSource(reader, isAborted);
                bool firstV = false;

                stream(s =>
                {
                    if (isAborted())
                        return false;

                    if (s.Flags.EndOfStream)
                        return transforms(s);

                    if (!firstV && s.Stream.CurrentMediaType.IsVideo)
                    {
                        firstV = true;
                        return true;
                    }

                    if (s.Stream.CurrentMediaType.IsVideo)
                        s.Resequence(offsetV);

                    if (s.Stream.CurrentMediaType.IsAudio)
                        s.Resequence(offsetA);

                    return transforms(s);
                });
            };
        }
예제 #15
0
 public PgmReceiver(string address, int port, ISourceReader reader)
 {
     _socket = new PgmSocket();
     _ip     = address;
     _port   = port;
     _reader = reader;
 }
예제 #16
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            var varexec    = DefaultLanguageNodes.Variable.Execute(reader, scope, true);
            var identifier = varexec.ExecuteNext() as string;

            reader.ReadNext();
            if (!reader.LastKeyword.Equals(DefaultLanguageKeywords.EachKeyword))
            {
                throw new SyntaxException(reader,
                                          "In loop each declaration, the variable name should be folowed by the each keyword");
            }
            reader.ReadNext();
            var    sourceexec = DefaultLanguageNodes.Operation.Execute(reader, scope, skipExec);
            object lastValue  = null;

            foreach (var o in sourceexec)
            {
                lastValue = o;
                yield return(o);
            }
            if (lastValue is ICollection == false)
            {
                throw new OperationException(reader, "Each loop source is not a collection");
            }
            var           source = (lastValue as ICollection).GetEnumerator();
            LoopCondition cond   = () => Condition(identifier, source, scope);

            yield return(cond);
        }
예제 #17
0
 private Program(ICloudMaker maker, IFilter[] filters, ISourceReader reader, IVisulisation ui, IWriter writer)
 {
     Maker = maker;
     Filters = filters;
     Reader = reader;
     UI = ui;
     Writer = writer;
 }
 public CompressionPipeline(
     ISourceReader reader, IWorker worker, IResultWriter writer, ILogger logger)
 {
     _reader = reader ?? throw new ArgumentNullException(nameof(reader));
     _worker = worker ?? throw new ArgumentNullException(nameof(worker));
     _writer = writer ?? throw new ArgumentNullException(nameof(writer));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #19
0
 public Snapshot(ISourceReader toSnap)
 {
     LastKeyword     = toSnap.LastKeyword;
     Column          = toSnap.Column;
     Line            = toSnap.Line;
     LineOfCode      = toSnap.LineOfCode;
     ReadingComplete = toSnap.ReadingComplete;
 }
예제 #20
0
        /// <summary>
        ///     Constructor for Script.
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="defaultScope"></param>
        public Script(ISourceReader reader, IExecutionScope defaultScope)
        {
            m_Reader = new LoopedSourceReader(reader);
            m_Scope  = defaultScope;
            var exec = DefaultLanguageNodes.ScriptRoot.Execute(m_Reader, m_Scope.MakeSubScope(), false);

            ExpectedArguments = exec.ExecuteNext() as IDictionary <string, Type>;
            m_Reader.Reset();
        }
예제 #21
0
 void TestReader(ISourceReader reader, string[] expected)
 {
     foreach (string str in expected)
     {
         Assert.IsFalse(reader.ReadingComplete);
         Assert.IsNotNull(reader.LastKeyword);
         Assert.AreEqual(str, reader.LastKeyword);
         reader.ReadNext();
     }
 }
예제 #22
0
        public Lexer(ISourceReader reader)
        {
            Expect.NotNull(reader);

            _reader    = reader;
            _line      = 1;
            _col       = 1;
            _startLine = 1;
            _startCol  = 1;
            _read      = String.Empty;
        }
예제 #23
0
 public GZipManager(string inFile, ISourceReader reader, IChunkWriter chunkWriter,
                    IFileSplitterFactory fileSplitterFactory, ICompressorFactory compressorFactory, ITaskFactory taskFactory, IErrorLogs errorLogs)
 {
     _chunkWriter         = chunkWriter;
     _sourceReader        = reader;
     _taskFactory         = taskFactory;
     _inFile              = inFile;
     _fileSplitterFactory = fileSplitterFactory;
     _compressorFactory   = compressorFactory;
     _errorLogs           = errorLogs;
 }
예제 #24
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (!IsStartOfNode(reader.LastKeyword, scope))
            {
                throw new SyntaxException(reader, "While declaration should start with while keyword.");
            }
            reader.ReadNext();
            var           conditionReader = new LoopedSourceReader(reader);
            LoopCondition cond            = () => Condition(conditionReader, scope, skipExec);

            yield return(cond);
        }
예제 #25
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (!IsStartOfNode(reader.LastKeyword, scope))
            {
                throw new SyntaxException(reader, "If section should start with if keyword");
            }
            reader.ReadNext();
            var    ifScope    = scope.MakeSubScope();
            var    condexec   = DefaultLanguageNodes.Operation.Execute(reader, ifScope, skipExec);
            object lastResult = null;

            foreach (var o in condexec)
            {
                lastResult = o;
                if (!skipExec)
                {
                    yield return(o);
                }
            }
            if (lastResult is bool == false)
            {
                throw new OperationException(reader, "if condition is not boolean value");
            }
            var cond     = (bool)lastResult;
            var thenexec = DefaultLanguageNodes.Statement.Execute(reader, ifScope, !cond);

            foreach (var o in thenexec)
            {
                if (cond)
                {
                    yield return(o);
                }
            }
            if (reader.ReadingComplete)
            {
                yield break;
            }
            if (!reader.LastKeyword.Equals(DefaultLanguageKeywords.ElseKeyword))
            {
                yield break;
            }
            reader.ReadNext();
            var elseexec = DefaultLanguageNodes.Statement.Execute(reader, ifScope, cond);

            foreach (var o in elseexec)
            {
                if (!cond)
                {
                    yield return(o);
                }
            }
        }
예제 #26
0
        public SourceReaderSample(ISourceReader reader, SourceStream stream, SourceReaderSampleFlags flags, long timestamp, long duration, Sample sample, int count)
        {
            Reader = reader;
            Stream = stream;
            Flags = flags;
            Timestamp = timestamp;
            Duration = duration;
            Count = count;
            Sample = sample;

            SegmentDuration = duration;
            SegmentTimeStamp = timestamp;
        }
예제 #27
0
 public ParallelCompressionOrchestrationService(
     IClientOptionsService clientOptionsService,
     IParallelCompressionService parallelCompressionService,
     ISourceReader sourceReader,
     IDestinationWriter destinationWriter,
     IOutcomeService outcomeService,
     IThreadService threadService)
 {
     _clientOptionsService       = clientOptionsService;
     _parallelCompressionService = parallelCompressionService;
     _sourceReader      = sourceReader;
     _destinationWriter = destinationWriter;
     _outcomeService    = outcomeService;
     _threadService     = threadService;
 }
예제 #28
0
        public static void CreateAllExcelFiles(ISourceReader reader, string base_out_put_folder)
        {
            if (!Directory.Exists(base_out_put_folder))
            {
                Directory.CreateDirectory(base_out_put_folder);
            }

            Console.WriteLine("Creating list of Buyers...");
            CreateBuyersList(reader, base_out_put_folder);
            Console.WriteLine("Creating Picklists...");
            CreatePicklists(reader, base_out_put_folder);
            Console.WriteLine("Creating lists of buyers reservations...");
            CreateBuyerSummeryLists(reader, base_out_put_folder);
            Console.WriteLine("Creating a Master list...");
            CreateMasterlist(reader, base_out_put_folder);
        }
예제 #29
0
        public static IList <string> MakeFileForLugbulkDatabase(ISourceReader reader)
        {
            var lines = new List <string>();

            // Elements
            // [tblElements]: [ElementId], [BlId], [Description], [BLColor], [TlgColor], [TlgColorId]
            //      ,[Price], [SumQuantity], [Remainder]

            lines.Add("-- Elements --");
            var elements = reader.GetElements();

            foreach (var element in elements)
            {
                lines.Add(string.Format("INSERT INTO tblElements (ElementId, BlId, Description, BLColor) VALUES ({0}, '{1}', '{2}', '{3}')",
                                        element.ElementID, element.BricklinkId, element.BricklinkDescription, element.BricklinkColor));
            }
            lines.Add("");

            // Buyers
            // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
            lines.Add("-- Buyers --");
            var buyers = reader.GetBuyers();

            foreach (var buyer in buyers)
            {
                // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
                lines.Add(string.Format("INSERT INTO tblBuyers (Username) VALUES ('{0}')", buyer.Name));
            }
            lines.Add("");

            // Amounts
            // [tblBuyersAmounts]: [Username], [ElementId], [Amount], [Difference]
            lines.Add("-- Amounts --");
            var amounts = reader.GetReservations();

            foreach (var amount in amounts)
            {
                // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
                lines.Add(string.Format("INSERT INTO tblBuyersAmounts (Username, ElementId, Amount) VALUES ('{0}', {1}, {2})",
                                        amount.Buyer.Name, amount.Element.ElementID, amount.Amount));
            }
            lines.Add("");

            //File.WriteAllLines("lugbulk_data.sql", lines);
            return(lines);
        }
        /// <summary>
        /// Validate the provided <paramref name="reader" />.
        /// </summary>
        /// <param name="reader">The data source to validate</param>
        /// <returns>An enumerable of <see cref="ColumnValidationError" /> </returns>
        public IEnumerable <ColumnValidationError> ValidateCols(ISourceReader reader)
        {
            foreach (string line in reader.ReadLines(_rowSeperator))
            {
                Header = _rowValidator.GetHeader(line);

                if (!_colValidator.IsValid(line))
                {
                    ColumnValidationError error = _colValidator.GetError();
                    _colValidator.ClearErrors();

                    yield return(error);
                }

                break; // only process the first line
            }
        }
예제 #31
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader.ReadingComplete)
            {
                throw new SyntaxException(reader, "Unexpected end of file");
            }
            var word   = reader.LastKeyword;
            var method = scope[word] as MethodInfo;

            if (method == null)
            {
                throw new SyntaxException(reader, string.Format("{0} is not a call", word));
            }
            reader.ReadNext();
            var parameters = method.GetParameters();
            var args       = new object[parameters.Length];
            var i          = 0;

            foreach (var param in parameters)
            {
                if (reader.ReadingComplete)
                {
                    throw new SyntaxException(reader, "Unexpected end of file");
                }
                var    exec      = DefaultLanguageNodes.Operation.Execute(reader, scope, skipExec);
                object lastValue = null;
                foreach (var o in exec)
                {
                    lastValue = o;
                    if (!skipExec)
                    {
                        yield return(o);
                    }
                }
                if (!skipExec && !param.ParameterType.IsAssignableFrom(lastValue.GetType()))
                {
                    throw new OperationException(reader,
                                                 string.Format("Wrong parameter for argument {0} of call {1}", param.Name, method.Name));
                }
                args[i++] = lastValue;
            }
            if (!skipExec)
            {
                yield return(method.Invoke(null, args));
            }
        }
예제 #32
0
        private IEnumerator <object> Exec(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            IDictionary <string, Type> pmap = new Dictionary <string, Type>();

            if (DefaultLanguageNodes.InputSection.IsStartOfNode(reader.LastKeyword, scope))
            {
                var    inputexec = DefaultLanguageNodes.InputSection.Execute(reader, scope, skipExec);
                object lastValue = null;
                foreach (var o in inputexec)
                {
                    lastValue = o;
                }
                if (lastValue is IDictionary <string, Type> == false)
                {
                    throw new OperationException(reader, "Input section does not yield parameters map.");
                }
                pmap = lastValue as IDictionary <string, Type>;
            }
            yield return(pmap);

            foreach (var kvp in pmap)
            {
                if (!scope.Contains(kvp.Key))
                {
                    throw new OperationException(reader,
                                                 string.Format("Execution scope does not contain input parameter {0}", kvp.Key));
                }
                if (!kvp.Value.IsAssignableFrom(scope[kvp.Key].GetType()))
                {
                    throw new OperationException(reader,
                                                 string.Format("Provided input parameter {0} wrong type. Expected {1}got {2}", kvp.Key,
                                                               kvp.Value, scope[kvp.Key].GetType()));
                }
            }
            var scriptScope = scope.MakeSubScope();

            while (!reader.ReadingComplete)
            {
                var exec = DefaultLanguageNodes.Statement.Execute(reader, scriptScope, skipExec);
                foreach (var o in exec)
                {
                    yield return(o);
                }
            }
        }
예제 #33
0
        /// <summary>
        ///     <see cref="ISyntaxTreeItem.Execute(ISourceReader, IExecutionScope,bool)" />
        /// </summary>
        public IScriptExecution Execute(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader == null)
            {
                return(null);
            }
            if (DefaultLanguageNodes.Declaration.IsStartOfNode(reader.LastKeyword, scope))
            {
                return(DefaultLanguageNodes.Declaration.Execute(reader, scope, skipExec));
            }

            if (DefaultLanguageNodes.ListOfDeclarations.IsStartOfNode(reader.LastKeyword, scope))
            {
                return(DefaultLanguageNodes.ListOfDeclarations.Execute(reader, scope, skipExec));
            }

            throw new SyntaxException(reader, "Not recognized as input statement");
        }
예제 #34
0
        /// <summary>
        ///     <see cref="ISyntaxTreeItem.Execute(ISourceReader, IExecutionScope, bool)" />
        /// </summary>
        public IScriptExecution Execute(ISourceReader reader, IExecutionScope scope, bool skipExec)
        {
            if (reader == null)
            {
                return(null);
            }
            if (DefaultLanguageNodes.If.IsStartOfNode(reader.LastKeyword, scope))
            {
                return(DefaultLanguageNodes.If.Execute(reader, scope, skipExec));
            }

            if (DefaultLanguageNodes.Loop.IsStartOfNode(reader.LastKeyword, scope))
            {
                return(DefaultLanguageNodes.Loop.Execute(reader, scope, skipExec));
            }

            throw new SyntaxException(reader, "Not recognized as section");
        }
예제 #35
0
        public IEnumerable <RowValidationError> Validate(ISourceReader reader)
        {
            foreach (string line in reader.ReadLines(_rowSeperator))
            {
                _totalRowsChecked++;

                if (IsHeaderRow())
                {
                }
                else if (!_rowValidator.IsValid(line))
                {
                    RowValidationError error = _rowValidator.GetError();
                    error.Row = _totalRowsChecked;
                    _rowValidator.ClearErrors();

                    yield return(error);
                }
            }
        }
예제 #36
0
파일: Concat.cs 프로젝트: vipoo/SuperMFLib
        public static Action<long, long> Concat(ISourceReader reader, ProcessSample transforms, Action<long, long> next, Func<bool> isAborted)
        {
            return (offsetA, offsetV) =>
            {
                var newOffsetA = offsetA;
                var newOffsetV = offsetV;

                reader.SetCurrentPosition(0);
                var stream = FromSource(reader, isAborted);

                stream(s =>
                {
                    if (isAborted())
                        return false;

                    if (s.Flags.EndOfStream)
                        return false;

                    if (s.Stream.CurrentMediaType.IsVideo)
                        s.Resequence(offsetV);

                    if (s.Stream.CurrentMediaType.IsAudio)
                        s.Resequence(offsetA);

                    var r = transforms(s);

                    if (s.Stream.CurrentMediaType.IsVideo)
                        newOffsetV = s.SampleTime;

                    if (s.Stream.CurrentMediaType.IsAudio)
                        newOffsetA = s.SampleTime;

                    return r;
                });

                next(newOffsetA, newOffsetV);
            };
        }
예제 #37
0
        internal void Resequence(long offset, long duration, ISourceReader reader)
        {
            this.Reader = reader;

            Duration = SegmentDuration = duration;

            Timestamp += offset;
            SampleTime += offset;
            SegmentTimeStamp += offset;
        }
예제 #38
0
 public TokenScanner(ISourceReader reader)
 {
     this.reader = reader;
 }
예제 #39
0
 public StockQuotesStream(ISourceReader<StockQuote> stockQuotesReader)
 {
     _stockQuotesReader = stockQuotesReader;
 }
예제 #40
0
파일: Concat.cs 프로젝트: vipoo/SuperMFLib
 public static void StartConcat(ISourceReader reader, ProcessSample transforms, Action<long, long> next, Func<bool> isAborted)
 {
     Concat(reader, transforms, next, isAborted)(0, 0);
 }
예제 #41
0
파일: Concat.cs 프로젝트: vipoo/SuperMFLib
 public static Action<ProcessSample> FromSource(ISourceReader shortSourceReader, Func<bool> isAborted)
 {
     return next =>
     {
         foreach (var s in shortSourceReader.Samples())
             if (isAborted())
                 break;
             else
                 next(s);
     };
 }
예제 #42
0
 public FilesController()
 {
     _excelReader = new ExcelReader();
 }