User: xtoff
Date: 2009/12/20 03:09 PM

Added:
 
/InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/Converters/
  NullableConverter.cs

Modified:
 /InversionOfControl/trunk/src/Castle.MicroKernel/
  Castle.MicroKernel-vs2008.csproj
 /InversionOfControl/trunk/src/Castle.MicroKernel/LifecycleConcerns/
  SupportInitializeConcern.cs
 /InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/
  DefaultConversionManager.cs
 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/FACILITIES-ISSUE-111/Components/
  A_Facilities_Issue_111.cs

Log:
 - Added NullableConverter for the Silverlight build

File Changes:

Directory: /InversionOfControl/trunk/src/Castle.MicroKernel/
============================================================

File [modified]: Castle.MicroKernel-vs2008.csproj
Delta lines: +0 -2
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel/LifecycleConcerns/SupportInitializeConcern.cs
       2009-12-20 14:42:53 UTC (rev 6505)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel/LifecycleConcerns/SupportInitializeConcern.cs
       2009-12-20 22:09:51 UTC (rev 6506)
@@ -44,7 +44,5 @@
                        (component as ISupportInitialize).EndInit();
                }
        }
-#else
-#warning ISupportInitialize is internal in Silverlight
 #endif

Directory: 
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/FACILITIES-ISSUE-111/Components/
===================================================================================================

File [modified]: A_Facilities_Issue_111.cs
Delta lines: +0 -0
===================================================================

Directory: 
/InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/
==================================================================================

File [modified]: DefaultConversionManager.cs
Delta lines: +4 -6
===================================================================

--- 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/FACILITIES-ISSUE-111/Components/A_Facilities_Issue_111.cs
    2009-12-20 14:42:53 UTC (rev 6505)
+++ 
InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/FACILITIES-ISSUE-111/Components/A_Facilities_Issue_111.cs
    2009-12-20 22:09:51 UTC (rev 6506)
@@ -1,11 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Castle.Core;
-
 namespace Castle.Windsor.Tests.Bugs.FACILITIES_ISSUE_111.Components
 {
+       using System;
+
+       using Castle.Core;
+
        public class A_Facilities_Issue_111 : IA_Facilities_Issue_111, 
IStartable
        {

Directory: 
/InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/Converters/
=============================================================================================

File [added]: NullableConverter.cs
Delta lines: +5 -4
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs
   2009-12-20 14:42:53 UTC (rev 6505)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/DefaultConversionManager.cs
   2009-12-20 22:09:51 UTC (rev 6506)
@@ -35,8 +35,8 @@
                [ThreadStatic]
                private static Stack<ComponentModel> slot;
 #endif
-        private readonly IList<ITypeConverter> converters = new 
List<ITypeConverter>();
-        private readonly IList<ITypeConverter> standAloneConverters = new 
List<ITypeConverter>();
+               private readonly IList<ITypeConverter> converters = new 
List<ITypeConverter>();
+               private readonly IList<ITypeConverter> standAloneConverters = 
new List<ITypeConverter>();
 
                public DefaultConversionManager()
                {
@@ -56,9 +56,10 @@
                        Add(new ArrayConverter());
                        Add(new ComponentConverter());
                        Add(new AttributeAwareConverter());
-#if (!SILVERLIGHT)
+#if (SILVERLIGHT)
+                       Add(new NullableConverter(this));
+#endif
                        Add(new ComponentModelConverter());
-#endif
                }
 

Directory: /InversionOfControl/trunk/src/Castle.MicroKernel/LifecycleConcerns/
==============================================================================

File [modified]: SupportInitializeConcern.cs
Delta lines: +59 -0
===================================================================

--- 
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/Converters/NullableConverter.cs
                               (rev 0)
+++ 
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Conversion/Converters/NullableConverter.cs
       2009-12-20 22:09:51 UTC (rev 6506)
@@ -0,0 +1,59 @@
+// Copyright 2004-2009 Castle Project - http://www.castleproject.org/
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Castle.MicroKernel.SubSystems.Conversion
+{
+#if (SILVERLIGHT)
+       using System;
+       using System.Linq;
+
+       using Castle.Core.Configuration;
+
+       public class NullableConverter:AbstractTypeConverter
+       {
+               private ITypeConverter innerConverter;
+
+               public NullableConverter(ITypeConverter innerConverter)
+               {
+                       this.innerConverter = innerConverter;
+               }
+
+               public override bool CanHandleType(Type type)
+               {
+                       return type.IsGenericType &&
+                              
type.GetGenericTypeDefinition().Equals(typeof(Nullable<>)) &&
+                              innerConverter.CanHandleType(GetInnerType(type));
+               }
+
+               private Type GetInnerType(Type type)
+               {
+                       return type.GetGenericArguments().Single();
+               }
+
+               public override object PerformConversion(string value, Type 
targetType)
+               {
+                       if(string.IsNullOrEmpty(value))
+                       {
+                               return null;
+                       }
+                       return innerConverter.PerformConversion(value, 
GetInnerType(targetType));
+               }
+
+               public override object PerformConversion(IConfiguration 
configuration, Type targetType)
+               {
+                       return PerformConversion(configuration.Value, 
targetType);
+               }
+       }
+#endif
+}

--

You received this message because you are subscribed to the Google Groups 
"Castle Project Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-commits?hl=en.


Reply via email to