/* * b06da2ab-56df-4072-90ee-1cff9dd181c3 * 2774c4f3-0bc2-454d-9e2f-d3d41973ad80 * 631329bb-4af0-4c16-af23-7c183361b97a * 1cc02201-e6c3-4a2f-9c8e-6c74e84012f7 * 47888df9-f01e-488f-bd09-5a0ad3950da9 * */ public Task <IEnumerable <Movie> > GetMovies(IDataConverter <List <Movie> > dataConverter) { var newData = new List <Movie> { new Movie() { id = Guid.Parse("b06da2ab-56df-4072-90ee-1cff9dd181c3"), headline = "Test Movie 1 Updated", lastUpdated = DateTime.Today.AddDays(11).ToShortDateString(), cardImages = new Cardimage[1] { new Cardimage() { url = "https://www.xyz.com/wp-content/themes/xyz/careers/img/office2.jpg", h = 500, w = 500 } } }, new Movie() { id = Guid.Parse("2774c4f3-0bc2-454d-9e2f-d3d41973ad80"), headline = "Test Movie 2", lastUpdated = DateTime.Today.AddDays(1).ToShortDateString() }, new Movie() { id = Guid.Parse("631329bb-4af0-4c16-af23-7c183361b97a"), headline = "Test Movie 3.", lastUpdated = DateTime.Today.AddDays(1).ToShortDateString() }, new Movie() { id = Guid.Parse("1cc02201-e6c3-4a2f-9c8e-6c74e84012f7"), headline = "Test Movie 4.", lastUpdated = DateTime.Today.AddDays(1).ToShortDateString() }, new Movie() { id = Guid.Parse("47888df9-f01e-488f-bd09-5a0ad3950da9"), headline = "Test Movie 5.", lastUpdated = DateTime.Today.AddDays(1).ToShortDateString() } }; return(Task.FromResult((IEnumerable <Movie>)newData)); }
public InitializePopularMoviesCacheCommandHandler(IMovieServer movieServer, IMediator mediator, IDataConverter <List <Movie> > dataConverterService, ILogger <InitializeMovieRepositoryCommandHandler> logger) { _movieServer = movieServer; _mediator = mediator; _dataConverterService = dataConverterService; _logger = logger; }
/// <summary> /// This method performs a conversion and exposes it as a 'Try' method. /// </summary> /// <typeparam name="T">The type to be converted from.</typeparam> /// <typeparam name="U">The type to be converted to.</typeparam> /// <param name="converter">The IDataConverter object.</param> /// <param name="value">The value to be converted.</param> /// <param name="result">Out result parameter for the conversion result.</param> /// <returns>True if the conversion was successful.</returns> public static bool TryConvert <T, U>(this IDataConverter converter, T value, out U result) { var conversionResult = converter.DoConversion <T, U>(value); result = conversionResult.Result; return(conversionResult.IsSuccessful); }
public void InitOneTime() { var mapperConfiguration = new MapperConfiguration(cfg => cfg.AddProfile <IgcRestApiMappingProfile>()); var mapper = mapperConfiguration.CreateMapper(); _dataConverter = new AutoMapperDataConverter(mapper); }
public Axis(IDataConverter <T> dataConverter, float numericDataMin, float numericDataMax) { Title = ""; DataConverter = dataConverter; NumericDataMin = numericDataMin; NumericDataMax = numericDataMax; }
public TDto RetrieveSupplierInfo <TDto>(object supplierId, IDataConverter <SupplierInfoData, TDto> converter) where TDto : class { TDto instance = SupplierSystem.RetrieveSupplierInfo(supplierId, converter); return(instance); }
/// <summary> /// 載入中介資料並依指定的資料物件回傳。 /// </summary> /// <typeparam name="TModel">指定回傳的資料物件型別。</typeparam> /// <param name="pi_objSource">待載入的中介資料。</param> /// <returns>載入中介資料的資料物件。</returns> /// <remarks> /// Author: 黃竣祥 /// Time: 2017/09/21 /// History: /// 未提供對應的轉換器就忽略該屬性,避免物件缺少例外。(黃竣祥 2017/10/25) /// DB Object: N/A /// </remarks> public TModel Loading <TModel>(XElement pi_objSource) where TModel : new() { TModel objReturn = new TModel(); DefaultConverter <TModel> objDefaultConverter = new DefaultConverter <TModel>(this); if (pi_objSource != null) { foreach (System.Reflection.PropertyInfo objProperty in objReturn.GetType().GetProperties()) { if (objProperty.CanWrite && this.IsExistPropertyValues(pi_objSource, objProperty)) { string sTagName = string.Empty; TransitDataTagAttribute[] objTags = (TransitDataTagAttribute[])objProperty.GetCustomAttributes(typeof(TransitDataTagAttribute), false); IDataConverter <XElement> objConverter = this.FindConverter(objProperty); if ((objTags != null) && (objTags.Count() > 0)) { sTagName = objTags[0].ImportTag; } if (string.IsNullOrEmpty(sTagName)) { sTagName = objProperty.Name; } if (objConverter != null) { objConverter.Successor = objDefaultConverter; objConverter.SetValue(objReturn, objProperty, pi_objSource.Element(sTagName)); } } } } return(objReturn); }
public Receiver(ILogger logger, IDataConverter <TData> converter, Socket socket, CancellationToken ct) { _logger = logger; _socket = socket; _parser = new Parser <TData>(logger, converter); _ct = ct; }
public List <TDto> RetrieveAllSupplier <TDto>(IDataConverter <SupplierInfoData, TDto> converter) where TDto : class { SupplierCriteria criteria = new SupplierCriteria(); return(RetrieveSuppliersBySearch(criteria, converter)); }
public ReceiptService(IImageFormating imageFormating, IOcr ocr, IDataConverter dataConverter, IItemManager dataManager) { _imageFormating = imageFormating; _ocr = ocr; _dataConverter = dataConverter; _dataManager = dataManager; }
private static IEnumerable <Type> GetReferencedTypes(this Type type, IDataConverter converter) { foreach (var property in type.GetPublicProperties()) { if (property.PropertyType.TryGetTypeToGenerate(converter, out var propertyType)) { yield return(propertyType); } } foreach (var method in type.GetPublicMethods()) { if (method.ReturnType.TryGetTypeToGenerate(converter, out var returnType)) { yield return(returnType); } foreach (var parameter in method.GetParameters()) { if (parameter.ParameterType.TryGetTypeToGenerate(converter, out var parameterType)) { yield return(parameterType); } } } }
public DataRecordAdapter(IDataConverter dataConverter, IDataReader dataReader, IRecordCache cache, IShuffler shuffler) { _dataConverter = dataConverter; _dataReader = dataReader; _cache = cache; _shuffler = shuffler; }
public ReceiptService() { _imageFormating = new ImageFormating(); _ocr = new EmguOcr(); _dataConverter = new DataConverter(); _dataManager = new ItemManager(); }
public ReceiptService() { _imageFormating = new ImageFormating(); _receiptCreating = new ReceiptMaking(); _dataConverter = new DataConverter(); _itemCategorization = new ItemCategorization(); }
public ReceiptService(IImageFormating imageFormating, IReceiptMaking receiptCreating, IDataConverter dataConverter, IItemCategorization itemCategorization) { _imageFormating = imageFormating; _receiptCreating = receiptCreating; _dataConverter = dataConverter; _itemCategorization = itemCategorization; }
public DataConverterTests(string name, string desc) { _converter = new TConverter(); _name = name; _desc = desc; _dataStub = CreateDataStub(); }
/// <summary> /// creates a new xml object reader /// </summary> /// <param name="stream">source stream of serialized java data</param> /// <param name="converter">converter used to convert data to target representation</param> /// <param name="reducer">reduces java data structures to a more compact format (optional but necessary for specific converters to work)</param> public ObjectReader(Stream stream, IDataConverter <T> converter, StructureReducer reducer = null) { basestream = stream; this.stream = new ObjectStream(stream); this.converter = converter; this.reducer = reducer; }
public Configuration RegisterConverter(IDataConverter dataConverter) { string typeString = dataConverter.GetDataType().FullName; converters[typeString] = dataConverter; return(this); }
/// <summary> /// 匯出傳入物件為 XElement 資料型態。 /// </summary> /// <typeparam name="TModel">待匯出資料物件型別。</typeparam> /// <param name="pi_objSource">待匯出資料的資料物件。</param> /// <returns>匯出資料物件的中介資料。</returns> /// <remarks> /// Author: 黃竣祥 /// Time: 2017/09/21 /// History: N/A /// 未提供對應的轉換器就忽略該屬性,避免物件缺少例外。(黃竣祥 2017/10/25) /// DB Object: N/A /// </remarks> private XElement ExportToXElement <TModel>(TModel pi_objSource) { XElement objRoot = new XElement("Root"); EmptyConverter objEmptyConverter = new EmptyConverter(); foreach (System.Reflection.PropertyInfo objProperty in pi_objSource.GetType().GetProperties()) { if (objProperty.CanRead) { XElement objChild = null; IDataConverter <XElement> objConverter = this.FindConverter(objProperty); if (objConverter != null) { objConverter.Successor = objEmptyConverter; objChild = objConverter.Export(pi_objSource, objProperty); if (objChild != null) { objRoot.Add(objChild); } } } } return(objRoot); }
public CustomerAndAddressService(ICustomerRepository customerRepository, IAddressRepository addressRepository, IUnitOfWork unitOfWork, IDataConverter dataConverter) { _customerRepository = customerRepository; _addressRepository = addressRepository; _unitOfWork = unitOfWork; _dataConverter = dataConverter; }
public TDto RetrieveOrderInfo <TDto>(object id, IDataConverter <OrderInfoData, TDto> converter) where TDto : class { TDto orderInfo = OrderSystem.RetrieveOrderInfo(id, converter); return(orderInfo); }
public App(ILogger <App> logger, IS3Repository s3Repository, IDataConverter dataConverterService, IDataUploader dataUploader) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _s3Repository = s3Repository ?? throw new ArgumentNullException(nameof(s3Repository)); _dataConverterService = dataConverterService ?? throw new ArgumentNullException(nameof(dataConverterService)); _dataUploader = dataUploader ?? throw new ArgumentNullException(nameof(dataUploader)); }
public TDto RetrieveProductInfo <TDto>(object productId, IDataConverter <ProductInfoData, TDto> converter) where TDto : class { TDto instance = ProductSystem.RetrieveProductInfo(productId, converter); return(instance); }
public static Action <WebProgressTask, object?>?ApplyResult(IDataConverter converter, Type type) { var conv = converter.GetConverter(type); if (conv is null) { return(null); } return((task, value) => { if (value != null) { var source = conv(value); if (source != null) { task.Document.DataSources.Add(source); } else { task.Document.DataSources.Add(new HttpStringDataSource("Cannot create data")); task.Response.StatusCode = HttpStateCode.InternalServerError; } } }); }
public WeakAction(Delegate action, IDataConverter converter, object parameter) { System.Diagnostics.Debug.Assert(action != null); Action = action; Converter = converter; Parameter = parameter; }
/// <summary> /// Writes an object to a specific clipboard format. /// </summary> /// <typeparam name="T">Type of object to store on the clipboard.</typeparam> /// <param name="cfFormat">The Id of the format to write.</param> /// <param name="obj">The object to write to the clipboard.</param> /// <param name="converter">The coverter responsible for writing the object to an HGlobal.</param> /// <exception cref="Exception">If the object was not written successfully.</exception> protected virtual void SetFormatObject <T>(uint cfFormat, T obj, IDataConverter <T> converter) { ThrowIfDisposed(); // EmptyClipboard must be called to update the current clipboard owner before setting data if (!_cleared) { Empty(); } var hglobal = converter.WriteToHGlobal(obj); if (hglobal == IntPtr.Zero) { throw new Exception("Unable to copy data into global memory"); } try { var hdata = NativeMethods.SetClipboardData(cfFormat, hglobal); if (hdata == IntPtr.Zero) { throw new Win32Exception(); } } catch { // free hglobal only if error, if success - ownership of hglobal has transferred to system NativeMethods.GlobalFree(hglobal); } }
public ItemService( IDataConverter dataConverter, IItemManager dataManager, IItemCategorization itemCategorization) { _dataConverter = dataConverter; _dataManager = dataManager; _itemCategorization = itemCategorization; }
public TDto RetrieveOrderInfo <TDto>(string orderNumber, IDataConverter <OrderInfoData, TDto> converter) where TDto : class { TDto orderInfo = OrderSystem.RetrieveOrderInfo(orderNumber, converter); return(orderInfo); }
/// <summary> /// Устанавливает последовательность байтов data в качестве текста в textBox /// </summary> /// <param name="textBox">Компонент, куда будет заноситься текст</param> /// <param name="data">Последовательность байтов</param> /// <param name="converter">Конвертер в string</param> public void UpdateText(TextBox textBox, byte[] data, IDataConverter converter) { if (textBox?.IsLoaded ?? false) { textBox.Text = converter.ToText(data, 50); } }
public CosmosDbOutputProcessor(ILogger logger, IDataDocumentRepository dataDocumentRepository, IDataConverter dataConverter, string projectName, int batchSize) { this.logger = logger; this.dataDocumentRepository = dataDocumentRepository; this.dataConverter = dataConverter; this.projectName = projectName; this.batchSize = batchSize; }
public UserController(IAuthRepository authRepository, IAccountService accountService, IDataConverter mapper, IUserService userService, ILogService logService) : base(mapper) { _authRepository = authRepository; _accountService = accountService; _userService = userService; _logService = logService; }
/// <summary> /// Sets the property binding. /// </summary> /// <param name="source">The source.</param> /// <param name="target">The target.</param> /// <param name="sourceProp">The source prop.</param> /// <param name="targetProp">The target prop.</param> /// <param name="notify">if set to <c>true</c> update immediately.</param> /// <param name="converter">The converter.</param> /// <param name="parameter">The converter parameter.</param> public static void SetPropertyBinding(Object source, INotifyPropertyChanged target, string sourceProp, string targetProp, bool notify = true, IDataConverter converter = null, object parameter = null) { WeakEntry entry = new WeakEntry(source.GetType(), target.GetType(), sourceProp, targetProp); Delegate setAction = GetExpressionAction(entry, source, true, converter); WeakSource wSource = WeakSource.Register(source, target, setAction, targetProp, converter, parameter); if (notify) { wSource.NotifyPropertyChanged(target, targetProp); } }
/// <summary> /// Gets the expression action. /// </summary> /// <param name="entry">The entry.</param> /// <param name="source">The source.</param> /// <param name="createNew">if set to <c>true</c> [create new].</param> /// <param name="converter">The converter.</param> /// <returns></returns> private static Delegate GetExpressionAction(WeakEntry entry, object source, bool createNew, IDataConverter converter = null) { Delegate action = null; if (_expressionSources.ContainsKey(entry)) { action = _expressionSources[entry]; } else if (createNew) { ///// Code of the below Expression Tree //////////////////////////////// //if (converter != null) //{ // target.Property = converter.Convert(source.Property, parameter); //} //else //{ // if (target.Property.GetType() == source.Property.GetType()) // { // target.Property = source.Property; // } // else // { // throw new InvalidOperationException("The property type between binding source and target does not match, please use IDataConverter to do custom convert."); // } //} ////////////////////////////////////////////////////////////////////////// //Set Property var prop = entry.SourceType.GetProperty(entry.SourceProp); var paraObj = Expression.Parameter(entry.SourceType); //Get Property var targetProperty = entry.TargetType.GetProperty(entry.TargetProp); var paraTarget = Expression.Parameter(entry.TargetType); var getter = Expression.Property(paraTarget, targetProperty); //Combine Expression boy; var paraConvert = Expression.Variable(typeof(IDataConverter)); var paraParameter = Expression.Variable(typeof(object)); boy = Expression.IfThenElse( Expression.NotEqual(paraConvert, Expression.Constant(null)), Expression.Call(paraObj, prop.GetSetMethod(), Expression.Convert(Expression.Call(paraConvert, typeof(IDataConverter).GetMethod("Convert"), Expression.Convert(getter, typeof(object)), Expression.Convert(paraParameter, typeof(object))), prop.PropertyType)), Expression.IfThenElse( Expression.Equal(Expression.Constant(prop.PropertyType, typeof(Type)), Expression.Constant(getter.Type, typeof(Type))), Expression.Call(paraObj, prop.GetSetMethod(), Expression.Convert(Expression.Convert(getter, typeof(object)), prop.PropertyType)), Expression.Throw(Expression.Constant(new InvalidOperationException( "The property type between binding source and target does not match, please use IDataConverter to do custom convert."))))); action = Expression.Lambda(boy, paraObj, paraTarget, paraConvert, paraParameter).Compile(); _expressionSources.Add(entry, action); } return action; }
protected CommonDataProfile(IDataConverter converter) { Converter = converter; }
public UserProfile(IDataConverter converter) : base(converter) { }
public BaseApiController(IDataConverter mapper) { _mapper = mapper; }
public CreditApplicationProfile(IDataConverter converter) : base(converter) { }
public void AttachConverter(IDataConverter converter) { Converters.Add(converter); }
public CreditTypeProfile(IDataConverter converter) : base(converter) { }
public WeakAction(Delegate action, IDataConverter converter, object parameter) { System.Diagnostics.Debug.Assert(action != null); Action = action; Converter = converter; Parameter = parameter; }
/// <summary> /// Registers the specified source. /// </summary> /// <param name="source">The source.</param> /// <param name="target">The target.</param> /// <param name="action">The action.</param> /// <param name="targetProp">The target prop.</param> /// <param name="converter">The converter.</param> /// <param name="parameter">The converter parameter.</param> /// <returns></returns> public static WeakSource Register(Object source, INotifyPropertyChanged target, Delegate action, string targetProp, IDataConverter converter = null, object parameter = null) { WeakSource wSource = _weakSources.ContainsKey(source.GetHashCode()) ? _weakSources[source.GetHashCode()] : null; if (wSource == null) { wSource = new WeakSource(source); _weakSources.Add(source.GetHashCode(), wSource); } IList<WeakAction> actions; if (wSource.Actions.ContainsKey(targetProp)) { actions = wSource.Actions[targetProp]; } else { actions = new List<WeakAction>(); wSource.Actions.Add(targetProp, actions); } actions.Add(new WeakAction(action, converter, parameter)); IList<string> props; if (!wSource.Targets.ContainsKey(target.GetHashCode())) { props = new List<string>(); props.Add(targetProp); wSource.Targets.Add(target.GetHashCode(), props); target.PropertyChanged += new PropertyChangedEventHandler(wSource.HandlePropertyChanged); } else { props = wSource.Targets[target.GetHashCode()]; if (!props.Contains(targetProp)) { props.Add(targetProp); } } return wSource; }
public void Initialize() { this.converter = new Base64DataConverter(); }
public CreditApplicationController(ICreditApplicationService creditApplicationService, ILogService logService, IDataConverter mapper) : base(mapper) { _creditApplicationService = creditApplicationService; _logService = logService; }
public MimeHandler (string name, IDataConverter converter, params string [] aliases) { Name = name; Converter = converter; Aliases = aliases; }
public MimeHandler (string name, IDataConverter converter) : this (name, converter, name) { }
public PaymentProfile(IDataConverter converter) : base(converter) { }
public AccountProfile(IDataConverter converter) : base(converter) { }
public virtual void AddDataRow(DataTable table, IDataRecord record, IDataConverter dataConverter, Map map) { if (table != null && record != null) { DataRow row = table.NewRow(); foreach (Field field in Fields) { row[field.Name] = dataConverter.GetEntityValue(record[field.Name], field.Type); } if (record.GetOrdinal(DateModifiedFieldName) > -1) { row[DateModifiedFieldName] = dataConverter.GetEntityValue(record[DateModifiedFieldName], typeof(DateTime)); } if (map != null && record.GetOrdinal(ParentLinkFieldName) > -1) { row[ParentLinkFieldName] = dataConverter.GetEntityValue(record[ParentLinkFieldName], map.Root.Identifier.Type); } table.Rows.Add(row); } }
public LogProfile(IDataConverter converter) : base(converter) { }
public CreditTypeController(ICreditTypeService creditTypeService, ILogService logService, IDataConverter mapper) : base(mapper) { _creditTypeService = creditTypeService; _logService = logService; }