CSLA Config cleanup
This commit is contained in:
@@ -13,8 +13,6 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
@@ -97,26 +95,26 @@ namespace DescriptiveEnum
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if(value is Enum && destinationType == typeof(string))
|
||||
if(value is Enum myenum && destinationType == typeof(string))
|
||||
{
|
||||
return EnumDescConverter.GetEnumDescription((Enum)value);
|
||||
return EnumDescConverter.GetEnumDescription(myenum);
|
||||
}
|
||||
if(value is string && destinationType == typeof(string))
|
||||
if(value is string mystr && destinationType == typeof(string))
|
||||
{
|
||||
return EnumDescConverter.GetEnumDescription(myVal, (string)value);
|
||||
return EnumDescConverter.GetEnumDescription(myVal, mystr);
|
||||
}
|
||||
return base.ConvertTo (context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
||||
{
|
||||
if(value is string)
|
||||
if(value is string mystr)
|
||||
{
|
||||
return EnumDescConverter.GetEnumValue(myVal, (string)value);
|
||||
return EnumDescConverter.GetEnumValue(myVal, mystr);
|
||||
}
|
||||
if(value is Enum)
|
||||
if(value is Enum myenum)
|
||||
{
|
||||
return EnumDescConverter.GetEnumDescription((Enum)value);
|
||||
return EnumDescConverter.GetEnumDescription(myenum);
|
||||
}
|
||||
return base.ConvertFrom (context, culture, value);
|
||||
}
|
||||
@@ -125,7 +123,8 @@ namespace DescriptiveEnum
|
||||
return true;
|
||||
}
|
||||
|
||||
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "Keeping attributes for future extensions")]
|
||||
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
{
|
||||
ArrayList values = new ArrayList();
|
||||
FieldInfo[] fis = myVal.GetFields();
|
||||
@@ -133,7 +132,6 @@ namespace DescriptiveEnum
|
||||
{
|
||||
DescriptionAttribute[] attributes =(DescriptionAttribute[])fi.GetCustomAttributes(
|
||||
typeof(DescriptionAttribute), false);
|
||||
//if (attributes.Length > 0)
|
||||
if (fi.Name != "value__")
|
||||
values.Add(fi.GetValue(fi.Name));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user