Exemple #1
0
        /// <summary>
        /// Adds a new workspace mapping to an existing build definition
        /// </summary>
        /// <param name="buildDefinition">Build definition for the new mapping</param>
        /// <param name="localItem">Local path for the mapping</param>
        /// <param name="serverItem">Server path for the mapping</param>
        /// <param name="mappingType">Type of mapping (map or cloak)</param>
        /// <param name="depth">The Mapping Depth</param>
        /// <returns>The created workspace mapping</returns>
        /// <remarks>The build definition is not saved after the mapping is added.</remarks>
        public static IWorkspaceMapping AddWorkspaceMapping(IBuildDefinition buildDefinition, string localItem, string serverItem, WorkspaceMappingType mappingType, WorkspaceMappingDepth depth)
        {
            // Validation
            ArgumentValidation.ValidateObjectIsNotNull(buildDefinition, "buildDefinition");
            ArgumentValidation.ValidateStringIsNotEmpty(localItem, "localPath");
            ArgumentValidation.ValidateStringIsNotEmpty(serverItem, "serverPath");

            var mapping = buildDefinition.Workspace.AddMapping(serverItem, localItem, mappingType, depth);

            return(mapping);
        }
Exemple #2
0
        /// <summary>
        /// Removes a specified local mapping from a build definition
        /// </summary>
        /// <param name="buildDefinition">Build definition to remove the mapping from.</param>
        /// <param name="localItem">Local mapping to remove.</param>
        /// <remarks>The build definition is not saved after the mappings are cleared.</remarks>
        public static void RemoveLocalMapping(IBuildDefinition buildDefinition, string localItem)
        {
            // Validation
            ArgumentValidation.ValidateObjectIsNotNull(buildDefinition, "buildDefinition");
            ArgumentValidation.ValidateStringIsNotEmpty(localItem, "localItem");

            var buildWorkspaceMappings = buildDefinition.Workspace.Mappings;

            foreach (var mapping in buildWorkspaceMappings)
            {
                if (mapping.LocalItem.Equals(localItem, StringComparison.OrdinalIgnoreCase))
                {
                    buildWorkspaceMappings.Remove(mapping);
                    break;
                }
            }
        }