OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / design / RationalConverter.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/design/RationalConverter.cpp b/SlimDXc_Jun2010(VC++2008)/source/design/RationalConverter.cpp
deleted file mode 100644 (file)
index 53bf187..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-\r
-#include "../InternalHelpers.h"\r
-#include "../math/Rational.h"\r
-\r
-#include "RationalConverter.h"\r
-#include "FieldPropertyDescriptor.h"\r
-\r
-using namespace System;\r
-using namespace System::Collections;\r
-using namespace System::Drawing;\r
-using namespace System::ComponentModel;\r
-using namespace System::ComponentModel::Design::Serialization;\r
-using namespace System::Globalization;\r
-using namespace System::Reflection;\r
-\r
-namespace SlimDX\r
-{\r
-namespace Design\r
-{\r
-       RationalConverter::RationalConverter()\r
-       {\r
-               Type^ type = Rational::typeid;\r
-               array<PropertyDescriptor^>^ propArray =\r
-               {\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Numerator")),\r
-                       gcnew FieldPropertyDescriptor(type->GetField("Denominator")),\r
-               };\r
-\r
-               m_Properties = gcnew PropertyDescriptorCollection(propArray);\r
-       }\r
-\r
-       bool RationalConverter::CanConvertTo(ITypeDescriptorContext^ context, Type^ destinationType)\r
-       {\r
-               if( destinationType == String::typeid || destinationType == InstanceDescriptor::typeid )\r
-                       return true;\r
-               else\r
-                       return ExpandableObjectConverter::CanConvertTo(context, destinationType);\r
-       }\r
-\r
-       bool RationalConverter::CanConvertFrom(ITypeDescriptorContext^ context, Type^ sourceType)\r
-       {\r
-               if( sourceType == String::typeid )\r
-                       return true;\r
-               else\r
-                       return ExpandableObjectConverter::CanConvertFrom(context, sourceType);\r
-       }\r
-\r
-       Object^ RationalConverter::ConvertTo(ITypeDescriptorContext^ context, CultureInfo^ culture, Object^ value, Type^ destinationType)\r
-       {\r
-               if( destinationType == nullptr )\r
-                       throw gcnew ArgumentNullException( "destinationType" );\r
-\r
-               if( culture == nullptr )\r
-                       culture = CultureInfo::CurrentCulture;\r
-\r
-               Rational^ rational = dynamic_cast<Rational^>( value );\r
-\r
-               if( destinationType == String::typeid && rational != nullptr )\r
-               {\r
-                       String^ separator = culture->TextInfo->ListSeparator + " ";\r
-                       TypeConverter^ converter = TypeDescriptor::GetConverter(int::typeid);\r
-                       array<String^>^ stringArray = gcnew array<String^>( 2 );\r
-\r
-                       stringArray[0] = converter->ConvertToString( context, culture, rational->Numerator );\r
-                       stringArray[1] = converter->ConvertToString( context, culture, rational->Denominator );\r
-\r
-                       return String::Join( separator, stringArray );\r
-               }\r
-               else if( destinationType == InstanceDescriptor::typeid && rational != nullptr )\r
-               {\r
-                       ConstructorInfo^ info = (Rational::typeid)->GetConstructor( gcnew array<Type^> { int::typeid, int::typeid } );\r
-                       if( info != nullptr )\r
-                               return gcnew InstanceDescriptor( info, gcnew array<Object^> { rational->Numerator, rational->Denominator } );\r
-               }\r
-\r
-               return ExpandableObjectConverter::ConvertTo(context, culture, value, destinationType);\r
-       }\r
-\r
-       Object^ RationalConverter::ConvertFrom(ITypeDescriptorContext^ context, CultureInfo^ culture, Object^ value)\r
-       {\r
-               if( culture == nullptr )\r
-                       culture = CultureInfo::CurrentCulture;\r
-\r
-               String^ string = dynamic_cast<String^>( value );\r
-\r
-               if( string != nullptr )\r
-               {\r
-                       string = string->Trim();\r
-                       TypeConverter^ converter = TypeDescriptor::GetConverter(int::typeid);\r
-                       array<String^>^ stringArray = string->Split( culture->TextInfo->ListSeparator[0] );\r
-\r
-                       if( stringArray->Length != 2 )\r
-                               throw gcnew ArgumentException("Invalid rational format.");\r
-\r
-                       int Numerator = safe_cast<int>( converter->ConvertFromString( context, culture, stringArray[0] ) );\r
-                       int Denominator = safe_cast<int>( converter->ConvertFromString( context, culture, stringArray[1] ) );\r
-\r
-                       return gcnew Rational(Numerator, Denominator);\r
-               }\r
-\r
-               return ExpandableObjectConverter::ConvertFrom(context, culture, value);\r
-       }\r
-\r
-       bool RationalConverter::GetCreateInstanceSupported(ITypeDescriptorContext^ context)\r
-       {\r
-               SLIMDX_UNREFERENCED_PARAMETER(context);\r
-\r
-               return true;\r
-       }\r
-\r
-       Object^ RationalConverter::CreateInstance(ITypeDescriptorContext^ context, IDictionary^ propertyValues)\r
-       {\r
-               SLIMDX_UNREFERENCED_PARAMETER(context);\r
-\r
-               if( propertyValues == nullptr )\r
-                       throw gcnew ArgumentNullException( "propertyValues" );\r
-\r
-               return gcnew Rational( safe_cast<int>( propertyValues["Numerator"] ), safe_cast<int>( propertyValues["Denominator"] ) );\r
-       }\r
-\r
-       bool RationalConverter::GetPropertiesSupported(ITypeDescriptorContext^)\r
-       {\r
-               return true;\r
-       }\r
-\r
-       PropertyDescriptorCollection^ RationalConverter::GetProperties(ITypeDescriptorContext^, Object^, array<Attribute^>^)\r
-       {\r
-               return m_Properties;\r
-       }\r
-}\r
-}
\ No newline at end of file