private static TypeDescription GetTypeDescription(Type sourceClass) { var propertySource = new ClassSource(sourceClass); var typeDesctiption = new TypeDescription(sourceClass.FullName, propertySource.GetProperties()); return(typeDesctiption); }
private string GetOrCreateDexFilename(ClassSource source, string hash) { string jarFileName = GetJarFileName(source, hash); if (!source.IsDiskFile && !File.Exists(jarFileName)) { Directory.CreateDirectory(_temporaryDirectory); File.WriteAllBytes(jarFileName, source.JarData); } string baseName = Path.GetFileNameWithoutExtension(jarFileName); if (!baseName.Contains(hash)) { baseName += "." + hash; } var dexFileName = Path.Combine(_temporaryDirectory, baseName + ".dex"); if (!File.Exists(dexFileName)) { Directory.CreateDirectory(_temporaryDirectory); DxInvoker.CompileToDex(jarFileName, dexFileName, _generateDebugSymbols); } return(dexFileName); }
public void GetProperties_should_return_property_with_only_set_method() { ClassSource classSource = new ClassSource(typeof(IOnlySet)); var result = classSource.GetProperties(); Assert.AreEqual(1, result.Count()); result.ShouldContainsKeyAndValue("Text", typeof(string)); }
public void GetProperties_should_return_all_properties_from_simple_class() { ClassSource classSource = new ClassSource(typeof(SimpleClass)); var result = classSource.GetProperties(); Assert.AreEqual(2, result.Count()); result.ShouldContainsKeyAndValue("Number", typeof(int)); result.ShouldContainsKeyAndValue("Text", typeof(string)); }
private string GetJarFileName(ClassSource source, string hash) { if (source.IsDiskFile) { return(source.FileName); } string baseName = Path.GetFileName(source.FileName); return(Path.Combine(_temporaryDirectory, baseName + "-" + hash + ".jar")); }
private string GetHash(ClassSource source) { if (source.JarStreamHash != null) { return(source.JarStreamHash); } if (source.JarData != null) { return(JarReferenceHash.ComputeJarReferenceHash(source.JarData)); } return(JarReferenceHash.ComputeJarReferenceHash(source.FileName)); }
public void Map_Success() { ClassDest actual = null; ClassSource expected = Builder <ClassSource> .CreateNew().Build(); Init(null); Mapper.Initialize(); actual = Mapper <ClassDest> .Map(expected); Assert.IsNotNull(actual); Assert.AreEqual(actual.PropInt1, expected.PropInt1); Assert.AreEqual(actual.PropString2, expected.PropString1); Clean(); }
public void Map_ReturnDestinationObject_Success() { Mapper.Initialize(); ClassDest actual = null; ClassSource expected = new ClassSource() { PropInt1 = 1, PropSourceInt1 = 1, PropString1 = "test" }; actual = Mapper.Map <ClassSource, ClassDest>(expected); Assert.AreEqual(actual.PropInt1, expected.PropInt1); Assert.AreEqual(actual.PropString2, expected.PropString1); Assert.AreEqual(actual.PropInt2, 0); }
public void Map_ReturnDestinationObject_Success() { ExpressionMapper.Initialize(); ClassSource expected = new ClassSource() { PropInt1 = 1, PropSourceInt1 = 1, PropString1 = "test" }; var actual = expected.Map <ClassSource, ClassDest>(); Assert.Equal(actual.PropInt1, expected.PropInt1); Assert.Equal(actual.PropString2, expected.PropString1); Assert.Equal(0, actual.PropInt2); }
static void Main(string[] args) { List <Register> students = ClassSource.GetStudents(); // Bu örnek, 1.yazılı sınav notu 55 ve daha büyük olan öğrencileri //1.sınav notlarına göre artan sırada(küçükten büyüğe) seçer. var query = from student in students where student.Notes[0] >= 55 orderby student.Notes[0] select student; foreach (var student in query) { Console.WriteLine(student.Name); } Console.ReadKey(); /* * // LINQ Yöntem Sözdizimi ile sorgu : * var query = students.Where(std => std.Notes[0] >= 55) * .OrderBy(std => std.Notes[0]); */ Console.WriteLine("---------------"); //Eğer tersine bir sıralama isteniyorsa descending ifadesi //cümleciğin sonuna eklenir. var query2 = from student in students where student.Notes[0] >= 55 orderby student.Notes[0] descending select student; foreach (var student in query2) { Console.WriteLine(student.Name); } Console.ReadKey(); /* * // LINQ Yöntem Sözdizimi ile sorgu : * var query = students.Where(std => std.Notes[0] >= 55) * .OrderByDescending(std => std.Notes[0]); */ }
public ITurnamentorBuilder <Contestant, Score, ScoreBoard> SetGameEngine(ClassSource source, string directoryWithFile) { ITypeLoader loader = GetTypeLoader(source); var types = loader.LoadTypes <IGameEngine <Contestant, Score> >(new string[] { directoryWithFile }); if (types.Count == 0) { throw new NoInstanceOfGameEngineFoundException(); } if (types.Count > 1) { throw new AmbiguousGameEngine(); } turnamentor.EngineProvider = () => Activator.CreateInstance(types[0]); return(this); }
public void Map_Return_null() { ClassDest actual = null; ClassSource expected = new ClassSource() { PropInt1 = 1, PropSourceInt1 = 1, PropString1 = "test" }; using (ShimsContext.Create()) { MapperExpression.Core.Fakes.ShimMapperConfiguration <ClassSource, ClassDest> .AllInstances.GetFuncDelegate = (s) => { return(null); }; actual = Mapper.Map <ClassSource, ClassDest>(expected); } Assert.IsNull(actual); }
public ITurnamentorBuilder <Contestant, Score, ScoreBoard> AddContestants(ClassSource source, params string[] directories) { ITypeLoader loader = GetTypeLoader(source); if (directories.Length == 0) { directories = new string[] { "" } } ; //add at least work directory var loadedTypes = loader.LoadTypes <Contestant>(directories); roundSelectorConfig.Contestants.AddRange( loadedTypes.Where(type => !roundSelectorConfig.Contestants.Contains(type)) ); return(this); }
public void Map_MapperNotInitialise_Exception() { Mapper.CreateMap <ClassSource, ClassDest>() .ForMember(s => s.PropString1, d => d.PropString2); ClassDest actual = null; ClassSource expected = new ClassSource() { PropInt1 = 1, PropSourceInt1 = 1, PropString1 = "test" }; using (ShimsContext.Create()) { MapperExpression.Core.Fakes.ShimMapperConfiguration <ClassSource, ClassDest> .AllInstances.GetFuncDelegate = (s) => { throw new MapperNotInitializedException(typeof(ClassSource), typeof(ClassDest)); }; actual = Mapper.Map <ClassSource, ClassDest>(expected); } }
static void Main(string[] args) { List <Register> students = ClassSource.GetStudents(); //(1. yazılı sınav notu 55 ve daha büyük olan öğrencilerin soyadlarını seç.) var query = from student in students where student.Notes[0] >= 55 select student.Surname; foreach (var s in query) { Console.WriteLine(s); } Console.ReadKey(); /* //LINQ Yöntem Sözdizimi ile sorgu : * var query = students.Where(std => std.Notes[0] >= 55) * .Select(ogr => ogr.Surname); */ Console.WriteLine("---------------"); var query2 = from student in students where student.Notes[0] >= 55 && student.Success == false select student; foreach (var s in query2) { Console.WriteLine(s.Surname); } Console.ReadKey(); /* * // LINQ Yöntem Sözdizimi ile sorgu : * var query = students.Where(std => std.Notes[0] >= 55 && ogr.Success == false); */ }
private DexLookup GetOrCreateDex(ClassSource source, bool waitForResult) { string hash = GetHash(source); var jarFileName = GetJarFileName(source, hash); Task <DexLookup> dex; lock (_dexes) { if (_dexes.TryGetValue(jarFileName, out dex)) { if (!waitForResult) { return(null); } return(dex.Result); } dex = new Task <DexLookup>(() => { var dexFileName = GetOrCreateDexFilename(source, hash); return(new DexLookup(DexLib.Dex.Read(dexFileName))); }, TaskCreationOptions.LongRunning); _dexes[jarFileName] = dex; } dex.Start(); if (waitForResult) { return(dex.Result); } return(null); }
private ITypeLoader GetTypeLoader(ClassSource source) => source switch {
public void PreloadJar(ClassSource source) { GetOrCreateDex(source, waitForResult: false); }
public void Ctor_should_throw_exception_when_value_is_null() { ClassSource classSource = new ClassSource(null); }