本文整理汇总了C#中Account.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Account.Initialize方法的具体用法?C# Account.Initialize怎么用?C# Account.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var acc = new Account(Guid.NewGuid());
acc.Deposit(new Amount(3100));
acc.Withdraw(new Amount(100));
acc.Withdraw(new Amount(10000));
foreach (var @event in acc.RecordedEvents())
Console.WriteLine(@event);
Console.ReadLine();
var sw = new Stopwatch();
sw.Start();
var accountId = Guid.Parse("44b9da68-8415-4adc-b99f-2631f1115f9e");
var account = new Account(accountId);
for (var i = 0; i < 500; i++)
{
account.Withdraw(new Amount(i * 1000));
account.Deposit(new Amount(i * 1000 * 2));
}
var eventStore = new FileEventStore();
eventStore.Create(accountId, account.RecordedEvents());
sw.Stop();
Console.WriteLine(string.Format("Appended {0} events to stream in {1}.", account.RecordedEvents().Count(), sw.Elapsed.TotalSeconds));
sw.Restart();
var stream = eventStore.GetStream(accountId);
new ProjectionToConsole().Handle(stream);
sw.Stop();
Console.WriteLine(string.Format("Read {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));
sw.Reset();
var restoredAccount = new Account(accountId);
restoredAccount.Initialize(stream);
sw.Stop();
Console.WriteLine(string.Format("Replayed {0} events from stream in {1}.", stream.Count(), sw.Elapsed.TotalSeconds));
Console.ReadLine();
}
示例2: ToSettingSet
private static SettingSet ToSettingSet(XmlNode content)
{
SettingSet settingSet = new SettingSet();
List<Instrument> instruments = null;
List<Customer> customers = null;
List<TradePolicyDetail> tradePolicyDetails = null;
List<QuotePolicyDetail> quotePolicyDetails = null;
foreach (XmlNode xmlNode in content.ChildNodes)
{
string name = xmlNode.Name;
if (name == "PrivateDailyQuotation")
{
settingSet.PrivateDailyQuotation = new PrivateDailyQuotation();
settingSet.PrivateDailyQuotation.Initialize(xmlNode);
}
else if (name == "SystemParameter")
{
settingSet.SystemParameter = new SystemParameter();
settingSet.SystemParameter.Initialize(xmlNode);
}
else if (name == "Instruments")
{
foreach (XmlNode instrumentNode in xmlNode.ChildNodes)
{
Instrument instrument = new Instrument();
instrument.Initialize(instrumentNode);
if (instruments == null) instruments = new List<Instrument>();
instruments.Add(instrument);
}
}
else if (name == "Instrument")
{
Instrument instrument = new Instrument();
instrument.Initialize(xmlNode);
if (instruments == null) instruments = new List<Instrument>();
instruments.Add(instrument);
}
else if (name == "Account")
{
Account account = new Account();
account.Initialize(xmlNode);
settingSet.Accounts = new Account[] { account };
}
else if (name == "Customers")
{
foreach (XmlNode customerNode in xmlNode.ChildNodes)
{
Customer customer = new Customer();
customer.Initialize(customerNode);
if (customers == null) customers = new List<Customer>();
customers.Add(customer);
}
}
else if (name == "TradePolicyDetail")
{
TradePolicyDetail tradePolicyDetail = new TradePolicyDetail();
tradePolicyDetail.Initialize(xmlNode);
if (tradePolicyDetails == null) tradePolicyDetails = new List<TradePolicyDetail>();
tradePolicyDetails.Add(tradePolicyDetail);
}
else if (name == "QuotePolicyDetail")
{
QuotePolicyDetail quotePolicyDetail = new QuotePolicyDetail();
quotePolicyDetail.Initialize(xmlNode);
if (quotePolicyDetails == null) quotePolicyDetails = new List<QuotePolicyDetail>();
quotePolicyDetails.Add(quotePolicyDetail);
}
else if (name == "QuotePolicyDetails")
{
foreach (XmlNode childNode in xmlNode.ChildNodes)
{
QuotePolicyDetail quotePolicyDetail = new QuotePolicyDetail();
quotePolicyDetail.Initialize(childNode);
if (quotePolicyDetails == null) quotePolicyDetails = new List<QuotePolicyDetail>();
quotePolicyDetails.Add(quotePolicyDetail);
}
}
}
settingSet.Instruments = (instruments.IsNullOrEmpty() ? null : instruments.ToArray());
settingSet.Customers = (customers.IsNullOrEmpty() ? null : customers.ToArray());
settingSet.TradePolicyDetails = (tradePolicyDetails.IsNullOrEmpty() ? null : tradePolicyDetails.ToArray());
settingSet.QuotePolicyDetails = (quotePolicyDetails.IsNullOrEmpty() ? null : quotePolicyDetails.ToArray());
return settingSet;
}