aboutsummaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs
diff options
context:
space:
mode:
authorAndreas Haas2017-10-03 00:13:40 +0200
committerGitHub2017-10-03 00:13:40 +0200
commitb0194a33f65970948ef66819913bf3034a3a22e8 (patch)
tree35e21b53b10bbd525506bb5b72b7f89214e1234f /modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs
parent5cd68abf8896fd86a33c048d6fece61c3cd3f8e5 (diff)
parentd5caf71c3fcdeb422d1b0ea97a836fcdb57a8713 (diff)
downloadgodot-b0194a33f65970948ef66819913bf3034a3a22e8.tar.gz
godot-b0194a33f65970948ef66819913bf3034a3a22e8.tar.zst
godot-b0194a33f65970948ef66819913bf3034a3a22e8.zip
Merge pull request #11739 from neikeq/tengo-el-mono
Moved mono module here
Diffstat (limited to 'modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs')
-rw-r--r--modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs b/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs
new file mode 100644
index 000000000..6a9773153
--- /dev/null
+++ b/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs
@@ -0,0 +1,49 @@
+using System;
+using Microsoft.Build.Construction;
+
+namespace GodotSharpTools.Project
+{
+ public static class ProjectExtensions
+ {
+ public static bool HasItem(this ProjectRootElement root, string itemType, string include)
+ {
+ string includeNormalized = include.NormalizePath();
+
+ foreach (var itemGroup in root.ItemGroups)
+ {
+ if (itemGroup.Condition.Length != 0)
+ continue;
+
+ foreach (var item in itemGroup.Items)
+ {
+ if (item.ItemType == itemType)
+ {
+ if (item.Include.NormalizePath() == includeNormalized)
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public static void AddItemChecked(this ProjectRootElement root, string itemType, string include)
+ {
+ if (!root.HasItem(itemType, include))
+ {
+ root.AddItem(itemType, include);
+ }
+ }
+
+ public static Guid GetGuid(this ProjectRootElement root)
+ {
+ foreach (var property in root.Properties)
+ {
+ if (property.Name == "ProjectGuid")
+ return Guid.Parse(property.Value);
+ }
+
+ return Guid.Empty;
+ }
+ }
+}