protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {

            builder.AddPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY,
                GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
            XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
            if (txAttributes.Count > 1 )
            {
                parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
            }
            else if (txAttributes.Count == 1)
            {
                //using xml defined source
                XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
                AbstractObjectDefinition attributeSourceDefinition =
                    ParseAttributeSource(attributeSourceElement, parserContext);
                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
            }
            else
            {
                //Assume attibutes source
                ObjectDefinitionBuilder txAttributeSourceBuilder = 
                    parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));

                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
                                         txAttributeSourceBuilder.ObjectDefinition);

            }
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException(nameof(xmlElement));
            }
            if (xmlElement.HasAttribute("URI"))
            {
                this.uriAttribute = xmlElement.GetAttribute("URI");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:Issuer", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.issuer = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:IssueTime", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.issueTime = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Local);
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:Number", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.number = long.Parse(xmlNodeList.Item(0).InnerText);
            }
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException(nameof(xmlElement));
            }
            if (xmlElement.HasAttribute("URI"))
            {
                this.uriAttribute = xmlElement.GetAttribute("URI");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xades", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xades:ResponderID", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                //this.responderID = xmlNodeList.Item(0).InnerText;
                XmlNode child = xmlNodeList.Item(0).ChildNodes.Item(0);

                ByKey       = child.Name.Contains("ByKey");
                responderID = child.InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xades:ProducedAt", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.producedAt = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Local);
            }
        }
示例#4
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:ClaimedRoles", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.claimedRoles = new ClaimedRoles();
                this.claimedRoles.LoadXml((XmlElement)xmlNodeList.Item(0));
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:CertifiedRoles", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.certifiedRoles = new CertifiedRoles();
                this.certifiedRoles.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public override void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SPUserNotice/xsd:NoticeRef", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.noticeRef = new NoticeRef();
                this.noticeRef.LoadXml((XmlElement)xmlNodeList.Item(0));
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:SPUserNotice/xsd:ExplicitText", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.explicitText = xmlNodeList.Item(0).InnerText;
            }
        }
示例#6
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyId", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.signaturePolicyId = new SignaturePolicyId();
                this.signaturePolicyId.LoadXml((XmlElement)xmlNodeList.Item(0));
                this.signaturePolicyImplied = false;
            }
            else
            {
                xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyImplied", xmlNamespaceManager);
                if (xmlNodeList.Count != 0)
                {
                    this.signaturePolicyImplied = true;
                    this.signaturePolicyId      = null;
                }
                else
                {
                    throw new CryptographicException("SignaturePolicyId or SignaturePolicyImplied missing");
                }
            }
        }
示例#7
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            //xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            xmlNamespaceManager.AddNamespace("ds", "");
            xmlNodeList = xmlElement.SelectNodes("ds:X509IssuerName", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("X509IssuerName missing");
            }
            this.x509IssuerName = xmlNodeList.Item(0).InnerText;

            xmlNodeList = xmlElement.SelectNodes("ds:X509SerialNumber", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("X509SerialNumber missing");
            }
            this.x509SerialNumber = xmlNodeList.Item(0).InnerText;
        }
示例#8
0
 public static List<PageControl> RecursiveCreatePageControl(XmlElement root)
 {
     var result = new List<PageControl>();
     var nodeList = root.SelectNodes("Children/Child");
     if (nodeList.Count <= 0)
     {
         nodeList = root.SelectNodes("Child");
     }
     foreach (XmlNode node in nodeList)
     {
         var element = node as XmlElement;
         var control = new PageControl();
         control.Id = XmlUtility.GetAttrValue(element, "Id");
         control.Type = XmlUtility.GetAttrValue(element, "Type");
         var dynamicProperty = new DynamicProperty();
         dynamicProperty.InitProperty();
         var flashProperty = new FlashProperty();
         flashProperty.InitProperty();
         EvaluateProperty(element, control, dynamicProperty, flashProperty);
         EvaluateEvent(element, control, dynamicProperty, flashProperty);
         if (dynamicProperty.FlashEvents.Count > 0
             || dynamicProperty.FlashPropertys.Count > 0)
         {
             control.Properties.Add(new Property()
             {
                 Name = PropertyUtility.DYNAMICNAME,
                 Type = PropertyValueType.str.ToString(),
                 Value = dynamicProperty.ToXml()
             });
         }
         control.Children = RecursiveCreatePageControl(element);
         result.Add(control);
     }
     return result;
 }
示例#9
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);


            xmlNodeList = xmlElement.SelectNodes("ds:DigestMethod", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("DigestMethod missing");
            }
            this.digestMethod = new DigestMethod();
            this.digestMethod.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("ds:DigestValue", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("DigestValue missing");
            }
            this.digestValue = Convert.FromBase64String(xmlNodeList.Item(0).InnerText);
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:Organization", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("Organization missing");
            }
            this.organization = xmlNodeList.Item(0).InnerText;

            xmlNodeList = xmlElement.SelectNodes("xsd:NoticeNumbers", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("NoticeNumbers missing");
            }
            this.noticeNumbers = new NoticeNumbers();
            this.noticeNumbers.LoadXml((XmlElement)xmlNodeList.Item(0));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectConfigurationType"/> class.
        /// </summary>
        /// <param name="node">The node.</param>
        public ObjectConfigurationType(XmlElement node)
        {
            properties = new List<PropertyConfigurationType>();
            constructorArgs = new List<PropertyConfigurationType>();

            name = node.GetAttribute(NameAttr);
            type = node.GetAttribute(TypeAttr);

            XmlNodeList nodeProperties = node.SelectNodes(PropertyElement);
            foreach (XmlNode nodeProperty in nodeProperties)
            {
                properties.Add(new PropertyConfigurationType((XmlElement)nodeProperty));
            }

            var nodeConstructorArgs = node.SelectNodes(ConstructorArgElement);
            const int FIRST_INDEX = 0;
            var index = FIRST_INDEX;
            var argMap = new SortedDictionary<int, PropertyConfigurationType>();
            foreach (XmlNode nodeConstructorArg in nodeConstructorArgs)
            {
                var el = (XmlElement)nodeConstructorArg;
                if (!string.IsNullOrEmpty(el.GetAttribute(IndexAttr)))
                {
                    index = Convert.ToInt32(el.GetAttribute(IndexAttr));
                }
                argMap[index++] = new PropertyConfigurationType(el);
            }
            if (nodeConstructorArgs.Count > 0 && !argMap.ContainsKey(FIRST_INDEX))
            {
                throw new ConfigurationErrorsException("constructor-arg index must start at: " + FIRST_INDEX);
            }
            constructorArgs.AddRange(argMap.Values);
        }
        public WorkItemTypeDefinition(XmlElement witdElement, bool isWritable)
        {
            if (witdElement.SelectSingleNode("WORKITEMTYPE") == null)
            {
                throw new ArgumentException("Invalid definition document, missing WORKITEMTYPE element.");
            }

            _witdElement = (XmlElement)witdElement.Clone();
            _isWritable = isWritable;

            if (!_isWritable)
            {
                _fields = _witdElement
                    .SelectNodes("WORKITEMTYPE/FIELDS/FIELD")
                    .Cast<XmlElement>()
                    .Select(e => new WitdField(e))
                    .ToArray();

                _states = _witdElement
                    .SelectNodes("WORKITEMTYPE/WORKFLOW/STATES/STATE")
                    .Cast<XmlElement>()
                    .Select(e => new WitdState(e))
                    .ToArray();

                _transitions = new HashSet<WitdTransition>(witdElement
                                                               .SelectNodes("WORKITEMTYPE/WORKFLOW/TRANSITIONS/TRANSITION")
                                                               .Cast<XmlElement>()
                                                               .Select(e => new WitdTransition(e)));

            }
        }
        public EnumeratedFieldMapping(XmlElement elem, XmlElement parentElem)
        {
            NodeName = elem.Attributes["NodeName"].Value;
            FieldName = elem.Attributes["FieldName"].Value;
            MissingFieldValue = XmlUtils.GetOptionalAttribute(elem, "MissingFieldValue");
            AttrName = XmlUtils.GetOptionalAttribute(elem, "AttrName");
            if (string.IsNullOrEmpty(AttrName))
                AttrName = "val";

            foreach (XmlElement subElem in elem.SelectNodes("./x:AttributeValueMapping", GenerationContext.NamespaceManager))
            {
                attrValueMappings.Add(subElem.Attributes["AttrValue"].Value, subElem.Attributes["FieldValue"].Value);
            }


            foreach (XmlElement subElem in elem.SelectNodes("./x:EnumerationMappingReference", GenerationContext.NamespaceManager))
            {
                string enumMappingRefName = subElem.GetAttribute("ref");
                foreach (XmlElement enumElem in parentElem.ParentNode.SelectNodes("./x:EnumerationMappingDefinition", GenerationContext.NamespaceManager))
                {
                    if (enumElem.GetAttribute("name") == enumMappingRefName)
                    {
                        foreach (XmlElement inElem in enumElem.SelectNodes("./x:AttributeValueMapping", GenerationContext.NamespaceManager))
                        {
                            attrValueMappings.Add(inElem.Attributes["AttrValue"].Value, inElem.Attributes["FieldValue"].Value);
                        }
                    }
                }
            }
        }
示例#14
0
文件: Cert.cs 项目: ylepikhov/dssnet
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:CertDigest", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("CertDigest missing");
            }
            this.certDigest = new DigestAlgAndValueType("CertDigest");
            this.certDigest.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:IssuerSerial", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("IssuerSerial missing");
            }
            this.issuerSerial = new IssuerSerial();
            this.issuerSerial.LoadXml((XmlElement)xmlNodeList.Item(0));
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        /// <param name="counterSignedXmlElement">Element containing parent signature (needed if there are counter signatures)</param>
        public void LoadXml(System.Xml.XmlElement xmlElement, XmlElement counterSignedXmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }
            if (xmlElement.HasAttribute("Id"))
            {
                this.id = xmlElement.GetAttribute("Id");
            }
            else
            {
                this.id = "";
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedSignatureProperties", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.unsignedSignatureProperties = new UnsignedSignatureProperties();
                this.unsignedSignatureProperties.LoadXml((XmlElement)xmlNodeList.Item(0), counterSignedXmlElement);
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:UnsignedDataObjectProperties", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.unsignedDataObjectProperties = new UnsignedDataObjectProperties();
                this.unsignedDataObjectProperties.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#16
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:OCSPIdentifier", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("OCSPIdentifier missing");
            }
            this.ocspIdentifier = new OCSPIdentifier();
            this.ocspIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:DigestAlgAndValue", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                this.digestAlgAndValue = null;
            }
            else
            {
                this.digestAlgAndValue = new DigestAlgAndValueType("DigestAlgAndValue");
                this.digestAlgAndValue.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#17
0
        /**
                <Question type="checkedlistbox" label="血型" />
         * */
        public Question(string subjectName, List<QuestionListItem> listItems, XmlElement question)
        {
            this.subjectName = subjectName;
            this.listItems = listItems;
            this.qType = question.GetAttribute("type");
            this.qName = question.GetAttribute("name");
            this.qLabel = question.GetAttribute("label");
            this.qWidth = question.GetAttribute("width");
            this.qRows = question.GetAttribute("rows");
            if (string.IsNullOrEmpty(this.qRows))
                this.qRows = "2";   //Default value;

            //parse column definitions
            this.columns = new List<GridColumn>();
            foreach (XmlElement xmlCol in question.SelectNodes("Cols/Col"))
            {
                this.columns.Add(new GridColumn(xmlCol));
            }

            //parse default values
            this.defaultRecords = new List<Dictionary<string, string>>();

            foreach (XmlElement xmlItem in question.SelectNodes("Default/Item"))  //every record
            {
                Dictionary<string, string> key_values = new Dictionary<string, string>();
                this.defaultRecords.Add(key_values);
                foreach (XmlElement elmField in xmlItem.SelectNodes("Field"))
                {
                    key_values.Add(elmField.GetAttribute("key"), elmField.GetAttribute("value"));
                }
            }
        }
示例#18
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:Identifier", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("Identifier missing");
            }
            this.identifier = new Identifier();
            this.identifier.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:Description", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.description = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:DocumentationReferences", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.documentationReferences = new DocumentationReferences();
                this.documentationReferences.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#19
0
        private string tempLabel = ""; //如果label = "" 時,會造成 SubjectUIMaker 中的 Dictionary 會重覆""

        #endregion Fields

        #region Constructors

        public QuestionGroup(XmlElement elmQGDef)
        {
            this.elmQGDef = elmQGDef;

            //parse titleName
            this.label = elmQGDef.GetAttribute("label");

            this.labelWidth = elmQGDef.GetAttribute("width");

            //如果label = "" 時,可能會造成 Subject 中的 Dictionary 會重覆"",所以先給他一個 Guid 值
            if (string.IsNullOrEmpty(this.label))
                this.tempLabel = Guid.NewGuid().ToString();
            else
                this.tempLabel = this.label;

            //parse hideLabel attribute
            this.showLabel = (elmQGDef.GetAttribute("hideLabel").ToUpper() != "TRUE");

            //parse ListItems
            this.listItems = new List<QuestionListItem>();
            foreach (XmlElement elm in elmQGDef.SelectNodes("Choices/Item"))
            {
                this.listItems.Add(new QuestionListItem(elm));
            }

            //Questions
            this.questions = new List<Question>();
            foreach (XmlElement elm in elmQGDef.SelectNodes("Qs/Q"))
            {
                Question q = new Question(this.label, this.listItems, elm);
                this.questions.Add(q);
            }
        }
示例#20
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SigningTime", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("SigningTime missing");
            }
            this.signingTime = XmlConvert.ToDateTime(xmlNodeList.Item(0).InnerText, XmlDateTimeSerializationMode.Utc);

            xmlNodeList = xmlElement.SelectNodes("xsd:SigningCertificate", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("SigningCertificate missing");
            }
            this.signingCertificate = new SigningCertificate();
            this.signingCertificate.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:SignaturePolicyIdentifier", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("SignaturePolicyIdentifier missing");
            }
            this.signaturePolicyIdentifier = new SignaturePolicyIdentifier();
            this.signaturePolicyIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:SignatureProductionPlace", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.signatureProductionPlace = new SignatureProductionPlace();
                this.signatureProductionPlace.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
            else
            {
                this.signatureProductionPlace = null;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:SignerRole", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.signerRole = new SignerRole();
                this.signerRole.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
            else
            {
                this.signerRole = null;
            }
        }
示例#21
0
 protected ItemDescriptor(XmlElement elem, ItemGroup group, ClassDescriptor klass)
 {
     this.klass = klass;
     isInternal = elem.HasAttribute ("internal");
     deps = AddSubprops (elem.SelectNodes ("./disabled-if"), group, klass);
     visdeps = AddSubprops (elem.SelectNodes ("./invisible-if"), group, klass);
     targetGtkVersion = elem.GetAttribute ("gtk-version");
     if (targetGtkVersion.Length == 0)
         targetGtkVersion = null;
 }
		public static NeatGenome Read(XmlElement xmlGenome)
		{
			int inputNeuronCount=0;
			int outputNeuronCount=0;

			uint id = uint.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "id"));

			//--- Read neuron genes into a list.
			NeuronGeneList neuronGeneList = new NeuronGeneList();
			XmlNodeList listNeuronGenes = xmlGenome.SelectNodes("neurons/neuron");
			foreach(XmlElement xmlNeuronGene in listNeuronGenes)
			{
				NeuronGene neuronGene = ReadNeuronGene(xmlNeuronGene);

				// Count the input and output neurons as we go.
				switch(neuronGene.NeuronType)
				{
					case NeuronType.Input:
						inputNeuronCount++;
						break;
					case NeuronType.Output:
						outputNeuronCount++;
						break;
				}

				neuronGeneList.Add(neuronGene);
			}

            //--- Read module genes into a list.
            List<ModuleGene> moduleGeneList = new List<ModuleGene>();
            XmlNodeList listModuleGenes = xmlGenome.SelectNodes("modules/module");
            foreach (XmlElement xmlModuleGene in listModuleGenes) {
                moduleGeneList.Add(ReadModuleGene(xmlModuleGene));
            }

			//--- Read connection genes into a list.
			ConnectionGeneList connectionGeneList = new ConnectionGeneList();
			XmlNodeList listConnectionGenes = xmlGenome.SelectNodes("connections/connection");
			foreach(XmlElement xmlConnectionGene in listConnectionGenes)
				connectionGeneList.Add(ReadConnectionGene(xmlConnectionGene));
			
			//return new NeatGenome(id, neuronGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
            NeatGenome g = new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
            g.Behavior = ReadBehavior(xmlGenome.SelectSingleNode("behavior"));
            g.Behavior.objectives = new double[6];
            g.objectives = new double[6];


            // JUSTIN: Read grid/trajectory info
            g.GridCoords = ReadGrid(xmlGenome.SelectSingleNode("grid"));
            g.Behavior.trajectory = ReadTrajectory(xmlGenome.SelectSingleNode("trajectory"));

            return g;
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="ModularXmlLanguageDefinition"/> class.
        /// </summary>
        /// <param name="languageElement">The XML element that defines the language.</param>
        public ModularXmlLanguageDefinition(XmlElement languageElement)
        {
            Contract.Requires<ArgumentNullException>(languageElement != null);

            XmlNamespaceManager nm = Sage.XmlNamespaces.Manager;

            this.Name = languageElement.GetAttribute("name");

            foreach (XmlElement groupNode in languageElement.SelectNodes("mod:elements/mod:group", nm))
                this.Elements.Add(new ExpressionGroup(groupNode, true));

            foreach (XmlElement groupNode in languageElement.SelectNodes("mod:attributes/mod:group", nm))
                this.Attributes.Add(new ExpressionGroup(groupNode, true));
        }
		public static NeatGenome Read(XmlElement xmlGenome)
		{
			int inputNeuronCount=0;
			int outputNeuronCount=0;

			uint id = uint.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "id"));
            // Schrum: Retrieve this new property, which is saved to xml files now
            int outputsPerPolicy = int.Parse(XmlUtilities.GetAttributeValue(xmlGenome, "outputsperpolicy"));

			//--- Read neuron genes into a list.
			NeuronGeneList neuronGeneList = new NeuronGeneList();
			XmlNodeList listNeuronGenes = xmlGenome.SelectNodes("neurons/neuron");
			foreach(XmlElement xmlNeuronGene in listNeuronGenes)
			{
				NeuronGene neuronGene = ReadNeuronGene(xmlNeuronGene);

				// Count the input and output neurons as we go.
				switch(neuronGene.NeuronType)
				{
					case NeuronType.Input:
						inputNeuronCount++;
						break;
					case NeuronType.Output:
						outputNeuronCount++;
						break;
				}

				neuronGeneList.Add(neuronGene);
			}

            //--- Read module genes into a list.
            List<ModuleGene> moduleGeneList = new List<ModuleGene>();
            XmlNodeList listModuleGenes = xmlGenome.SelectNodes("modules/module");
            foreach (XmlElement xmlModuleGene in listModuleGenes) {
                moduleGeneList.Add(ReadModuleGene(xmlModuleGene));
            }

			//--- Read connection genes into a list.
			ConnectionGeneList connectionGeneList = new ConnectionGeneList();
			XmlNodeList listConnectionGenes = xmlGenome.SelectNodes("connections/connection");
			foreach(XmlElement xmlConnectionGene in listConnectionGenes)
				connectionGeneList.Add(ReadConnectionGene(xmlConnectionGene));
			
			//return new NeatGenome(id, neuronGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
            //return new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount);
            // Schrum: Changed to include the outputs per policy
            return new NeatGenome(id, neuronGeneList, moduleGeneList, connectionGeneList, inputNeuronCount, outputNeuronCount, outputsPerPolicy);
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            if (xmlElement.HasAttribute("ObjectReference"))
            {
                this.objectReferenceAttribute = xmlElement.GetAttribute("ObjectReference");
            }
            else
            {
                this.objectReferenceAttribute = "";
                throw new CryptographicException("ObjectReference attribute missing");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:Description", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.description = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:ObjectIdentifier", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.objectIdentifier = new ObjectIdentifier("ObjectIdentifier");
                this.objectIdentifier.LoadXml((XmlElement)xmlNodeList.Item(0));
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:MimeType", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.mimeType = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:Encoding", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.encoding = xmlNodeList.Item(0).InnerText;
            }
        }
示例#26
0
 protected UpdateObject(XmlElement node)
 {
     foreach (XmlNode fileNode in node.SelectNodes("./File"))
     {
         AllFiles.Add(new File(fileNode as XmlElement));
     }
 }
        internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement)
            : base(parentFile)
        {
            _parentFunction = storeFunction;

            _parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl);
            if (ordinal > 0)
            {
                XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM);
                if (propertyNodes.Count >= ordinal)
                {
                    parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]);
                }
                else
                {
                    parentTypeElement.AppendChild(_parameterElement);
                }
            }
            else
            {
                parentTypeElement.AppendChild(_parameterElement);
            }

            this.Name = name;
        }
示例#28
0
        public InstallLog(XmlElement element)
        {
            string dateString = element.GetAttribute("dateTime");
            string resultString = element.GetAttribute("result");

            if (!string.IsNullOrWhiteSpace(dateString))
            {
                DateTime dateTime;
                if (DateTime.TryParse(dateString, out dateTime))
                    this.Date = dateTime;
            }

            if (!string.IsNullOrWhiteSpace(resultString))
            {
                InstallState result;
                if (Enum.TryParse(resultString, true, out result))
                    this.Result = result;
            }

            this.Items = new List<InstallItem>();
            foreach (XmlElement fileElem in element.SelectNodes("files/file"))
            {
                InstallItem file = this.AddFile(fileElem.GetAttribute("path"));
                file.CrcCode = fileElem.GetAttribute("crc");
                string stateString = fileElem.GetAttribute("state");
                if (!string.IsNullOrWhiteSpace(stateString))
                {
                    InstallState state;
                    if (Enum.TryParse(resultString, true, out state))
                        file.State = state;
                }
            }
        }
示例#29
0
        protected internal override void ReadFromXml(System.Xml.XmlElement xel)
        {
            Name  = ReadText(xel);
            Notes = ReadCData(xel, "notes");
            SizeX = ReadIntAttribute(xel, "xsize");
            SizeY = ReadIntAttribute(xel, "ysize");
            ReadCollection <Door>(xel, "map.doors", "door", doors, null);
            ReadCollection <Wall>(xel, "map.walls", "wall", walls, null);
            ReadCollection <PointOfInterest>(xel, "map.pointofinterests", "pointofinterest", pois, null);
            ReadCollection <Block>(xel, "map.blocks", "block", blocks, null);
            ReadCollection <Effect>(xel, "map.effects", "effect", effects, null);

            XmlNodeList xnl = xel.SelectNodes("map.characters/character");

            foreach (XmlNode xn in xnl)
            {
                XmlElement x    = xn as XmlElement;
                string     code = ReadAttribute(x, "code");
                Character  chr  = SessionManager.Singleton.Characters.FirstOrDefault(f => f.Value == code);
                if (chr != null)
                {
                    Characters.Add(chr);
                }
            }
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNodeList xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }
            if (xmlElement.HasAttribute("Algorithm"))
            {
                this.algorithm = xmlElement.GetAttribute("Algorithm");
            }
            else
            {
                this.algorithm = "";
            }

            xmlNodeList = xmlElement.SelectNodes("XPath");
            if (xmlNodeList.Count != 0)
            {
                this.xpath = xmlNodeList.Item(0).InnerText;
            }
            else
            {
                this.xpath = "";
            }
        }
示例#31
0
        public override void Load(System.Xml.XmlElement filenode, MonoDevelop.Core.FilePath baseDirectory)
        {
            var replacements = filenode.SelectNodes("Replacements/Replacement");

            Replacements = replacements.OfType <XmlElement>().Select(r => new Replacement(r)).ToDictionary(r => r.Name, StringComparer.OrdinalIgnoreCase);
            base.Load(filenode, baseDirectory);
        }
 public void Load(XmlElement xmlInfo)
 {
     try
       {
     foreach (XmlElement xmlElement in xmlInfo.SelectNodes("StaticTiles"))
     {
       try
       {
     foreach (XmlElement xmlInfo1 in xmlElement.SelectNodes("StaticTile"))
       this.InnerList.Add((object) new StaticTile(xmlInfo1));
       }
       finally
       {
     IEnumerator enumerator;
     if (enumerator is IDisposable)
       ((IDisposable) enumerator).Dispose();
       }
     }
       }
       finally
       {
     IEnumerator enumerator;
     if (enumerator is IDisposable)
       ((IDisposable) enumerator).Dispose();
       }
 }
 internal void LoadXml(XmlElement value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(value.OwnerDocument.NameTable);
     nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
     XmlNodeList list = value.SelectNodes("ds:Transform", nsmgr);
     if (list.Count == 0)
     {
         throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_InvalidElement"), "Transforms");
     }
     this.m_transforms.Clear();
     for (int i = 0; i < list.Count; i++)
     {
         XmlElement element = (XmlElement) list.Item(i);
         Transform transform = CryptoConfig.CreateFromName(System.Security.Cryptography.Xml.Utils.GetAttribute(element, "Algorithm", "http://www.w3.org/2000/09/xmldsig#")) as Transform;
         if (transform == null)
         {
             throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_UnknownTransform"));
         }
         transform.LoadInnerXml(element.ChildNodes);
         this.m_transforms.Add(transform);
     }
 }
示例#34
0
		protected string GetAddinTextFromUrl (XmlElement addin, string addinId, string fileId)
		{
			if (addin == null)
				return "<html>Add-in not found: " + addinId + "</html>";
			
			StringBuilder sb = new StringBuilder ("<html>");
			sb.Append ("<h1>").Append (addin.GetAttribute ("name")).Append ("</h1>");
			XmlElement docs = (XmlElement) addin.SelectSingleNode ("Description");
			if (docs != null)
				sb.Append (docs.InnerText);

			sb.Append ("<p><table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">");
			sb.AppendFormat ("<tr><td><b>Id</b></td><td>{0}</td></tr>", addin.GetAttribute ("addinId"));
			sb.AppendFormat ("<tr><td><b>Namespace</b></td><td>{0}</td></tr>", addin.GetAttribute ("namespace"));
			sb.AppendFormat ("<tr><td><b>Version</b></td><td>{0}</td></tr>", addin.GetAttribute ("version"));
			sb.Append ("</table></p>");
			sb.Append ("<p><b>Extension Points</b>:</p>");
			sb.Append ("<ul>");
			
			foreach (XmlElement ep in addin.SelectNodes ("ExtensionPoint")) {
				sb.AppendFormat ("<li><a href=\"extension-point:{0}#{1}#{2}\">{3}</li>", fileId, addinId, ep.GetAttribute ("path"), ep.GetAttribute ("name"));
			}
			sb.Append ("</ul>");
			
			sb.Append ("</html>");
			return sb.ToString ();
		}
示例#35
0
        /// <summary>
        /// Create xml nodes for given variable specification
        /// </summary>
        /// <param name="parentNode">target parent node where new nodes will be added</param>
        /// <param name="variables">variable definition</param>
        /// <param name="sourceNode">source node containing input variables to be merged</param>
        /// <param name="nsmgr">namespace manager for selecting variables from sourceNode</param>
        public static void CreateInitialXml(XmlElement parentNode, IList<VariableDef> variables, XmlElement sourceNode, XmlNamespaceManager nsmgr)
        {
            foreach(VariableDef vd in variables)
            {
                XmlNodeList nl = sourceNode != null ? sourceNode.SelectNodes(vd.Name, nsmgr) : null;
                List<XmlNode> newNodes = new List<XmlNode>();
                if (nl != null && nl.Count > 0)
                {
                    foreach (XmlNode xn in nl)
                    {
                        newNodes.Add(parentNode.OwnerDocument.ImportNode(xn, true));
                    }
                }
                else
                {
                    XmlNode xn = parentNode.OwnerDocument.CreateElement(vd.Name);
                    if (vd.DefaultValueExpr != null) xn.InnerText = vd.DefaultValueExpr;
                    newNodes.Add(xn);
                }
                foreach(XmlNode xn in newNodes)
                {
                    parentNode.AppendChild(xn);
                }
            }

            //binding result: map: variable name -> List<XmlElement> (variable value)
        }
示例#36
0
文件: File.cs 项目: hpavlov/occurec
        //    <File Path="/OccuRec_3_0_0_0/OccuRec.zip" LocalPath="OccuRec.exe" Archived="true" />
        //    <File Path="/OccuRec_3_0_0_0/OccuRec.Core.zip" LocalPath="OccuRec.Core.dll" Archived="true" />
        //    <File Path="/OccuRec_3_0_0_0/OccuRec.SDK.dll" />
        //    <File Path="/OccuRec_3_0_0_0/OccuRec.EN.pdf" LocalPath="/Documentation/OccuRec.pdf" Action="ShellExecute">
        //      <Language Id="1" Path="/OccuRec_3_0_0_0/OccuRec.EN.pdf" />
        //      <Language Id="2" Path="/OccuRec_3_0_0_0/OccuRec.DE.pdf" />
        //    </File>
        internal File(XmlElement node)
        {
            Path = node.Attributes["Path"].Value;

            if (node.Attributes["LocalPath"] != null)
                LocalPath = node.Attributes["LocalPath"].Value;

            if (node.Attributes["Archived"] != null)
                Archived = Convert.ToBoolean(node.Attributes["Archived"].Value, CultureInfo.InvariantCulture);
            else
                Archived = false;

            if (node.Attributes["Action"] != null)
                Action = node.Attributes["Action"].Value;

            foreach (XmlNode langNode in node.SelectNodes("./Language"))
            {
                int langId = int.Parse(langNode.Attributes["Id"].Value, CultureInfo.InvariantCulture);
                string path = langNode.Attributes["Path"].Value;

                try
                {
                    LanguageSpecificFiles.Add(langId, path);
                }
                catch { }
            }
        }
        internal ModelMemberProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, int ordinal, XmlElement entityTypeElement)
            : base(parentFile)
        {
            _modelEntityType = modelEntityType;
            _modelEntityType.Removed += new EventHandler(ModelEntityType_Removed);

            _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIcsdl);
            if (ordinal > 0)
            {
                XmlNodeList propertyNodes = entityTypeElement.SelectNodes("edm:Property", NSM);
                if (propertyNodes.Count >= ordinal)
                {
                    entityTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]);
                }
                else
                {
                    entityTypeElement.AppendChild(_propertyElement);
                }
            }
            else
            {
                entityTypeElement.AppendChild(_propertyElement);
            }

            Name = name;
        }
示例#38
0
 public static XmlElement GetElementByAttribute( XmlElement parent,
                                                 string elementName,
                                                 string attributeName,
                                                 string attributeValue,
                                                 bool filtered )
 {
     if ( parent == null || elementName == null || attributeName == null ||
          attributeValue == null ) {
         return null;
     }
     // TODO: Implement better filtering in the xpath expression so that the multiple steps of operations are not necessary
     XmlElement element = null;
     string xPath = elementName + "[@" + attributeName + "=\"" + attributeValue + "\"]";
     if ( filtered ) {
         FilteredElementList list = new FilteredElementList( parent.SelectNodes( xPath ) );
         IEnumerator enumerator = list.GetEnumerator();
         if ( enumerator.MoveNext() ) {
             element = (XmlElement) enumerator.Current;
         }
     }
     else {
         element = (XmlElement) parent.SelectSingleNode( xPath );
     }
     return element;
 }
示例#39
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            base.DeserializeCore(element, context); //Base implementation must be called

            if (context == SaveContext.Undo)
            {
                //Reads in the new number of ports required from the data stored in the Xml Element
                //during Serialize (nextLength). Changes the current In Port Data to match the
                //required size by adding or removing port data.
                int currLength = InPortData.Count;
                XmlNodeList inNodes = element.SelectNodes("Input");
                int nextLength = inNodes.Count;
                if (nextLength > currLength)
                {
                    for (; currLength < nextLength; currLength++)
                    {
                        XmlNode subNode = inNodes.Item(currLength);
                        string nickName = subNode.Attributes["name"].Value;
                        InPortData.Add(new PortData(nickName, "", typeof(object)));
                    }
                }
                else if (nextLength < currLength)
                    InPortData.RemoveRange(nextLength, currLength - nextLength);

                RegisterAllPorts();
            }
        }
示例#40
0
		public ItemGroup (XmlElement elem, ClassDescriptor klass)
		{
			declaringType = klass;
			label = elem.GetAttribute ("label");
			name = elem.GetAttribute ("name");

			XmlNodeList nodes = elem.SelectNodes ("property | command | signal");
			for (int i = 0; i < nodes.Count; i++) {
				XmlElement item = (XmlElement)nodes[i];
				string refname = item.GetAttribute ("ref");
				if (refname != "") {
					if (refname.IndexOf ('.') != -1) {
						ItemDescriptor desc = (ItemDescriptor) Registry.LookupItem (refname);
						items [desc.Name] = desc;
					} else {
						ItemDescriptor desc = (ItemDescriptor) klass[refname];
						items [desc.Name] = desc;
					}
					continue;
				}

				ItemDescriptor idesc = klass.CreateItemDescriptor ((XmlElement)item, this);
				if (idesc != null)
					items [idesc.Name] = idesc;
			}
		}
示例#41
0
		public static void LoadTaxes( XmlElement xml, Map map )
		{
			Dictionary<string, int> towns = new Dictionary<string, int>();
			foreach ( XmlElement town in xml.SelectNodes( "Town" ) )
			{
				string name = null;
				int tax = 0;

				Region.ReadString( town, "name", ref name, false );
				Region.ReadInt32( town, "tax", ref tax, false );

				if( name != null && tax > 0 )
				{
					try{ towns.Add( name, tax ); }
					catch( Exception e ){ Console.WriteLine("Taxes error: {0}", e.Message); }
				}
			}

			List<Region> regions = Server.Region.Regions;
			int tempInt = 0;
			for( int i = 0; i < regions.Count; i++ )
			{
				if( !(regions[i] is TownRegion) || regions[i].Map != map )
					continue;
				if( towns.TryGetValue( regions[i].Name, out tempInt ) )
				{
					((TownRegion)regions[i]).Tax = tempInt;
					Console.WriteLine( "      '{0}' has been added, with a tax of {1}%.", regions[i].Name, tempInt );
				}
			}
		}
		public void SetUpFixture()
		{
			WixDocument doc = new WixDocument();
			doc.LoadXml(GetWixXml());
			CreatedComponents.Clear();
			WixDialog wixDialog = doc.CreateWixDialog("AcceptLicenseDialog", new MockTextFileReader());
			using (Form dialog = wixDialog.CreateDialog(this)) {

				Panel radioButtonGroup = (Panel)dialog.Controls[0];
				radioButtonGroup.Left = 30;
				radioButtonGroup.Top = 100;
				
				RadioButton acceptRadioButton = (RadioButton)radioButtonGroup.Controls[0];
				acceptRadioButton.Left = 0;
				acceptRadioButton.Top = 5;
				acceptRadioButton.Width = 100;
				acceptRadioButton.Height = 50;
				acceptRadioButton.Text = "Accept";

				RadioButton declineRadioButton = (RadioButton)radioButtonGroup.Controls[1];
				declineRadioButton.Left = 10;
				declineRadioButton.Top = 20;
				declineRadioButton.Width = 200;
				declineRadioButton.Height = 30;
				declineRadioButton.Text = String.Empty;
				
				XmlElement dialogElement = wixDialog.UpdateDialogElement(dialog);
				radioButtonGroupElement = (XmlElement)dialogElement.SelectSingleNode("w:Control[@Id='Buttons']", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable));
				
				XmlNodeList radioButtonElements = radioButtonGroupElement.SelectNodes("//w:RadioButtonGroup/w:RadioButton", new WixNamespaceManager(dialogElement.OwnerDocument.NameTable));
				acceptRadioButtonElement = (XmlElement)radioButtonElements[0];
				declineRadioButtonElement = (XmlElement)radioButtonElements[1];
			}
		}
示例#43
0
        /// <summary>
        /// 從XML載入設定值
        /// <![CDATA[
        /// ]]>
        /// </summary>
        /// <param name="data"></param>
        public void Load(XmlElement data)
        {
            RefStudentID = data.GetAttribute("RefStudentID");

            Permanent = new AddressItem(data.SelectSingleNode("Permanent/Address") as XmlElement);
            Mailing = new AddressItem(data.SelectSingleNode("Mailing/Address") as XmlElement);

            Address1 = new AddressItem(null);
            Address2 = new AddressItem(null);
            Address3 = new AddressItem(null);

            int index = 0;
            foreach (XmlElement each in data.SelectNodes("Addresses/AddressList/Address"))
            {
                if (index == 0)
                    Address1 = new AddressItem(each);

                if (index == 1)
                    Address2 = new AddressItem(each);

                if (index == 2)
                    Address3 = new AddressItem(each);

                index++;
            }
        }
示例#44
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }
            if (xmlElement.HasAttribute("uri"))
            {
                this.uriAttribute = xmlElement.GetAttribute("uri");
            }
            else
            {
                this.uriAttribute = "";
                throw new CryptographicException("uri attribute missing");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:Transforms", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.transforms = new Transforms();
                this.transforms.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#45
0
        private static void ExtractArtistsUsingXPath(XmlElement catalogue)
        {
            var xPathQuery = "/catalogue/album/artist";
            var artists = catalogue.SelectNodes(xPathQuery);

            var artistsAlbumsCount = new Dictionary<string, int>();

            foreach (XmlNode artistNode in artists)
            {
                string artistStr = artistNode.InnerText;

                bool artistExists = artistsAlbumsCount.ContainsKey(artistStr);
                if (!artistExists)
                {
                    artistsAlbumsCount.Add(artistStr, 0);
                }

                artistsAlbumsCount[artistStr]++;
            }

            foreach (var artistAlbumsCount in artistsAlbumsCount)
            {
                string artist = artistAlbumsCount.Key;
                int albumsCound = artistAlbumsCount.Value;
                Console.WriteLine("Artist: {0} | Albums: {1} ", artist, albumsCound);
            }
        }
示例#46
0
        /// <summary>
        /// 加载主机站点信息
        /// </summary>
        /// <param name="node"></param>
        public override void Load(System.Xml.XmlElement node)
        {
            base.Load(node);

            XmlNodeList _siteNodeList = node.SelectNodes("MaSite");

            foreach (XmlElement item in _siteNodeList)
            {
                IMaSite _site = MaConfigManager.LoadConfig(item) as IMaSite;
                if (_site != null)
                {
                    #region 设置站点主机头

                    //设置站点主机头
                    XmlNodeList _hostNodeList = item.SelectNodes("host");
                    foreach (XmlElement host in _hostNodeList)
                    {
                        if (host.Attributes["value"] != null &&
                            !string.IsNullOrEmpty(host.Attributes["value"].Value))
                        {
                            _site.SetHost(host.Attributes["value"].Value);
                        }
                    }

                    #endregion
                    m_maSiteConfigList.Add(_site);
                }
                else
                {
                    throw new Exception("站点信息配置错误:" + item.Name + ":" + item.OuterXml);
                }
            }
        }
        internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType storeEntityType, string name, int ordinal, XmlElement parentTypeElement)
            : base(parentFile)
        {
            _parentEntityType = storeEntityType;
            _parentEntityType.Removed += new EventHandler(ParentEntityType_Removed);

            _propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIssdl);
            if (ordinal > 0)
            {
                XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Property", NSM);
                if (propertyNodes.Count >= ordinal)
                {
                    parentTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]);
                }
                else
                {
                    parentTypeElement.AppendChild(_propertyElement);
                }
            }
            else
            {
                parentTypeElement.AppendChild(_propertyElement);
            }

            this.Name = name;
        }
示例#48
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException(nameof(xmlElement));
            }
            if (xmlElement.HasAttribute("Id"))
            {
                this.id = xmlElement.GetAttribute("Id");
            }
            else
            {
                this.id = "";
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:CertRefs", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.certRefs = new CertRefs();
                this.certRefs.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
        private bool ReadFromXmlElement(XmlElement el)
        {
            XmlNodeList lst = el.SelectNodes("ParameterBitFlagValue");
            foreach (XmlElement child in lst)
                values.Add(DecoderParameterValueBitFlag.FromXmlElement(child));

            return (values.Count != 0);
        }
        public UniqueKeyRowValidator(XmlElement XmlNode)
        {
            mKey = new Dictionary<string, string>();
            mKeyFieldCol = new List<string>();

            foreach (XmlElement n in XmlNode.SelectNodes("KeyField"))
                mKeyFieldCol.Add(n.InnerText);
        }
示例#51
0
        //public List<FileSystemDirectoryFilterEntry> Entries = new List<FileSystemDirectoryFilterEntry>();

        #region IAgentConfig Members
        public void ReadConfiguration(string configurationString)
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(configurationString);
            Entries.Clear();
            System.Xml.XmlElement root = config.DocumentElement;
            foreach (System.Xml.XmlElement host in root.SelectNodes("directoryList/directory"))
            {
                FileSystemDirectoryFilterEntry directoryFilterEntry = new FileSystemDirectoryFilterEntry();
                directoryFilterEntry.FilterFullPath     = host.Attributes.GetNamedItem("directoryPathFilter").Value;
                directoryFilterEntry.DirectoryExistOnly = bool.Parse(host.ReadXmlElementAttr("testDirectoryExistOnly", "False"));
                directoryFilterEntry.FilesExistOnly     = bool.Parse(host.ReadXmlElementAttr("testFilesExistOnly", "False"));
                directoryFilterEntry.ErrorOnFilesExist  = bool.Parse(host.ReadXmlElementAttr("errorOnFilesExist", "False"));
                directoryFilterEntry.ContainsText       = host.ReadXmlElementAttr("containsText", "");
                directoryFilterEntry.UseRegEx           = host.ReadXmlElementAttr("useRegEx", false);

                int tmp = 0;
                if (int.TryParse(host.ReadXmlElementAttr("warningFileCountMax", "0"), out tmp))
                {
                    directoryFilterEntry.CountWarningIndicator = tmp;
                }
                if (int.TryParse(host.ReadXmlElementAttr("errorFileCountMax", "0"), out tmp))
                {
                    directoryFilterEntry.CountErrorIndicator = tmp;
                }
                long tmpl;

                if (long.TryParse(host.ReadXmlElementAttr("warningFileSizeMaxKB", "0"), out tmpl))
                {
                    directoryFilterEntry.SizeKBWarningIndicator = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("errorFileSizeMaxKB", "0"), out tmpl))
                {
                    directoryFilterEntry.SizeKBErrorIndicator = tmpl;
                }

                if (long.TryParse(host.ReadXmlElementAttr("fileMaxAgeSec", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMaxAgeSec = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMinAgeSec", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMinAgeSec = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMinSizeKB", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMinSizeKB = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMaxSizeKB", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMaxSizeKB = tmpl;
                }

                Entries.Add(directoryFilterEntry);
            }
        }
示例#52
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyId", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("SigPolicyId missing");
            }
            this.sigPolicyId = new ObjectIdentifier("SigPolicyId");
            this.sigPolicyId.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("ds:Transforms", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.transforms = new Transforms();
                this.transforms.LoadXml((XmlElement)xmlNodeList.Item(0));
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyHash", xmlNamespaceManager);
            if (xmlNodeList.Count == 0)
            {
                throw new CryptographicException("SigPolicyHash missing");
            }
            this.sigPolicyHash = new DigestAlgAndValueType("SigPolicyHash");
            this.sigPolicyHash.LoadXml((XmlElement)xmlNodeList.Item(0));

            xmlNodeList = xmlElement.SelectNodes("xsd:SigPolicyQualifiers", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.sigPolicyQualifiers = new SigPolicyQualifiers();
                this.sigPolicyQualifiers.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#53
0
        private List <DirectoryFilterEntry> ReadConfig()
        {
            XmlDocument config = new XmlDocument();

            config.LoadXml(CustomConfig);
            List <DirectoryFilterEntry> directorieFilters = new List <DirectoryFilterEntry>();

            System.Xml.XmlElement root = config.DocumentElement;
            foreach (XmlElement host in root.SelectNodes("directoryList/directory"))
            {
                DirectoryFilterEntry directoryFilterEntry = new DirectoryFilterEntry();
                directoryFilterEntry.FilterFullPath     = host.Attributes.GetNamedItem("directoryPathFilter").Value;
                directoryFilterEntry.DirectoryExistOnly = bool.Parse(host.ReadXmlElementAttr("testDirectoryExistOnly", "False"));

                int tmp = 0;
                if (int.TryParse(host.ReadXmlElementAttr("warningFileCountMax", "0"), out tmp))
                {
                    directoryFilterEntry.CountWarningIndicator = tmp;
                }
                if (int.TryParse(host.ReadXmlElementAttr("errorFileCountMax", "0"), out tmp))
                {
                    directoryFilterEntry.CountErrorIndicator = tmp;
                }
                long tmpl;

                if (long.TryParse(host.ReadXmlElementAttr("warningFileSizeMaxKB", "0"), out tmpl))
                {
                    directoryFilterEntry.SizeKBWarningIndicator = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("errorFileSizeMaxKB", "0"), out tmpl))
                {
                    directoryFilterEntry.SizeKBErrorIndicator = tmpl;
                }

                if (long.TryParse(host.ReadXmlElementAttr("fileMaxAgeSec", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMaxAgeSec = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMinAgeSec", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMinAgeSec = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMinSizeKB", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMinSizeKB = tmpl;
                }
                if (long.TryParse(host.ReadXmlElementAttr("fileMaxSizeKB", "0"), out tmpl))
                {
                    directoryFilterEntry.FileMaxSizeKB = tmpl;
                }

                directorieFilters.Add(directoryFilterEntry);
            }
            return(directorieFilters);
        }
示例#54
0
        public void InitFromXMLNode(System.Xml.XmlElement XmlNode)
        {
            _date_format   = XmlNode.SelectSingleNode("Matchs/@CorrectTo").InnerText;
            _valid_pattern = new DateMatcher(XmlNode.SelectSingleNode("ValidPattern") as XmlElement);

            _matchs = new List <DateMatcher>();
            foreach (XmlElement each in XmlNode.SelectNodes("Matchs/Match"))
            {
                _matchs.Add(new DateMatcher(each));
            }
        }
示例#55
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }
            if (xmlElement.HasAttribute("Id"))
            {
                this.id = xmlElement.GetAttribute("Id");
            }
            else
            {
                this.id = "";
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xades", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xades:CRLValues", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.crlValues = new CRLValues();
                this.crlValues.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
            xmlNodeList = xmlElement.SelectNodes("xades:OCSPValues", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.ocspValues = new OCSPValues();
                this.ocspValues.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
            xmlNodeList = xmlElement.SelectNodes("xades:OtherValues", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.otherValues = new OtherValues();
                this.otherValues.LoadXml((XmlElement)xmlNodeList.Item(0));
            }
        }
示例#56
0
        public override void Load(System.Xml.XmlElement filenode, MonoDevelop.Core.FilePath baseDirectory)
        {
            var formatCodeString = filenode.GetAttribute("FormatCode");

            if (!string.IsNullOrEmpty(formatCodeString))
            {
                FormatCode = bool.Parse(formatCodeString);
            }
            ResourceId = filenode.GetAttribute("ResourceId");
            var replacements = filenode.SelectNodes("Replacements/Replacement");

            Replacements = replacements.OfType <XmlElement>().Select(r => new Replacement(r)).ToDictionary(r => r.Name, StringComparer.OrdinalIgnoreCase);
            inner.Load(filenode, baseDirectory);
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:City", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.city = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:PostalCode", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.postalCode = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:StateOrProvince", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.stateOrProvince = xmlNodeList.Item(0).InnerText;
            }

            xmlNodeList = xmlElement.SelectNodes("xsd:CountryName", xmlNamespaceManager);
            if (xmlNodeList.Count != 0)
            {
                this.countryName = xmlNodeList.Item(0).InnerText;
            }
        }
示例#58
0
        private void readPathInfo()
        {
            XmlDocument docavidconfig = new XmlDocument();

            docavidconfig.Load(Application.StartupPath + "\\pathinfo.xml");
            System.Xml.XmlElement avidconfig = docavidconfig.DocumentElement;

            XmlNodeList relationlists = avidconfig.SelectNodes("//relation");

            htpaths = new Hashtable();  //路径对应关系
            foreach (XmlNode relationNode in relationlists)
            {
                string keyinpath   = relationNode.FirstChild.InnerText;
                string valueinpath = relationNode.FirstChild.NextSibling.InnerText;
                htpaths.Add(keyinpath, valueinpath);
            }
        }
示例#59
0
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public override void LoadXml(System.Xml.XmlElement xmlElement)
        {
            XmlNamespaceManager xmlNamespaceManager;
            XmlNodeList         xmlNodeList;

            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            xmlNamespaceManager = new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
            xmlNamespaceManager.AddNamespace("xsd", XadesSignedXml.XadesNamespaceUri);

            xmlNodeList = xmlElement.SelectNodes("xsd:SPURI", xmlNamespaceManager);

            this.uri = ((XmlElement)xmlNodeList.Item(0)).InnerText;
        }
        public void InitFromXMLNode(System.Xml.XmlElement XmlNode)
        {
            _skip_empty = bool.Parse(XmlNode.GetAttribute("SkipEmpty"));

            _activate_validator = false;
            foreach (XmlElement each in XmlNode.SelectNodes("ActivatorField"))
            {
                string fieldName = each.InnerText;
                _activate_validator |= (_context.SelectedFields.Contains(fieldName));
            }

            if (!_activate_validator)
            {
                return;
            }

            _lookup = _context.Extensions[TeacherLookup.Name] as TeacherLookup;
        }