Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@33 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
28 changed files with 352 additions and 182 deletions
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Collections.Generic; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Description of XmlDoc.
|
||||
/// </summary>
|
||||
public class XmlDoc |
||||
{ |
||||
Dictionary<string, string> xmlDescription = new Dictionary<string, string>(); |
||||
|
||||
public Dictionary<string, string> XmlDescription { |
||||
get { |
||||
return xmlDescription; |
||||
} |
||||
} |
||||
public XmlDoc() |
||||
{ |
||||
} |
||||
|
||||
void ReadMembersSection(XmlTextReader reader) |
||||
{ |
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.EndElement: |
||||
if (reader.LocalName == "members") { |
||||
return; |
||||
} |
||||
break; |
||||
case XmlNodeType.Element: |
||||
if (reader.LocalName == "member") { |
||||
string memberAttr = reader.GetAttribute(0); |
||||
string innerXml = reader.ReadInnerXml(); |
||||
xmlDescription[memberAttr] = innerXml; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static XmlDoc Load(TextReader textReader) |
||||
{ |
||||
XmlDoc newXmlDoc = new XmlDoc(); |
||||
using (XmlTextReader reader = new XmlTextReader(textReader)) { |
||||
while (reader.Read()) { |
||||
if (reader.IsStartElement()) { |
||||
switch (reader.LocalName) { |
||||
case "members": |
||||
newXmlDoc.ReadMembersSection(reader); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return newXmlDoc; |
||||
} |
||||
|
||||
public static XmlDoc Load(string fileName) |
||||
{ |
||||
using (TextReader textReader = File.OpenText(fileName)) { |
||||
return Load(textReader); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
using System; |
||||
using System.IO; |
||||
using System.Threading; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
using System.Runtime.Serialization; |
||||
using System.Runtime.Serialization.Formatters; |
||||
using System.Runtime.Serialization.Formatters.Binary; |
||||
using System.Security; |
||||
using System.Security.Permissions; |
||||
using System.Security.Policy; |
||||
using System.Xml; |
||||
using System.Text; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
public class ProjectContentRegistry |
||||
{ |
||||
static Dictionary<string, IProjectContent> contents = new Dictionary<string, IProjectContent>(); |
||||
|
||||
public static IProjectContent GetMscorlibContent() |
||||
{ |
||||
if (contents.ContainsKey("mscorlib")) { |
||||
return contents["mscorlib"]; |
||||
} |
||||
contents["mscorlib"] = CaseSensitiveProjectContent.Create(typeof(object).Assembly); |
||||
return contents["mscorlib"]; |
||||
} |
||||
|
||||
public static IProjectContent GetProjectContentForReference(ReferenceProjectItem item) |
||||
{ |
||||
if (contents.ContainsKey(item.FileName)) { |
||||
Console.WriteLine("Get Content for : " + item.FileName); |
||||
return contents[item.FileName]; |
||||
} |
||||
if (contents.ContainsKey(item.Include)) { |
||||
Console.WriteLine("Get Content for : " + item.Include); |
||||
return contents[item.Include]; |
||||
} |
||||
Assembly assembly = null; |
||||
|
||||
try { |
||||
assembly = Assembly.ReflectionOnlyLoadFrom(item.FileName); |
||||
Console.WriteLine(assembly.Location); |
||||
if (assembly != null) { |
||||
contents[item.FileName] = CaseSensitiveProjectContent.Create(assembly); |
||||
return contents[item.FileName]; |
||||
} |
||||
} catch (Exception) { |
||||
try { |
||||
assembly = Assembly.LoadWithPartialName(item.Include); |
||||
Console.WriteLine(assembly.Location); |
||||
if (assembly != null) { |
||||
contents[item.Include] = CaseSensitiveProjectContent.Create(assembly); |
||||
return contents[item.Include]; |
||||
} |
||||
} catch (Exception e) { |
||||
Console.WriteLine("Can't load assembly '{0}' : " + e.Message, item.Include); |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue