本文整理汇总了C#中Operation.XmlSerialize方法的典型用法代码示例。如果您正苦于以下问题:C# Operation.XmlSerialize方法的具体用法?C# Operation.XmlSerialize怎么用?C# Operation.XmlSerialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation.XmlSerialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: serialize
public void serialize()
{
using (var temp = new TempDirectory())
{
var obj = new Operation(Guid.NewGuid())
{
Info = "example"
};
obj.Commands.Add(new DirectoryCreateCommand(temp.Info.FullName));
var navigator = obj.XmlSerialize().CreateNavigator();
Assert.True(navigator.Evaluate<bool>("1 = count(/operation/commands/command)"));
var xpath = "1 = count(/operation[@info='example']/commands/command[@type='{0}']/directory.create[@path='{1}'][@undo='false'])".FormatWith(typeof(DirectoryCreateCommand).AssemblyQualifiedName, temp.Info.FullName);
Assert.True(navigator.Evaluate<bool>(xpath));
}
}
示例2: serialize_whenEmpty
public void serialize_whenEmpty()
{
var obj = new Operation(Guid.NewGuid());
var navigator = obj.XmlSerialize().CreateNavigator();
Assert.True(navigator.Evaluate<bool>("1 = count(/operation)"));
}
示例3: Save
private static FileInfo Save(Operation operation,
bool? success)
{
Trace.WriteIf(Tracing.Is.TraceVerbose, string.Empty);
var file = ItemFile(operation);
if (null != file.Directory && !file.Directory.Exists)
{
file.Directory.Create();
}
file.Create(operation.XmlSerialize());
if (success.HasValue)
{
var source = file.FullName;
file = ItemDirectory(operation, success.Value ? "Commit" : "Rollback").ToFile(file.Name);
if (null != file.Directory && !file.Directory.Exists)
{
file.Directory.Create();
}
File.Move(source, file.FullName);
}
return file;
}