2007-07-24 Igor Zelmanovich <igorz@mainsoft.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / FontNamesConverter.cs
index cc7d3e5604539f28bcc59c8adff4f7ec93682dc5..425ad8044794cca2d37787e8441d65647e595dd5 100644 (file)
@@ -1,5 +1,3 @@
-
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-/**\r
- * Namespace: System.Web.UI.WebControls\r
- * Class:     FontNamesConverter\r
- *\r
- * Author:  Gaurav Vaish\r
- * Maintainer: gvaish@iitk.ac.in\r
- * Contact: <my_scripts2001@yahoo.com>, <gvaish@iitk.ac.in>\r
- * Implementation: yes\r
- * Status:  100%\r
- *\r
- * (C) Gaurav Vaish (2002)\r
- */\r
-\r
-using System;\r
-using System.Globalization;\r
-using System.ComponentModel;\r
-using System.Web;\r
-using System.Web.UI;\r
-\r
-namespace System.Web.UI.WebControls\r
-{\r
-       public class FontNamesConverter : TypeConverter\r
-       {\r
-               public FontNamesConverter(): base()\r
-               {\r
-               }\r
-\r
-               public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)\r
-               {\r
-                       return (sourceType == typeof(string));\r
-               }\r
-\r
-               public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)\r
-               {\r
-                       if(value is string)\r
-                       {\r
-                               string fontNames = (string)value;\r
-                               if(fontNames.Length == 0)\r
-                               {\r
-                                       return (new string[0]);\r
-                               }\r
-                               string[] names = fontNames.Split(new char[] { ','});\r
-                               for(int i=0; i < names.Length; i++)\r
-                               {\r
-                                       names[i] = names[i].Trim();\r
-                               }\r
-                               return names;\r
-                       }\r
-                       throw GetConvertFromException(value);\r
-               }\r
-\r
-               public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)\r
-               {\r
-                       if(destinationType == typeof(string))\r
-                       {\r
-                               if(value == null || ((string[])value) == null)\r
-                                       return String.Empty;\r
-                               return String.Join(",", (string[])value);\r
-                       }\r
-                       throw GetConvertToException(value, destinationType);\r
-               }\r
-       }\r
-}\r
+// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+//     Peter Bartok    (pbartok@novell.com)
+//
+//
+
+using System.ComponentModel;
+using System.Globalization;
+using System.Security.Permissions;
+
+namespace System.Web.UI.WebControls {
+
+       // CAS
+       [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       public class FontNamesConverter : System.ComponentModel.TypeConverter 
+       {
+               #region Public Constructors
+               public FontNamesConverter() 
+               {
+               }
+               #endregion      // Public Constructors
+
+               #region Public Instance Methods
+               public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) 
+               {
+                       if (sourceType == typeof(string)) 
+                       {
+                               return true;
+                       }
+
+                       return base.CanConvertFrom(context, sourceType);
+               }
+
+               public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) 
+               {
+                       if (value is string) 
+                       {
+                               string[]        names;
+                               string          namelist;
+                               int             count;
+
+                               namelist = (string)value;
+
+                               if (namelist == string.Empty) 
+                               {
+                                       return new string[0];
+                               }
+
+                               names = namelist.Split(new char[] { ',' });
+
+                               count = names.Length;
+                               for (int i = 0; i < count; i++) 
+                               {
+                                       names[i] = names[i].Trim();
+                               }
+
+                               return names;
+                       }
+                       return base.ConvertFrom(context, culture, value);
+               }
+
+               public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) 
+               {
+                       if ((destinationType == typeof(string)) && (value is string[])) 
+                       {
+                               return String.Join(",", (string[])value);
+                       }
+                       return base.ConvertTo(context, culture, value, destinationType);
+               }
+               #endregion      // Public Instance Methods
+       }
+}