当前位置: 首页>>代码示例>>C#>>正文


C# RowSet.ToTextTable方法代码示例

本文整理汇总了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);

                }
            }
        }
开发者ID:xsharper,项目名称:xsharper,代码行数:91,代码来源:Updater.cs


注:本文中的RowSet.ToTextTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。