コード例 #1
0
ファイル: Provider.cs プロジェクト: ForTrade/CSharp
 protected internal virtual void SetProperties(ProviderPropertyList properties)
 {
     PropertyInfo[] properties2 = base.GetType().GetProperties();
     for (int i = 0; i < properties2.Length; i++)
     {
         PropertyInfo propertyInfo = properties2[i];
         if (propertyInfo.CanRead && propertyInfo.CanWrite)
         {
             TypeConverter converter = TypeDescriptor.GetConverter(propertyInfo.PropertyType);
             if (converter != null && converter.CanConvertFrom(typeof(string)))
             {
                 string stringValue = properties.GetStringValue(propertyInfo.Name, null);
                 if (stringValue != null && converter.IsValid(stringValue))
                 {
                     propertyInfo.SetValue(this, converter.ConvertFromInvariantString(stringValue), null);
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: Provider.cs プロジェクト: ForTrade/CSharp
 protected internal virtual ProviderPropertyList GetProperties()
 {
     ProviderPropertyList providerPropertyList = new ProviderPropertyList();
     PropertyInfo[] properties = base.GetType().GetProperties();
     for (int i = 0; i < properties.Length; i++)
     {
         PropertyInfo propertyInfo = properties[i];
         if (propertyInfo.CanRead && propertyInfo.CanWrite && !(propertyInfo.DeclaringType == typeof(Provider)))
         {
             TypeConverter converter = TypeDescriptor.GetConverter(propertyInfo.PropertyType);
             if (converter != null && converter.CanConvertTo(typeof(string)) && converter.CanConvertFrom(typeof(string)))
             {
                 object value = propertyInfo.GetValue(this, null);
                 providerPropertyList.SetValue(propertyInfo.Name, converter.ConvertToInvariantString(value));
             }
         }
     }
     return providerPropertyList;
 }