當前位置: 首頁>>代碼示例>>C#>>正文


C# ConfigurationProperty.ConvertFromString方法代碼示例

本文整理匯總了C#中System.Configuration.ConfigurationProperty.ConvertFromString方法的典型用法代碼示例。如果您正苦於以下問題:C# ConfigurationProperty.ConvertFromString方法的具體用法?C# ConfigurationProperty.ConvertFromString怎麽用?C# ConfigurationProperty.ConvertFromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Configuration.ConfigurationProperty的用法示例。


在下文中一共展示了ConfigurationProperty.ConvertFromString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeserializePropertyValue

 private object DeserializePropertyValue(ConfigurationProperty prop, XmlReader reader)
 {
     string str = reader.Value;
     object obj2 = null;
     try
     {
         obj2 = prop.ConvertFromString(str);
         prop.Validate(obj2);
     }
     catch (ConfigurationException exception)
     {
         if (string.IsNullOrEmpty(exception.Filename))
         {
             exception = new ConfigurationErrorsException(exception.Message, reader);
         }
         obj2 = new InvalidPropValue(str, exception);
     }
     catch
     {
     }
     return obj2;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:22,代碼來源:ConfigurationElement.cs

示例2: ValidateValue

		void ValidateValue (ConfigurationProperty p, string value)
		{
			ConfigurationValidatorBase validator;
			if (p == null || (validator = p.Validator) == null)
				return;
			
			if (!validator.CanValidate (p.Type))
				throw new ConfigurationErrorsException (
					String.Format ("Validator does not support type {0}", p.Type));
			validator.Validate (p.ConvertFromString (value));
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:11,代碼來源:ConfigurationElement.cs

示例3: DeserializePropertyValue

        private object DeserializePropertyValue(ConfigurationProperty prop, XmlReader reader) {
            Debug.Assert(prop != null, "prop != null");
            Debug.Assert(reader != null, "reader != null");

            // By default we try to load (i.e. parse/validate ) all properties
            // If a property value is invalid ( cannot be parsed or is not valid ) we will keep the value
            // as string ( from the xml ) and will write it out unchanged if needed
            // If the property value is needed by users the actuall exception will be thrown

            string xmlValue = reader.Value;
            object propertyValue = null;

            try {
                propertyValue = prop.ConvertFromString(xmlValue);

                // Validate the loaded and converted value
                prop.Validate(propertyValue);
            }
            catch (ConfigurationException ce) {
                // If the error is incomplete - complete it :)
                if (string.IsNullOrEmpty(ce.Filename)) {
                    ce = new ConfigurationErrorsException(ce.Message, reader);
                }

                // Cannot parse/validate the value. Keep it as string
                propertyValue = new InvalidPropValue(xmlValue, ce);
            }
            catch {
                // If this is an exception related to the parsing/validating the 
                // value ConfigurationErrorsException should be thrown instead.
                // If not - the exception is ok to surface out of here
                Debug.Fail("Unknown exception type thrown");
            }

            return propertyValue;
        }
開發者ID:gbarnett,項目名稱:shared-source-cli-2.0,代碼行數:36,代碼來源:configurationelement.cs

示例4: DeserializePropertyValue

 private object DeserializePropertyValue(ConfigurationProperty prop, XmlReader reader)
 {
     string str = reader.Value;
       object obj = (object) null;
       try
       {
     obj = prop.ConvertFromString(str);
     prop.Validate(obj);
       }
       catch (ConfigurationException ex)
       {
     ConfigurationException error = ex;
     if (string.IsNullOrEmpty(error.Filename))
       error = (ConfigurationException) new ConfigurationErrorsException(error.Message, reader);
     obj = (object) new InvalidPropValue(str, error);
       }
       catch
       {
       }
       return obj;
 }
開發者ID:wcpro,項目名稱:iEnvoke,代碼行數:21,代碼來源:ConfigurationElement.cs


注:本文中的System.Configuration.ConfigurationProperty.ConvertFromString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。