/// <summary>
        /// Adds an existing output asset to enable multiple tasks to share the same output asset
        /// </summary>
        /// <param name="asset">An existing ouput asset</param>
        public void Add(IAsset asset)
        {
            if (asset == null)
            {
                throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture,
                                                              StringTable.ErrorArgCannotBeNull, "asset"));
            }

            CheckIfTaskIsPersistedAndThrowNotSupported();

            OutputAsset outputAsset = asset as OutputAsset;

            if (outputAsset == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, StringTable.ErrorAddingNonOutputAssetToTask), "asset");
            }

            if (outputAsset.GetAssociatedJob() == null || _task.GetParentJob() == null)
            {
                throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, StringTable.NonValidateStateToAddOutputAssetToTask));
            }

            if (!System.Object.ReferenceEquals(outputAsset.GetAssociatedJob(), _task.GetParentJob()))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, StringTable.ErrorAddAssetToOutputAssetsOfTask));
            }

            _assets.Add(outputAsset);
            return;
        }
        public bool IsExistingOutputAsset(object obj)
        {
            OutputAsset outputAsset = obj as OutputAsset;

            if (outputAsset != null)
            {
                TOutputAsset toutputAsset = outputAsset as TOutputAsset;
                return(Outputs.Contains(toutputAsset));
            }

            return(false);
        }
        /// <summary>
        /// Adds the new output asset.
        /// </summary>
        /// <param name="assetName">The asset name.</param>
        /// <param name="storageAccountName">he name of storage account where asset will be hosted</param>
        /// <param name="options">The options.</param>
        /// <returns>The new asset.</returns>
        public IAsset AddNew(string assetName, string storageAccountName, AssetCreationOptions options)
        {
            this.CheckIfTaskIsPersistedAndThrowNotSupported();

            var asset = new OutputAsset
            {
                Name               = assetName,
                Options            = options,
                StorageAccountName = storageAccountName
            };

            this._assets.Add(asset);

            return(asset);
        }
        /// <summary>
        /// Adds the new output asset.
        /// </summary>
        /// <param name="assetName">The asset name.</param>
        /// <param name="storageAccountName">The name of storage account where asset will be hosted</param>
        /// <param name="options">The asset creation options.</param>
        /// <param name="formatOption">The asset format option.</param>
        /// <returns>The new asset.</returns>
        public IAsset AddNew(string assetName, string storageAccountName, AssetCreationOptions options, AssetFormatOption formatOption)
        {
            this.CheckIfTaskIsPersistedAndThrowNotSupported();

            var asset = new OutputAsset
            {
                Name               = assetName,
                Options            = options,
                StorageAccountName = storageAccountName,
                AssociatedJob      = _task.GetParentJob(),
                FormatOption       = formatOption
            };

            this._assets.Add(asset);

            return(asset);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the asset ID for the specified object.
        /// </summary>
        /// <param name="obj">The object that represents an input or output asset.</param>
        /// <returns>The asset ID.</returns>
        public string GetAssetId(object obj)
        {
            TInputAsset asset = obj as TInputAsset;

            if (asset != null)
            {
                return(string.Format(CultureInfo.InvariantCulture, "JobInputAsset({0})", CalcIndex(asset, this._inputAssets)));
            }

            OutputAsset outputAsset = obj as OutputAsset;

            if (outputAsset != null)
            {
                TOutputAsset toutputAsset = outputAsset as TOutputAsset;
                return(string.Format(CultureInfo.InvariantCulture, "JobOutputAsset({0})", CalcIndex(toutputAsset, this._outputAssets)));
            }

            throw new InvalidCastException(StringTable.ErrorInvalidTaskInput);
        }