public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string stringValue = value as string; if (stringValue != null) { ViewBase toReturn = null; string completeName = stringValue; int pointIndex = completeName.IndexOf("."); string viewName = string.Empty; string themeName = string.Empty; if (pointIndex != -1) { viewName = completeName.Substring(0, pointIndex); themeName = completeName.Substring(pointIndex + 1); } else { viewName = completeName; } viewName = viewName.ToLowerInvariant(); switch (viewName) { case "tableview": toReturn = new TableView(); break; case "tableflowview": toReturn = new TableflowView(); break; } if (toReturn == null) { throw new ArgumentException("The specified view is invalid.", "value"); } else { if (!string.IsNullOrEmpty(themeName)) { ThemeConverter themeConverter = new ThemeConverter(); toReturn.Theme = (Theme)themeConverter.ConvertFromString(themeName); } } return(toReturn); } return(base.ConvertFrom(context, culture, value)); }
public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value ) { string stringValue = value as string; if( stringValue != null ) { ViewBase toReturn = null; string completeName = stringValue; int pointIndex = completeName.IndexOf( "." ); string viewName = string.Empty; string themeName = string.Empty; if(pointIndex != -1) { viewName = completeName.Substring( 0, pointIndex ); themeName = completeName.Substring( pointIndex + 1 ); } else { viewName = completeName; } viewName = viewName.ToLowerInvariant(); switch( viewName ) { case "tableview": toReturn = new TableView(); break; case "tableflowview": toReturn = new TableflowView(); break; } if( toReturn == null ) { throw new ArgumentException( "The specified view is invalid.", "value" ); } else { if( !string.IsNullOrEmpty( themeName ) ) { ThemeConverter themeConverter = new ThemeConverter(); toReturn.Theme = (Theme)themeConverter.ConvertFromString(themeName); } } return toReturn; } return base.ConvertFrom( context, culture, value ); }