SetProjectFileDirty() public method

Set dirty state of project
public SetProjectFileDirty ( bool value ) : void
value bool boolean value indicating dirty state
return void
Esempio n. 1
0
        /// <summary>
        /// Set an attribute on the project element
        /// </summary>
        /// <param name="attributeName">Name of the attribute to set</param>
        /// <param name="attributeValue">Value to give to the attribute.  Use <c>null</c> to delete the metadata definition.</param>
        public void SetMetadata(string attributeName, string attributeValue)
        {
            Debug.Assert(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) != 0, "Use rename as this won't work");

            if (this.IsVirtual)
            {
                // For virtual node, use our virtual property collection
                if (virtualProperties.ContainsKey(attributeName))
                {
                    virtualProperties.Remove(attributeName);
                }
                virtualProperties.Add(attributeName, attributeValue);
                return;
            }

            // Build Action is the type, not a property, so intercept
            if (String.Equals(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase))
            {
                item.ItemType = attributeValue;
                return;
            }
            ThreadHelper.ThrowIfNotOnUIThread();

            String currentValue = item?.GetMetadataValue(attributeName);
            bool   changed;

            if (String.IsNullOrEmpty(currentValue) && String.IsNullOrEmpty(attributeValue))
            {
                changed = false;
            }
            else
            {
                changed = String.Compare(currentValue, attributeValue) != 0;
            }
            if (changed)
            {
                // Check out the project file.
                if (!this.itemProject.QueryEditProjectFile(false))
                {
                    throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
                }

                if (attributeValue == null)
                {
                    item.RemoveMetadata(attributeName);
                }
                else
                {
                    item.SetMetadataValue(attributeName, attributeValue);
                }
                itemProject.SetProjectFileDirty(true);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Set an attribute on the project element
        /// </summary>
        /// <param name="attributeName">Name of the attribute to set</param>
        /// <param name="attributeValue">Value to give to the attribute</param>
        public void SetMetadata(string attributeName, string attributeValue)
        {
            Debug.Assert(String.Compare(attributeName, ProjectFileConstants.Include, StringComparison.OrdinalIgnoreCase) != 0, "Use rename as this won't work");

            if (this.IsVirtual)
            {
                // For virtual node, use our virtual property collection
                if (virtualProperties.ContainsKey(attributeName))
                {
                    virtualProperties.Remove(attributeName);
                }
                virtualProperties.Add(attributeName, attributeValue);
                return;
            }

            // Build Action is the type, not a property, so intercept
            if (String.Compare(attributeName, ProjectFileConstants.BuildAction, StringComparison.OrdinalIgnoreCase) == 0)
            {
                item.Name = attributeValue;
                return;
            }

            // Check out the project file.
            if (!this.itemProject.QueryEditProjectFile(false))
            {
                throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
            }

            if (attributeValue == null)
            {
                item.RemoveMetadata(attributeName);
            }
            else
            {
                item.SetMetadata(attributeName, attributeValue);
            }
            itemProject.SetProjectFileDirty(true);
        }