예제 #1
0
 public int Find(Microsoft.Build.Evaluation.Project prj)
 {
     int iCount = Items.Count;
     int i = 0;
     string sGUID = prj.GetPropertyValue("ProjectGuid");
     for (i=0;i<iCount;i++)
     {
         string GuidOfItem = Items[i].Project.GetPropertyValue("ProjectGuid");
         if (sGUID.Equals(GuidOfItem))
         {
             return i;
         }
     }
     return -1;
 }
예제 #2
0
		static bool? GetBoolProperty(Microsoft.Build.Evaluation.Project p, string propertyName)
		{
			string val = p.GetPropertyValue(propertyName);
			if (val.Equals("true", StringComparison.OrdinalIgnoreCase))
				return true;
			if (val.Equals("false", StringComparison.OrdinalIgnoreCase))
				return false;
			return null;
		}
예제 #3
0
        void SetCompilerSettings(Microsoft.Build.Evaluation.Project p)
        {
            CompilerSettings = new CompilerSettings
            {
                AllowUnsafeBlocks = GetBoolProperty(p, "AllowUnsafeBlocks") ?? false,
                CheckForOverflow = GetBoolProperty(p, "CheckForOverflowUnderflow") ?? false
            };
            string[] defines = p.GetPropertyValue("DefineConstants")
                .Split(new [] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string define in defines)
                CompilerSettings.ConditionalSymbols.Add(define);

            var config = ConfigurationLoader.Config;
            foreach (var define in config.Defines)
                CompilerSettings.ConditionalSymbols.Add(define);
        }
예제 #4
0
        public static string GetCommandsDisplayLabel(
            Microsoft.Build.Evaluation.Project project,
            IPythonProject2 projectNode
        ) {
            var label = project.GetPropertyValue("PythonCommandsDisplayLabel") ?? string.Empty;
            
            var match = _customCommandLabelRegex.Match(label);
            if (match.Success) {
                label = LoadResourceFromAssembly(
                    match.Groups["assembly"].Value,
                    match.Groups["namespace"].Value,
                    match.Groups["key"].Value
                );
            }

            if (string.IsNullOrEmpty(label)) {
                return Strings.PythonMenuLabel;
            }

            return PerformSubstitutions(projectNode, label);
        }
예제 #5
0
        public static IEnumerable<CustomCommand> GetCommands(
            Microsoft.Build.Evaluation.Project project,
            PythonProjectNode projectNode
        ) {
            var commandNames = project.GetPropertyValue(PythonCommands);
            if (!string.IsNullOrEmpty(commandNames)) {
                foreach (var name in commandNames.Split(';').Where(n => !string.IsNullOrEmpty(n)).Distinct()) {
                    ProjectTargetInstance targetInstance;
                    if (!project.Targets.TryGetValue(name, out targetInstance)) {
                        continue;
                    }

                    var targetXml = (targetInstance.Location.File == project.FullPath) ?
                        project.Xml :
                        // TryOpen will only return targets that were already
                        // loaded in the current collection; otherwise, null.
                        ProjectRootElement.TryOpen(targetInstance.Location.File, project.ProjectCollection);

                    if (targetXml == null) {
                        continue;
                    }

                    var target = targetXml.Targets.FirstOrDefault(t => name.Equals(t.Name, StringComparison.OrdinalIgnoreCase));
                    if (target != null) {
                        yield return new CustomCommand(projectNode, target.Name, target.Label);
                    }
                }
            }
        }
예제 #6
0
 static bool? GetBoolProperty(Microsoft.Build.Evaluation.Project p, string propertyName)
 {
     string val = p.GetPropertyValue(propertyName);
     bool result;
     if (bool.TryParse(val, out result))
         return result;
     else
         return null;
 }
 public static String GetEvaluatedProperty(Microsoft.Build.Evaluation.Project project, String name)
 {
     return project.GetPropertyValue(name);
 }