示例#1
0
        public string LoadItems(string asmName, string typeName, string fileName)
        {
            XmlDataSerializer       ser    = new XmlDataSerializer(MonoDevelop.Projects.Services.ProjectService.DataContext);
            ToolboxList             tl     = new ToolboxList();
            object                  ob     = Activator.CreateInstance(asmName, typeName).Unwrap();
            IExternalToolboxLoader  loader = (IExternalToolboxLoader)ob;
            IList <ItemToolboxNode> list   = loader.Load(fileName);

            tl.AddRange(list);
            StringWriter sw = new StringWriter();

            ser.Serialize(sw, tl);
            return(sw.ToString());
        }
示例#2
0
 public IList <ItemToolboxNode> LoadItemsIsolated(TargetRuntime runtime, Type loaderType, string filename)
 {
     if (!typeof(IExternalToolboxLoader).IsAssignableFrom(loaderType))
     {
         throw new InvalidOperationException("Type '" + loaderType + "' does not implement 'IExternalToolboxLoader'");
     }
     try {
         ExternalItemLoader loader = CreateExternalLoader <ExternalItemLoader> (runtime);
         string             s      = loader.LoadItems(loaderType.Assembly.FullName, loaderType.FullName, filename);
         XmlDataSerializer  ser    = new XmlDataSerializer(MonoDevelop.Projects.Services.ProjectService.DataContext);
         ToolboxList        list   = (ToolboxList)ser.Deserialize(new StringReader(s), typeof(ToolboxList));
         return(list);
     } catch {
         return(new List <ItemToolboxNode> ());
     }
 }