public LazyConditionEvaluator(AddIn addIn, Properties properties)
 {
     this.addIn = addIn;
     this.name = properties["name"];
     this.className = properties["class"];
 }
예제 #2
0
        private static void SetupAddIn(XmlTextReader reader, AddIn addIn, string hintPath)
        {
            while (reader.Read())
            {
                string str3;
                string localName;
                if ((reader.NodeType == XmlNodeType.Element) && reader.IsStartElement())
                {
                    localName = reader.LocalName;
                    switch (localName)
                    {
                        case "StringResources":
                        case "BitmapResources":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("BitmapResources requires ONE attribute.");
                            }
                            break;

                        case "Runtime":
                            if (reader.IsEmptyElement)
                            {
                                goto Label_02E9;
                            }
                            goto Label_01DB;

                        case "Include":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("Include requires ONE attribute.");
                            }
                            goto Label_020B;

                        case "Path":
                            if (reader.AttributeCount != 1)
                            {
                                throw new AddInLoadException("Import node requires ONE attribute.");
                            }
                            goto Label_0293;

                        case "Manifest":
                            addIn.Manifest.ReadManifestSection(reader, hintPath);
                            goto Label_02E9;

                        default:
                            throw new AddInLoadException("Unknown root path node:" + reader.LocalName);
                    }
                    string item = SkyMap.Net.Core.StringParser.Parse(reader.GetAttribute("file"));
                    if (reader.LocalName == "BitmapResources")
                    {
                        addIn.BitmapResources.Add(item);
                    }
                    else
                    {
                        addIn.StringResources.Add(item);
                    }
                }
                goto Label_02E9;
            Label_014B:
                if ((reader.NodeType == XmlNodeType.EndElement) && (reader.LocalName == "Runtime"))
                {
                    goto Label_02E9;
                }
                if ((reader.NodeType == XmlNodeType.Element) && reader.IsStartElement())
                {
                    localName = reader.LocalName;
                    if ((localName == null) || !(localName == "Import"))
                    {
                        throw new AddInLoadException("Unknown node in runtime section :" + reader.LocalName);
                    }
                    addIn.runtimes.Add(Runtime.Read(addIn, reader, hintPath));
                }
            Label_01DB:
                if (reader.Read())
                {
                    goto Label_014B;
                }
                goto Label_02E9;
            Label_020B:
                if (!reader.IsEmptyElement)
                {
                    throw new AddInLoadException("Include nodes must be empty!");
                }
                if (hintPath == null)
                {
                    throw new AddInLoadException("Cannot use include nodes when hintPath was not specified (e.g. when AddInManager reads a .addin file)!");
                }
                string url = Path.Combine(hintPath, reader.GetAttribute(0));
                using (XmlTextReader reader2 = new XmlTextReader(url))
                {
                    SetupAddIn(reader2, addIn, Path.GetDirectoryName(url));
                }
                goto Label_02E9;
            Label_0293:
                str3 = reader.GetAttribute(0);
                ExtensionPath extensionPath = addIn.GetExtensionPath(str3);
                if (!reader.IsEmptyElement)
                {
                    ExtensionPath.SetUp(extensionPath, reader, "Path");
                }
            Label_02E9:;
            }
        }
예제 #3
0
 public static AddIn Load(TextReader textReader, string hintPath)
 {
     AddIn addIn = new AddIn();
     using (XmlTextReader reader = new XmlTextReader(textReader))
     {
         while (reader.Read())
         {
             if (reader.IsStartElement())
             {
                 string localName = reader.LocalName;
                 if ((localName == null) || !(localName == "AddIn"))
                 {
                     throw new AddInLoadException("Unknown add-in file.");
                 }
                 addIn.properties = SkyMap.Net.Core.Properties.ReadFromAttributes(reader);
                 SetupAddIn(reader, addIn, hintPath);
             }
         }
     }
     return addIn;
 }
예제 #4
0
 internal static Runtime Read(AddIn addIn, XmlTextReader reader, string hintPath)
 {
     if (reader.AttributeCount != 1)
     {
         throw new AddInLoadException("Import node requires ONE attribute.");
     }
     Runtime runtime = new Runtime(reader.GetAttribute(0), hintPath);
     if (!reader.IsEmptyElement)
     {
         while (reader.Read())
         {
             string localName;
             Properties properties;
             XmlNodeType nodeType = reader.NodeType;
             if (nodeType != XmlNodeType.Element)
             {
                 if ((nodeType == XmlNodeType.EndElement) && (reader.LocalName == "Import"))
                 {
                     return runtime;
                 }
             }
             else
             {
                 localName = reader.LocalName;
                 properties = Properties.ReadFromAttributes(reader);
                 string str2 = localName;
                 if (str2 == null)
                 {
                     goto Label_01A2;
                 }
                 if (!(str2 == "Doozer"))
                 {
                     if (str2 == "ConditionEvaluator")
                     {
                         goto Label_012C;
                     }
                     goto Label_01A2;
                 }
                 if (!reader.IsEmptyElement)
                 {
                     throw new AddInLoadException("Doozer nodes must be empty!");
                 }
                 LazyLoadDoozer doozer = new LazyLoadDoozer(addIn, properties);
                 if (AddInTree.Doozers.ContainsKey(doozer.Name))
                 {
                     throw new AddInLoadException("Duplicate doozer: " + doozer.Name);
                 }
                 AddInTree.Doozers.Add(doozer.Name, doozer);
                 runtime.definedDoozers.Add(properties);
             }
             goto Label_01B5;
         Label_012C:
             if (!reader.IsEmptyElement)
             {
                 throw new AddInLoadException("ConditionEvaluator nodes must be empty!");
             }
             LazyConditionEvaluator evaluator = new LazyConditionEvaluator(addIn, properties);
             if (AddInTree.ConditionEvaluators.ContainsKey(evaluator.Name))
             {
                 throw new AddInLoadException("Duplicate condition evaluator: " + evaluator.Name);
             }
             AddInTree.ConditionEvaluators.Add(evaluator.Name, evaluator);
             runtime.definedConditionEvaluators.Add(properties);
             goto Label_01B5;
         Label_01A2:
             throw new AddInLoadException("Unknown node in Import section:" + localName);
         Label_01B5:;
         }
     }
     return runtime;
 }
예제 #5
0
 public LazyLoadDoozer(AddIn addIn, Properties properties)
 {
     this.addIn = addIn;
     this.name = properties["name"];
     this.className = properties["class"];
 }
 public DefaultDialogPanelDescriptor(string id, string label, AddIn addin, string dialogPanelPath) : this(id, label)
 {
     this.addin = addin;
     this.dialogPanelPath = dialogPanelPath;
 }