PageRenderTime 57ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/Microsoft.Build/Microsoft.Build/Microsoft/Build/Evaluation/ProjectItem.cs

#
C# | 608 lines | 555 code | 53 blank | 0 comment | 81 complexity | 6a31feaabd3ad2df700450de32ae5b2d MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
  1. namespace Microsoft.Build.Evaluation
  2. {
  3. using Microsoft.Build.Collections;
  4. using Microsoft.Build.Construction;
  5. using Microsoft.Build.Shared;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Diagnostics;
  9. using System.Runtime;
  10. [DebuggerDisplay("{ItemType}={EvaluatedInclude} [{UnevaluatedInclude}] #DirectMetadata={DirectMetadataCount}")]
  11. public class ProjectItem : IItem<ProjectMetadata>, IItem, IKeyed, IProjectMetadataParent, IMetadataTable
  12. {
  13. private Microsoft.Build.Evaluation.BuiltInMetadata builtInMetadata;
  14. private PropertyDictionary<ProjectMetadata> directMetadata;
  15. private readonly string evaluatedIncludeBeforeWildcardExpansionEscaped;
  16. private string evaluatedIncludeEscaped;
  17. private readonly List<ProjectItemDefinition> inheritedItemDefinitions;
  18. private readonly Microsoft.Build.Evaluation.Project project;
  19. private ProjectItemElement xml;
  20. internal ProjectItem(Microsoft.Build.Evaluation.Project project, ProjectItemElement xml, string evaluatedIncludeEscaped, string evaluatedIncludeBeforeWildcardExpansionEscaped, PropertyDictionary<ProjectMetadata> directMetadataCloned, List<ProjectItemDefinition> inheritedItemDefinitionsCloned)
  21. {
  22. ErrorUtilities.VerifyThrowInternalNull(project, "project");
  23. ErrorUtilities.VerifyThrowArgumentNull(xml, "xml");
  24. ErrorUtilities.VerifyThrowArgumentNull(evaluatedIncludeEscaped, "evaluatedIncludeEscaped");
  25. ErrorUtilities.VerifyThrowArgumentNull(evaluatedIncludeBeforeWildcardExpansionEscaped, "evaluatedIncludeBeforeWildcardExpansionEscaped");
  26. this.xml = xml;
  27. this.project = project;
  28. this.evaluatedIncludeEscaped = evaluatedIncludeEscaped;
  29. this.evaluatedIncludeBeforeWildcardExpansionEscaped = evaluatedIncludeBeforeWildcardExpansionEscaped;
  30. this.directMetadata = directMetadataCloned;
  31. this.inheritedItemDefinitions = inheritedItemDefinitionsCloned;
  32. }
  33. internal void ChangeItemType(string newItemType)
  34. {
  35. ErrorUtilities.VerifyThrowArgumentLength(newItemType, "ItemType");
  36. this.Project.VerifyThrowInvalidOperationNotImported(this.xml.ContainingProject);
  37. ErrorUtilities.VerifyThrowInvalidOperation((this.xml.Parent != null) && (this.xml.Parent.Parent != null), "OM_ObjectIsNoLongerActive");
  38. if (!string.Equals(this.ItemType, newItemType, StringComparison.Ordinal))
  39. {
  40. this.project.SplitItemElementIfNecessary(this.xml);
  41. this.project.RemoveItemBeforeItemTypeChange(this);
  42. try
  43. {
  44. this.xml.ChangeItemType(newItemType);
  45. }
  46. finally
  47. {
  48. this.project.ReAddExistingItemAfterItemTypeChange(this);
  49. }
  50. }
  51. }
  52. private string GetBuiltInMetadataEscaped(string name)
  53. {
  54. string str = null;
  55. if (!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name))
  56. {
  57. return str;
  58. }
  59. this.builtInMetadata = this.builtInMetadata ?? new Microsoft.Build.Evaluation.BuiltInMetadata(this.project.DirectoryPath);
  60. return this.builtInMetadata.GetMetadataValueEscaped(this.project.DirectoryPath, this.evaluatedIncludeBeforeWildcardExpansionEscaped, this.evaluatedIncludeEscaped, name);
  61. }
  62. private ProjectMetadata GetItemDefinitionMetadata(string name)
  63. {
  64. ProjectMetadata metadata = null;
  65. ProjectItemDefinition definition2;
  66. if (this.inheritedItemDefinitions != null)
  67. {
  68. foreach (ProjectItemDefinition definition in this.inheritedItemDefinitions)
  69. {
  70. metadata = definition.GetMetadata(name);
  71. if (metadata != null)
  72. {
  73. return metadata;
  74. }
  75. }
  76. }
  77. if (this.project.ItemDefinitions.TryGetValue(this.ItemType, out definition2))
  78. {
  79. metadata = definition2.GetMetadata(name);
  80. }
  81. return metadata;
  82. }
  83. public ProjectMetadata GetMetadata(string name)
  84. {
  85. ErrorUtilities.VerifyThrowArgumentLength(name, "name");
  86. ProjectMetadata itemDefinitionMetadata = null;
  87. if (this.directMetadata != null)
  88. {
  89. itemDefinitionMetadata = this.directMetadata[name];
  90. }
  91. if (itemDefinitionMetadata == null)
  92. {
  93. itemDefinitionMetadata = this.GetItemDefinitionMetadata(name);
  94. }
  95. return itemDefinitionMetadata;
  96. }
  97. public string GetMetadataValue(string name)
  98. {
  99. return EscapingUtilities.UnescapeAll(((IItem) this).GetMetadataValueEscaped(name));
  100. }
  101. public bool HasMetadata(string name)
  102. {
  103. return (((this.directMetadata != null) && this.directMetadata.Contains(name)) || (FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name) || (this.GetItemDefinitionMetadata(name) != null)));
  104. }
  105. string IItem.GetMetadataValueEscaped(string name)
  106. {
  107. ErrorUtilities.VerifyThrowArgumentLength(name, "name");
  108. string evaluatedValueEscaped = null;
  109. if (this.directMetadata != null)
  110. {
  111. ProjectMetadata metadata = this.directMetadata[name];
  112. if (metadata != null)
  113. {
  114. evaluatedValueEscaped = metadata.EvaluatedValueEscaped;
  115. }
  116. }
  117. if (evaluatedValueEscaped == null)
  118. {
  119. evaluatedValueEscaped = this.GetBuiltInMetadataEscaped(name);
  120. }
  121. if (evaluatedValueEscaped == null)
  122. {
  123. ProjectMetadata itemDefinitionMetadata = this.GetItemDefinitionMetadata(name);
  124. if ((itemDefinitionMetadata != null) && Expander<ProjectProperty, ProjectItem>.ExpressionMayContainExpandableExpressions(itemDefinitionMetadata.EvaluatedValueEscaped))
  125. {
  126. evaluatedValueEscaped = new Expander<ProjectProperty, ProjectItem>(null, null, new BuiltInMetadataTable(this)).ExpandIntoStringLeaveEscaped(itemDefinitionMetadata.EvaluatedValueEscaped, ExpanderOptions.ExpandBuiltInMetadata, itemDefinitionMetadata.Location);
  127. }
  128. else if (itemDefinitionMetadata != null)
  129. {
  130. return itemDefinitionMetadata.EvaluatedValueEscaped;
  131. }
  132. }
  133. return (evaluatedValueEscaped ?? string.Empty);
  134. }
  135. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  136. ProjectMetadata IItem<ProjectMetadata>.GetMetadata(string name)
  137. {
  138. return this.GetMetadata(name);
  139. }
  140. ProjectMetadata IItem<ProjectMetadata>.SetMetadata(ProjectMetadataElement metadataElement, string evaluatedInclude)
  141. {
  142. this.directMetadata = this.directMetadata ?? new PropertyDictionary<ProjectMetadata>();
  143. ProjectMetadata predecessor = this.GetMetadata(metadataElement.Name);
  144. ProjectMetadata projectProperty = new ProjectMetadata(this, metadataElement, evaluatedInclude, predecessor);
  145. this.directMetadata.Set(projectProperty);
  146. return projectProperty;
  147. }
  148. string IMetadataTable.GetEscapedValue(string name)
  149. {
  150. return ((IMetadataTable) this).GetEscapedValue(null, name);
  151. }
  152. string IMetadataTable.GetEscapedValue(string itemType, string name)
  153. {
  154. return (((IMetadataTable) this).GetEscapedValueIfPresent(itemType, name) ?? string.Empty);
  155. }
  156. string IMetadataTable.GetEscapedValueIfPresent(string itemType, string name)
  157. {
  158. if ((itemType == null) || MSBuildNameIgnoreCaseComparer.Default.Equals(this.ItemType, itemType))
  159. {
  160. string metadataValueEscaped = ((IItem) this).GetMetadataValueEscaped(name);
  161. if ((metadataValueEscaped.Length > 0) || this.HasMetadata(name))
  162. {
  163. return metadataValueEscaped;
  164. }
  165. }
  166. return null;
  167. }
  168. public bool RemoveMetadata(string name)
  169. {
  170. ErrorUtilities.VerifyThrowArgumentLength(name, "name");
  171. ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name), "ItemSpecModifierCannotBeCustomMetadata", name);
  172. this.Project.VerifyThrowInvalidOperationNotImported(this.xml.ContainingProject);
  173. ErrorUtilities.VerifyThrowInvalidOperation((this.xml.Parent != null) && (this.xml.Parent.Parent != null), "OM_ObjectIsNoLongerActive");
  174. if (((this.directMetadata == null) ? null : this.directMetadata[name]) == null)
  175. {
  176. ErrorUtilities.VerifyThrowInvalidOperation(this.GetItemDefinitionMetadata(name) == null, "OM_CannotRemoveMetadataOriginatingFromItemDefinition", name);
  177. return false;
  178. }
  179. this.project.SplitItemElementIfNecessary(this.xml);
  180. ProjectMetadata metadata = this.directMetadata[name];
  181. this.xml.RemoveChild(metadata.Xml);
  182. this.directMetadata.Remove(name);
  183. return true;
  184. }
  185. public void Rename(string name)
  186. {
  187. this.Project.VerifyThrowInvalidOperationNotImported(this.xml.ContainingProject);
  188. ErrorUtilities.VerifyThrowInvalidOperation((this.xml.Parent != null) && (this.xml.Parent.Parent != null), "OM_ObjectIsNoLongerActive");
  189. if (!string.Equals(this.UnevaluatedInclude, name, StringComparison.Ordinal))
  190. {
  191. if (((this.xml.Count == 0) && this.project.IsSuitableExistingItemXml(this.xml, name, null)) && !FileMatcher.HasWildcardsSemicolonItemOrPropertyReferences(name))
  192. {
  193. this.evaluatedIncludeEscaped = name;
  194. }
  195. else
  196. {
  197. bool flag = this.project.SplitItemElementIfNecessary(this.xml);
  198. this.xml.Include = name;
  199. if (flag)
  200. {
  201. this.evaluatedIncludeEscaped = name;
  202. }
  203. else
  204. {
  205. this.evaluatedIncludeEscaped = this.project.ExpandItemIncludeBestEffortLeaveEscaped(this.xml);
  206. }
  207. this.builtInMetadata = null;
  208. }
  209. }
  210. }
  211. public ProjectMetadata SetMetadataValue(string name, string unevaluatedValue)
  212. {
  213. ProjectMetadata metadata;
  214. this.Project.VerifyThrowInvalidOperationNotImported(this.xml.ContainingProject);
  215. XmlUtilities.VerifyThrowArgumentValidElementName(name);
  216. ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name), "ItemSpecModifierCannotBeCustomMetadata", name);
  217. ErrorUtilities.VerifyThrowInvalidOperation(XMakeElements.IllegalItemPropertyNames[name] == null, "CannotModifyReservedItemMetadata", name);
  218. ErrorUtilities.VerifyThrowInvalidOperation((this.xml.Parent != null) && (this.xml.Parent.Parent != null), "OM_ObjectIsNoLongerActive");
  219. this.project.SplitItemElementIfNecessary(this.xml);
  220. if (this.directMetadata != null)
  221. {
  222. metadata = this.directMetadata[name];
  223. if (metadata != null)
  224. {
  225. metadata.UnevaluatedValue = unevaluatedValue;
  226. return metadata;
  227. }
  228. }
  229. ProjectMetadataElement xml = this.xml.AddMetadata(name, unevaluatedValue);
  230. this.directMetadata = this.directMetadata ?? new PropertyDictionary<ProjectMetadata>();
  231. string evaluatedValueEscaped = this.project.ExpandMetadataValueBestEffortLeaveEscaped(this, unevaluatedValue, xml.Location);
  232. metadata = new ProjectMetadata(this, xml, evaluatedValueEscaped, null);
  233. this.directMetadata.Set(metadata);
  234. return metadata;
  235. }
  236. internal void SplitOwnItemElement()
  237. {
  238. ProjectItemElement xml = this.xml;
  239. this.xml = this.xml.ContainingProject.CreateItemElement(this.ItemType, ((IItem) this).EvaluatedIncludeEscaped);
  240. xml.Parent.InsertBeforeChild(this.xml, xml);
  241. if (this.directMetadata != null)
  242. {
  243. List<ProjectMetadata> list = new List<ProjectMetadata>(this.directMetadata.Count);
  244. foreach (ProjectMetadata metadata in this.directMetadata)
  245. {
  246. list.Add(metadata);
  247. }
  248. this.directMetadata = (this.directMetadata == null) ? null : new PropertyDictionary<ProjectMetadata>(this.directMetadata.Count);
  249. foreach (ProjectMetadata metadata2 in list)
  250. {
  251. this.SetMetadataValue(metadata2.Name, metadata2.EvaluatedValueEscaped);
  252. }
  253. }
  254. }
  255. internal Microsoft.Build.Evaluation.BuiltInMetadata BuiltInMetadata
  256. {
  257. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  258. get
  259. {
  260. return this.builtInMetadata;
  261. }
  262. }
  263. public IEnumerable<ProjectMetadata> DirectMetadata
  264. {
  265. get
  266. {
  267. return (this.directMetadata ?? ReadOnlyEmptyCollection<ProjectMetadata>.Instance);
  268. }
  269. }
  270. public int DirectMetadataCount
  271. {
  272. [DebuggerStepThrough]
  273. get
  274. {
  275. if (this.directMetadata == null)
  276. {
  277. return 0;
  278. }
  279. return this.directMetadata.Count;
  280. }
  281. }
  282. public string EvaluatedInclude
  283. {
  284. [DebuggerStepThrough]
  285. get
  286. {
  287. return EscapingUtilities.UnescapeAll(this.evaluatedIncludeEscaped);
  288. }
  289. }
  290. internal string EvaluatedIncludeBeforeWildcardExpansion
  291. {
  292. [DebuggerStepThrough]
  293. get
  294. {
  295. return EscapingUtilities.UnescapeAll(this.evaluatedIncludeBeforeWildcardExpansionEscaped);
  296. }
  297. }
  298. internal string EvaluatedIncludeBeforeWildcardExpansionEscaped
  299. {
  300. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  301. get
  302. {
  303. return this.evaluatedIncludeBeforeWildcardExpansionEscaped;
  304. }
  305. }
  306. internal List<ProjectItemDefinition> InheritedItemDefinitions
  307. {
  308. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  309. get
  310. {
  311. return this.inheritedItemDefinitions;
  312. }
  313. }
  314. public bool IsImported
  315. {
  316. get
  317. {
  318. return !object.ReferenceEquals(this.xml.ContainingProject, this.project.Xml);
  319. }
  320. }
  321. public string ItemType
  322. {
  323. [DebuggerStepThrough]
  324. get
  325. {
  326. return this.xml.ItemType;
  327. }
  328. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  329. set
  330. {
  331. this.ChangeItemType(value);
  332. }
  333. }
  334. public ICollection<ProjectMetadata> Metadata
  335. {
  336. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  337. get
  338. {
  339. return this.MetadataCollection;
  340. }
  341. }
  342. internal ICollection<ProjectMetadata> MetadataCollection
  343. {
  344. get
  345. {
  346. Dictionary<string, ProjectMetadata> dictionary = new Dictionary<string, ProjectMetadata>(MSBuildNameIgnoreCaseComparer.Default);
  347. ProjectItemDefinition definition = null;
  348. if (this.project.ItemDefinitions.TryGetValue(this.ItemType, out definition))
  349. {
  350. foreach (ProjectMetadata metadata in definition.Metadata)
  351. {
  352. dictionary[metadata.Name] = metadata;
  353. }
  354. }
  355. if (this.inheritedItemDefinitions != null)
  356. {
  357. for (int i = this.inheritedItemDefinitions.Count - 1; i >= 0; i--)
  358. {
  359. foreach (ProjectMetadata metadata2 in this.inheritedItemDefinitions[i].Metadata)
  360. {
  361. dictionary[metadata2.Name] = metadata2;
  362. }
  363. }
  364. }
  365. if (this.directMetadata != null)
  366. {
  367. foreach (ProjectMetadata metadata3 in this.directMetadata)
  368. {
  369. dictionary[metadata3.Name] = metadata3;
  370. }
  371. }
  372. return dictionary.Values;
  373. }
  374. }
  375. public int MetadataCount
  376. {
  377. [DebuggerStepThrough]
  378. get
  379. {
  380. return (this.MetadataCollection.Count + FileUtilities.ItemSpecModifiers.All.Length);
  381. }
  382. }
  383. string IKeyed.Key
  384. {
  385. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  386. get
  387. {
  388. return this.ItemType;
  389. }
  390. }
  391. [DebuggerBrowsable(DebuggerBrowsableState.Never)]
  392. string IItem.EvaluatedIncludeEscaped
  393. {
  394. [DebuggerStepThrough]
  395. get
  396. {
  397. return this.evaluatedIncludeEscaped;
  398. }
  399. }
  400. string IItem.ProjectDirectory
  401. {
  402. get
  403. {
  404. return this.project.DirectoryPath;
  405. }
  406. }
  407. [DebuggerBrowsable(DebuggerBrowsableState.Never)]
  408. public Microsoft.Build.Evaluation.Project Project
  409. {
  410. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  411. get
  412. {
  413. return this.project;
  414. }
  415. }
  416. public string UnevaluatedInclude
  417. {
  418. [DebuggerStepThrough]
  419. get
  420. {
  421. return this.xml.Include;
  422. }
  423. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  424. set
  425. {
  426. this.Rename(value);
  427. }
  428. }
  429. [DebuggerBrowsable(DebuggerBrowsableState.Never)]
  430. public ProjectItemElement Xml
  431. {
  432. [DebuggerStepThrough, TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  433. get
  434. {
  435. return this.xml;
  436. }
  437. }
  438. private class BuiltInMetadataTable : IMetadataTable
  439. {
  440. private ProjectItem item;
  441. internal BuiltInMetadataTable(ProjectItem item)
  442. {
  443. this.item = item;
  444. }
  445. public string GetEscapedValue(string name)
  446. {
  447. return this.item.GetBuiltInMetadataEscaped(name);
  448. }
  449. public string GetEscapedValue(string itemType, string name)
  450. {
  451. return (this.GetEscapedValueIfPresent(itemType, name) ?? string.Empty);
  452. }
  453. public string GetEscapedValueIfPresent(string itemType, string name)
  454. {
  455. string str = null;
  456. if ((itemType != null) && !string.Equals(this.item.ItemType, itemType, StringComparison.OrdinalIgnoreCase))
  457. {
  458. return str;
  459. }
  460. return this.GetEscapedValue(name);
  461. }
  462. }
  463. internal class ProjectItemFactory : IItemFactory<ProjectItem, ProjectItem>
  464. {
  465. private readonly Project project;
  466. private ProjectItemElement xml;
  467. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  468. internal ProjectItemFactory(Project project)
  469. {
  470. this.project = project;
  471. }
  472. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  473. internal ProjectItemFactory(Project project, ProjectItemElement xml)
  474. {
  475. this.project = project;
  476. this.xml = xml;
  477. }
  478. public ProjectItem CreateItem(ProjectItem source)
  479. {
  480. return this.CreateItem(source.evaluatedIncludeEscaped, source.evaluatedIncludeBeforeWildcardExpansionEscaped, source);
  481. }
  482. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  483. public ProjectItem CreateItem(string include)
  484. {
  485. return this.CreateItem(include, include);
  486. }
  487. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  488. public ProjectItem CreateItem(string evaluatedIncludeEscaped, ProjectItem source)
  489. {
  490. return this.CreateItem(evaluatedIncludeEscaped, evaluatedIncludeEscaped, source);
  491. }
  492. public ProjectItem CreateItem(string evaluatedIncludeEscaped, string evaluatedIncludeBeforeWildcardExpansion)
  493. {
  494. ErrorUtilities.VerifyThrowInternalNull(this.xml, "xml");
  495. return new ProjectItem(this.project, this.xml, evaluatedIncludeEscaped, evaluatedIncludeBeforeWildcardExpansion, null, null);
  496. }
  497. private ProjectItem CreateItem(string evaluatedIncludeEscaped, string evaluatedIncludeBeforeWildcardExpansionEscaped, ProjectItem source)
  498. {
  499. ProjectItemDefinition definition;
  500. ErrorUtilities.VerifyThrowInternalNull(this.xml, "xml");
  501. PropertyDictionary<ProjectMetadata> directMetadataCloned = null;
  502. if (source.DirectMetadataCount > 0)
  503. {
  504. directMetadataCloned = new PropertyDictionary<ProjectMetadata>(source.DirectMetadataCount);
  505. foreach (ProjectMetadata metadata in source.directMetadata)
  506. {
  507. directMetadataCloned.Set(metadata.DeepClone());
  508. }
  509. }
  510. int num = (source.inheritedItemDefinitions == null) ? 0 : source.inheritedItemDefinitions.Count;
  511. List<ProjectItemDefinition> inheritedItemDefinitionsCloned = null;
  512. if (source.inheritedItemDefinitions != null)
  513. {
  514. inheritedItemDefinitionsCloned = inheritedItemDefinitionsCloned ?? new List<ProjectItemDefinition>(num + 1);
  515. inheritedItemDefinitionsCloned.AddRange(source.inheritedItemDefinitions);
  516. }
  517. if (this.project.ItemDefinitions.TryGetValue(source.ItemType, out definition))
  518. {
  519. inheritedItemDefinitionsCloned = inheritedItemDefinitionsCloned ?? new List<ProjectItemDefinition>(num + 1);
  520. inheritedItemDefinitionsCloned.Add(definition);
  521. }
  522. return new ProjectItem(this.project, this.xml, evaluatedIncludeEscaped, evaluatedIncludeBeforeWildcardExpansionEscaped, directMetadataCloned, inheritedItemDefinitionsCloned);
  523. }
  524. public void SetMetadata(IEnumerable<Pair<ProjectMetadataElement, string>> metadata, IEnumerable<ProjectItem> destinationItems)
  525. {
  526. foreach (IItem<ProjectMetadata> item in destinationItems)
  527. {
  528. foreach (Pair<ProjectMetadataElement, string> pair in metadata)
  529. {
  530. item.SetMetadata(pair.Key, pair.Value);
  531. }
  532. }
  533. }
  534. public ProjectItemElement ItemElement
  535. {
  536. [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
  537. set
  538. {
  539. this.xml = value;
  540. }
  541. }
  542. public string ItemType
  543. {
  544. get
  545. {
  546. return this.xml.ItemType;
  547. }
  548. set
  549. {
  550. ErrorUtilities.ThrowInternalError("Cannot change the item type on ProjectItem.ProjectItemFactory", new object[0]);
  551. }
  552. }
  553. }
  554. }
  555. }