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


C# Options.GetType方法代码示例

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


在下文中一共展示了Options.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
            
            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

示例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);
			
            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

示例3: SaveSetToFile

 /// <summary>
 /// Сохранение настроек в файл
 /// </summary>
 /// <returns>True, если все получилось; False, если возникла ошибка</returns>
 public bool SaveSetToFile()
 {
     Options OP = new Options();
     OP.NotifyAllow = this.NotifyAllow;
     OP.LogFolderName = this.LogFolderName;
     OP.TestPeriod = this.TestPeriod;
     OP.SMTPServer = this.SMTPServ;
     OP.PortNumber = this.PortN;
     OP.FromField = this.Sender;
     OP.Username = this.Username;
     OP.Password = this.Password;
     OP.SSLEnabled = this.Secure;
     try
     {
         if (!Directory.Exists(SettingsFolder))
         {
             Directory.CreateDirectory(SettingsFolder);
         }
         XmlSerializer XmlSer = new XmlSerializer(OP.GetType());
         StreamWriter Writer = new StreamWriter(SettingsPath);
         XmlSer.Serialize(Writer, OP);
         Writer.Close();
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Exception saving settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return false;
     }
 }
开发者ID:solovyevn,项目名称:SiteMonitor,代码行数:34,代码来源:Settings.cs

示例4: AddProjectWithHttpInfo

        /// <summary>
        /// Create project Create a project for the specified organization
        /// </summary>
        /// <param name="orgid">Organization identifier</param> 
        /// <param name="options">Options for project create/update</param> 
        /// <returns>ApiResponse of InlineResponse2001</returns>
        public ApiResponse< InlineResponse2001 > AddProjectWithHttpInfo (string orgid, Options options)
        {
            
            // verify the required parameter 'orgid' is set
            if (orgid == null)
                throw new ApiException(400, "Missing required parameter 'orgid' when calling ProjectsApi->AddProject");
            
            // verify the required parameter 'options' is set
            if (options == null)
                throw new ApiException(400, "Missing required parameter 'options' when calling ProjectsApi->AddProject");
            
    
            var path_ = "/orgs/{orgid}/projects";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>(Configuration.DefaultHeader);
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/json", "text/plain", "text/html"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (orgid != null) pathParams.Add("orgid", Configuration.ApiClient.ParameterToString(orgid)); // path parameter
            
            
            
            
            if (options.GetType() != typeof(byte[]))
            {
                postBody = Configuration.ApiClient.Serialize(options); // http body (model) parameter
            }
            else
            {
                postBody = options; // byte array
            }

            // authentication (apikey) required
            
            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }
            // authentication (permissions) required
            
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }
            
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, 
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int) response.StatusCode;
    
            if (statusCode >= 400)
                throw new ApiException (statusCode, "Error calling AddProject: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException (statusCode, "Error calling AddProject: " + response.ErrorMessage, response.ErrorMessage);
    
            return new ApiResponse<InlineResponse2001>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (InlineResponse2001) Configuration.ApiClient.Deserialize(response, typeof(InlineResponse2001)));
            
        }
开发者ID:guitarrapc,项目名称:UnityCloudbuildApi,代码行数:91,代码来源:ProjectsApi.cs

示例5: SaveSetToFile

 /// <summary>
 /// Сохранение настроек в файл
 /// </summary>
 /// <returns>True, если все получилось; False, если возникла ошибка</returns>
 public bool SaveSetToFile()
 {
     Options OP = new Options();
     OP.AutoStart = this.AutoStart;
     OP.SSL = this.SSL;
     OP.ServerAdress = this.ServerAdress;
     OP.ServerPort = this.ServerPort;
     OP.TestInterval = this.TestInterval;
     OP.TCPInterval = this.TCPInterval;
     OP.TCPTriesLimit = this.TCPTriesLimit;
     OP.ICMPInterval = this.ICMPInterval;
     OP.ICMPTriesLimit = this.ICMPTriesLimit;
     OP.MailFrom = this.MailFrom;
     OP.MailUsername = this.MailUsername;
     OP.MailPassword = this.MailPassword;
     OP.SMTPServer = this.SMTPServer;
     OP.SMTPPort = this.SMTPPort;
     OP.ServerAdminEmail = this.ServerAdminEmail;
     OP.WebAdminEmail = this.WebAdminEmail;
     this.PointDateTime.CopyTo(OP.PointDateTime, 0);
     this.PointAdress.CopyTo(OP.PointAdress, 0);
     try
     {
         XmlSerializer XmlSer = new XmlSerializer(OP.GetType());
         StreamWriter Writer = new StreamWriter(SettingsPath);
         XmlSer.Serialize(Writer, OP);
         Writer.Close();
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error saving settings", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return false;
     }
 }
开发者ID:viktor-prokashev,项目名称:WebMonitor,代码行数:39,代码来源:Settings.cs

示例6: LoadSetfromFile

 public bool LoadSetfromFile()
 {
     Options OP = new Options();
     try
     {
         if (Directory.Exists(SettingsFolder))
         {
             if (File.Exists(SettingsFolder + @"\" + SettingsFile))
             {
                 XmlSerializer XmlSer = new XmlSerializer(OP.GetType());
                 FileStream Set = new FileStream(SettingsFolder + @"\" + SettingsFile, FileMode.Open);
                 OP = (Options)XmlSer.Deserialize(Set);
                 Set.Close();
                 this.SettingsFile = OP.SettingsFile;
                 this.SettingsFolder = OP.SettingsFolder;
                 this.EnableLog = OP.EnableLog;
                 this.LogPeriod = OP.LogPeriod;
                 this.LogFolderName = OP.LogFolderName;
                 this.AlarmSoundFile = OP.AlarmSoundFile;
                 this.MinCoolantTemp = OP.MinCoolantTemp;
                 this.MaxCoolantTemp = OP.MaxCoolantTemp;
                 this.NoDataAlarmPeriod = OP.NoDataAlarmPeriod;
                 this.SerialPortSelect = OP.SerialPortSelect;
                 this.BaudRate = OP.BaudRate;
                 this.DataBits = OP.DataBits;
                 this.StopBitsSelect = OP.StopBitsSelect;
                 this.ParitySelect = OP.ParitySelect;
                 this.HandshakeSelect = OP.HandshakeSelect;
                 return true;
             }
             else return false;
         }
         else return false;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, RM.GetString("strLoadSetExc"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return false;
     }
 }
开发者ID:solovyevn,项目名称:CustomDKGMonitor,代码行数:40,代码来源:Settings.cs

示例7: SaveSetToFile

 public bool SaveSetToFile()
 {
     Options OP = new Options();
     OP.SettingsFile = this.SettingsFile;
     OP.SettingsFolder = this.SettingsFolder;
     OP.EnableLog = this.EnableLog;
     OP.LogPeriod = this.LogPeriod;
     OP.LogFolderName = this.LogFolderName;
     OP.AlarmSoundFile = this.AlarmSoundFile;
     OP.MinCoolantTemp = this.MinCoolantTemp;
     OP.MaxCoolantTemp = this.MaxCoolantTemp;
     OP.NoDataAlarmPeriod = this.NoDataAlarmPeriod;
     OP.SerialPortSelect = this.SerialPortSelect;
     OP.BaudRate = this.BaudRate;
     OP.DataBits = this.DataBits;
     OP.StopBitsSelect = this.StopBitsSelect;
     OP.ParitySelect = this.ParitySelect;
     OP.HandshakeSelect = this.HandshakeSelect;
     try
     {
         if (!Directory.Exists(SettingsFolder))
         {
             Directory.CreateDirectory(SettingsFolder);
         }
         XmlSerializer XmlSer = new XmlSerializer(OP.GetType());
         StreamWriter Writer = new StreamWriter([email protected]"\"+SettingsFile);
         XmlSer.Serialize(Writer, OP);
         Writer.Close();
         return true;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, RM.GetString("strSaveSetExc"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return false;
     }
 }
开发者ID:solovyevn,项目名称:CustomDKGMonitor,代码行数:36,代码来源:Settings.cs


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