本文整理汇总了C#中Mono.Addins.RuntimeAddin.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# RuntimeAddin.GetType方法的具体用法?C# RuntimeAddin.GetType怎么用?C# RuntimeAddin.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Addins.RuntimeAddin
的用法示例。
在下文中一共展示了RuntimeAddin.GetType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertAddin
bool InsertAddin(IProgressStatus statusMonitor, Addin iad)
{
try {
RuntimeAddin p = new RuntimeAddin (this);
// Read the config file and load the add-in assemblies
AddinDescription description = p.Load (iad);
// Register the add-in
loadedAddins [Addin.GetIdName (p.Id)] = p;
if (!AddinDatabase.RunningSetupProcess) {
// Load the extension points and other addin data
foreach (ExtensionNodeSet rel in description.ExtensionNodeSets) {
RegisterNodeSet (rel);
}
foreach (ConditionTypeDescription cond in description.ConditionTypes) {
Type ctype = p.GetType (cond.TypeName, true);
RegisterCondition (cond.Id, ctype);
}
}
foreach (ExtensionPoint ep in description.ExtensionPoints)
InsertExtensionPoint (p, ep);
// Fire loaded event
NotifyAddinLoaded (p);
ReportAddinLoad (p.Id);
return true;
}
catch (Exception ex) {
ReportError ("Add-in could not be loaded", iad.Id, ex, false);
if (statusMonitor != null)
statusMonitor.ReportError ("Add-in '" + iad.Id + "' could not be loaded.", ex);
return false;
}
}
示例2: LoadFileTemplate
private static FileTemplate LoadFileTemplate (RuntimeAddin addin, ProjectTemplateCodon codon)
{
XmlDocument xmlDocument = codon.GetTemplate ();
FilePath baseDirectory = codon.BaseDirectory;
//Configuration
XmlElement xmlNodeConfig = xmlDocument.DocumentElement["TemplateConfiguration"];
FileTemplate fileTemplate = null;
if (xmlNodeConfig["Type"] != null) {
Type configType = addin.GetType (xmlNodeConfig["Type"].InnerText);
if (typeof (FileTemplate).IsAssignableFrom (configType)) {
fileTemplate = (FileTemplate)Activator.CreateInstance (configType);
}
else
throw new InvalidOperationException (string.Format ("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig["Type"].InnerText));
}
else
fileTemplate = new FileTemplate ();
fileTemplate.originator = xmlDocument.DocumentElement.GetAttribute ("Originator");
fileTemplate.created = xmlDocument.DocumentElement.GetAttribute ("Created");
fileTemplate.lastModified = xmlDocument.DocumentElement.GetAttribute ("LastModified");
if (xmlNodeConfig["_Name"] != null) {
fileTemplate.name = xmlNodeConfig["_Name"].InnerText;
}
else {
throw new InvalidOperationException (string.Format ("Missing element '_Name' in file template: {0}", codon.Id));
}
if (xmlNodeConfig["_Category"] != null) {
fileTemplate.category = xmlNodeConfig["_Category"].InnerText;
}
else {
throw new InvalidOperationException (string.Format ("Missing element '_Category' in file template: {0}", codon.Id));
}
if (xmlNodeConfig["LanguageName"] != null) {
fileTemplate.languageName = xmlNodeConfig["LanguageName"].InnerText;
}
if (xmlNodeConfig["ProjectType"] != null) {
fileTemplate.projecttype = xmlNodeConfig["ProjectType"].InnerText;
}
if (xmlNodeConfig["_Description"] != null) {
fileTemplate.description = xmlNodeConfig["_Description"].InnerText;
}
if (xmlNodeConfig["Icon"] != null) {
fileTemplate.icon = ImageService.GetStockId (addin, xmlNodeConfig["Icon"].InnerText, IconSize.Dnd); //xmlNodeConfig["_Description"].InnerText;
}
if (xmlNodeConfig["Wizard"] != null) {
fileTemplate.icon = xmlNodeConfig["Wizard"].Attributes["path"].InnerText;
}
if (xmlNodeConfig["DefaultFilename"] != null) {
fileTemplate.defaultFilename = xmlNodeConfig["DefaultFilename"].InnerText;
string isFixed = xmlNodeConfig["DefaultFilename"].GetAttribute ("IsFixed");
if (isFixed.Length > 0) {
bool bFixed;
if (bool.TryParse (isFixed, out bFixed))
fileTemplate.isFixedFilename = bFixed;
else
throw new InvalidOperationException ("Invalid value for IsFixed in template.");
}
}
//Template files
XmlNode xmlNodeTemplates = xmlDocument.DocumentElement["TemplateFiles"];
if(xmlNodeTemplates != null) {
foreach(XmlNode xmlNode in xmlNodeTemplates.ChildNodes) {
if(xmlNode is XmlElement) {
fileTemplate.files.Add (
FileDescriptionTemplate.CreateTemplate ((XmlElement)xmlNode, baseDirectory));
}
}
}
//Conditions
XmlNode xmlNodeConditions = xmlDocument.DocumentElement["Conditions"];
if(xmlNodeConditions != null) {
foreach(XmlNode xmlNode in xmlNodeConditions.ChildNodes) {
if(xmlNode is XmlElement) {
fileTemplate.conditions.Add (FileTemplateCondition.CreateCondition ((XmlElement)xmlNode));
}
}
}
return fileTemplate;
}
示例3: InsertExtensionPoint
internal void InsertExtensionPoint(RuntimeAddin addin, ExtensionPoint ep)
{
CreateExtensionPoint (ep);
foreach (ExtensionNodeType nt in ep.NodeSet.NodeTypes) {
if (nt.ObjectTypeName.Length > 0) {
Type ntype = addin.GetType (nt.ObjectTypeName, true);
RegisterAutoTypeExtensionPoint (ntype, ep.Path);
}
}
}
示例4: UnregisterProperty
public void UnregisterProperty (RuntimeAddin addin, string targetType, string name)
{
TypeRef tr;
if (!pendingTypesByTypeName.TryGetValue (targetType, out tr))
return;
if (tr.DataType != null) {
Type t = addin.GetType (targetType, false);
if (t != null)
UnregisterProperty (t, name);
return;
}
PropertyRef prop = tr.Properties;
PropertyRef prev = null;
while (prop != null) {
if (prop.Name == name) {
if (prev != null)
prev.Next = prop.Next;
else
tr.Properties = null;
break;
}
prev = prop;
prop = prop.Next;
}
}
示例5: RegisterProperty
public void RegisterProperty (RuntimeAddin addin, string targetType, string name, string propertyType, bool isExternal, bool skipEmpty)
{
TypeRef tr;
if (!pendingTypesByTypeName.TryGetValue (targetType, out tr)) {
tr = new TypeRef (addin, targetType);
pendingTypesByTypeName [targetType] = tr;
}
if (tr.DataType != null) {
RegisterProperty (addin.GetType (targetType, true), name, addin.GetType (propertyType, true), isExternal, skipEmpty);
return;
}
PropertyRef prop = new PropertyRef (addin, targetType, name, propertyType, isExternal, skipEmpty);
if (tr.Properties == null)
tr.Properties = prop;
else {
PropertyRef plink = tr.Properties;
while (plink.Next != null)
plink = plink.Next;
plink.Next = prop;
}
}
示例6: AddMap
public void AddMap (RuntimeAddin addin, string xmlMap, string fileId)
{
XmlDocument doc = new XmlDocument ();
doc.LoadXml (xmlMap);
foreach (XmlElement elem in doc.DocumentElement.SelectNodes ("DataItem")) {
string tname = elem.GetAttribute ("class");
Type type = addin.GetType (tname);
if (type == null) {
LoggingService.LogError ("[SerializationMap " + fileId + "] Type not found: '" + tname + "'");
continue;
}
string cname = elem.GetAttribute ("name");
string ftname = elem.GetAttribute ("fallbackType");
SerializationMap map;
if (!maps.TryGetValue (type, out map)) {
map = new SerializationMap (type);
maps [type] = map;
map.FileId = fileId;
if (cname.Length > 0 || ftname.Length > 0) {
DataItemAttribute iat = new DataItemAttribute ();
if (cname.Length > 0)
iat.Name = cname;
if (ftname.Length > 0)
iat.FallbackType = addin.GetType (ftname, true);
map.TypeAttributes.Add (iat);
}
} else {
if (!string.IsNullOrEmpty (cname))
throw new InvalidOperationException (string.Format ("Type name for type '{0}' in map '{1}' already specified in another serialization map for the same type ({2}).", type, fileId, map.FileId));
if (!string.IsNullOrEmpty (ftname))
throw new InvalidOperationException (string.Format ("Fallback type for type '{0}' in map '{1}' already specified in another serialization map for the same type ({2}).", type, fileId, map.FileId));
}
string customDataItem = elem.GetAttribute ("customDataItem");
if (customDataItem.Length > 0) {
ICustomDataItemHandler ch = (ICustomDataItemHandler) addin.CreateInstance (customDataItem, true);
if (map.CustomHandler != null)
map.CustomHandler = new CustomDataItemHandlerChain (map.CustomHandler, ch);
else
map.CustomHandler = ch;
}
ItemMember lastMember = null;
int litc = 0;
foreach (XmlElement att in elem.SelectNodes ("ItemProperty|ExpandedCollection|LiteralProperty|ItemMember"))
{
string memberName = null;
ItemMember prevMember = lastMember;
lastMember = null;
if (att.Name == "LiteralProperty") {
ItemMember mem = new ItemMember ();
memberName = mem.Name = "_literal_" + (++litc);
mem.Type = typeof(string);
mem.InitValue = att.GetAttribute ("value");
mem.DeclaringType = map.Type;
map.ExtendedMembers.Add (mem);
ItemPropertyAttribute itemAtt = new ItemPropertyAttribute ();
itemAtt.Name = att.GetAttribute ("name");
map.AddMemberAttribute (mem, itemAtt);
lastMember = mem;
continue;
}
else if (att.Name == "ItemMember") {
ItemMember mem = new ItemMember ();
memberName = mem.Name = att.GetAttribute ("name");
mem.Type = addin.GetType (att.GetAttribute ("type"), true);
mem.DeclaringType = map.Type;
map.ExtendedMembers.Add (mem);
lastMember = mem;
continue;
}
else
{
memberName = att.GetAttribute ("member");
Type mt;
object mi;
if (!FindMember (map, memberName, out mi, out mt)) {
LoggingService.LogError ("[SerializationMap " + fileId + "] Member '" + memberName + "' not found in type '" + tname + "'");
continue;
}
if (att.Name == "ItemProperty")
{
ItemPropertyAttribute itemAtt = new ItemPropertyAttribute ();
string val = att.GetAttribute ("name");
if (val.Length > 0)
itemAtt.Name = val;
val = att.GetAttribute ("scope");
if (val.Length > 0)
itemAtt.Scope = val;
if (att.Attributes ["defaultValue"] != null) {
//.........这里部分代码省略.........
示例7: LoadFileTemplate
internal static FileTemplate LoadFileTemplate (RuntimeAddin addin, XmlDocument xmlDocument, FilePath baseDirectory = new FilePath (), string templateId = "")
{
//Configuration
XmlElement xmlNodeConfig = xmlDocument.DocumentElement ["TemplateConfiguration"];
FileTemplate fileTemplate;
if (xmlNodeConfig ["Type"] != null) {
Type configType = addin.GetType (xmlNodeConfig ["Type"].InnerText);
if (typeof(FileTemplate).IsAssignableFrom (configType)) {
fileTemplate = (FileTemplate)Activator.CreateInstance (configType);
} else
throw new InvalidOperationException (string.Format ("The file template class '{0}' must be a subclass of MonoDevelop.Ide.Templates.FileTemplate", xmlNodeConfig ["Type"].InnerText));
} else
fileTemplate = new FileTemplate ();
fileTemplate.Originator = xmlDocument.DocumentElement.GetAttribute ("Originator");
fileTemplate.Created = xmlDocument.DocumentElement.GetAttribute ("Created");
fileTemplate.LastModified = xmlDocument.DocumentElement.GetAttribute ("LastModified");
if (xmlNodeConfig ["_Name"] != null) {
fileTemplate.Name = xmlNodeConfig ["_Name"].InnerText;
} else {
throw new InvalidOperationException (string.Format ("Missing element '_Name' in file template: {0}", templateId));
}
if (xmlNodeConfig ["LanguageName"] != null) {
fileTemplate.LanguageName = xmlNodeConfig ["LanguageName"].InnerText;
}
if (xmlNodeConfig ["ProjectType"] != null) {
var projectTypeList = new List<string> ();
foreach (var item in xmlNodeConfig["ProjectType"].InnerText.Split (','))
projectTypeList.Add (item.Trim ());
fileTemplate.ProjectTypes = projectTypeList;
}
fileTemplate.Categories = new Dictionary<string, string> ();
if (xmlNodeConfig ["_Category"] != null) {
foreach (XmlNode xmlNode in xmlNodeConfig.GetElementsByTagName ("_Category")) {
if (xmlNode is XmlElement) {
string projectType = "";
if (xmlNode.Attributes ["projectType"] != null)
projectType = xmlNode.Attributes ["projectType"].Value;
if (!string.IsNullOrEmpty (projectType) && fileTemplate.ProjectTypes.Contains (projectType))
fileTemplate.Categories.Add (projectType, xmlNode.InnerText);
else if (!fileTemplate.Categories.ContainsKey (DefaultCategoryKey))
fileTemplate.Categories.Add (DefaultCategoryKey, xmlNode.InnerText);
}
}
} else {
throw new InvalidOperationException (string.Format ("Missing element '_Category' in file template: {0}", templateId));
}
if (xmlNodeConfig ["_Description"] != null) {
fileTemplate.Description = xmlNodeConfig ["_Description"].InnerText;
}
if (xmlNodeConfig ["Icon"] != null) {
fileTemplate.Icon = ImageService.GetStockId (addin, xmlNodeConfig ["Icon"].InnerText, IconSize.Dnd);
}
if (xmlNodeConfig ["Wizard"] != null) {
fileTemplate.Icon = xmlNodeConfig ["Wizard"].Attributes ["path"].InnerText;
}
if (xmlNodeConfig ["DefaultFilename"] != null) {
fileTemplate.DefaultFilename = xmlNodeConfig ["DefaultFilename"].InnerText;
string isFixed = xmlNodeConfig ["DefaultFilename"].GetAttribute ("IsFixed");
if (isFixed.Length > 0) {
bool bFixed;
if (bool.TryParse (isFixed, out bFixed))
fileTemplate.IsFixedFilename = bFixed;
else
throw new InvalidOperationException ("Invalid value for IsFixed in template.");
}
}
//Template files
XmlNode xmlNodeTemplates = xmlDocument.DocumentElement ["TemplateFiles"];
if (xmlNodeTemplates != null) {
foreach (XmlNode xmlNode in xmlNodeTemplates.ChildNodes) {
var xmlElement = xmlNode as XmlElement;
if (xmlElement != null) {
fileTemplate.Files.Add (
FileDescriptionTemplate.CreateTemplate (xmlElement, baseDirectory));
}
}
}
//Conditions
XmlNode xmlNodeConditions = xmlDocument.DocumentElement ["Conditions"];
if (xmlNodeConditions != null) {
foreach (XmlNode xmlNode in xmlNodeConditions.ChildNodes) {
var xmlElement = xmlNode as XmlElement;
if (xmlElement != null) {
fileTemplate.Conditions.Add (FileTemplateCondition.CreateCondition (xmlElement));
}
//.........这里部分代码省略.........