Пример #1
0
        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);
        }
Пример #2
0
 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);
                 }
             }
         }
     }
 }
Пример #3
0
 public ProviderSettings(int providerId, int instanceId)
 {
     this.ProviderId = providerId;
     this.InstanceId = instanceId;
     this.Properties = new ProviderPropertyList();
 }
Пример #4
0
 internal ProviderPropertyList(ProviderPropertyList list)
 {
     this.dictionary = new Dictionary <string, string>(list.dictionary);
 }