/// <summary>
        /// Tries to parse transformation instance by name and properties string. 
        /// </summary>
        /// <param name="name">The transformation name.</param>
        /// <param name="serializedProperties">The serialized transformation properties string.</param>
        /// <param name="transformation">The transformation instance.</param>
        /// <returns>
        /// <c>true</c> if transformation is successfully parsed, otherwise - <c>False</c>
        /// </returns>
        protected override bool TryParse(string name, string serializedProperties, out IImageTransformation transformation)
        {
            if (base.TryParse(name, serializedProperties, out transformation))
            {
                return true;
            }

            try
            {
                Type type = Type.GetType(name);
                if (type != null && typeof(IImageTransformation).IsAssignableFrom(type))
                {
                    var ctor = type.GetConstructor(new[] { typeof(string) });
                    if (ctor != null)
                    {
                        object instance = ctor.Invoke(new object[] { serializedProperties });
                        transformation = (IImageTransformation)instance;
                        return true;
                    }
                }
            }
            catch
            {
                return false;
            }

            return false;
        }
Exemplo n.º 2
0
 public GameControllerTest()
 {
     _gameService         = A.Fake <IGameService>();
     _nodeService         = A.Fake <INodeService>();
     _imageService        = A.Fake <IImageService>();
     _actionService       = A.Fake <IActionService>();
     _logger              = A.Fake <ILogger <GameController> >();
     _imageTransformation = A.Fake <IImageTransformation>();
     _target              = new GameController(_gameService, _imageService, _nodeService, _actionService, _logger, _imageTransformation);
 }
Exemplo n.º 3
0
 public GameController(IGameService gameService,
                       IImageService imageService,
                       INodeService nodeService,
                       IActionService actionService,
                       ILogger <GameController> logger,
                       IImageTransformation imageTransformation)
 {
     _gameService         = gameService;
     _imageService        = imageService;
     _nodeService         = nodeService;
     _actionService       = actionService;
     _logger              = logger;
     _imageTransformation = imageTransformation;
 }
 /// <summary>
 /// Applies transformation to an image.
 /// </summary>
 /// <param name="image">The image.</param>
 public void ApplyToImage(IImage image)
 {
     PrepareSize(image);
     ImageTransformation = CreateTransformation();
     ImageTransformation.ApplyToImage(image);
 }
Exemplo n.º 5
0
 public ImageControllerTest()
 {
     _imageService        = A.Fake <IImageService>();
     _imageTransformation = A.Fake <IImageTransformation>();
     _target = new ImageController(_imageService, _imageTransformation);
 }
Exemplo n.º 6
0
 public ImageController(IImageService imageService, IImageTransformation imageTransformation)
 {
     _imageService        = imageService;
     _imageTransformation = imageTransformation;
 }