Beispiel #1
0
        public DynamicBundleSourceModel(DynamicBundleSource bundleSource)
        {
            _itemsProvider =
                bundleSource.ItemsProvider ??
                throw ErrorHelper.PropertyNotSpecifed(nameof(DynamicBundleSource), nameof(DynamicBundleSource.ItemsProvider));

            _itemTransforms = bundleSource.ItemTransforms;

            _changeTokenFactory = bundleSource.ChangeTokenFactory;
        }
        public DynamicBundleSourceModel(DynamicBundleSource bundleSource, bool enableChangeDetection)
        {
            _itemTransforms = bundleSource.ItemTransforms;

            _itemsProvider =
                bundleSource.ItemsProvider ??
                throw ErrorHelper.PropertyNotSpecifed(nameof(DynamicBundleSource), nameof(DynamicBundleSource.ItemsProvider));

            var changeTokenFactory =
                enableChangeDetection && bundleSource.ChangeTokenFactory != null ?
                bundleSource.ChangeTokenFactory :
                () => NullChangeToken.Singleton;

            Initialize(changeTokenFactory);
        }
        public BundleConfigurer AddDynamicSource(BuildItemsProvider itemsProvider, Func <IChangeToken> changeTokenFactory = null,
                                                 Action <List <IBundleItemTransform> > itemTransformsModification         = null)
        {
            if (itemsProvider == null)
            {
                throw new ArgumentNullException(nameof(itemsProvider));
            }

            var bundleSource = new DynamicBundleSource(Bundle)
            {
                ItemsProvider      = itemsProvider,
                ChangeTokenFactory = changeTokenFactory
            };

            if (itemTransformsModification != null)
            {
                bundleSource.ItemTransforms = bundleSource.ItemTransforms.Modify(itemTransformsModification);
            }

            Bundle.Sources.Add(bundleSource);

            return(this);
        }