SetMetadata() public method

Set an attribute on the project element
public SetMetadata ( string attributeName, string attributeValue ) : void
attributeName string Name of the attribute to set
attributeValue string Value to give to the attribute. Use null to delete the metadata definition.
return void
Esempio n. 1
0
        /// <summary>
        ///     Links a reference node to the project file.
        /// </summary>
        protected override void BindReferenceData()
        {
            Debug.Assert(!string.IsNullOrEmpty(ReferencedProjectName),
                "The referencedProjectName field has not been initialized");
            Debug.Assert(referencedProjectGuid != Guid.Empty, "The referencedProjectName field has not been initialized");

            ItemNode = new ProjectElement(ProjectMgr, referencedProjectRelativePath,
                ProjectFileConstants.ProjectReference);

            ItemNode.SetMetadata(ProjectFileConstants.Name, ReferencedProjectName);
            ItemNode.SetMetadata(ProjectFileConstants.Project, referencedProjectGuid.ToString("B"));
            ItemNode.SetMetadata(ProjectFileConstants.Private, true.ToString());
        }
Esempio n. 2
0
        private ProjectElement GetProjectElementBasedOnInputFromComponentSelectorData()
        {
            var element = new ProjectElement(ProjectMgr, typeName, ProjectFileConstants.COMReference);

            // Set the basic information regarding this COM component
            element.SetMetadata(ProjectFileConstants.Guid, typeGuid.ToString("B"));
            element.SetMetadata(ProjectFileConstants.VersionMajor, majorVersionNumber);
            element.SetMetadata(ProjectFileConstants.VersionMinor, minorVersionNumber);
            element.SetMetadata(ProjectFileConstants.Lcid, LCID);
            element.SetMetadata(ProjectFileConstants.Isolated, false.ToString());

            // See if a PIA exist for this component
            var typelib = new TypeLibConverter();
            string assemblyName;
            string assemblyCodeBase;
            if (typelib.GetPrimaryInteropAssembly(typeGuid, int.Parse(majorVersionNumber, CultureInfo.InvariantCulture),
                int.Parse(minorVersionNumber, CultureInfo.InvariantCulture),
                int.Parse(LCID, CultureInfo.InvariantCulture), out assemblyName, out assemblyCodeBase))
            {
                element.SetMetadata(ProjectFileConstants.WrapperTool,
                    WrapperToolAttributeValue.Primary.ToString().ToLowerInvariant());
            }
            else
            {
                // MSBuild will have to generate an interop assembly
                element.SetMetadata(ProjectFileConstants.WrapperTool,
                    WrapperToolAttributeValue.TlbImp.ToString().ToLowerInvariant());
                element.SetMetadata(ProjectFileConstants.EmbedInteropTypes, true.ToString());
                element.SetMetadata(ProjectFileConstants.Private, true.ToString());
            }
            return element;
        }