Example #1
0
            public Stitcher UsingConfig(StitchConfig stitchConfig)
            {
                if (_stitcher._container == null)
                {
                    _stitcher._container = new Urunium.Stitch.TinyIoC.TinyIoCContainer();
                }

                return(_stitcher.UsingConfig(stitchConfig));
            }
Example #2
0
        private Stitcher UsingConfig(StitchConfig config)
        {
            if (config.Into == null)
            {
                throw new Exception("Compiler config is required");
            }

            if (string.IsNullOrWhiteSpace(config.Into.Directory))
            {
                throw new Exception("DestinationDirectory is required");
            }

            if (config.From == null)
            {
                throw new Exception("Packager config is required");
            }

            if (string.IsNullOrWhiteSpace(config.From.RootPath))
            {
                throw new Exception("RootPath is required");
            }

            if (((config.From.EntryPoints?.Length ?? 0) == 0) && (config.From.CopyFiles?.Length ?? 0) == 0)
            {
                throw new Exception("EntryPoints or CopyFiles is required");
            }

            _sourceConfig      = config.From;
            _destinationConfig = config.Into;

            if (config.Extendibility != null)
            {
                if (config.Extendibility.DI != null)
                {
                    foreach (var diEntry in config.Extendibility.DI)
                    {
                        Type registerType       = Type.GetType(diEntry.Key, true);
                        Type implementationType = Type.GetType(diEntry.Value, true);
                        _container.Register(registerType, implementationType);
                    }
                }
                if (config.Extendibility.Transformers?.Count > 0)
                {
                    _useDefaultTransformers = false;
                    _transformerTypes.Clear();
                    foreach (var moduleTransformerTypeName in config.Extendibility.Transformers)
                    {
                        Type moduleTransformerType = Type.GetType(moduleTransformerTypeName, true);
                        _transformerTypes.Add(moduleTransformerType);
                    }
                }
            }

            return(this);
        }