public ProjectReferencesFromPackagesFolderNode (
			DotNetProject project,
			ProjectReferenceCollection projectReferences)
		{
			Project = project;
			References = projectReferences;
		}
Пример #2
0
 public FakeDotNetProject(string fileName)
     : base(fileName)
 {
     References = new ProjectReferenceCollection();
     Files      = new ProjectFileCollection();
     CreateEqualsAction();
 }
Пример #3
0
		public FakeDotNetProject ()
		{
			References = new ProjectReferenceCollection ();
			Files = new ProjectFileCollection ();
			TargetFrameworkMoniker = new TargetFrameworkMoniker ("v4.5");
			CreateEqualsAction ();
		}
Пример #4
0
		public FakeDotNetProject (string fileName)
			: base (fileName)
		{
			References = new ProjectReferenceCollection ();
			Files = new ProjectFileCollection ();
			CreateEqualsAction ();
		}
 public ProjectReferencesFromPackagesFolderNode(
     DotNetProject project,
     ProjectReferenceCollection projectReferences)
 {
     Project    = project;
     References = projectReferences;
 }
Пример #6
0
 public FakeDotNetProject()
 {
     References             = new ProjectReferenceCollection();
     Files                  = new ProjectFileCollection();
     TargetFrameworkMoniker = new TargetFrameworkMoniker("v4.5");
     CreateEqualsAction();
 }
 public ProjectReferencesFromPackagesFolderNode(
     DotNetProject project,
     ProjectReferenceCollection projectReferences,
     FilePath packagesFolderPath)
 {
     Project            = project;
     References         = projectReferences;
     PackagesFolderPath = packagesFolderPath;
 }
        public override void BuildChildNodes(ITreeBuilder ctx, object dataObject)
        {
            ProjectReferenceCollection refs = (ProjectReferenceCollection)dataObject;

            foreach (ProjectReference pref in refs)
            {
                ctx.AddChild(pref);
            }
        }
 public ProjectReferencesFromPackagesFolderNode(
     ProjectPackagesFolderNode packagesFolder,
     ProjectReferenceCollection projectReferences)
     : this(
         packagesFolder.DotNetProject,
         projectReferences,
         packagesFolder.PackagesFolderPath)
 {
 }
Пример #10
0
		public DotNetProject ()
		{
			Runtime.SystemAssemblyService.DefaultRuntimeChanged += RuntimeSystemAssemblyServiceDefaultRuntimeChanged;
			projectReferences = new ProjectReferenceCollection ();
			Items.Bind (projectReferences);
			if (IsLibraryBasedProjectType)
				CompileTarget = CompileTarget.Library;
			FileService.FileRemoved += OnFileRemoved;
		}
		public ProjectReferencesFromPackagesFolderNode (
			ProjectPackagesFolderNode packagesFolder,
			ProjectReferenceCollection projectReferences)
			: this (
				packagesFolder.DotNetProject,
				projectReferences,
				packagesFolder.PackagesFolderPath)
		{
		}
		public ProjectReferencesFromPackagesFolderNode (
			DotNetProject project,
			ProjectReferenceCollection projectReferences,
			FilePath packagesFolderPath)
		{
			Project = project;
			References = projectReferences;
			PackagesFolderPath = packagesFolderPath;
		}
Пример #13
0
        public override void BuildChildNodes(ITreeBuilder ctx, object dataObject)
        {
            ProjectReferenceCollection refs = (ProjectReferenceCollection)dataObject;

            ctx.AddChildren(refs);

            // For portable libraries, add node that represents all framework assemblies
            var project = (DotNetProject)ctx.GetParentDataItem(typeof(DotNetProject), false);

            if (project != null && project.IsPortableLibrary)
            {
                ctx.AddChild(new PortableFrameworkSubset(project));
            }
        }
Пример #14
0
    public static void Main()
    {
        ProjectReferenceCollection         references     = Program.ActiveProjectShell.Project.References;
        ProjectAllKnowledgeItemsCollection knowledgeItems = Program.ActiveProjectShell.Project.AllKnowledgeItems;

        foreach (Reference reference in references)
        {
            CheckText("Titel", reference.Abstract.TextRtf, reference.ShortTitle, reference.Id, "Abstract");
            CheckText("Titel", reference.TableOfContents.TextRtf, reference.ShortTitle, reference.Id, "TableOfContents");
            CheckText("Titel", reference.Evaluation.TextRtf, reference.ShortTitle, reference.Id, "Evaluation");
        }
        foreach (KnowledgeItem knowledgeItem in knowledgeItems)
        {
            CheckText("Wissenselement", knowledgeItem.TextRtf, knowledgeItem.CoreStatement, knowledgeItem.Id, "Text");
        }
    }
Пример #15
0
        public void SetReferenceCollection(ProjectReferenceCollection references, AssemblyContext runtime, TargetFramework targetVersion)
        {
            ((ListStore)ReferencesTreeView.Model).Clear();

            projectRefPanel.Hide();

            gacRefPanel.SetTargetFramework(runtime, targetVersion);
            gacRefPanel.Reset();
            assemblyRefPanel.SetBasePath(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

            foreach (ProjectReference refInfo in references)
            {
                AppendReference(refInfo);
            }

            OnChanged(null, null);
        }
        public override void BuildChildNodes(ITreeBuilder ctx, object dataObject)
        {
            ProjectReferenceCollection refs = (ProjectReferenceCollection)dataObject;

            foreach (ProjectReference pref in refs)
            {
                ctx.AddChild(pref);
            }

            // For portable libraries, add node that represents all framework assemblies
            var project = ctx.GetParentDataItem(typeof(DotNetProject), false) as PortableDotNetProject;

            if (project != null)
            {
                ctx.AddChild(new TreeViewItem(GettextCatalog.GetString(".NET Portable Subset"), "md-reference-package"));
            }
        }
        public override void BuildChildNodes(ITreeBuilder ctx, object dataObject)
        {
            ProjectReferenceCollection refs = (ProjectReferenceCollection)dataObject;

            ctx.AddChildren(refs);

            // For portable libraries, add node that represents all framework assemblies
            var project = (DotNetProject)ctx.GetParentDataItem(typeof(DotNetProject), false);

            if (project != null)
            {
                var tfm = project.TargetFramework.Id;
                if (tfm.Identifier == MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.ID_PORTABLE && tfm.Version != "5.0")
                {
                    ctx.AddChild(new PortableFrameworkSubset(project));
                }
            }
        }
        public BuildResult Compile(ProjectFileCollection projectFiles, ProjectReferenceCollection projectReferences, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
        {
            NemerleParameters cp = (NemerleParameters)configuration.CompilationParameters;

            if (cp == null)
            {
                cp = new NemerleParameters();
            }

            string references = "";
            string files      = "";

            foreach (ProjectReference lib in projectReferences)
            {
                foreach (string a in lib.GetReferencedFileNames())
                {
                    references += " -r \"" + a + "\"";
                }
            }

            foreach (ProjectFile f in projectFiles)
            {
                if (f.Subtype != Subtype.Directory)
                {
                    switch (f.BuildAction)
                    {
                    case BuildAction.Compile:
                        files += " \"" + f.Name + "\"";
                        break;
                    }
                }
            }

            if (!Directory.Exists(configuration.OutputDirectory))
            {
                Directory.CreateDirectory(configuration.OutputDirectory);
            }

            string args = "-q -no-color " + GetOptionsString(configuration, cp) + references + files + " -o " + configuration.CompiledOutputName;

            return(DoCompilation(args));
        }
Пример #19
0
 public BuildResult Compile(ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
 {
     return(compilerServices.Compile(projectFiles, references, configuration, monitor));
 }
Пример #20
0
        public static void LoadTargetReferences(this List <SequenceNumberImportInfo> sequenceNumberImportInfos, ProjectReferenceCollection references)
        {
            foreach (var sequenceNumberInfo in sequenceNumberImportInfos)
            {
                sequenceNumberInfo.TargetReference = references.FirstOrDefault(reference => reference.Id == sequenceNumberInfo.SourceId);
            }

            sequenceNumberImportInfos.RemoveAll(reference => reference.TargetReference == null);
        }
Пример #21
0
		protected override void OnInitialize ()
		{
			projectReferences = new ProjectReferenceCollection ();
			Items.Bind (projectReferences);
			FileService.FileRemoved += OnFileRemoved;
			Runtime.SystemAssemblyService.DefaultRuntimeChanged += RuntimeSystemAssemblyServiceDefaultRuntimeChanged;

			base.OnInitialize ();

			if (languageName == null)
				languageName = MSBuildProjectService.GetLanguageFromGuid (TypeGuid);
		}
Пример #22
0
		public bool SelectProjectReferences (ProjectReferenceCollection references, AssemblyContext ctx, TargetFramework targetVersion)
		{
			try {
				if (selDialog == null)
					selDialog = new SelectReferenceDialog ();
				
				selDialog.SetReferenceCollection (references, ctx, targetVersion);

				if (MessageService.RunCustomDialog (selDialog) == (int)Gtk.ResponseType.Ok) {
					references.Clear ();
					references.AddRange (selDialog.ReferenceInformations);
					return true;
				}
				else
					return false;
			} finally {
				if (selDialog != null)
					selDialog.Hide ();
			}
		}
Пример #23
0
		public BuildResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection references, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
		{
			return compilerServices.Compile (projectFiles, references, configuration, monitor);
		}
		protected void GetReferences (Project project, MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References, ProjectReferenceCollection references, IProgressMonitor monitor)
		{
			if (References == null || References.Length == 0)
				return;
			
			monitor.BeginTask (null, 5 + References.Length);
			                      
			try {
				// Get the GAC path
				string strBasePathMono1_0 = GetPackageDirectory ("mono", "mono/1.0");
				
				monitor.Step (1);

				string strBasePathGtkSharp = GetPackageDirectory ("gtk-sharp", "mono/gtk-sharp");
				
				monitor.Step (1);

				string strBasePathGtkSharp2_0 = GetPackageDirectory ("gtk-sharp-2.0", "mono/gtk-sharp-2.0");
				
				monitor.Step (1);

				string strBasePathGeckoSharp = GetPackageDirectory ("gecko-sharp", "mono/gecko-sharp");
				
				monitor.Step (1);

				string strBasePathGeckoSharp2_0 = GetPackageDirectory ("gecko-sharp-2.0", "mono/gecko-sharp-2.0");
				
				string[] monoLibs = new string [] {
					strBasePathMono1_0,
					strBasePathGtkSharp2_0,
					strBasePathGtkSharp,
					strBasePathGeckoSharp2_0,
					strBasePathGeckoSharp
				};

				// Iterate through the reference collection of the csproj file
				foreach (MonoDevelop.Prj2Make.Schema.Csproj.Reference rf in References)
				{
					monitor.Step (1);
					
					ProjectReference rfOut = null;
					
					if (rf.Package != null && rf.Package.Length != 0)
					{
						rfOut = new ProjectReference (MonoDevelop.Projects.ReferenceType.Project, Path.GetFileName (rf.Name));
						rfOut.LocalCopy = true;
						references.Add (rfOut);
					}
					else if (rf.AssemblyName != null)
					{
						string rname = rf.AssemblyName;
						if (rname == "System.XML")
							rname = "System.Xml";
						
						string oref = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyFullName (rname, fx);
						if (oref == null) {
							if (rf.HintPath != null) {
								string asm = MapPath (project.ItemDirectory, rf.HintPath);
								if (!System.IO.File.Exists (asm))
									monitor.ReportWarning (GettextCatalog.GetString ("Referenced assembly not found: ") + asm);
								ProjectReference aref = new ProjectReference (MonoDevelop.Projects.ReferenceType.Assembly, asm);
								references.Add (aref);
								continue;
							}
							monitor.ReportWarning (GettextCatalog.GetString ("Assembly reference could not be imported: ") + rf.AssemblyName);
							continue;
						}
						rfOut = new ProjectReference (MonoDevelop.Projects.ReferenceType.Gac, oref);
						rfOut.LocalCopy = true;
						references.Add (rfOut);
					}
					else if (rf.HintPath != null)
					{
						// HACK - under Unix filenames are case sensitive
						// Under Windows there's no agreement on Xml vs XML ;-)    					
						if (Path.GetFileName (rf.HintPath) == "System.XML.dll")
						{
							ProjectReference pref = GetMonoReferece (strBasePathMono1_0, "System.Xml.dll");
							if (pref != null) {
								references.Add (pref);
								continue;
							}
						} else {
							foreach (string libDir in monoLibs) {
								if (libDir == null) continue;
								if (rf.HintPath == null)
									continue;
								rfOut = GetMonoReferece (libDir, rf.HintPath);
								if (rfOut != null)
									break;
							}
							
							if (rfOut == null) {
								rfOut = new ProjectReference (MonoDevelop.Projects.ReferenceType.Gac, Path.GetFileName (rf.HintPath));
								rfOut.LocalCopy = true;
							}
							references.Add (rfOut);
						}
					}
					else {
						monitor.ReportWarning (GettextCatalog.GetString ("Assembly reference could not be imported: ") + rf.Name);
					}
				}
			} finally {
				monitor.EndTask ();
			}
		}
		public BuildResult Compile (ProjectFileCollection projectFiles, ProjectReferenceCollection projectReferences, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
		{
			NemerleParameters cp = (NemerleParameters) configuration.CompilationParameters;
			if (cp == null) cp = new NemerleParameters ();
			
			string references = "";
			string files   = "";
			
			foreach (ProjectReference lib in projectReferences)
				foreach (string a in lib.GetReferencedFileNames())
					references += " -r \"" + a + "\"";
			
			foreach (ProjectFile f in projectFiles)
				if (f.Subtype != Subtype.Directory)
					switch (f.BuildAction)
					{
						case BuildAction.Compile:
							files += " \"" + f.Name + "\"";
						break;
					}

			if (!Directory.Exists (configuration.OutputDirectory))
				Directory.CreateDirectory (configuration.OutputDirectory);
			
			string args = "-q -no-color " + GetOptionsString (configuration, cp) + references + files  + " -o " + configuration.CompiledOutputName;
			return DoCompilation (args);
		}
        public BuildResult Compile(ProjectItemCollection items, DotNetProjectConfiguration configuration, IProgressMonitor monitor)
        {
            FSharpCompilerParameters compilerparameters = (FSharpCompilerParameters) configuration.CompilationParameters;
            if (compilerparameters == null) compilerparameters = new FSharpCompilerParameters ();

            string responseFileName = Path.GetTempFileName();
            StringWriter writer = new StringWriter ();
            ArrayList gacRoots = new ArrayList ();

            AddOption(writer, "--fullpaths");
            AddOption(writer, "--utf8output");

            ProjectFileCollection projectFiles = new ProjectFileCollection();
            ProjectReferenceCollection references = new ProjectReferenceCollection();
            // FIXME: Plain guesswork
            foreach(ProjectItem item in items)
            {
                ProjectFile file = null;
                ProjectReference reference = null;
                if((file = item as ProjectFile) != null)
                {
                    projectFiles.Add(file);
                }
                else if((reference = item as ProjectReference) != null)
                {
                    references.Add(reference);
                }
                else
                {
                    // Nada...
                }
            }

            if (references != null) {
                foreach (ProjectReference lib in references) {
                    if ((lib.ReferenceType == ReferenceType.Project) &&
                        (!(lib.OwnerProject.ParentSolution.FindProjectByName (lib.Reference) is DotNetProject)))
                        continue;
                    foreach (string fileName in lib.GetReferencedFileNames (configuration.Id)) {
                        switch (lib.ReferenceType) {
                        case ReferenceType.Gac:
                            SystemPackage[] pkgs = Runtime.SystemAssemblyService.GetPackagesFromFullName(lib.Reference);
                            SystemPackage pkg = null;
                            if(pkgs != null && pkgs.Length > 0)
                            {
                                // FIXME: Now handling only one package
                                pkg = pkgs[0];
                            }

                            if (pkg == null) {
                                string msg = String.Format (GettextCatalog.GetString ("{0} could not be found or is invalid."), lib.Reference);
                                monitor.ReportWarning (msg);
                                continue;
                            }
                            else if (pkg.IsInternalPackage) {
                                AddOption(writer,"-r \"" + fileName + "\"");
                            }
                            if (pkg.GacRoot != null && !gacRoots.Contains (pkg.GacRoot))
                                gacRoots.Add (pkg.GacRoot);
                            break;
                        default:
                            AddOption(writer,"-r \"" + fileName + "\"");
                            break;
                        }
                    }
                }
            }

            string exe = configuration.CompiledOutputName;
            AddOption(writer,"--out \"" + exe + '"');

            if (configuration.SignAssembly) {
                if (File.Exists (configuration.AssemblyKeyFile))
                    AddOption(writer,"--keyfile \"" + configuration.AssemblyKeyFile + '"');
            }

            if (configuration.DebugMode) {
                AddOption(writer,"--debug");
            }
            else
                if (compilerparameters.Optimize)
                    AddOption(writer,"--optimize");

            if (compilerparameters.CodePage != 0) {
                AddOption(writer,"--codepage " + compilerparameters.CodePage);
            }

            if (compilerparameters.TreatWarningsAsErrors) {
                AddOption(writer,"--warnaserror");
            }

            if (compilerparameters.DefineSymbols.Length > 0) {
                AddOption(writer,"--define " + compilerparameters.DefineSymbols);
            }

            switch (configuration.CompileTarget) {
                case CompileTarget.Exe:
                    AddOption(writer,"--target exe");
                    break;
                case CompileTarget.WinExe:
                    AddOption(writer,"--target winexe");
                    break;
                case CompileTarget.Library:
                    AddOption(writer,"--target library");
                    break;
                case CompileTarget.Module:
                    AddOption(writer,"--target module");
                    break;
            }

            if (compilerparameters.GenerateXmlDocumentation) {
                AddOption(writer,"-doc \"" + Path.ChangeExtension(exe, ".xml") + '"');
            }

            if (!string.IsNullOrEmpty (compilerparameters.AdditionalArguments)) {
                AddOption(writer,compilerparameters.AdditionalArguments);
            }

            if (!string.IsNullOrEmpty (compilerparameters.NoWarnings)) {
                AddOption(writer, String.Format("--nowarn {0}", compilerparameters.NoWarnings));
            }

            foreach (ProjectFile finfo in projectFiles) {
                if (finfo.Subtype == Subtype.Directory)
                    continue;

                switch (finfo.BuildAction) {
                    case BuildAction.Compile:
                        AddOption(writer,'"' + finfo.Name + '"');
                        break;
            //					case BuildAction.EmbedAsResource:
            //						string fname = finfo.Name;
            //						if (String.Compare (Path.GetExtension (fname), ".resx", true) == 0)
            //							fname = Path.ChangeExtension (fname, ".resources");
            //
            //						AddOption(writer,@"""/res:{0},{1}""", fname, finfo.ResourceId);
            //						break;
                    default:
                        continue;
                }
            }

            writer.Close();

            string output = String.Empty;
            string error  = String.Empty;

            File.WriteAllText (responseFileName, writer.ToString ());

            string compilerName;
            try {
                compilerName = GetCompilerName (configuration.ClrVersion);
            } catch (Exception e) {
                string message = "Could not obtain F# compiler";
                monitor.ReportError (message, e);
                return null;
            }

            //string outstr = compilerName + " @" + responseFileName;
            string outstr = compilerName + " "+ writer.ToString ();
            TempFileCollection tf = new TempFileCollection();

            string workingDir = ".";
            if (projectFiles != null && projectFiles.Count > 0) {
                workingDir = projectFiles [0].Project.BaseDirectory;
                if (workingDir == null)
                    // Dummy projects created for single files have no filename
                    // and so no BaseDirectory.
                    // This is a workaround for a bug in
                    // ProcessStartInfo.WorkingDirectory - not able to handle null
                    workingDir = ".";
            }

            LoggingService.LogInfo (compilerName + " " + writer.ToString ());

            int exitCode = DoCompilation (outstr, tf, workingDir, gacRoots, ref output, ref error);

            BuildResult result = ParseOutput(tf, output, error);
            if (result.CompilerOutput.Trim ().Length != 0)
                monitor.Log.WriteLine (result.CompilerOutput);

            //if compiler crashes, output entire error string
            if (result.ErrorCount == 0 && exitCode != 0) {
                if (!string.IsNullOrEmpty (error))
                    result.AddError (error);
                else
                    result.AddError ("The compiler appears to have crashed without any error output.");
            }

            FileService.DeleteFile (responseFileName);
            FileService.DeleteFile (output);
            FileService.DeleteFile (error);
            return result;
        }
		public void SetReferenceCollection (ProjectReferenceCollection references, AssemblyContext runtime, TargetFramework targetVersion)
		{
			((ListStore) ReferencesTreeView.Model).Clear ();

			projectRefPanel.Hide ();
			
			gacRefPanel.SetTargetFramework (runtime, targetVersion);
			gacRefPanel.Reset ();
			assemblyRefPanel.SetBasePath  (Environment.GetFolderPath (Environment.SpecialFolder.Personal));

			foreach (ProjectReference refInfo in references)
				AppendReference (refInfo);

			OnChanged (null, null);
		}
Пример #28
0
    public static String Export(String path)
    {
        String FOLDERPATH = path + "\\Files\\";
        string Errors     = "";
        string Success    = "";

        try
        {
            var exportedFilenames = new HashSet <string>();

            ProjectReferenceCollection references = Program.ActiveProjectShell.Project.References;

            foreach (Reference reference in references)
            {
                if (reference.Locations.ToList().Count > 0)
                {
                    foreach (Location loc in reference.Locations)
                    {
                        if (loc.Address.LinkedResourceType.ToString().Equals("NotAnUri") ||
                            loc.Address.LinkedResourceType.ToString().Equals("Empty"))
                        {
                            continue;
                        }
                        else if (loc.LocationType == LocationType.Library)
                        {
                            continue;
                        }

                        var saveFilename = loc.Address.Properties.FileName;

                        if (saveFilename == null)
                        {
                            saveFilename = reference.Id.ToString() + "_" + loc.Index.ToString(); // + ".pdf";
                        }

                        if (exportedFilenames.Contains(saveFilename))
                        {
                            Errors += "[ERROR] Duplicate Filename:" + saveFilename + "\n";
                            continue;
                        }

                        exportedFilenames.Add(saveFilename);
                        var resolvedLocation = "";

                        try
                        {
                            resolvedLocation = loc.Address.Resolve(true).ToString();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                            throw;
                        }


                        //if (loc.Address.LinkedResourceType.ToString().Equals("AttachmentFile"))
                        //{
                        //	try
                        //	{
                        //	    if (loc.Address.ToString().EndsWith(".pdf"))
                        //	    {
                        //	        PdfExportOptions opt = new PdfExportOptions();
                        //	        loc.ExportPdf(FOLDERPATH + saveFilename, opt, true);
                        //	        Success += "Successfully exported local PDF (AttachmentFile): \"" +
                        //	                   reference.Title + "\" Address: \"" + loc.Address.ToString() + "\"\r\n";
                        //	    }
                        //	    else
                        //	    {
                        //	        var test = 0;
                        //	    }
                        //	}
                        //	catch (Exception ex)
                        //	{
                        //		Errors += "[ERROR] Failed to export PDF (AttachmentFile): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "ERROR: "+ex+" "+"\"\r\n";
                        //	}
                        //
                        //
                        //}
                        //else //if (loc.Address.LinkedResourceType.ToString().Equals("RemoteUri"))
                        //{
                        try
                        {
                            using (WebClient client = new WebClient())
                            {
                                //client.DownloadFile(loc.Address.ToString(), FOLDERPATH + saveFilename);

                                var    data      = client.DownloadData(resolvedLocation);
                                string extension = "";
                                switch (client.ResponseHeaders["Content-Type"])
                                {
                                case "application/pdf":
                                case "application/pdf;charset=Binary":
                                case "application/pdf;charset=binary":
                                case "application/pdf;charset=base64":
                                case "application/pdf;charset=ISO-8859-1":
                                case "application/pdf; charset=ISO-8859-1":
                                case "image/pdf;charset=ISO-8859-1":
                                    extension = ".pdf";
                                    break;

                                case "text/html; charset=utf-8":
                                case "text/html;charset=UTF-8":
                                case "text/html":
                                case "text/html; charset=UTF-8":
                                case "text/html;charset=utf-8":
                                case "text/html;charset=ISO-8859-1":
                                case "text/html; charset=ISO-8859-1":
                                    extension = ".html";
                                    break;

                                case "image/png":
                                    extension = ".png";
                                    break;

                                case "image/jpeg":
                                    extension = ".jpg";
                                    break;

                                case "application/octet-stream":
                                case null:
                                    extension = "";
                                    break;

                                default:
                                    Success += "Unknown content type:" +
                                               client.ResponseHeaders["Content-Type"];
                                    break;
                                }

                                if (!saveFilename.EndsWith(extension))
                                {
                                    saveFilename += extension;
                                }

                                File.WriteAllBytes(FOLDERPATH + saveFilename, data);

                                Success += "Successfully exported remote PDF(RemoteUri): \"" + reference.Title +
                                           "\" Address: \"" + resolvedLocation + "\"\r\n";
                            }
                        }
                        catch (WebException ex)
                        {
                            DebugMacro.WriteLine("Exception while downloading " + reference.Id.ToString());
                            Errors += "[ERROR] Failed to Download RemoteUri (Web Error): \"" + reference.Title +
                                      "\" Address: \"" + resolvedLocation + " Ex: " + ex + "\"\r\n";
                        }

                        //}
                        //else if (loc.Address.LinkedResourceType.ToString().Equals("AbsoluteFileUri"))
                        //{
                        //	try
                        //	{
                        //	    if (loc.Address.ToString().EndsWith(".pdf"))
                        //	    {
                        //	        PdfExportOptions opt = new PdfExportOptions();
                        //	        loc.ExportPdf(FOLDERPATH + saveFilename, opt, true);
                        //	        Success += "Successfully exported PDF (AbsoluteFileUri): \"" + reference.Title +
                        //	                   "\" Address: \"" + loc.Address.ToString() + "\"\r\n";
                        //	    }
                        //	    else
                        //	    {
                        //	        var test = 0;
                        //	    }
                        //    }
                        //	catch (Exception ex)
                        //	{
                        //		Errors += "Failed to export PDF (AbsoluteFileUri): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "ERROR: " + ex + " " + "\"\r\n";
                        //	}
                        //
                        //
                        //}
                        //else if (loc.Address.LinkedResourceType.ToString().Equals("AttachmentRemote"))
                        //{
                        //	try
                        //	{
                        //	    //if (loc.Address.ToString().EndsWith(".pdf"))
                        //	    //{
                        //	        PdfExportOptions opt = new PdfExportOptions();
                        //	        ;
                        //	        using (WebClient client = new WebClient())
                        //	        {
                        //	            client.DownloadFile(loc.Address.Resolve(true).ToString(), FOLDERPATH + saveFilename);
                        //	            Success += "Successfully exported remote PDF(RemoteUri): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "\"\r\n";
                        //	        }
                        //
                        //            //loc.ExportPdf(FOLDERPATH + saveFilename, opt, true);
                        //	        //Success += "Successfully exported local PDF (AttachmentRemote): \"" +
                        //	        //           reference.Title + "\" Address: \"" + loc.Address.ToString() + "\"\r\n";
                        //	    //}
                        //	    //else
                        //	    //{
                        //	     //   var test = 0;
                        //	    //}
                        //    }
                        //	catch (Exception ex)
                        //	{
                        //		Errors += "Failed to export PDF (AttachmentRemote): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "ERROR: " + ex + " " + "\"\r\n";
                        //	}
                        //
                        //
                        //}
                        //else if (loc.Address.LinkedResourceType.ToString().Equals("NotAnUri"))
                        //{
                        //	Success += loc.Address.ToString() + " NotAnUri \r\n";
                        //}
                        //else if (loc.Address.LinkedResourceType.ToString().Equals("RelativeFileUri"))
                        //{
                        //
                        //	try
                        //	{
                        //	    if (loc.Address.ToString().EndsWith(".pdf"))
                        //	    {
                        //            PdfExportOptions opt = new PdfExportOptions();
                        //		    loc.ExportPdf(FOLDERPATH + saveFilename, opt, true);
                        //		    Success += "Successfully exported local PDF (RelativeFileUri): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "\"\r\n";
                        //	    }
                        //	    else
                        //	    {
                        //	        var test = 0;
                        //	    }
                        //    }
                        //	catch (Exception ex)
                        //	{
                        //		Errors += "Failed to export PDF (RelativeFileUri): \"" + reference.Title + "\" Address: \"" + loc.Address.ToString() + "ERROR: " + ex + " " + "\"\r\n";
                        //	}
                        //
                        //
                        //
                        //}
                    }
                }
            }
        }
        catch (Exception e)
        {
            Errors += "Exception: " + e.Message + "\r\n";
            DebugMacro.WriteLine("Exception:" + e.Message);
            DebugMacro.WriteLine(e.StackTrace);

            System.Windows.Forms.MessageBox.Show("Exception:" + e.Message);
        }

        Success += Errors;
        return(Success);
    }
Пример #29
0
        protected void GetReferences(Project project, MonoDevelop.Prj2Make.Schema.Csproj.Reference[] References, ProjectReferenceCollection references, IProgressMonitor monitor)
        {
            if (References == null || References.Length == 0)
            {
                return;
            }

            monitor.BeginTask(null, 5 + References.Length);

            try {
                // Get the GAC path
                string strBasePathMono1_0 = GetPackageDirectory("mono", "mono/1.0");

                monitor.Step(1);

                string strBasePathGtkSharp = GetPackageDirectory("gtk-sharp", "mono/gtk-sharp");

                monitor.Step(1);

                string strBasePathGtkSharp2_0 = GetPackageDirectory("gtk-sharp-2.0", "mono/gtk-sharp-2.0");

                monitor.Step(1);

                string strBasePathGeckoSharp = GetPackageDirectory("gecko-sharp", "mono/gecko-sharp");

                monitor.Step(1);

                string strBasePathGeckoSharp2_0 = GetPackageDirectory("gecko-sharp-2.0", "mono/gecko-sharp-2.0");

                string[] monoLibs = new string [] {
                    strBasePathMono1_0,
                    strBasePathGtkSharp2_0,
                    strBasePathGtkSharp,
                    strBasePathGeckoSharp2_0,
                    strBasePathGeckoSharp
                };

                // Iterate through the reference collection of the csproj file
                foreach (MonoDevelop.Prj2Make.Schema.Csproj.Reference rf in References)
                {
                    monitor.Step(1);

                    ProjectReference rfOut = null;

                    if (rf.Package != null && rf.Package.Length != 0)
                    {
                        rfOut           = new ProjectReference(MonoDevelop.Projects.ReferenceType.Project, Path.GetFileName(rf.Name));
                        rfOut.LocalCopy = true;
                        references.Add(rfOut);
                    }
                    else if (rf.AssemblyName != null)
                    {
                        string rname = rf.AssemblyName;
                        if (rname == "System.XML")
                        {
                            rname = "System.Xml";
                        }

                        string oref = Runtime.SystemAssemblyService.DefaultAssemblyContext.GetAssemblyFullName(rname, fx);
                        if (oref == null)
                        {
                            if (rf.HintPath != null)
                            {
                                string asm = MapPath(project.ItemDirectory, rf.HintPath);
                                if (!System.IO.File.Exists(asm))
                                {
                                    monitor.ReportWarning(GettextCatalog.GetString("Referenced assembly not found: ") + asm);
                                }
                                ProjectReference aref = new ProjectReference(MonoDevelop.Projects.ReferenceType.Assembly, asm);
                                references.Add(aref);
                                continue;
                            }
                            monitor.ReportWarning(GettextCatalog.GetString("Assembly reference could not be imported: ") + rf.AssemblyName);
                            continue;
                        }
                        rfOut           = new ProjectReference(MonoDevelop.Projects.ReferenceType.Gac, oref);
                        rfOut.LocalCopy = true;
                        references.Add(rfOut);
                    }
                    else if (rf.HintPath != null)
                    {
                        // HACK - under Unix filenames are case sensitive
                        // Under Windows there's no agreement on Xml vs XML ;-)
                        if (Path.GetFileName(rf.HintPath) == "System.XML.dll")
                        {
                            ProjectReference pref = GetMonoReferece(strBasePathMono1_0, "System.Xml.dll");
                            if (pref != null)
                            {
                                references.Add(pref);
                                continue;
                            }
                        }
                        else
                        {
                            foreach (string libDir in monoLibs)
                            {
                                if (libDir == null)
                                {
                                    continue;
                                }
                                if (rf.HintPath == null)
                                {
                                    continue;
                                }
                                rfOut = GetMonoReferece(libDir, rf.HintPath);
                                if (rfOut != null)
                                {
                                    break;
                                }
                            }

                            if (rfOut == null)
                            {
                                rfOut           = new ProjectReference(MonoDevelop.Projects.ReferenceType.Gac, Path.GetFileName(rf.HintPath));
                                rfOut.LocalCopy = true;
                            }
                            references.Add(rfOut);
                        }
                    }
                    else
                    {
                        monitor.ReportWarning(GettextCatalog.GetString("Assembly reference could not be imported: ") + rf.Name);
                    }
                }
            } finally {
                monitor.EndTask();
            }
        }