Example #1
0
        /// <summary>
        /// Parses a given folder into a Project
        /// </summary>
        /// <param name="folderPath">The path to a csv file</param>
        /// <param name="sourceAction">The action to be performed on the source files</param>
        /// <param name="fillMissing">Whether to fill the missing values</param>
        /// <returns>
        /// A <see cref="Project"/> containing a <see cref="Package"/> per found string table csv file.
        /// </returns>
        public static Project ParseProject(string folderPath, SourceAction sourceAction = SourceAction.Nothing, bool fillMissing = false)
        {
            if (!Directory.Exists(folderPath))
            {
                throw new ApplicationException(string.Format("The specified folder does not exist: {0}", folderPath));
            }

            var project = new Project()
            {
                Name = new DirectoryInfo(folderPath).Name
            };

            // get all stringtables
            foreach (var stringtablefile in Directory.EnumerateFiles(folderPath, "*.csv", SearchOption.AllDirectories))
            {
                try
                {
                    var package = Parse(stringtablefile, fillMissing);
                    project.Packages.Add(package);

                    // perform action on the source files
                    switch (sourceAction)
                    {
                    case SourceAction.Delete:
                        File.Delete(stringtablefile);
                        break;

                    case SourceAction.Rename:
                        File.Move(stringtablefile, string.Format("{0}.bkup", stringtablefile));
                        break;

                    case SourceAction.Nothing:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(string.Format("Failed parsing file: {0} Error: {1}", stringtablefile, ex.Message));
                }
            }

            return(project);
        }
Example #2
0
        /// <summary>
        /// Parses a given folder into a Project
        /// </summary>
        /// <param name="folderPath">The path to a csv file</param>
        /// <param name="sourceAction">The action to be performed on the source files</param>
        /// <param name="fillMissing">Whether to fill the missing values</param>
        /// <returns>
        /// A <see cref="Project"/> containing a <see cref="Package"/> per found string table csv file.
        /// </returns>
        public static Project ParseProject(string folderPath, SourceAction sourceAction = SourceAction.Nothing, bool fillMissing = false)
        {
            if (!Directory.Exists(folderPath))
                throw new ApplicationException(string.Format("The specified folder does not exist: {0}", folderPath));

            var project = new Project()
            {
                Name = new DirectoryInfo(folderPath).Name
            };

            // get all stringtables
            foreach (var stringtablefile in Directory.EnumerateFiles(folderPath, "*.csv", SearchOption.AllDirectories))
            {
                try
                {
                    var package = Parse(stringtablefile, fillMissing);
                    project.Packages.Add(package);

                    // perform action on the source files
                    switch (sourceAction)
                    {
                        case SourceAction.Delete:
                            File.Delete(stringtablefile);
                            break;

                        case SourceAction.Rename:
                            File.Move(stringtablefile, string.Format("{0}.bkup", stringtablefile));
                            break;

                        case SourceAction.Nothing:
                            break;
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(string.Format("Failed parsing file: {0} Error: {1}", stringtablefile, ex.Message));
                }
            }

            return project;
        }
Example #3
0
        public static Pipeline <T> FromSource(string name, SourceAction <T> source)
        {
            var pipeline = new Pipeline <T>(new SourceChannel <T>(source), new IRoutine[0]);

            return(pipeline.Pipe(name, EmptyTransform));
        }
Example #4
0
        public SourceChannel(SourceAction <T> action)
        {
            Guard.NotNull(action, nameof(action));

            this.action = action;
        }