public AlbumService(IConverterFactory factory, BaseProvider <Album> providerAlbum, IPhotoService photoService)
 {
     _providerAlbum = providerAlbum;
     _factory       = factory;
     _photoService  = photoService;
     _converter     = _factory.GetConverter <IAlbumConverter>();
 }
 public ProductsRepository(IProductEntityDAO productEntityDAO,
                           IConverterFactory converterFactory)
 {
     this.productEntityDAO = productEntityDAO;
     this.converterFactory = converterFactory;
     productCache          = new Dictionary <Product, IProductEntity>();
 }
Beispiel #3
0
 public static void MyClassInitialize(TestContext testContext)
 {
     _ninjectKernel    = new StandardKernel();
     _providerFactory  = new ProviderFactory(_ninjectKernel);
     _converterFactory = new ConverterFactory(_ninjectKernel);
     _homeController   = new HomeController(_providerFactory, _converterFactory);
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     _ninjectKernel = new StandardKernel();
     _providerFactory = new ProviderFactory(_ninjectKernel);
     _converterFactory = new ConverterFactory(_ninjectKernel);
     _homeController = new HomeController(_providerFactory, _converterFactory);
 }
        /// <summary>
        /// Creates and initializes a converter. This takes care of nested types (recursive converter creation).
        /// </summary>
        /// <param name="factory">The converter factory to use. This must not be null.</param>
        /// <param name="type">The type for which to create the converter.</param>
        /// <param name="converterParameters">The constructor parameters for the new converter. This may be null.</param>
        /// <returns>The new converter.</returns>
        public static IConverter CreateConverter(IConverterFactory factory, Type type, object[] converterParameters)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            IConverter converter;

            lock (CURRENTLY_INITIALIZED_TYPES)
            {
                if (CURRENTLY_INITIALIZED_TYPES.TryGetValue(type, out converter))
                {
                    return(converter);
                }

                converter = factory.Create(type, converterParameters);
                if (!(converter is IConverterInitialization))
                {
                    return(converter);
                }

                CURRENTLY_INITIALIZED_TYPES[type] = converter;
            }
            try
            {
                ((IConverterInitialization)converter).InitializeConverter();
            }
            finally
            {
                lock (CURRENTLY_INITIALIZED_TYPES)
                    CURRENTLY_INITIALIZED_TYPES.Remove(type);
            }
            return(converter);
        }
        /// <summary>
        /// Creates a converter for the given type and the optionally given converter type.
        /// </summary>
        /// <param name="converterType">An optional converter type. This type can either be implementing
        /// <see cref="IConverter"/> or <see cref="IConverterFactory"/> or just be left null.</param>
        /// <param name="type">The type for which to create a converter.</param>
        /// <param name="converterParameters">Optional constructor parameters for converter to create.</param>
        /// <returns>The new converter.</returns>
        public static IConverter CreateConverter(Type converterType, Type type, object[] converterParameters)
        {
            // Get the factory. This may return null, if the given converter type is null.
            IConverterFactory factory = FromType(converterType);

            return(GetConverter(factory, type, converterParameters));
        }
Beispiel #7
0
 /// <summary>
 /// 添加一个类型转换函数实现类工厂。
 /// </summary>
 /// <param name="factory">转换函数实现类工厂</param>
 public static void AddImplFactory(IConverterFactory factory)
 {
     lock (InternalConvert.factories)
     {
         InternalConvert.factories.Add(factory);
     }
 }
        public static void Use(IConverterFactory converterFactory)
        {
            if (converterFactory == null)
            {
                throw new ArgumentNullException("converterFactory", "'ConverterFactory' parameter should be set to non nullable value.");
            }

            ConverterFactory = converterFactory;
        }
Beispiel #9
0
 public TagService(IConverterFactory factory, BaseProvider <Tag> provider,
                   BaseProvider <PhotoToTag> providerPhotoToTag, BaseProvider <Photo> providerPhoto)
 {
     _providerTag        = provider;
     _providerPhoto      = providerPhoto;
     _providerPhotoToTag = providerPhotoToTag;
     _factory            = factory;
     _converter          = _factory.GetConverter <ITagConverter>();
 }
Beispiel #10
0
        public static IConverterFactory Create()
        {
            if (Factory == null)
            {
                Factory = new ConverterFactory();
            }

            return(Factory);
        }
        public MappingService(IConverterFactory converterFactory)
        {
            if (converterFactory == null)
            {
                throw new ArgumentNullException("converterFactory");
            }

            this.converterCache   = new ConcurrentDictionary <string, object>();
            this.converterFactory = converterFactory;
        }
        /// <summary>
        /// Adds a <see cref="IConverterFactory"/> which is asked to convert types
        /// which are new to the <see cref="ConverterRegistry"/>.
        ///
        /// If a type can be handled by multiple converter factories, the factory which
        /// has been added last, will be used to create a converter for the type.
        /// </summary>
        /// <param name="converterFactory">The converter factory to add.</param>
        public static void AddConverterFactory(IConverterFactory converterFactory)
        {
            if (converterFactory == null)
            {
                throw new ArgumentNullException(nameof(converterFactory));
            }

            lock (FACTORIES)
                FACTORIES.Add(converterFactory);
        }
        public IModelConverterInterceptorBuilder UseLocator(IServiceLocator serviceLocator)
        {
            if (serviceLocator == null)
            {
                throw new ArgumentNullException(nameof(serviceLocator));
            }

            ConverterFactory = new ConverterFactory(serviceLocator);

            return this;
        }
 public SaveForeignExchange(ILogger logger,
                            ITaskActions taskActions,
                            IConverterFactory converterFactory,
                            ISaverMurrData saver,
                            ICbrDownloader cbrDownloader)
     : base(logger, taskActions)
 {
     _converterFactory = converterFactory;
     _saver            = saver;
     _cbrDownloader    = cbrDownloader;
 }
 public ManagementController(ITextAttributeService attrService, IImageProcessor imageProcessor,
                             IConverterFactory factory, IAlbumService albumService, IPhotoService photoService,
                             ITagService tagService, IWatermarkService watermarkService)
 {
     _imageProcessor   = imageProcessor;
     _factory          = factory;
     _converterAttr    = _factory.GetConverter <ITextAttributeConverter>();
     _attrService      = attrService;
     _albumService     = albumService;
     _tagService       = tagService;
     _photoService     = photoService;
     _watermarkService = watermarkService;
 }
Beispiel #16
0
 public JobRunner(ITokenReplacerFactory tokenReplacerFactory,
                  IPdfProcessor processor, IConverterFactory converterFactory, IActionManager actionManager,
                  IJobCleanUp jobClean, ITempFolderProvider tempFolderProvider, IDirectory directory, IDirectoryHelper directoryHelper)
 {
     _tokenReplacerFactory = tokenReplacerFactory;
     _processor            = processor;
     _converterFactory     = converterFactory;
     _actionManager        = actionManager;
     _jobClean             = jobClean;
     _tempFolderProvider   = tempFolderProvider;
     _directory            = directory;
     _directoryHelper      = directoryHelper;
 }
 public PhotoService(IConverterFactory factory, BaseProvider <Photo> provider,
                     BaseProvider <Watermark> providerWatermark, BaseProvider <Tag> providerTag,
                     BaseProvider <PhotoToTag> providerPhotoToTag, BaseProvider <Album> providerAlbum)
 {
     _providerPhoto      = provider;
     _providerWatermark  = providerWatermark;
     _providerPhotoToTag = providerPhotoToTag;
     _providerTag        = providerTag;
     _factory            = factory;
     _providerAlbum      = providerAlbum;
     _converter          = _factory.GetConverter <IPhotoConverter>();
     _converterWatermark = _factory.GetConverter <IWatermarkConverter>();
     _converterTag       = _factory.GetConverter <ITagConverter>();
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            HashSet <Type> types = new HashSet <Type>(); // lets store all Types for this particualr factory type

            Console.WriteLine("Write type of Converter you need Unity,Unreal,Blender");
            string converter = Console.ReadLine();

            converter = converter.ToLowerInvariant();
            var firstLetter = converter[0].ToString().ToUpperInvariant();

            converter = converter.Substring(1);
            converter = converter.Insert(0, firstLetter);
            IConverterFactory converterFactory = null;

            try
            {
                var allclasses = from cl in Assembly.GetExecutingAssembly().GetTypes()
                                 where cl.IsClass && cl.Namespace.Contains("AbstractFactoryPattern")
                                 select cl;
                var otherClassTypes = from cl in allclasses
                                      where cl.FullName.ToUpperInvariant().Contains(converter.ToUpperInvariant())
                                      select cl;

                var factorytype = from cl in allclasses
                                  where cl.FullName.Equals($"AbstractFactoryPattern.Factories.{converter}ConverterFactory")
                                  select cl;
                types            = new HashSet <Type>(otherClassTypes);
                converterFactory = (IConverterFactory)Activator.CreateInstance(factorytype.First()); //Unity Container . get
            }
            catch (Exception e)
            {
                converterFactory = null;
            }

            if (converterFactory == null)
            {
                Console.WriteLine($"{converter} Factory not defined");
            }
            else
            {
                Console.WriteLine($"Constructing {converter}Factory");
                var axisconverter = converterFactory.CreateAxisConverter();
                var nodeConverter = converterFactory.CreateNodesConverter();
                Console.WriteLine($"AxisConverter check: {CheckPassFail(types.Contains(axisconverter.GetType()))}");
                Console.WriteLine($"NodeConverter check: {CheckPassFail(types.Contains(nodeConverter.GetType()))}");
            }

            Console.Read();
        }
 public JobRunner(IOutputFileMover outputFileMover, ITokenReplacerFactory tokenReplacerFactory,
                  IPdfProcessor processor, IConverterFactory converterFactory, IActionManager actionManager,
                  IJobCleanUp jobClean, ITempFolderProvider tempFolderProvider, IDirectory directory,
                  IConversionProgress conversionProgress)
 {
     _outputFileMover      = outputFileMover;
     _tokenReplacerFactory = tokenReplacerFactory;
     _processor            = processor;
     _converterFactory     = converterFactory;
     _actionManager        = actionManager;
     _jobClean             = jobClean;
     _tempFolderProvider   = tempFolderProvider;
     _directory            = directory;
     _conversionProgress   = conversionProgress;
 }
Beispiel #20
0
 public CalculationFactory(ILogger logger,
                           ITaskActions taskAction,
                           ICbrDownloader cbrDownloader,
                           IMoexDownloader moexDownloader,
                           IXmlSaver xmlSaver,
                           ICsvSaver csvSaver,
                           IConverterFactory converterFactory,
                           ISaverMurrData saverMurrData)
 {
     _logger         = logger;
     _taskAction     = taskAction;
     _cbrDownloader  = cbrDownloader;
     _moexDownloader = moexDownloader;
     _xmlSave        = xmlSaver;
     _csvSaver       = csvSaver;
     _convertFactory = converterFactory;
     _saverMurrData  = saverMurrData;
 }
        private static IConverter GetConverter(IConverterFactory factory, Type type, object[] converterParameters)
        {
            if (factory != null)
            {
                if (!factory.CanConvert(type))
                {
                    throw new Exception($"Converter factory {factory.GetType()} is not able to convert type '{type}'.");
                }

                IConverter converter = factory.Create(type, converterParameters);
                if (converter == null)
                {
                    throw new Exception($"{nameof(IConverterFactory.Create)} implementation of {factory.GetType()} did not return a converter for type {type}.");
                }

                return(converter);
            }

            return(ConverterRegistry.Get(type, converterParameters));
        }
        public ExampleDataProviderDamHelper(IExampleServiceHelper serviceHelper, ICacheHandler cacheHandler, ILogHelper logHelper, IConverterFactory converterFactory, ISettingsHelper settingsHelper)
        {
            var enabledMethods = new List <DataProviderMethods>();

            enabledMethods.Add(DataProviderMethods.BlobStreamExists);
            enabledMethods.Add(DataProviderMethods.MoveItem);
            enabledMethods.Add(DataProviderMethods.GetBlobStream);
            enabledMethods.Add(DataProviderMethods.GetChildIDs);
            enabledMethods.Add(DataProviderMethods.GetItemDefinition);
            enabledMethods.Add(DataProviderMethods.GetItemFields);
            enabledMethods.Add(DataProviderMethods.GetItemVersions);
            enabledMethods.Add(DataProviderMethods.GetParentID);

            this.EnabledMethods   = enabledMethods;
            this.ServiceHelper    = serviceHelper;
            this.CacheHandler     = cacheHandler;
            this.LogHelper        = logHelper;
            this.ConverterFactory = converterFactory;
            this.SettingsHelper   = settingsHelper;
        }
        private void CreateConverterFactory(Type type)
        {
            var converterFactoryType = typeof (ConverterFactory<>).MakeGenericType(type);

            _converterFactory = (IConverterFactory)Activator.CreateInstance(converterFactoryType);
        }
Beispiel #24
0
 public Prompt(IConsole console = null, IConverterFactory converterFactory = null)
 {
     _console          = console ?? new SystemConsole();
     _converterFactory = converterFactory ?? new SystemConverterFactory();
 }
 public HomeController(IProviderFactory providerFactory, IConverterFactory converterFactory)
 {
     _providerFactory = providerFactory;
     _converterFactory = converterFactory;
 }
 public CustomCssController(IConverterFactory converterFactory)
 {
     ThemeService.Instance.Converter = converterFactory.Make();
 }
Beispiel #27
0
 public ConsoleApplication(ICsvFileRepository repository,
                           IConverterFactory converterFactory)
 {
     _repository       = repository;
     _converterFactory = converterFactory;
 }
Beispiel #28
0
        private void CreateConverterFactory(Type type)
        {
            var converterFactoryType = typeof(ConverterFactory <>).MakeGenericType(type);

            _converterFactory = (IConverterFactory)Activator.CreateInstance(converterFactoryType);
        }
Beispiel #29
0
 public WatermarkService(IConverterFactory factory, BaseProvider <Watermark> provider)
 {
     _providerWatermark = provider;
     _factory           = factory;
     _converter         = _factory.GetConverter <IWatermarkConverter>();
 }
 public StocksRepository(IStockEntityDAO stockEntityDAO, IConverterFactory converterFactory)
 {
     this.converterFactory = converterFactory;
     this.stockEntityDAO   = stockEntityDAO;
     stockCache            = new Dictionary <Stock, IStockEntity>();
 }
Beispiel #31
0
 public MassController(IConverterFactory converterFactory)
 {
     _converterFactory = converterFactory ?? throw new ArgumentNullException(nameof(converterFactory));
 }
 public TemperatureConverter(IConverterFactory converterFactory)
 {
     this.converterFactory = converterFactory;
 }
Beispiel #33
0
 public ConvertController(IInputToByteArrayConverter toByteArrayConverter, IConverterFactory converterFactory)
 {
     _toByteArrayConverter = toByteArrayConverter;
     _converterFactory     = converterFactory;
 }
Beispiel #34
0
 public static void MyClassInitialize(TestContext testContext)
 {
     _ninjectKernel    = new StandardKernel();
     _converterFactory = new ConverterFactory(_ninjectKernel);
 }
 public static void MyClassInitialize(TestContext testContext)
 {
     _ninjectKernel = new StandardKernel();
     _converterFactory = new ConverterFactory(_ninjectKernel);
 }