https://github.com/gingray/macrosprocessor
Библиотекта, которая помогает мапить данные из нескольких файлов в один на основе макро подстановок. Library for macro text manipulation.
https://github.com/gingray/macrosprocessor
Last synced: 8 days ago
JSON representation
Библиотекта, которая помогает мапить данные из нескольких файлов в один на основе макро подстановок. Library for macro text manipulation.
- Host: GitHub
- URL: https://github.com/gingray/macrosprocessor
- Owner: gingray
- Created: 2014-01-03T16:23:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-18T14:48:13.000Z (over 12 years ago)
- Last Synced: 2026-02-19T04:30:30.545Z (4 months ago)
- Language: C#
- Homepage:
- Size: 172 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MacrosProcessor
===============
Библиотекта, которая помогает мапить данные из нескольких файлов в один на основе макро подстановок.
К примеру у тебя вот такая структура каталогов
``` text
test
|-- 1\title.txt
|-- 1\description.txt
|-- 1\image.txt
|-- 2\title.txt
|-- 2\description.txt
|-- 2\image.txt
|-- 3\title.txt
|-- 3\description.txt
|-- 3\image.txt
```
есть шаблон вида
``` text
{title}
{description}
{image}
```
``` csharp
namespace SandBox
{
class Program
{
static void Main(string[] args)
{
var mapCollection = new MapCollection();
var item = new FileMapper("title.txt", "title");
mapCollection.Add(item);
item = new FileMapper("description.txt", "description");
mapCollection.Add(item);
item = new FileMapper("image.txt", "image");
mapCollection.Add(item);
var action = new MapToFiles(File.ReadAllText("template.txt"), "test", mapCollection);
action.FileMaping += ActionFileMaping;
action.Process();
}
static void ActionFileMaping(object sender, MapFileArgs e)
{
File.WriteAllText(Path.Combine(e.Folder,"result.txt"), e.MapResult);
}
}
}
```
теперь в каждой директории будет создам файл result.txt где будет подставлен контент из указанных файлов.