public void Test_Implicit_String() { var obj = new ConversionClass(); var name = obj.DoSomeImplicit(); Assert.AreEqual(name, "awais cheema"); }
private static ConversionClass ClassifyCLRArrayToInterfaceConversion(Type TargetInterface, Type SourceArrayType) { if (!Symbols.Implements(SourceArrayType, TargetInterface)) { if (SourceArrayType.GetArrayRank() > 1) { return(ConversionClass.Narrowing); } Type elementType = SourceArrayType.GetElementType(); ConversionClass none = ConversionClass.None; if (TargetInterface.IsGenericType && !TargetInterface.IsGenericTypeDefinition) { Type genericTypeDefinition = TargetInterface.GetGenericTypeDefinition(); if (((genericTypeDefinition == typeof(IList <>)) || (genericTypeDefinition == typeof(ICollection <>))) || (genericTypeDefinition == typeof(IEnumerable <>))) { none = ClassifyCLRConversionForArrayElementTypes(TargetInterface.GetGenericArguments()[0], elementType); } } else { #if NOT_PFX none = ClassifyPredefinedCLRConversion(TargetInterface, typeof(IList <>).MakeGenericType(new Type[] { elementType })); #else throw new NotImplementedException(); #endif } if ((none != ConversionClass.Identity) && (none != ConversionClass.Widening)) { return(ConversionClass.Narrowing); } } return(ConversionClass.Widening); }
private static bool NotEncompasses(Type Larger, Type Smaller) { ConversionClass class2 = ClassifyPredefinedConversion(Larger, Smaller); if ((class2 != ConversionClass.Narrowing) && (class2 != ConversionClass.Identity)) { return(false); } return(true); }
static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), arrTemp => Convert.ToInt32(arrTemp)); var myConversion = new ConversionClass(); Console.WriteLine(myConversion.Reverse(arr.Take(n).ToArray())); }
internal static ConversionClass ClassifyConversion(Type TargetType, Type SourceType, ref Symbols.Method OperatorMethod) { ConversionClass class3 = ClassifyPredefinedConversion(TargetType, SourceType); if ((((class3 != ConversionClass.None) || Symbols.IsInterface(SourceType)) || Symbols.IsInterface(TargetType)) || (!Symbols.IsClassOrValueType(SourceType) && !Symbols.IsClassOrValueType(TargetType))) { return(class3); } if (Symbols.IsIntrinsicType(SourceType) && Symbols.IsIntrinsicType(TargetType)) { return(class3); } return(ClassifyUserDefinedConversion(TargetType, SourceType, ref OperatorMethod)); }
public async Task TypeConvertFrom() { const string value = "value"; var obj = new ConversionClass(); var provider = new ReflectionEditorProvider(); IObjectEditor editor = await provider.GetObjectEditorAsync(obj); Assume.That(editor.Properties.Count, Is.EqualTo(1)); await editor.SetValueAsync(editor.Properties.Single(), new ValueInfo <string> { Value = value, Source = ValueSource.Local }); Assert.That(obj.Property, Is.Not.Null); Assert.That(obj.Property.Property, Is.EqualTo(value)); }
public async Task TypeConverterTo() { const string value = "value"; var obj = new ConversionClass { Property = new TestClass { Property = value } }; var provider = new ReflectionEditorProvider(); IObjectEditor editor = await provider.GetObjectEditorAsync(obj); Assume.That(editor.Properties.Count, Is.EqualTo(1)); ValueInfo <string> info = await editor.GetValueAsync <string> (editor.Properties.Single()); Assert.That(info.Value, Is.EqualTo(value)); Assert.That(info.Source, Is.EqualTo(ValueSource.Local)); }
internal static ConversionClass ClassifyUserDefinedConversion(Type TargetType, Type SourceType, ref Symbols.Method OperatorMethod) { ConversionClass class3 = 0; OperatorCaches.FixedList conversionCache = OperatorCaches.ConversionCache; lock (conversionCache) { if (OperatorCaches.UnconvertibleTypeCache.Lookup(TargetType) && OperatorCaches.UnconvertibleTypeCache.Lookup(SourceType)) { return(ConversionClass.None); } if (OperatorCaches.ConversionCache.Lookup(TargetType, SourceType, ref class3, ref OperatorMethod)) { return(class3); } } bool foundTargetTypeOperators = false; bool foundSourceTypeOperators = false; class3 = DoClassifyUserDefinedConversion(TargetType, SourceType, ref OperatorMethod, ref foundTargetTypeOperators, ref foundSourceTypeOperators); OperatorCaches.FixedList list2 = OperatorCaches.ConversionCache; lock (list2) { if (!foundTargetTypeOperators) { OperatorCaches.UnconvertibleTypeCache.Insert(TargetType); } if (!foundSourceTypeOperators) { OperatorCaches.UnconvertibleTypeCache.Insert(SourceType); } if (!foundTargetTypeOperators && !foundSourceTypeOperators) { return(class3); } OperatorCaches.ConversionCache.Insert(TargetType, SourceType, class3, OperatorMethod); } return(class3); }
static void Main(string[] args) { var conv = new ConversionClass(26); byte[] mas = { 139, 52, 27, 139, 53, 27, 139, 54, 27, 139, 55, 27, 139, 56, 27, 139, 53, 27, 139, 56, 47, 139, 66, 47 }; int erros = 0; int num = 0; int res; do { res = conv.Conversion(mas, (uint)mas.Length, true, ref erros); if (res > 6) { var resArray = conv.Read(0, 10); } }while (true); Console.WriteLine("Gotcha"); }
void Start () { // Initialization of the main menu showListLanguage = false; hideMenuGUI = false; theScene = gameObject.GetComponent<BaseSceneClass>(); dataBase = gameObject.GetComponent<ConversionClass>(); // The setting of the GUI style for Pop up calls theListStyle.fontSize = ( BaseSceneClass.ourScreen.width / 100f < 16f ) ? 16 : ( int ) BaseSceneClass.ourScreen.width / 100; theListStyle.normal.textColor = Color.white; theListStyle.padding.left = theListStyle.padding.right = theListStyle.padding.top = theListStyle.padding.bottom = 4; if ( sample1 == null ) theListStyle.onHover.background = theListStyle.hover.background = new Texture2D( 2, 2 ); else { theListStyle.normal.background = sample1; theListStyle.onHover.background = theListStyle.hover.background = sample2; } }
public TemperatureConversion() { InitializeComponent(); _convTemp = new ConversionClass(); }
public static void Main(string[] args) { var conversionClass = new ConversionClass(); conversionClass.ConvertFile(args); }