_Samples/Example_ImportExport.cs
(开头部分) 7KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Data.Common;
using System.Security.Cryptography;
//<doc:using>
using ComLib;
using ComLib.ImportExport;
//</doc:using>
using ComLib.Application;
using ComLib.MapperSupport;
using ComLib.ValidationSupport;
namespace ComLib.Samples
{
/// <summary>
/// Example for the ImportExport namespace.
/// </summary>
public class Example_ImportExport : App
{
/// <summary>
/// Run the application.
/// </summary>
public override BoolMessageItem Execute()
{
//<doc:example>
var io = ImportExports.Instance;
// =======================================================================
// REGISTRATION :
// =======================================================================
// Example 1.
// - Register Person as importable using default service, mappers, and formats as "csv,xml,ini"
// - Set the actions for the various import/export behaviour
io.Register<Person>();
io.For<Person>().SetImport((allPersons) => Console.WriteLine("Importing : " + allPersons.Count + " people."));
io.For<Person>().SetExportPage( (page, pageSize) => GetPersons() );
io.For<Person>().SetExportAll( () => GetPersons() );
io.For<Person>().SetTotal(() => GetPersons().Count);
// Example 2.
// - Set the actions for the various import/export behaviour, ExportByPage lamda not supplied, exportbypage will call export all
// - Explicitly enable validation after mapping(using validator supplied), supported formats, and whether service is ReUsable ( e.g. singleton ).
// - .
io.Register<Meeting>(new MeetingValidator(), new string[]{"csv", "ini", "xml"}, true );
io.For<Meeting>().SetImport((allMeetings) => Console.WriteLine("Importing : " + allMeetings.Count + " meetings."));
io.For<Meeting>().SetExportAll( () => GetMeetings() );
io.For<Meeting>().SetTotal(() => GetMeetings().Count);
// Example 3.
// - Set the actions for the various import/export behaviour in a single call. import, exportbypage, exportall, gettotals.
// - Explicitly enable validation after mapping(using validator supplied), whether service is ReUsable ( e.g. singleton ), and mappers("ini","csv") to use.
io.Register<BlogPost>(new MeetingValidator(), true, new MapperIni<BlogPost>(), new MapperCsv<BlogPost>());
后面还有 130 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
