public XmlParameterMapping(MethodInfo methodInfo, XElement xParameter) { DbParameterName = xParameter.Attribute("db-name").Value; var parameterName = xParameter.Attribute("name").Value; Parameter = methodInfo.GetParameters().FirstOrDefault(p => p.Name == parameterName); if (Parameter == null) { throw new DocumentParseException("Canot find parameter '{0}'", parameterName); } XAttribute xConverter; if (xParameter.TryGetAttribute("converter", out xConverter)) { Converter = ConverterFactory.Create(xConverter.Value); } XAttribute xDbType; if (xParameter.TryGetAttribute("db-type", out xDbType)) { DbType = xDbType.GetAsEnum <DbType>(); } XAttribute xLength; if (xParameter.TryGetAttribute("length", out xLength)) { Length = xLength.GetAsInt(); } }
/// <summary> /// load main method /// </summary> static void Main() { PreInputMessage(); ILogger logger = new ConsoleLogger(); IConverterProcessor numConvert = ConverterFactory.GetProcessorFactory(CountryEnum.British, logger); while (true) { Console.ForegroundColor = ConsoleColor.White; var query = Console.ReadLine(); if (query == "EXIT") { break; } if (ValidationInput.IsValidInput(query) == ErrorCode.Valid) { var result = numConvert.ConvertDigitToString(Convert.ToInt32(query)); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(result); } else { logger.LogError("Invalid Input"); } PostInputMessage(); } }
public void UpdateTextCreative() { TextAdCreative creative = TextAdCreative.Create(15073UL, 16244UL, 29834UL, 100UL, new AdAction(0U)); creative.Name = "12update"; creative.Action.Id = 2; creative.Status = AdStatus.Launching; creative.Size.ImageSizeId = 30; creative.LogoImageUrl = "http://172.16.18.6/conversion/15135/c7751dd234cd4414b8e9dc704c4e2cc7.png"; creative.Title = "12"; creative.Desc1 = "12"; creative.Desc2 = "12"; creative.DisplayUrl = "www.baidu.com.cn"; creative.DestinationUrl = "www.google.com.cn"; _adTextCreativeData = ConverterFactory.GetAdTextCreativeConverter().ConvertToNetworkObject(creative); UpdateAdTextCreativeByIdProcessor processor = new UpdateAdTextCreativeByIdProcessor(); FakedBusinessTransaction transaction = new FakedBusinessTransaction(); transaction.Request = new UpdateAdTextCreativeByIdRequestMessage { UserId = 9083, AccountId = 6179, Data = _adTextCreativeData }; processor.Process(transaction); UpdateAdTextCreativeByIdResponseMessage rspMsg = (UpdateAdTextCreativeByIdResponseMessage)transaction.Response; }
static XmlMappingBuilder() { var assembly = Assembly.GetAssembly(typeof(XmlMappingBuilder)); var tableMappingSchemaStream = assembly.GetManifestResourceStream("SimpleORM.Impl.Mappings.Xml.XSD.TableMapping.xsd"); if (tableMappingSchemaStream == null) { throw new Exception("Cannot find table mapping schema"); } var viewMappingSchemaStream = assembly.GetManifestResourceStream("SimpleORM.Impl.Mappings.Xml.XSD.ViewMapping.xsd"); if (viewMappingSchemaStream == null) { throw new Exception("Cannot find view mapping schema"); } RegisterMappingBuilder("table-mapping", new StreamReader(tableMappingSchemaStream), xMapping => new XmlTableMapping(xMapping)); RegisterMappingBuilder("view-mapping", new StreamReader(viewMappingSchemaStream), xMapping => new XmlViewMapping(xMapping)); ConverterFactory.RegisterShorthand <YesNoConverter>("YN"); ConverterFactory.RegisterShorthand <LowerYesNoConverter>("yn"); ConverterFactory.RegisterShorthand <TrueFalseConverter>("TF"); ConverterFactory.RegisterShorthand <LowerTrueFalseConverter>("tf"); }
public void SetConverterFactory(ConverterFactory factory) { for (int i = 0; i < _all.Count; i++) { _all[i].SetConverterFactory(factory); } }
static void Main(string[] args) { var imagePath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Samples" + Path.DirectorySeparatorChar + "dotbot.jpg"; var percentage = 0.05f; var convertFactory = new ConverterFactory( new ImageConverter( new ImageBytes(), new ImageGrayscale(), new ImageResizer() ), new BytesConverter() ); var text = convertFactory.Convert(imagePath, percentage, DefaultRamps.DefaultRamp); var tmp = Path.GetTempFileName() + ".txt"; File.WriteAllLines(tmp, text); // var process = new Process(); process.StartInfo = new ProcessStartInfo() { UseShellExecute = true, FileName = tmp }; process.Start(); process.WaitForExit(); }
public override void SetConverterFactory(ConverterFactory factory) { base.SetConverterFactory(factory); _exceptionConverter = factory.CreateExceptionConverter(); _stackSourceConverter = factory.CreateStackSourceConverter(); }
/// <summary> /// Устанавливает фабрику для создания конвертеров, /// необходимых для преобразования логируемых данных в строки для вывода в файл или консоль /// </summary> /// <param name="factory"></param> public override void SetConverterFactory(ConverterFactory factory) { base.SetConverterFactory(factory); _templateConverter = TemplateParser.Parse(_rawTemplate, factory); _filenameConverter = TemplateParser.Parse(_rawFilename, factory); }
static void Main(string[] args) { if (args.Length != 1) { Console.Error.WriteLine("The program accept only 1 argument, arabic or roman numeral!"); return; } string argument = args[0]; int.TryParse(argument, out int result); IConverter <string, int> converter = ConverterFactory.Build <string, int>(); IValidator <string, int> validator = ValidatorFactory.Build <string, int>(); if (result > 0) { if (!validator.validateFrom(result)) { Console.Error.WriteLine($"The number ( {result} ) can't be converted to roman numerals, please provide number in range 0-3999"); return; } Console.WriteLine("The converted roman numeral is " + converter.convertFrom(result)); } else { if (!validator.validateTo(argument)) { Console.Error.WriteLine("Can't be convert roman numeral to arabic number, please provide a valid roman numeral"); return; } Console.WriteLine("The converted arabic numeral is " + converter.convertTo(argument)); } }
static void Main(string[] args) { //CreateResultFileTest(); /*var converter = new ConverterFactory().CreateWcfConverterV1(new EndpointAddress("http://*****:*****@"d:\LO-PDF\test.txt", @"d:\LO-PDF\resume.pdf");*/ //(new PrecizeSoft.IO.Tests.Converters.LOToPdfConverterTests()).ParallelTest(@"..\..\..\precizesoft-io\tests\samples\mini.docx", 100, 2, false); //ConvertBytesTest(@"d:\LO-PDF\resume.docx", @"d:\LO-PDF\resume.pdf"); LOEnvironment.ConfigureFromRegistry(); // LOEnvironment.ConfigureByUnoPath(@"D:\LibreOfficePortable\App\libreoffice\program"); var factory = new ConverterFactory(); //var converter = factory.CreateWcfConverterV1(new EndpointAddress("http://*****:*****@"resume.docx", @"resume.pdf"); /*(new Task(() => { converter.Convert(@"d:\LO-PDF\resume.docx", @"d:\LO-PDF\resume.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume2.docx", @"d:\LO-PDF\resume2.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume3.docx", @"d:\LO-PDF\resume3.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume4.docx", @"d:\LO-PDF\resume4.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume5.docx", @"d:\LO-PDF\resume5.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume6.docx", @"d:\LO-PDF\resume6.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume7.docx", @"d:\LO-PDF\resume7.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume8.docx", @"d:\LO-PDF\resume8.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume9.docx", @"d:\LO-PDF\resume9.pdf"); })).Start(); * (new Task(() => { converter.Convert(@"d:\LO-PDF\resume10.docx", @"d:\LO-PDF\resume10.pdf"); })).Start();*/ Console.WriteLine("Finished"); Console.ReadKey(); }
public static object StringToField(this IFieldInfoDescriptor fieldDescriptor, string value) { if (value == null) { return(null); } value = fieldDescriptor.StringTrim(value); if (string.Empty.Equals(value) && fieldDescriptor.Converter == null) { return(value); } if (fieldDescriptor.Converter == null && fieldDescriptor.Type == null) { return(value); } ConverterBase converterInstance = fieldDescriptor.Converter == null ? ConverterFactory.GetDefaultConverter(fieldDescriptor.Type, fieldDescriptor.ConverterFormat) : ConverterFactory.GetConverter(fieldDescriptor.Converter, fieldDescriptor.ConverterFormat); return(converterInstance == null ? value : converterInstance.StringToField(value)); }
public void CreateNewTextCreative() { TextAdCreative creative = TextAdCreative.Create(14788UL, 16165UL, 0UL, 100UL, new AdAction(3U)); creative.Name = "12"; creative.Action.Id = 2; creative.Status = AdStatus.Launching; creative.Size.ImageSizeId = 30; creative.LogoImageUrl = "http://172.16.18.6/conversion/15135/c7751dd234cd4414b8e9dc704c4e2cc7.png"; creative.Title = "12"; creative.Desc1 = "12"; creative.Desc2 = "12"; creative.DisplayUrl = "www.baidu.com"; creative.DestinationUrl = "www.google.com"; creative.CustomElement.AddElementItem(1, "123"); creative.CustomElement.AddElementItem(5, "123"); creative.CustomElement.AddElementItem(8, "123"); _adTextCreativeData = ConverterFactory.GetAdTextCreativeConverter().ConvertToNetworkObject(creative); CreateNewAdTextCreativeProcessor processor = new CreateNewAdTextCreativeProcessor(); FakedBusinessTransaction transaction = new FakedBusinessTransaction(); transaction.Request = new CreateNewAdTextCreativeRequestMessage { UserId = 9062, AccountId = 5715, Data = _adTextCreativeData }; processor.Process(transaction); CreateNewAdTextCreativeResponseMessage rspMsg = (CreateNewAdTextCreativeResponseMessage)transaction.Response; }
public async Task <string> ConvertAsync(ConverterType converterType, string input, bool writeGeneratorHeader = true, StringWriter stringWriter = null) { bool dispose = false; if (stringWriter == null) { stringWriter = new StringWriter(); dispose = true; } if (writeGeneratorHeader) { stringWriter.WriteClassStudioHeader(); } await ConverterFactory.Get(converterType).ConvertAsync(input, stringWriter).ConfigureAwait(false); string result = stringWriter.ToString(); if (dispose) { await stringWriter.DisposeAsync(); } return(result); }
public void UpdateCampaign() { GeoTargeting currentGeo = new GeoTargeting("512,513"); DateTime startTime = new DateTime(2013, 5, 24, 12, 00, 0, 0); DateTime endTime = new DateTime(2013, 5, 29, 12, 00, 0, 0); campaign = Campaign.Create(5661, 13985, 1, currentGeo, BidTypes.CPC, true, startTime, AdSourceTypes.MobiSage); campaign.EndDate = endTime; campaign.Name = "111"; campaign.Status = AdStatus.Delete; campaign.IsMoreDaysBudget = 1; campaign.MoreDayBudget.Initialize(null); campaign.MoreDayBudget.Initialize("('2012-05-25 00:00:00','66.0000'),('2012-05-26 00:00:00','66.0000'),('2012-05-27 00:00:00','66.0000'),('2012-05-28 00:00:00','66.0000'),('2012-05-29 00:00:00','66.0000')"); campaign.DailyBudget = 5; campaign.AdUrl = "http://iphone.myzaker.com/zaker/ad/adsage.php?u={udid}&t={timestamp}"; campaign.AppleStore = ""; campaignData = ConverterFactory.GetCampaignConverter().ConvertToNetworkObject(campaign); UpdateCampaignByIdProcessor processor = new UpdateCampaignByIdProcessor(); FakedBusinessTransaction transaction = new FakedBusinessTransaction(); transaction.Request = new UpdateCampaignByIdRequestMessage { UserId = 4696, Data = campaignData }; processor.Process(transaction); UpdateCampaignByIdResponseMessage rsqMsg = (UpdateCampaignByIdResponseMessage)transaction.Response; }
public void CreateCampaign() { GeoTargeting currentGeo = new GeoTargeting("512,513"); DateTime startTime = new DateTime(2013, 12, 30, 14, 00, 0, 0); DateTime endTime = new DateTime(2014, 1, 1, 00, 00, 0, 0); campaign = Campaign.Create(5709, 0, 1, currentGeo, BidTypes.CPC, true, startTime, AdSourceTypes.AdHub); campaign.EndDate = endTime; campaign.Name = "7777"; campaign.Status = AdStatus.Launching; campaign.IsMoreDaysBudget = 0; //campaign.MoreDayBudget.Initialize("('2013-06-04','3'),('2013-06-05','3'),('2013-06-06','3')"); campaign.DailyBudget = 5; campaign.AdUrl = "http://iphone.myzaker.com/zaker/ad/adsage.php?u={udid}&t={timestamp}"; campaign.AppleStore = ""; //campaignData = new CampaignData {AccountId = 5661}; campaignData = ConverterFactory.GetCampaignConverter().ConvertToNetworkObject(campaign); CreateNewCampaignProcessor processor = new CreateNewCampaignProcessor(); FakedBusinessTransaction transaction = new FakedBusinessTransaction(); transaction.Request = new CreateNewCampaignRequestMessage { UserId = 4696, Data = campaignData }; processor.Process(transaction); CreateNewCampaignResponseMessage rspMsg = (CreateNewCampaignResponseMessage)transaction.Response; }
public void Campaign_GetCampaigns_SucceedTest() { Exception exception = null; IExecuteResult executeResult; executeResult = _proxy.GetCampaigns(5658UL); if (executeResult.State != ExecuteResults.Succeed) { Console.WriteLine(executeResult.Error); exception = new Exception(executeResult.Error); } if (exception != null) { throw exception; } Campaign[] campaigns = executeResult.GetResult <Campaign[]>(); if (campaigns != null) { Console.WriteLine("#Get Campaigns Count: " + campaigns.Length); foreach (Campaign campaign in executeResult.GetResult <Campaign[]>()) { Console.WriteLine(ConverterFactory.GetCampaignConverter().ConvertToNetworkObject(campaign)); } } }
// TODO: review private async Task ConvertAndSendSurveyResultAsync(SurveyResult surveyResult, IEnumerable <SurveyQuestionResultDTO> results) { if (surveyResult == null) { return; } var lmsUserParameters = surveyResult.LmsUserParametersId.HasValue ? this.LmsUserParametersModel.GetOneById(surveyResult.LmsUserParametersId.Value).Value : null; if (lmsUserParameters == null) { return; } var lmsSurveyId = surveyResult.Survey.LmsSurveyId; if (lmsSurveyId == null) { return; } var converter = ConverterFactory.GetResultConverter((LmsProviderEnum)lmsUserParameters.CompanyLms.LmsProviderId); await converter.ConvertAndSendSurveyResultToLmsAsync(results, surveyResult, lmsUserParameters); }
public void NotRegisteredConverter() { var converterId = "chat/minecraft"; var factory = new ConverterFactory(); Assert.Throws <System.Exception>(() => factory.ConvertFile(path), $"No Converter found for the passed identifier '{converterId}' or fileextetnion '{System.IO.Path.GetExtension(path)}'"); }
/// <summary> /// <para> /// Decodes the input from Watson Representation to the specified format in <paramref name="options"/> and outputs it to the standard output /// Will read from the standard input if no files are specified /// </para> /// </summary> /// <param name="options">The decoding options</param> /// <returns>A string containing the Watson input in the specified format</returns> public static string Decode(DecodeOptions options) { var vm = new VM(new Lexer(options.InitialMode)); Converter converter = ConverterFactory.GetConverter(options.Type); string input; string output = null; if (options.Files.Count() == 0) { input = Console.ReadLine(); output = converter.Decode(input, vm); } else { var sb = new StringBuilder(); foreach (var file in options.Files) { using (var fileStream = new FileStream(file, FileMode.Open)) { using (var reader = new StreamReader(fileStream)) { output = converter.Decode(reader.ReadToEnd(), vm); } } } } return(output); }
public object OutputValue() { var converter = ConverterFactory.GetConverter(Definition); var output = converter.Output(Value); return(output); }
/// <summary> /// <para>Encodes the input to Watson Representation using <paramref name="options"/> and outputs it to the standard output. /// Will read from the standard input if the file isn't specified /// </para> /// </summary> /// <param name="options">The encoding options</param> /// <returns>A string containing the input's Watson Representation</returns> public static string Encode(EncodeOptions options) { var vm = new VM(options.InitialMode); Converter converter = ConverterFactory.GetConverter(options.Type); string output; if (options.File == null) { string input = Console.ReadLine(); output = converter.Encode(input, vm); } else { using (var fileStream = new FileStream(options.File, FileMode.Open)) { using (var streamReader = new StreamReader(fileStream)) { output = converter.Encode(streamReader.ReadToEnd(), vm); } } } return(output); }
/// <summary> /// <para> /// Encodes the input to Watson Representation using <paramref name="options"/> and stores it in <paramref name="stream"/> /// </para> /// </summary> /// <param name="options">The encoding options</param> /// <param name="stream">The output stream</param> public static void Encode(EncodeOptions options, Stream stream) { var vm = new VM(options.InitialMode); Converter converter = ConverterFactory.GetConverter(options.Type); using (var writer = new StreamWriter(stream)) { if (options.File == null) { string input = Console.ReadLine(); writer.Write(converter.Encode(input, vm)); } else { using (var fileStream = new FileStream(options.File, FileMode.Open)) { using (var reader = new StreamReader(fileStream)) { converter.Encode(reader, writer, vm); } } } } }
/// <summary> /// Iterates through the process model and creates the parsed solidity structure /// BFS algorithm is used to go through the model. /// !!! This approach is not very efficient and may create further issues if expanded upon. /// I have chosen it for simplicity, better solution would probably be recreating the given process model /// into a graph with references as links between each element. That would allow more flexibility for the converter /// objects, which is quite limited in the current implementation. /// </summary> /// <param name="process">The BPMN process model</param> void IterateProcess() { var flagged = new HashSet <string>(); var toVisit = new Queue <ProcessElement>(); //Find the startEvent var startEvent = FindStartEvent(); toVisit.Enqueue(startEvent); flagged.Add(startEvent.Id); //BFS - go through every element while (toVisit.Count > 0) { var current = toVisit.Dequeue(); var nextElements = new List <ElementConverter>(); //Iterate through all outgoing sequence flow ids of this element foreach (var outSequenceFlowId in current.Outgoing) { //Convert the sequence flow id to its target element var nextElement = GetSequenceFlowTarget(outSequenceFlowId); nextElements.Add(ConverterFactory.CreateConverter(nextElement)); //Add to queue if not visited yet and flag it if (!flagged.Contains(nextElement.Id)) { toVisit.Enqueue(nextElement); flagged.Add(nextElement.Id); } } //Create converter for the current element and use it to generate code elements var elementConverter = ConverterFactory.CreateConverter(current); var elementCode = elementConverter.GetElementCode(nextElements, SeqFlowIdToObject(current.Outgoing), dataModel); solidityContract.AddComponents(elementCode); } }
/// <summary> /// <para> /// Decodes the input from Watson Representation to the specified format in <paramref name="options"/> and stores it in <paramref name="stream"/> /// </para> /// </summary> /// <param name="options">The decoing options</param> /// <param name="stream">The output stream</param> public static void Decode(DecodeOptions options, Stream output) { var vm = new VM(new Lexer(options.InitialMode)); Converter converter = ConverterFactory.GetConverter(options.Type); string input; using (var writer = new StreamWriter(output)) { if (options.Files.Count() == 0) { input = Console.ReadLine(); writer.Write(converter.Decode(input, vm)); } else { var sb = new StringBuilder(); foreach (var file in options.Files) { using (var fileStream = new FileStream(file, FileMode.Open)) { using (var reader = new StreamReader(fileStream)) { converter.Decode(reader, writer, vm); } } } } } }
public void ConvertToBoolArray_Roundtrips(int boolArraySize) { var bools = new bool[boolArraySize]; var bytes = new byte[boolArraySize]; var random = new Random(); for (int i = 0; i < bools.Length; ++i) { bools[i] = random.Next() % 2 == 0; } var toS7Converter = ConverterFactory.GetToPlcConverter <bool[]>(); var fromS7Converter = ConverterFactory.GetFromPlcConverter <bool[]>(); int length = toS7Converter(bools, bools.Length, bytes); bool[]? actual = null; fromS7Converter(ref actual, bytes, boolArraySize); Assert.Equal(boolArraySize, actual !.Length); for (int i = 0; i < boolArraySize; ++i) { Assert.Equal(bools[i], actual[i]); } }
/// <summary> /// 根据指定编号异步获取Ticker对象的操作 /// </summary> /// <param name="coinType">币种编号</param> /// <param name="platformType">平台编号</param> /// <returns>返回执行结果</returns> public async Task <IExecuteResult> GetTickerAsync(CoinTypes coinType, PlatformTypes platformType) { MetadataMessageTransaction transaction = SystemWorker.Instance.CreateMetadataTransaction("CoinAPI"); MetadataContainer reqMsg = new MetadataContainer(); reqMsg.SetAttribute(0x00, new MessageIdentityValueStored(new MessageIdentity { ProtocolId = 1, ServiceId = 0, DetailsId = 0 })); reqMsg.SetAttribute(0x0F, new ByteValueStored((byte)coinType)); reqMsg.SetAttribute(0x10, new ByteValueStored((byte)platformType)); TaskCompletionSource <IExecuteResult> completionSource = new TaskCompletionSource <IExecuteResult>(); Task <IExecuteResult> task = completionSource.Task; transaction.ResponseArrived += delegate(object sender, LightSingleArgEventArgs <MetadataContainer> e) { MetadataContainer rspMsg = e.Target; completionSource.SetResult((!rspMsg.IsAttibuteExsits(0x0A)) ? (rspMsg.GetAttribute(0x0F).GetValue <ResourceBlock>() == null ? ExecuteResult.Succeed(null) : ExecuteResult.Succeed(ConverterFactory.GetTickerConverter().ConvertToDomainObject(rspMsg.GetAttribute(0x0F).GetValue <ResourceBlock>()))) : ExecuteResult.Fail(rspMsg.GetAttribute(0x0A).GetValue <byte>(), rspMsg.GetAttribute(0x0B).GetValue <string>())); }; transaction.Timeout += delegate { completionSource.SetResult(ExecuteResult.Fail(SystemErrors.Timeout, string.Format("[Async Handle] Transaction: {0} execute timeout!", transaction.Identity))); }; transaction.Failed += delegate { completionSource.SetResult(ExecuteResult.Fail(SystemErrors.Unknown, string.Format("[Async Handle] Transaction: {0} execute failed!", transaction.Identity))); }; transaction.SendRequest(reqMsg); return(await task); }
public void CustomResolverTest() { Mapper.CreateMap <House, HouseDto>(); Mapper.CreateMap <IList <House>, IList <HouseDto> >().ConvertUsing <IHouseListConverter>(); Mapper.CreateMap <Person, PersonDto>(); var house = new House { Address = "any" }; var john = new Person { OwnedHouse = new List <House> { house } }; var will = new Person { OwnedHouse = new List <House> { house } }; var converterFactory = new ConverterFactory(); var johnDto = Mapper.Map <PersonDto>(john, o => o.ConstructServicesUsing(converterFactory.Resolve)); var willDto = Mapper.Map <PersonDto>(will, o => o.ConstructServicesUsing(converterFactory.Resolve)); johnDto.OwnedHouse[0].Should().Be.SameInstanceAs(willDto.OwnedHouse[0]); johnDto.OwnedHouse[0].Address.Should().Be("any"); }
public ListMeshStream(IEnumerable <T> data, IStreamConverterFactory converterFactory = null, IStreamMetaInfo metaInfo = null) { ConverterFactory = converterFactory ?? StreamConverterFactory.Default; MetaInfo = metaInfo ?? ConverterFactory.GetMetaInfo(typeof(T)); AddRange(data); }
public ListMeshStream(int capacity, IStreamConverterFactory converterFactory = null, IStreamMetaInfo metaInfo = null) : base(capacity) { ConverterFactory = converterFactory ?? StreamConverterFactory.Default; MetaInfo = metaInfo ?? ConverterFactory.GetMetaInfo(typeof(T)); }
protected virtual void SetConverter() { Type _type = null; switch (this.Config.Converter) { case "Form": _type = typeof(FormConverter); break; case "Url": _type = typeof(UrlConverter); break; case "Json": _type = typeof(UrlConverter); break; } if (_type == null) { return; } this.SignParamter = this.SignParamter.Concat(this.Paramter).ToDictionary(m => m.Key, m => m.Value); this.Config.Result = ConverterFactory.GetService(_type).Convert(this.SignParamter); }
public void ReplaceDatetimeConverter() { ConverterFactory f = new ConverterFactory(); f.RemoveConverter( typeof( DateTime ) ); f.AddConverter( typeof( DateTime ), new ConverterStub( null ) ); IConverter c = f.GetConverter( typeof( DateTime ) ); DateTime now = DateTime.Now; Assert.AreEqual( "Stub: " + now.ToString(), c.ToString( now ) ); }
public void Convert_With_ShouldNotBeNull() { var locator = new Mock<IServiceLocator>(); locator.Setup(x=>x.Resolve<IConverter<CustomerRequest, Customer>>()).Returns(new CustomerRequestCustomerConverter()); var sut = new ConverterFactory(locator.Object); var converter = sut.Create<CustomerRequest, Customer>(); converter.ShouldNotBeNull(); }
public ActionResult Edit(long id) { var entity = _controleHelper.FirstOrDefault<LoanApplication>(application => application.Id == id, la => la.Loan, la => la.Client, a => a.Status, a => a.Route, a => a.Sureties, a => a.BailObject); if (entity == null) return RedirectToError(Request.Url.ToString()); var model = new ConverterFactory().CreateConvertor<LoanApplication, LoanApplicationViewModel>().ParseToModel(entity); return View(model); }
public void FixtureSetup() { _factory = new ConverterFactory(); }
public ActionResult Edit(int id) { var entity = _controleHelper.FirstOrDefault<ExpertResolution>(sr => sr.Id == id, sr => sr.LoanApplication, sr => sr.LoanApplication.SystemResolutions, sr => sr.LoanApplication.SystemResolutions.Select(s => s.EstimatesWeight), sr => sr.LoanApplication.Loan); if (entity == null) return RedirectToError(Request.Url.ToString()); var model = new ConverterFactory().CreateConvertor<ExpertResolution, ExpertResolutionViewModel>().ParseToModel(entity); return View(model); }
public ActionResult Edit(long id) { var entity = _controleHelper.FirstOrDefault<CommitteeResolution>(sr => sr.Id == id, sr => sr.LoanApplication, sr => sr.LoanApplication.Loan); if (entity == null) return RedirectToError(Request.Url.ToString()); var model = new ConverterFactory().CreateConvertor<CommitteeResolution, CommitteeResolutionViewModel>().ParseToModel(entity); return View(model); }