本文整理汇总了C#中RowSet.ToTextTable方法的典型用法代码示例。如果您正苦于以下问题:C# RowSet.ToTextTable方法的具体用法?C# RowSet.ToTextTable怎么用?C# RowSet.ToTextTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RowSet
的用法示例。
在下文中一共展示了RowSet.ToTextTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// Execute action
public override object Execute()
{
downloadPackagesInfo();
RowSet rs=new RowSet();
Context.Initialize(rs);
List<Package> toUpdate = new List<Package>();
var filter = new StringFilter(Syntax, Context.TransformStr(Filter, Transform));
//VerboseMessage("Filter: {0} {1}", Syntax, Dump.ToDump( Context.TransformStr(Filter, Transform)));
foreach (var c in Items)
{
var rv=c.CheckVersion();
Version currentVersion = null;
string str = (rv==null?null:(ReturnValue.Unwrap(rv)??string.Empty).ToString());
if (!string.IsNullOrEmpty(str))
currentVersion = new Version(str);
var pinfo = GetPackage(c.Name);
Version newVersion =(pinfo != null) ?pinfo.Version:null;
rs.AddRow(new Vars(){
{"Package",c.FriendlyName},
{"Installed",(currentVersion==null)?"not installed":currentVersion.ToString()},
{"Available",(newVersion == null) ? "n/a" : newVersion.ToString()}}
);
bool update = false;
if (currentVersion != null && ((newVersion > currentVersion) || ForceUpdate) && filter.IsMatch(c.Name))
{
toUpdate.Add(c);
update = true;
}
VerboseMessage("{0}: {1}=>{2}. Update={3}",c.Name,currentVersion,newVersion,update);
}
Context.Out.WriteLine(string.Empty);
Context.Out.WriteLine(rs.ToTextTable(TableFormatOptions.Header));
if (toUpdate.Count==0)
{
Context.Out.WriteLine("All packages are up to date!");
return null;
}
try
{
VerboseMessage("--- Downloading components... --- ");
foreach (var c in toUpdate)
c.Download(this);
VerboseMessage("--- Download completed. --- ");
VerboseMessage(string.Empty);
VerboseMessage("--- Starting update... ---");
Context.Execute(BeforeUpdate);
try
{
foreach (var c in toUpdate)
c.DoUpdate(this);
}
finally
{
Context.Execute(AfterUpdate);
}
VerboseMessage("--- Update completed. ---");
VerboseMessage(string.Empty);
return null;
}
finally
{
if (Cleanup)
{
VerboseMessage("--- Cleaning up... ---");
foreach (var c in toUpdate)
{
try
{
c.Cleanup(this);
}
catch
{
Context.WriteLine(OutputType.Error, string.Format("Cleanup failed for {0}...", c.Name));
}
}
VerboseMessage("--- Cleaning completed. ---");
VerboseMessage(string.Empty);
}
}
}