Exemplo n.º 1
0
        public virtual string GetDefaultResourceId(ProjectFile file)
        {
            string fname = file.ProjectVirtualPath;

            fname = FileService.NormalizeRelativePath(fname);
            fname = Path.Combine(Path.GetDirectoryName(fname).Replace(' ', '_'), Path.GetFileName(fname));

            if (String.Compare(Path.GetExtension(fname), ".resx", true) == 0)
            {
                fname = Path.ChangeExtension(fname, ".resources");
            }
            else
            {
                string only_filename, culture, extn;
                if (MSBuildProjectService.TrySplitResourceName(fname, out only_filename, out culture, out extn))
                {
                    //remove the culture from fname
                    //foo.it.bmp -> foo.bmp
                    fname = only_filename + "." + extn;
                }
            }

            string rname = fname.Replace(Path.DirectorySeparatorChar, '.');

            DotNetProject dp = file.Project as DotNetProject;

            if (dp == null || String.IsNullOrEmpty(dp.DefaultNamespace))
            {
                return(rname);
            }
            else
            {
                return(dp.DefaultNamespace + "." + rname);
            }
        }
Exemplo n.º 2
0
 public object ReadFile(FilePath file, Type expectedType, MonoDevelop.Core.IProgressMonitor monitor)
 {
     if (slnFileFormat.CanReadFile(file, this))
     {
         return(slnFileFormat.ReadFile(file, this, monitor));
     }
     else
     {
         return(MSBuildProjectService.LoadItem(monitor, file, null, null, null));
     }
 }
 public void Dispose()
 {
     if (engine != null)
     {
         if (builder != null)
         {
             engine.UnloadProject(builder);
         }
         MSBuildProjectService.ReleaseProjectBuilder(engine);
         GC.SuppressFinalize(this);
         engine  = null;
         builder = null;
     }
 }
Exemplo n.º 4
0
		public void Dispose ()
		{
			if (!MSBuildProjectService.ShutDown && engine != null) {
				try {
					if (builder != null)
						engine.UnloadProject (builder);
					MSBuildProjectService.ReleaseProjectBuilder (engine);
				} catch {
					// Ignore
				}
				GC.SuppressFinalize (this);
				engine = null;
				builder = null;
			}
		}
Exemplo n.º 5
0
        public static bool SupportsProjectType(string projectFile)
        {
            if (!string.IsNullOrWhiteSpace(projectFile))
            {
                // If we have a project file, try to load it.
                try {
                    using (var monitor = new ConsoleProgressMonitor()) {
                        return(MSBuildProjectService.LoadItem(monitor, projectFile, null, null, null) != null);
                    }
                } catch {
                    return(false);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
 public bool CanReadFile(FilePath file, Type expectedType)
 {
     if (expectedType.IsAssignableFrom(typeof(Solution)) && slnFileFormat.CanReadFile(file, this))
     {
         return(true);
     }
     else if (expectedType.IsAssignableFrom(typeof(SolutionEntityItem)))
     {
         if (!MSBuildProjectService.CanReadFile(file))
         {
             return(false);
         }
         //TODO: check ProductVersion first
         return(SupportsToolsVersion(ReadToolsVersion(file)));
     }
     return(false);
 }
Exemplo n.º 7
0
 public bool CanReadFile(FilePath file, Type expectedType)
 {
     if (expectedType.IsAssignableFrom(typeof(Solution)) && slnFileFormat.CanReadFile(file, this))
     {
         return(true);
     }
     else if (expectedType.IsAssignableFrom(typeof(SolutionEntityItem)))
     {
         ItemTypeNode node = MSBuildProjectService.FindHandlerForFile(file);
         if (node == null)
         {
             return(false);
         }
         return(toolsVersion == ReadToolsVersion(file));
     }
     return(false);
 }
Exemplo n.º 8
0
 public void WriteFile(FilePath file, object obj, IProgressMonitor monitor)
 {
     if (slnFileFormat.CanWriteFile(obj, this))
     {
         slnFileFormat.WriteFile(file, obj, this, true, monitor);
     }
     else
     {
         SolutionEntityItem item = (SolutionEntityItem)obj;
         if (!(item.ItemHandler is MSBuildProjectHandler))
         {
             MSBuildProjectService.InitializeItemHandler(item);
         }
         MSBuildProjectHandler handler = (MSBuildProjectHandler)item.ItemHandler;
         handler.SetSolutionFormat(this, false);
         handler.Save(monitor);
     }
 }
Exemplo n.º 9
0
 public FilePath GetValidFormatName(object obj, FilePath fileName)
 {
     if (slnFileFormat.CanWriteFile(obj, this))
     {
         return(slnFileFormat.GetValidFormatName(obj, fileName, this));
     }
     else
     {
         string ext = MSBuildProjectService.GetExtensionForItem((SolutionEntityItem)obj);
         if (!string.IsNullOrEmpty(ext))
         {
             return(fileName.ChangeExtension("." + ext));
         }
         else
         {
             return(fileName);
         }
     }
 }
Exemplo n.º 10
0
        public static SolutionEntityItem LoadItem(IProgressMonitor monitor, string fileName, MSBuildFileFormat expectedFormat, string typeGuid, string itemGuid)
        {
            foreach (ItemTypeNode node in GetItemTypeNodes())
            {
                if (node.CanHandleFile(fileName, typeGuid))
                {
                    return(node.LoadSolutionItem(monitor, fileName, expectedFormat, itemGuid));
                }
            }

            if (string.IsNullOrEmpty(typeGuid) && IsProjectSubtypeFile(fileName))
            {
                typeGuid = LoadProjectTypeGuids(fileName);
                foreach (ItemTypeNode node in GetItemTypeNodes())
                {
                    if (node.CanHandleFile(fileName, typeGuid))
                    {
                        return(node.LoadSolutionItem(monitor, fileName, expectedFormat, itemGuid));
                    }
                }
            }

            // If it is a known unsupported project, load it as UnknownProject
            var projectInfo = MSBuildProjectService.GetUnknownProjectTypeInfo(typeGuid != null ? new [] { typeGuid } : new string[0], fileName);

            if (projectInfo != null && projectInfo.LoadFiles)
            {
                if (typeGuid == null)
                {
                    typeGuid = projectInfo.Guid;
                }
                var h = new MSBuildProjectHandler(typeGuid, "", itemGuid);
                h.SetUnsupportedType(projectInfo);
                return(h.Load(monitor, fileName, expectedFormat, "", null));
            }

            return(null);
        }
Exemplo n.º 11
0
        public void ConvertToFormat(object obj)
        {
            if (obj == null)
            {
                return;
            }

            MSBuildHandler handler;
            SolutionItem   item = obj as SolutionItem;

            if (item != null)
            {
                handler = item.GetItemHandler() as MSBuildHandler;
                if (handler != null)
                {
                    handler.SetSolutionFormat(this, true);
                    return;
                }
            }

            MSBuildProjectService.InitializeItemHandler(item);
            handler = (MSBuildHandler)item.ItemHandler;
            handler.SetSolutionFormat(this, true);
        }