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


C# Options.Fixup方法代码示例

本文整理汇总了C#中Options.Fixup方法的典型用法代码示例。如果您正苦于以下问题:C# Options.Fixup方法的具体用法?C# Options.Fixup怎么用?C# Options.Fixup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Options的用法示例。


在下文中一共展示了Options.Fixup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

		public static void Main (string[] _args)
		{			
			List<string> args = new List<string>(_args);
			Dictionary<string, string> options = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args);
			Options opt = new Options();
			
			foreach(FieldInfo fi in opt.GetType().GetFields())
				if (options.ContainsKey(fi.Name))
					fi.SetValue(opt, options[fi.Name]);
			
			opt.Fixup();			
			
            Duplicati.Library.Utility.IFilter filter = null;
			if (!string.IsNullOrEmpty(opt.ignorefilter))
                filter = new Duplicati.Library.Utility.FilterExpression(opt.ignorefilter, false);
			
            var paths = Duplicati.Library.Utility.Utility.EnumerateFileSystemEntries(opt.sourcefolder, filter).Select(x => x.Substring(opt.sourcefolder.Length));

			//A bit backwards, but we have flattend the file list, and now we re-construct the tree,
			// but we do not care much about performance here
			RootFolderInfo rootfolder = new RootFolderInfo(opt, paths);
			
			new XDocument(
				new XElement(XWIX + "Wix",
					new XElement(XWIX + "Fragment",
			            rootfolder.GroupNode,
						new XElement(XWIX + "DirectoryRef",
							new XAttribute("Id", opt.dirref),
			             	rootfolder.Node
						)
					)
				)
			).Save(opt.outputfile);

			WriteKeyDatabase(rootfolder.GeneratedKeys, opt.dbfilename, true);
			
			Console.WriteLine("Generated wxs: {0}", opt.outputfile);
			
		}
开发者ID:admz,项目名称:duplicati,代码行数:39,代码来源:Program.cs

示例2: Main

        public static void Main(string[] _args)
        {
            List<string> args = new List<string>(_args);
            Dictionary<string, string> options = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args);
            Options opt = new Options();
            
            foreach (FieldInfo fi in opt.GetType().GetFields())
                if (options.ContainsKey(fi.Name))
                    fi.SetValue(opt, options[fi.Name]);
            
            opt.Fixup();            
            
            Duplicati.Library.Utility.IFilter filter = null;
            if (!string.IsNullOrEmpty(opt.ignorefilter))
                filter = new Duplicati.Library.Utility.FilterExpression(opt.ignorefilter, false);
            
            Func<string, bool> isFile = (string x) => !x.EndsWith(DIR_SEP);
            
            var paths = Duplicati.Library.Utility.Utility.EnumerateFileSystemEntries(opt.sourcefolder, filter)
                .Where(x => isFile(x) && FILEMAP.ContainsKey(Path.GetFileName(x)))
                .Select(x =>
            {
                var m = FILEMAP[Path.GetFileName(x)].Match(File.ReadAllText(x));
                return m.Success ? 
                        new { File = x, Version = new Version(m.Groups["version"].Value.Replace("*", "0")), Display = m.Groups["version"].Value } 
                        : null;
            })
                .Where(x => x != null)
                .ToArray(); //No need to re-eval
            
            if (paths.Count() == 0)
            {
                Console.WriteLine("No files found to update...");
                return;
            }
            
            foreach (var p in paths)
                Console.WriteLine("{0}\t:{1}", p.Display, p.File);
            
            if (string.IsNullOrWhiteSpace(opt.version))
            {
                var maxv = paths.Select(x => x.Version).Max();
                opt.version = new Version(
                    maxv.Major,
                    maxv.Minor,
                    maxv.Build,
                    maxv.Revision).ToString();
            }
            
            //Sanity check
            var nv = new Version(opt.version).ToString(4);

            foreach (var p in paths)
            {
                var re = FILEMAP[Path.GetFileName(p.File)];
                var txt = File.ReadAllText(p.File);
                //var m = re.Match(txt).Groups["version"];
                txt = re.Replace(txt, (m) => {
                    var t = m.Groups["version"];
                    return m.Value.Replace(t.Value, nv);
                });
                File.WriteAllText(p.File, txt);
            }

            Console.WriteLine("Updated {0} files to version {1}", paths.Count(), opt.version);
        }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:66,代码来源:Program.cs


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