public void should_parse_a_single_generic_argument() { const string typeName = "FubuMVC.Tests.View.Registration.Generic<FubuMVC.Tests.View.Registration.Baz>"; var type = ClassUnderTest.Parse(typeName); type.ShouldBe(typeof(Generic <Baz>)); }
public void should_parse_a_single_generic_argument() { const string typeName = "FubuMVC.Spark.Tests.SparkModel.Binding.Generic<FubuMVC.Spark.Tests.SparkModel.Binding.Baz>"; var type = ClassUnderTest.Parse(typeName); type.ShouldEqual(typeof(Generic <Baz>)); }
void ISelfParser.ParseAndFill(BinaryReader reader) { this.CodecId = reader.ReadByte(); this.NumberOfData1 = reader.ReadByte(); _data = new List <AvlData>(); for (var index = 0; index < this.NumberOfData1; index++) { var avlData = GenericParser.Parse <AvlData>(reader); _data.Add(avlData); } this.NumberOfData2 = reader.ReadByte(); if (this.NumberOfData1 != this.NumberOfData2) { throw new InvalidDataException("record counts are not equal"); } if (this.NumberOfData1 != _data.Count) { throw new InvalidDataException("record counts are not equal"); } if (reader.BaseStream.Position != reader.BaseStream.Length) { throw new InvalidDataException("unfinished avl array data"); } }
private static void TestParse <T>(string stringValue, T expectedValue) { var result1 = GenericParser.Parse <T>(stringValue); Assert.Equal(expectedValue, result1); var result2 = GenericParser.Parse(stringValue, typeof(T)); Assert.Equal(expectedValue, result2); var result3 = GenericParser.TryParse(stringValue, out T out1); Assert.True(result3); Assert.Equal(expectedValue, out1); var result4 = GenericParser.TryParse(stringValue, out object out2, typeof(T)); Assert.True(result4); Assert.Equal(expectedValue, out2); var result5 = stringValue.Parse <T>(); Assert.Equal(expectedValue, result5); var result6 = stringValue.Parse(typeof(T)); Assert.Equal(expectedValue, result6); }
void ISelfParser.ParseAndFill(BinaryReader reader) { this.TimeStamp = GenericParser.Parse <AvlTimeStamp>(reader); this.Priority = (AvlDataPriority)reader.ReadByte(); this.GpsElement = GenericParser.Parse <GpsElement>(reader); this.IoElement = GenericParser.Parse <IoElement>(reader); }
public async Task <List <Shop> > Load() { var shopRootNode = await GenericParser.Parse <ShopLayoutNode>(Path.Combine(DataRoot, @"Data\Libs\Subsumption\Shops\ShopLayouts.xml")); return(GetShops(shopRootNode).Select(GetShop).ToList()); }
public async Task <List <RetailProduct> > Load() { var productList = await GenericParser.Parse <Node>(Path.Combine(DataRoot, @"Data\Libs\Subsumption\Shops\RetailProductPrices.xml")); return(GetNodes(productList).Select(GetRetailProductFromNode).Where(i => i != null).ToList()); }
public void ParseWrongConcept_EmptyErrorForUnrecognizedKeyword() { var simpleParser = new GenericParser(typeof(SimpleConceptInfo), "simple"); var tokenReader = TestTokenReader("simp simple abc"); var ciOrError = simpleParser.Parse(tokenReader, new Stack <IConceptInfo>()); Assert.IsTrue(ciOrError.IsError); Assert.AreEqual("", ciOrError.Error); }
public Type FindTypeByName(string typeFullName, Assembly defaultAssembly, Action <string> log) { if (GenericParser.IsGeneric(typeFullName)) { var genericParser = new GenericParser(_types.Assemblies); return(genericParser.Parse(typeFullName)); } return(findClosedTypeByFullName(typeFullName, defaultAssembly, log)); }
public Type FindTypeByName(string typeFullName, Action <string> log) { if (GenericParser.IsGeneric(typeFullName)) { var genericParser = new GenericParser(_graph.AllAssemblies()); return(genericParser.Parse(typeFullName)); } return(findClosedTypeByFullName(typeFullName, log)); }
public void should_return_null_when_generic_argument_type_is_not_in_assemblies() { ClassUnderTest = new GenericParser(new[] { typeof(Bar).Assembly }); const string typeName = "FubuMVC.Spark.Tests.SparkModel.Binding.Generic<FubuMVC.Spark.Tests.SparkModel.Binding.Baz, System.String>"; var type = ClassUnderTest.Parse(typeName); type.ShouldBeNull(); }
public void should_return_null_when_type_is_not_in_assemblies() { ClassUnderTest = new GenericParser(new[] { typeof(String).Assembly }); const string typeName = "FubuMVC.Tests.View.Registration.Generic<FubuMVC.Tests.View.Registration.Baz>"; var type = ClassUnderTest.Parse(typeName); type.ShouldBeNull(); }
public void Bind(IBindRequest request) { var logger = request.Logger; var template = request.Target; var genericParser = new GenericParser(request.Types.Assemblies); var viewModel = genericParser.Parse(request.Parsing.ViewModelType); if (viewModel != null) { var descriptor = template.Descriptor.As <ViewDescriptor>(); descriptor.ViewModel = viewModel; logger.Log(template, "Generic view model type is : {0}", descriptor.ViewModel); return; } genericParser.ParseErrors.Each(error => logger.Log(template, error)); }
public ValueOrError <ConceptSyntaxNode> Parse(ITokenReader tokenReader, Stack <ConceptSyntaxNode> context, out List <string> warnings) => GenericParser.Parse(tokenReader, context, out warnings);
public T ParseAs <T>() where T : ISelfParser { return(GenericParser.Parse <T>(this.GetRawDataReader())); }
public T GetValue <T>(string key) { return(GenericParser.Parse <T>(_values[key])); }
public static object Parse(this string stringValue, Type type) { return(GenericParser.Parse(stringValue, type)); }
public void TestParse_Unknown() { Assert.Throws <ArgumentException>(() => { GenericParser.Parse <MockClass>("foo"); }); Assert.Throws <ArgumentException>(() => { GenericParser.Parse("foo", typeof(MockClass)); }); }
public static T Parse <T>(this string s) { return(GenericParser.Parse <T>(s)); }
public static T Parse <T>(this string stringValue) { return(GenericParser.Parse <T>(stringValue)); }
static void TestString(string testString) { object result = GenericParser.Parse(testString); Console.WriteLine("\"{0}\"\t => {1}", testString, result.GetType().Name); }