protected override void ScenarioSetup() { ConverterProvider.Setup(instance => instance.FindConverter(It.IsAny <Type>())).Returns(new TestConverter()); PrimaryEntityMappingProvider = SetupMappingProviders <IProduct>("Product", "Name", "Price").ToList(); SecondaryEntityMappingProvider = SetupMappingProviders <IProduct>("Service", "Description", "Name").ToList(); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <ICollectionMappingProvider>())); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <IPropertyMappingProvider>())); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <IEntityMappingProvider>())); MappingSource.Setup(instance => instance.GatherEntityMappingProviders()) .Returns(PrimaryEntityMappingProvider.Concat(SecondaryEntityMappingProvider).Select(provider => provider.Object)); }
protected override void ScenarioSetup() { ConverterProvider.Setup(instance => instance.FindConverter(It.IsAny <Type>())).Returns(new TestConverter()); EntityMappingProvider = SetupMappingProviders(typeof(IProductOffering <>), "Offerring", "Image", "OfferedProduct", "Texts").ToList(); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <ICollectionMappingProvider>())); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <IPropertyMappingProvider>())); MappingProviderVisitor.Setup(instance => instance.Visit(It.IsAny <IEntityMappingProvider>())); MappingSource.Setup(instance => instance.GatherEntityMappingProviders()) .Returns(EntityMappingProvider.Select(provider => provider.Object)); Mappings = Builder.BuildMappings(new[] { MappingSource.Object }, OpenGenericMappingProviders = new Dictionary <Type, ICollection <ITermMappingProvider> >()); }
public PluginExecutionResult Execute(PluginExecutionData executionData) { ScanToEmailData data = executionData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); var manager = string.IsNullOrWhiteSpace(data.DigitalSendServer) ? new EmailScanManager(executionData) : new EmailScanManager(executionData, data.DigitalSendServer); manager.ActivityStatusChanged += UpdateStatus; manager.DeviceSelected += UpdateDevice; return(manager.RunScanActivity()); }
private void btnSave_Click(object sender, EventArgs e) { IConverter c = ConverterProvider.CreateConverter(cboType.Text); XmlElement element = XmlHelper.ParseAsDOM(txtContent.Text); element.SetAttribute("Name", txtName.Text); element.SetAttribute("Type", cboType.SelectedItem + string.Empty); c.Load(element); _converter = c; Completed.Invoke(this, EventArgs.Empty); this.Close(); }
private void cboType_SelectedIndexChanged(object sender, EventArgs e) { string type = cboType.Text; if (_converter != null && type == _converter.Type) { txtContent.Text = _converter.Output().OuterXml; } else { IConverter converter = ConverterProvider.CreateConverter(type); txtContent.Text = converter.GetSample().OuterXml; } txtContent.FormatXml(); }
private ServiceEntity(XmlElement definition) { XmlHelper h = new XmlHelper(definition); this.SQLTemplate = h.GetText("SQLTemplate"); ResponseRecordElement = h.GetText("ResponseRecordElement"); RequestRecordElement = h.GetText("RequestRecordElement"); FieldList = new FieldList(h.GetElement("FieldList")); ConditionList = new ConditionList(h.GetElement("Conditions")); Orders = new OrderList(h.GetElement("Orders")); Pagination = new Pagination(h.GetElement("Pagination")); ServiceAction action = ServiceAction.Select; if (!Enum.TryParse <ServiceAction>(h.GetText("Action"), true, out action)) { action = ServiceAction.Select; } Action = action; this.Variables = new List <IVariable>(); foreach (XmlElement varElement in h.GetElements("InternalVariable/Variable")) { IVariable v = VariableFactory.Parse(varElement); if (v != null) { Variables.Add(v); } } this.Converters = new List <IConverter>(); foreach (XmlElement cvElement in h.GetElements("Converters/Converter")) { string type = cvElement.GetAttribute("Type"); IConverter c = ConverterProvider.CreateConverter(type); c.Load(cvElement); this.Converters.Add(c); } this.Preprocesses = new List <Preprocess>(); foreach (XmlElement preElement in h.GetElements("Preprocesses/Preprocess")) { Preprocess p = Preprocess.Parse(preElement); this.Preprocesses.Add(p); } }
public async Task ReadWriteTest <T>(object?__ = null) where T : unmanaged, IComparable <T>, IEquatable <T> { const int n = 248; const int m = 496; var converter = ConverterProvider.GetImageConverter <T>(); var data = ArrayPool <T> .Shared.Rent(n *m); try { for (var i = 0; i < n * m; i++) { data[i] = Internal.UnsafeNumerics.MathOps.DangerousCast <double, T>(_r.NextDouble() * i); } var src = Image.Create <T>(data.AsSpan(0, n * m), n, m); await using var fs = new FileStream($"multiple_records_{typeof(T).Name}.fits", FileMode.Create, FileAccess.ReadWrite); await using (var writer = new FitsWriter(fs)) { await converter.WriteToFitsAsync(src, writer); await converter.WriteToFitsAsync(src, writer, true); } fs.Seek(0, SeekOrigin.Begin); var images = new List <IImage <T> >(2); await using (var reader = new FitsReader(fs)) { await foreach (var block in reader.EnumerateBlocksAsync()) { images.Add(converter.ConvertFromBlock(block, out _)); } } Assert.That(images, Has.Count.EqualTo(2)); Assert.AreEqual(src, images[0]); Assert.AreEqual(src, images[1]); } finally { ArrayPool <T> .Shared.Return(data); } }
/// <summary> /// Validates the given metadata against the ScanToEmail Activity data. /// </summary> /// <param name="configurationData">The configuration data.</param> /// <returns>true if valid</returns> public bool ValidateMetadata(ref PluginConfigurationData configurationData) { bool validData = true; ScanToEmailData activityData = null; try { activityData = configurationData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); } catch { activityData = new ScanToEmailData(); validData = false; } configurationData = new PluginConfigurationData(activityData, ScanToEmailConfigControl.Version); return(validData); }
private static IEntityMapping BuildMapping <TEntity>(this ICollection <ITermMappingProvider> mappingProviders, out IPropertyMapping firstPropertyMapping) { firstPropertyMapping = null; var entityMapping = new MergingEntityMapping(typeof(TEntity)); foreach (var mappingProvider in mappingProviders) { mappingProvider.Accept(MappingVisitors); var entityMappingProvider = mappingProvider as IEntityMappingProvider; if (entityMappingProvider != null) { entityMapping.Classes.Add(new StatementMapping(entityMappingProvider.GetGraph(QIriMappings), entityMappingProvider.GetTerm(QIriMappings))); continue; } var propertyMappingProvider = mappingProvider as IPropertyMappingProvider; if (propertyMappingProvider == null) { continue; } ILiteralConverter valueConverter = null; if (propertyMappingProvider.ValueConverterType != null) { valueConverter = ConverterProvider.FindConverter(propertyMappingProvider.ValueConverterType); } var collectionMappingProvider = mappingProvider as ICollectionMappingProvider; var propertyMapping = (collectionMappingProvider != null ? CollectionMapping.CreateFrom(entityMapping, collectionMappingProvider, valueConverter, QIriMappings) : PropertyMapping.CreateFrom(entityMapping, propertyMappingProvider, valueConverter, QIriMappings)); entityMapping.Properties.Add(propertyMapping); if (firstPropertyMapping == null) { firstPropertyMapping = propertyMapping; } } return(entityMapping); }
public void TestThroughBlocks <T>(object?__ = null) where T : unmanaged, IComparable <T>, IEquatable <T> { const int n = 248; const int m = 496; var data = ArrayPool <T> .Shared.Rent(n *m); var converter = ConverterProvider.GetImageConverter <T>(); try { for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { data[m * i + j] = Internal.UnsafeNumerics.MathOps.DangerousCast <double, T>(Math.Sqrt( (i - 50) * (i - 50) * (1 + Math.Pow(Math.Sin(Math.PI * (i + 23) * 10 / n), 2)) + (j / 2.0 - 100) * (j / 2.0 - 100) * (1.1 + Math.Sin(Math.PI * j * 10 / m)))); } } data[247 * 496 + 495] = default; var src = Image.Create <T>(data.AsSpan(..(n * m)), n, m); var key = FitsKey.Create("DEBUG", "Debug key", "With a comment"); var block = converter.ConvertToBlock(src, key); var rec = converter.ConvertFromBlock(block, out var keys); Assert.AreEqual(src, rec); Assert.AreEqual(data[247 * 496 + 495], src[247, 495]); Assert.AreEqual(data[247 * 496 + 495], rec[247, 495]); Assert.That(keys, Has.One.Items); Assert.That(keys, Contains.Item(key)); } finally { ArrayPool <T> .Shared.Return(data); } }
public void it_should_call_converter_provider() { Binder.GetArgumentValue(GetContext(Body, "POST", "multipart/form-data", Boundary)); ConverterProvider.Verify(instance => instance.FindBestInputConverter(It.IsAny <Type>(), It.IsAny <IRequestInfo>(), false), Times.Once); }
public EmailScanManager(PluginExecutionData executionData, string serverName) : base(executionData, serverName) { _data = executionData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); ScanOptions = _data.ScanOptions; }
public void Should_query_converter_provider_for_converter_instance() { ConverterProvider.Verify(instance => instance.FindLiteralConverter(PropertyType), Times.Once); }
public void it_should_not_call_converter_provider() { Binder.GetArgumentValue(GetContext()); ConverterProvider.Verify(instance => instance.FindBestInputConverter(It.IsAny <Type>(), It.IsAny <IRequestInfo>(), false), Times.Never); }
public void it_should_call_converter_provider() { Binder.GetArgumentValue(GetContext(Body, "POST", "application/x-www-url-encoded")); ConverterProvider.Verify(instance => instance.FindBestInputConverter(It.IsAny <Type>(), It.IsAny <IRequestInfo>(), false), Times.Once); }
public void Should_obtain_converter_capabilities() { ConverterProvider.Verify(instance => instance.FindLiteralConverter(PropertyType), Times.Once); }
public void Should_not_query_converter_provider_for_converter_instance() { ConverterProvider.Verify(instance => instance.FindLiteralConverter(It.IsAny <Type>()), Times.Never); }
/// <summary> /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />. /// </summary> /// <param name="configuration">The configuration data.</param> /// <param name="environment">Information about the plugin environment.</param> public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment) { ScanToEmailData activityData = configuration.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters()); ConfigureControls(activityData); assetSelectionControl.Initialize(configuration.Assets, DeviceAttributes); assetSelectionControl.AdfDocuments = configuration.Documents; lockTimeoutControl.Initialize(activityData.ScanOptions.LockTimeouts); }
/// <summary> /// Sets the logic that returns the value for <see cref="GlobalConverter.Current" />. /// </summary> /// <param name="newProvider">The new provider delegate.</param> public static void SetConverterProvider(ConverterProvider newProvider) { _provider = newProvider; }