示例#1
0
        public static List<PRO2ProjectDescriptor> createProjectDescriptorFromXML(string xmlResourcePath)
        {
            try
            {
                List<PRO2ProjectDescriptor> list = new List<PRO2ProjectDescriptor>();
                Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(xmlResourcePath);
                XmlDocument document = new XmlDocument();
                document.Load(manifestResourceStream);
                bool result = false;
                foreach (XmlNode node in document.GetElementsByTagName("ProjectDesctiptor"))
                {
                    PRO2ProjectDescriptor item = new PRO2ProjectDescriptor();
                    if (node.Attributes.GetNamedItem("name") != null)
                    {
                        item.Name = node.Attributes.GetNamedItem("name").Value;
                    }
                    if (node.Attributes.GetNamedItem("rfOperation") != null)
                    {
                        item.RfOperation = (RfOperation) Enum.Parse(typeof(RfOperation), node.Attributes.GetNamedItem("rfOperation").Value, true);
                    }
                    if (node.Attributes.GetNamedItem("modulationMode") != null)
                    {
                        item.ModulationMode = (ModulationMode) Enum.Parse(typeof(ModulationMode), node.Attributes.GetNamedItem("modulationMode").Value, true);
                    }
                    foreach (XmlNode node2 in node.ChildNodes)
                    {
                        switch (node2.Name)
                        {
                            case "Description":
                                item.Description = node2.InnerText.Trim();
                                break;

                            case "SupportedChips":
                                foreach (XmlNode node3 in node2.ChildNodes)
                                {
                                    if (((node3.Name == "Chip") && (node3.Attributes.GetNamedItem("chipType") != null)) && (node3.Attributes.GetNamedItem("chipRev") != null))
                                    {
                                        item.SupportedChips.Add(new Chip(node3.Attributes.GetNamedItem("chipType").Value, node3.Attributes.GetNamedItem("chipRev").Value));
                                    }
                                }
                                break;

                            case "Restrictions":
                                foreach (XmlNode node4 in node2.ChildNodes)
                                {
                                    if ((node4.Name == "Restriction") && (node4.Attributes.GetNamedItem("operation") != null))
                                    {
                                        Restriction restriction = new Restriction {
                                            Operation = node4.Attributes.GetNamedItem("operation").Value
                                        };
                                        if (node4.Attributes.GetNamedItem("targetName") != null)
                                        {
                                            restriction.TargetName = node4.Attributes.GetNamedItem("targetName").Value;
                                        }
                                        if (node4.Attributes.GetNamedItem("value") != null)
                                        {
                                            restriction.Value = node4.Attributes.GetNamedItem("value").Value;
                                        }
                                        item.Restrictions.Add(restriction);
                                    }
                                }
                                break;

                            case "PacketHandlerConfiguration":
                                foreach (XmlNode node5 in node2.ChildNodes)
                                {
                                    string name = node5.Name;
                                    if (name != null)
                                    {
                                        if (!(name == "RequiresVariablePacketConfiguration"))
                                        {
                                            if (name == "RequiresPacketContent")
                                            {
                                                goto Label_048D;
                                            }
                                            if (name == "RequiresMatchConfiguration")
                                            {
                                                goto Label_04CF;
                                            }
                                        }
                                        else if ((node5.Attributes.GetNamedItem("value") != null) && bool.TryParse(node5.Attributes.GetNamedItem("value").Value, out result))
                                        {
                                            item.PacketHandlerConfig.RequiresVariablePacketConfiguration = result;
                                        }
                                    }
                                    continue;
                                Label_048D:
                                    if ((node5.Attributes.GetNamedItem("value") != null) && bool.TryParse(node5.Attributes.GetNamedItem("value").Value, out result))
                                    {
                                        item.PacketHandlerConfig.RequiresPacketContent = result;
                                    }
                                    continue;
                                Label_04CF:
                                    if ((node5.Attributes.GetNamedItem("value") != null) && bool.TryParse(node5.Attributes.GetNamedItem("value").Value, out result))
                                    {
                                        item.PacketHandlerConfig.RequiresMatchConfiguration = result;
                                    }
                                }
                                break;

                            case "ExtraCommands":
                                foreach (XmlNode node6 in node2.ChildNodes)
                                {
                                    if (((node6.Name == "Command") && (node6.Attributes.GetNamedItem("name") != null)) && ((node6.Attributes.GetNamedItem("propName") != null) && (node6.Attributes.GetNamedItem("propValue") != null)))
                                    {
                                        byte num = 0;
                                        byte num2 = 0;
                                        if (((node6.Attributes.GetNamedItem("condition") != null) && (node6.Attributes.GetNamedItem("altPropValue") != null)) && (byte.TryParse(node6.Attributes.GetNamedItem("propValue").Value, NumberStyles.HexNumber, (IFormatProvider) null, out num) && byte.TryParse(node6.Attributes.GetNamedItem("altPropValue").Value, NumberStyles.HexNumber, (IFormatProvider) null, out num2)))
                                        {
                                            item.ExtraCommands.Add(new ExtraCommand(node6.Attributes.GetNamedItem("name").Value, node6.Attributes.GetNamedItem("propName").Value, num, node6.Attributes.GetNamedItem("condition").Value, num2));
                                        }
                                        else if (byte.TryParse(node6.Attributes.GetNamedItem("propValue").Value, NumberStyles.HexNumber, (IFormatProvider) null, out num))
                                        {
                                            item.ExtraCommands.Add(new ExtraCommand(node6.Attributes.GetNamedItem("name").Value, node6.Attributes.GetNamedItem("propName").Value, num));
                                        }
                                    }
                                }
                                break;

                            case "SaveBatch":
                                if ((node2.Attributes.GetNamedItem("enabled") != null) && bool.TryParse(node2.Attributes.GetNamedItem("enabled").Value, out result))
                                {
                                    item.SaveBatch.Enabled = result;
                                    if ((node2.Attributes.GetNamedItem("addFifoLoadCommand") != null) && bool.TryParse(node2.Attributes.GetNamedItem("addFifoLoadCommand").Value, out result))
                                    {
                                        item.SaveBatch.AddFifoLoadCommand = result;
                                    }
                                }
                                break;

                            case "ConfigureAndEvaluate":
                                if ((node2.Attributes.GetNamedItem("enabled") != null) && bool.TryParse(node2.Attributes.GetNamedItem("enabled").Value, out result))
                                {
                                    item.ConfigureAndEvaluate.Enabled = result;
                                }
                                foreach (XmlNode node7 in node2.ChildNodes)
                                {
                                    string str3;
                                    if (((str3 = node7.Name) != null) && (str3 == "InteractionOptions"))
                                    {
                                        XmlNodeList childNodes = node7.ChildNodes;
                                        List<string> list4 = new List<string>();
                                        foreach (XmlNode node8 in childNodes)
                                        {
                                            if (node8.Name == "Option")
                                            {
                                                list4.Add(node8.InnerText.Trim());
                                            }
                                        }
                                        item.ConfigureAndEvaluate.InteractionOptions = list4.ToArray();
                                    }
                                }
                                break;

                            case "DownloadProject":
                                if ((node2.Attributes.GetNamedItem("enabled") != null) && bool.TryParse(node2.Attributes.GetNamedItem("enabled").Value, out result))
                                {
                                    item.DownloadProject.Enabled = result;
                                    if (item.DownloadProject.Enabled)
                                    {
                                        foreach (XmlNode node9 in node2.ChildNodes)
                                        {
                                            string str4;
                                            if (((str4 = node9.Name) != null) && (str4 == "Firmware"))
                                            {
                                                if (node9.Attributes.GetNamedItem("name") != null)
                                                {
                                                    item.DownloadProject.Name = node9.Attributes.GetNamedItem("name").Value;
                                                }
                                                if (node9.Attributes.GetNamedItem("dataAddress") != null)
                                                {
                                                    item.DownloadProject.DataStartAddress = ushort.Parse(node9.Attributes.GetNamedItem("dataAddress").Value.Substring(2), NumberStyles.HexNumber);
                                                }
                                            }
                                        }
                                    }
                                }
                                break;

                            case "GenerateSource":
                                if ((node2.Attributes.GetNamedItem("enabled") != null) && bool.TryParse(node2.Attributes.GetNamedItem("enabled").Value, out result))
                                {
                                    item.GenerateSource.Enabled = result;
                                }
                                foreach (XmlNode node10 in node2.ChildNodes)
                                {
                                    string str5 = node10.Name;
                                    if (str5 != null)
                                    {
                                        if (!(str5 == "DirectoryName"))
                                        {
                                            if (str5 == "HeaderLocation")
                                            {
                                                goto Label_0AAF;
                                            }
                                            if (str5 == "HeaderTemplateName")
                                            {
                                                goto Label_0AC9;
                                            }
                                        }
                                        else
                                        {
                                            item.GenerateSource.DirectoryName = node10.InnerText.Trim();
                                        }
                                    }
                                    continue;
                                Label_0AAF:
                                    item.GenerateSource.HeaderLocation = node10.InnerText.Trim();
                                    continue;
                                Label_0AC9:
                                    item.GenerateSource.HeaderTemplateName = node10.InnerText.Trim();
                                }
                                break;
                        }
                    }
                    list.Add(item);
                }
                return list;
            }
            catch (Exception exception)
            {
                _log.Error("Project descreptor parsing problem: " + exception.Message);
                return null;
            }
        }
示例#2
0
 private void lstSelectProject_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((lstSelectProject.SelectedItems.Count > 0) && ((_selectedProject = (PRO2ProjectDescriptor) lstSelectProject.SelectedItems[0].Tag) != null))
     {
         setDescriptionText();
         reEnableControls();
         initProjectSpecificRestrictions();
         initChipSepecificRestrictions();
         initLicenseSpecificRestrictions();
         btnSaveBatch.Enabled = btnSaveBatchHelp.Enabled = _selectedProject.SaveBatch.Enabled;
         btnConfigureAndEvaluate.Enabled = btnConfigureAndEvaluateHelp.Enabled = _selectedProject.ConfigureAndEvaluate.Enabled;
         btnDownloadProject.Enabled = btnDownloadProjectHelp.Enabled = _selectedProject.DownloadProject.Enabled;
         btnGenerateSource.Enabled = btnGenerateSourceHelp.Enabled = _selectedProject.GenerateSource.Enabled;
         if (_evaluationWindow != null)
         {
             _evaluationWindow.Close();
         }
     }
 }