本文整理汇总了C#中Repository.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Load方法的具体用法?C# Repository.Load怎么用?C# Repository.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.Load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run()
{
using (var sut = new Repository(SERVER, TokenRepository.LoadFrom("ftp.credentials.txt"), "AppZwitschern_TweetStore"))
{
Console.WriteLine("storing...");
var versandaufträge = new[]
{
new Versandauftrag()
{Id = "1", Termin = new DateTime(2012, 3, 26, 12, 21, 0), Text = "a"},
new Versandauftrag()
{Id = "2", Termin = new DateTime(2011, 10, 27, 14, 17, 0), Text = "b"}
,
null
};
var versandt = false;
versandaufträge.ToList().ForEach(_ => sut.Store(_, () => versandt = true));
Console.WriteLine(" stored!");
Assert.IsTrue(versandt);
Console.WriteLine("listing...");
var filenames = new List<string>();
sut.List(filenames.Add);
filenames.ForEach(fn => Console.WriteLine("list {0}", fn));
Assert.AreEqual(3, filenames.Count);
Console.WriteLine("loading...");
var results = new List<Versandauftrag>();
filenames.ForEach(fn => sut.Load(fn, results.Add));
Console.WriteLine(" loaded!");
Assert.That(results.Select(_ => _ == null ? null : _.Id).ToArray(),
Is.EquivalentTo(new[] {"1", "2", null}));
Console.WriteLine("deleting...");
var deleted = false;
results.ForEach(va => sut.Delete(va, () => deleted = true));
Console.WriteLine(" deleted!");
Assert.IsTrue(deleted);
}
}
示例2: Run
public void Run()
{
const string TEST_REPO_PATH = @"c:\appzwitschern";
if (Directory.Exists(TEST_REPO_PATH)) Directory.Delete(TEST_REPO_PATH, true);
var repo = new Repository(TEST_REPO_PATH);
var va1 = new Versandauftrag() { Text = "a", Termin = new DateTime(2012, 6, 21), Id = Guid.NewGuid().ToString() };
repo.Store(va1, null);
var endOfStream = false;
var va2 = new Versandauftrag() { Text = "b", Termin = new DateTime(2012, 6, 20), Id = Guid.NewGuid().ToString() };
repo.Store(va2, null);
repo.Store(null, () => endOfStream = true);
Assert.IsTrue(endOfStream);
endOfStream = false;
var results = new List<string>();
repo.List(results.Add);
Assert.That(results.Select(fn => fn==null ? null : Path.GetFileName(fn)).ToArray(),
Is.EquivalentTo(new[] { va1.Id + ".tweet", va2.Id + ".tweet", null }));
var resultVAs = new List<Versandauftrag>();
foreach(var fn in results)
repo.Load(fn, resultVAs.Add);
Assert.That(resultVAs.Select(_ => _==null ? null : _.Text).ToArray(),
Is.EquivalentTo(new[]{"a", "b", null}));
resultVAs.ForEach(va => repo.Delete(va, () => endOfStream = true));
Assert.AreEqual(0, Directory.GetFiles(TEST_REPO_PATH).Length);
Assert.IsTrue(endOfStream);
Directory.Delete(TEST_REPO_PATH);
}
示例3: Main
static void Main(string[] args)
{
// arguments
// --help
// --provider=redis|mysql|sqlserver
// --server=hostname
// --port=
// --database=
// --uid=
// --pwd=
// --parallel-count
LogBuffer = new StringBuilder();
int parallelCount = 70;
//string provider = "redis";
//string server = "127.0.0.1";
//string port = "6379";
string provider = "mongodb";
string server = "50.62.1.71";
string port = "27017";
string database = "ls";
Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
PrintAndClearHeaderArea();
LogLine("Buffer width: " + Console.BufferWidth);
LogLine("Buffer height: " + Console.BufferHeight);
IPersistence persistence =
PersistenceFactory.GetPersistence(provider,
new Dictionary<string, string>
{
{ "server", server },
{ "port", port },
{ "database", database }
});
if (!persistence.Ping())
{
LogLine("Unable to connect to the database. Aborting.");
Environment.Exit(1);
}
Repository repository = new Repository(persistence);
RobotService robots = new RobotService();
CollectorPool pool;
VisitedUrls history;
VisitedDomains domainHistory = new VisitedDomains();
int poolCount = 0;
Log("Loading pool...");
repository.Load(out pool);
pool.Store("squidoo.com");
pool.Store("ezinearticles.com");
pool.Store("hubpages.com");
pool.Store("technorati.com");
pool.Store("buzzle.com");
pool.Store("suite101.com");
pool.Store("goarticles.com");
pool.Store("apsense.com");
pool.Store("allaboutcounseling.com");
pool.Store("digg.com");
pool.Store("dmoz.org");
pool.Store("dir.yahoo.com");
poolCount = pool.Count;
LogLine("done. Found " + poolCount);
Log("Loading link data...");
repository.LoadData();
LogLine("done. Found " + repository.Links.Count);
Log("Loading history...");
repository.Load(out history, DateTime.Today);
LogLine("done");
Log("Loading TLD parser...");
TldParser tldParser = new TldParser();
LogLine("done");
Thread.Sleep(5000);
PrintAndClearHeaderArea();
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
TaskScheduler scheduler = TaskScheduler.FromCurrentSynchronizationContext();
TaskScheduler.UnobservedTaskException += (o, ea) =>
{
LogLine("Exception: {0}", ea.Exception.Message);
ea.SetObserved();
};
DateTime start = DateTime.Now;
CancellationTokenSource cancelTokenSource = new CancellationTokenSource();
CancellationToken cancelToken = cancelTokenSource.Token;
//CountdownEvent countdown = new CountdownEvent(parallelCount);
Task[] tasks = new Task[parallelCount];
for (int i = 0; i < parallelCount; i++)
//.........这里部分代码省略.........
示例4: QuizModule
public QuizModule(Repository repository)
: base("/quiz")
{
Get["/list/"] = o =>
{
ViewBag.Title = "Quiz List";
var quizes = repository.Load(new AllQuizesQuery());
return View["Quiz/List", quizes];
};
Get["/{id}/edit/"] = o =>
{
ViewBag.Title = "Edit Quiz";
var quiz = repository.Load(new QuizByIdQuery(o.id));
return View["Quiz/Edit", quiz];
};
Get["/new/"] = o =>
{
ViewBag.Title = "New Quiz";
return View["Quiz/Edit", null];
};
Post["/new/"] = o =>
{
var quiz = this.Bind<Quiz>();
var quizSaveNewQuery = new QuizSaveNewQuery(quiz);
quiz = repository.Save(quizSaveNewQuery);
return Response.AsRedirect(string.Format("/quiz/{0}/", quiz.Id));
};
Get["/{id}/take/"] = o =>
{
var quiz = repository.Load(new QuizByIdQuery(o.id));
ViewBag.Title = "Taking " + quiz.Name;
return View["Quiz/Take", quiz];
};
Get["/{id}/review/"] = o =>
{
return Response.AsRedirect("/");
};
Get["/{id}/take/{step}/"] = o =>
{
var step = (int)(o.step ?? 0);
var quiz = repository.Load(new QuizByIdQuery(o.id));
var contents = "";
if (step >= quiz.Questions.Count())
{
using (var stream = new MemoryStream())
{
var x = View["Quiz/Review", quiz];
x.Contents(stream);
stream.Position = 0;
using (var reader = new StreamReader(stream))
{
contents = reader.ReadToEnd();
}
}
return Response.AsJson(new
{
type = "Review",
value = contents
});
}
var question = quiz.Questions.Skip(step).First();
return Response.AsJson(new
{
type = "Question",
value = question
});
};
Get["/{id}/"] = o =>
{
var quiz = repository.Load(new QuizByIdQuery(o.id));
ViewBag.Title = quiz.Name;
return View["Quiz/View", quiz];
};
}