HasAttribute() public method

public HasAttribute ( string name ) : bool
name string
return bool
		protected bool ProcessStatement(XmlElement element, IXmlProcessorEngine engine)
		{
			if (!element.HasAttribute(DefinedAttrName) &&
				!element.HasAttribute(NotDefinedAttrName))
			{
				throw new XmlProcessorException("'if' elements expects a non empty defined or not-defined attribute");
			}

			if (element.HasAttribute(DefinedAttrName) &&
				element.HasAttribute(NotDefinedAttrName))
			{
				throw new XmlProcessorException("'if' elements expects a non empty defined or not-defined attribute");
			}

			bool processContents = false;

			if (element.HasAttribute(DefinedAttrName))
			{
				processContents = engine.HasFlag(element.GetAttribute(DefinedAttrName));
			}
			else
			{
				processContents = !engine.HasFlag(element.GetAttribute(NotDefinedAttrName));
			}

			return processContents;
		}
		/// <summary>
		/// Creates a project descriptor for the project node specified by the xml element.
		/// </summary>
		/// <param name="element">The &lt;Project&gt; node of the xml template file.</param>
		/// <param name="hintPath">The directory on which relative paths (e.g. for referenced files) are based.</param>
		public ProjectDescriptor(XmlElement element, string hintPath)
		{
			if (element == null)
				throw new ArgumentNullException("element");
			if (hintPath == null)
				throw new ArgumentNullException("hintPath");
			
			if (element.HasAttribute("name")) {
				name = element.GetAttribute("name");
			} else {
				name = "${ProjectName}";
			}
			if (element.HasAttribute("directory")) {
				relativePath = element.GetAttribute("directory");
			} else {
				relativePath = ".";
			}
			languageName = element.GetAttribute("language");
			if (string.IsNullOrEmpty(languageName)) {
				ProjectTemplate.WarnAttributeMissing(element, "language");
			}
			defaultPlatform = element.GetAttribute("defaultPlatform");
			
			LoadElementChildren(element, hintPath);
		}
        public override bool FromXML(System.Xml.XmlElement myElement)
        {
            if (myElement != null)
            {
                base.FromXML(myElement);
                this.Type = StringCommon.GetTypeByName(myElement.GetAttribute("type"));
                this.Attributes.FromXML(myElement);
                this.Name = myElement.GetAttribute("name");
                this.text = myElement.GetAttribute("text");

                //新增加的属性,为了兼容以前格式
                if (this.Type == ElementType.HaveNotElement)
                {
                    if (myElement.HasAttribute("prifix"))
                    {
                        this.Prifix = myElement.GetAttribute("prifix");
                    }
                    else
                    {
                        this.Prifix = "有";
                    }

                    if (myElement.HasAttribute("postfix"))
                    {
                        this.Postfix = myElement.GetAttribute("postfix");
                    }
                    else
                    {
                        this.Postfix = "无";
                    }
                }

                this.myList.Clear();

                for (int i = 0; i < myElement.ChildNodes.Count; i++)
                {
                    if (myElement.ChildNodes.Item(i).Name == "item")
                    {
                        //string selected = (myElement.ChildNodes.Item(i) as XmlElement).GetAttribute("selected");
                        //bool isSelected = Convert.ToBoolean(selected);//(selected != "") ? true : false;

                        ZYSelectableElementItem eleItem = new ZYSelectableElementItem();

                        //eleItem.InnerValue = myElement.ChildNodes.Item(i).InnerText;
                        //eleItem.IsSelected = isSelected;
                        //eleItem.Code =

                        //eleItem.Parent = this;
                        //eleItem.OwnerDocument = this.OwnerDocument;

                        eleItem.FromXML(myElement.ChildNodes.Item(i) as XmlElement);
                        this.myList.Add(eleItem);
                    }
                }

                UpDateText();
                return(true);
            }
            return(false);
        }
		public override void Load (XmlElement element)
		{
			//GetAttribute returns String.Empty even if the attr does not exist
			//but we want null (empty attribute is significant), so do an extra check
			if (element.HasAttribute ("PermittedCreationPaths"))
				permittedCreationPaths = element.GetAttribute("PermittedCreationPaths").Split (':');
			
			if (element.HasAttribute ("ExcludedCreationPaths"))
				excludedCreationPaths = element.GetAttribute("ExcludedCreationPaths").Split (':');
			
			if (element.HasAttribute ("RequiredFiles"))
				requiredFiles = element.GetAttribute("RequiredFiles").Split (':');
			
			if (element.HasAttribute ("ExcludedFiles"))
				excludedFiles = element.GetAttribute("ExcludedFiles").Split (':');
			
			if (element.HasAttribute ("ProjectType"))
				projectType = element.GetAttribute("ProjectType");
			
			string requireExistsStr = element.GetAttribute ("RequireProject");
			if (!string.IsNullOrEmpty (requireExistsStr)) {
				try {
					requireExists = bool.Parse (requireExistsStr);
				} catch (FormatException) {
					throw new InvalidOperationException ("Invalid value for RequireExists in template.");
				}
			}
		}
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Span"/> class.
        /// </summary>
        /// <param name="span">The XML element that describes the span.</param>
        public Span(XmlElement span)
        {
            color = new HighlightColor(span);

              if (span.HasAttribute("rule"))
            rule = span.GetAttribute("rule");

              if (span.HasAttribute("escapecharacter"))
            escapeCharacter = span.GetAttribute("escapecharacter")[0];

              name = span.GetAttribute("name");
              if (span.HasAttribute("stopateol"))
            stopEOL = Boolean.Parse(span.GetAttribute("stopateol"));

              begin = span["Begin"].InnerText.ToCharArray();
              beginColor = new HighlightColor(span["Begin"], color);

              if (span["Begin"].HasAttribute("singleword"))
            isBeginSingleWord = Boolean.Parse(span["Begin"].GetAttribute("singleword"));

              if (span["Begin"].HasAttribute("startofline"))
            isBeginStartOfLine = Boolean.Parse(span["Begin"].GetAttribute("startofline"));

              if (span["End"] != null)
              {
            end = span["End"].InnerText.ToCharArray();
            endColor = new HighlightColor(span["End"], color);
            if (span["End"].HasAttribute("singleword"))
              isEndSingleWord = Boolean.Parse(span["End"].GetAttribute("singleword"));
              }
        }
 public void ReadFromXmlElement(XmlElement el)
 {
     if (el.HasAttribute("Name"))
         name = el.GetAttribute("Name");
     if (el.HasAttribute("Value"))
         value = el.GetAttribute("Value");
 }
Beispiel #7
0
        public static Attempt ParseXml(XmlElement node)
        {
            var newTime = Time.FromXml(node);
            var index = int.Parse(node.Attributes["id"].InnerText, CultureInfo.InvariantCulture);
            AtomicDateTime? started = null;
            var startedSynced = false;
            AtomicDateTime? ended = null;
            var endedSynced = false;

            if (node.HasAttribute("started"))
            {
                var startedTime = DateTime.Parse(node.Attributes["started"].InnerText, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
                if (node.HasAttribute("isStartedSynced"))
                    startedSynced = bool.Parse(node.Attributes["isStartedSynced"].InnerText);
                started = new AtomicDateTime(startedTime, startedSynced);
            }

            if (node.HasAttribute("ended"))
            {
                var endedTime = DateTime.Parse(node.Attributes["ended"].InnerText, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
                if (node.HasAttribute("isEndedSynced"))
                    endedSynced = bool.Parse(node.Attributes["isEndedSynced"].InnerText);
                ended = new AtomicDateTime(endedTime, endedSynced);
            }

            return new Attempt(index, newTime, started, ended);
        }
Beispiel #8
0
        public static void ProcessSetProperty(XmlElement actionElement, IBlockWeb containerWeb, string blockId)
        {
            string connectorKey = actionElement.GetAttribute("connectorKey");
            object value = ObjectReader.ReadObject(actionElement);
            bool createConnector = false;

            if (actionElement.HasAttribute("create") && actionElement.GetAttribute("create") == "true")
            {
                createConnector = true;
            }

            if (actionElement.HasAttribute("blockId"))
            {
                string aBlockId = actionElement.GetAttribute("blockId");

                if (createConnector)
                {
                    containerWeb[aBlockId].ProcessRequest("ProcessMetaService", BlockMetaServiceType.CreateConnector, connectorKey, null);
                }

                containerWeb[aBlockId][connectorKey].AttachEndPoint(value);
            }
            else
            {
                if (createConnector)
                {
                    containerWeb[blockId].ProcessRequest("ProcessMetaService", BlockMetaServiceType.CreateConnector, connectorKey, null);
                }

                containerWeb[blockId][connectorKey].AttachEndPoint(value);
            }
        }
        public override string GetValue(XmlElement element, Context context)
        {
            if(element != null)
            {
                if (element.HasAttribute(Name, string.Empty))
                {
                    return element.GetAttribute(Name);
                }
                else if (element.HasAttribute(Name, ResourceManager.VariableNamespace))
                {
                    IValueNode value = (IValueNode)context.GetVariable(element.GetAttribute(Name, ResourceManager.VariableNamespace));
                    value.InitNewState(context);
                    return value.Value;
                }
                else
                {
                    XmlElement valueNode = element[element.Name + "." + Name];

                    if (valueNode != null)
                    {
                        IValueNode value = (IValueNode)SequenceFactory.Instance.CreateChildrenAsSequence(valueNode, context);
                        value.InitNewState(context);
                        return value.Value;
                    }
                }
            }

            return null;
        }
Beispiel #10
0
        public Sequence(string unit, XmlElement e)
        {
            string srcOverride = e.GetAttribute("src");
            Name = e.GetAttribute("name");

            sprites = SpriteSheetBuilder.LoadAllSprites(string.IsNullOrEmpty(srcOverride) ? unit : srcOverride );
            start = int.Parse(e.GetAttribute("start"));

            if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*")
                length = sprites.Length - Start;
            else if (e.HasAttribute("length"))
                length = int.Parse(e.GetAttribute("length"));
            else if (e.HasAttribute("end"))
                length = int.Parse(e.GetAttribute("end")) - int.Parse(e.GetAttribute("start"));
            else
                length = 1;

            if( e.HasAttribute( "facings" ) )
                facings = int.Parse( e.GetAttribute( "facings" ) );
            else
                facings = 1;

            if (e.HasAttribute("tick"))
                tick = int.Parse(e.GetAttribute("tick"));
            else
                tick = 40;
        }
Beispiel #11
0
        public static new Inform Parse(XmlElement inform)
        {
            if (inform == null)
            {
                throw new Exception("parameter can't be null!");
            }

            string type = string.Empty;
            string operation = string.Empty;

            if (inform.HasAttribute("Type"))
            {
                type = inform.GetAttribute("Type");
            }
            else
            {
                throw new Exception("load hasn't type attribute!");
            }

            if (inform.HasAttribute("Operation"))
            {
                operation = inform.GetAttribute("Operation");
            }
            else
            {
                throw new Exception("parameter hasn't Operation attribute!");
            }

            Operation enumOperation = (Operation)Enum.Parse(typeof(Operation), operation);

            Inform result = new Inform(enumOperation, inform.Name, type, inform.InnerText);

            return result;

        }
Beispiel #12
0
        public Tuple(XmlElement elTuple)
        {
            XmlNodeList l = elTuple.GetElementsByTagName("field");
            fields = new Field[l.Count];
            for (int i = 0; i < l.Count; i++)
            {
                XmlElement elField = (XmlElement) l[i];
                fields[i] = new Field(elField);
            }

            if (elTuple.HasAttribute("id"))
            {
                tupleID = new TupleID(elTuple.GetAttribute("id"));
            }
            if (elTuple.HasAttribute("creationTimestamp"))
            {
                creationTimestamp = long.Parse(elTuple.GetAttribute("creationTimestamp"));
            }
            if (elTuple.HasAttribute("lastModificationTimestamp"))
            {
                lastModificationTimestamp = long.Parse(elTuple.GetAttribute("lastModificationTimestamp"));
            }
            if (elTuple.HasAttribute("expiration"))
            {
                expiration = long.Parse(elTuple.GetAttribute("expiration"));
            }
        }
        private Color ColorFromXML(XmlElement xmlElement)
        {
            if (xmlElement.HasAttribute("ColorName"))
            {
                return Color.FromName(xmlElement.GetAttribute("ColorName"));
            }
            else if (xmlElement.HasAttribute("Color"))
            {
                string clr = xmlElement.GetAttribute("Color");
                if (clr.Length == 7 && clr[0] =='#')
                {
                    // RGB
                    int r = int.Parse(clr.Substring(1, 2), System.Globalization.NumberStyles.HexNumber);
                    int g = int.Parse(clr.Substring(3, 2), System.Globalization.NumberStyles.HexNumber);
                    int b = int.Parse(clr.Substring(5, 2), System.Globalization.NumberStyles.HexNumber);
                    return Color.FromArgb(r, g, b);
                }
                else if (clr.Length == 9 && clr[0] == '#')
                {
                    // RGB
                    int a = int.Parse(clr.Substring(1, 2), System.Globalization.NumberStyles.HexNumber);
                    int r = int.Parse(clr.Substring(3, 2), System.Globalization.NumberStyles.HexNumber);
                    int g = int.Parse(clr.Substring(5, 2), System.Globalization.NumberStyles.HexNumber);
                    int b = int.Parse(clr.Substring(7, 2), System.Globalization.NumberStyles.HexNumber);
                    return Color.FromArgb(a, r, g, b);
                }
            }

            throw new Exception("Unknown colour XML");
        }
 private void ReadFromXmlElement(XmlElement el)
 {
     if (el.HasAttribute("Value"))
         value = uint.Parse(el.GetAttribute("Value"));
     if (el.HasAttribute("Name"))
         name = el.GetAttribute("Name");
 }
Beispiel #15
0
 internal override void ParseXml(XmlElement xml)
 {
     base.ParseXml(xml);
     foreach (XmlNode child in xml.ChildNodes)
     {
         string name = child.Name;
         if (string.Compare(name, "ShapeRepresentations") == 0)
         {
             List<IfcShapeModel> shapes = new List<IfcShapeModel>(child.ChildNodes.Count);
             foreach (XmlNode cn in child.ChildNodes)
             {
                 IfcShapeModel s = mDatabase.ParseXml<IfcShapeModel>(cn as XmlElement);
                 if (s != null)
                     shapes.Add(s);
             }
             ShapeRepresentations = shapes;
         }
         else if (string.Compare(name, "PartOfProductDefinitionShape") == 0)
             PartOfProductDefinitionShape = mDatabase.ParseXml<IfcProductRepresentationSelect>(child as XmlElement);
     }
     if (xml.HasAttribute("Name"))
         Name = xml.Attributes["Name"].Value;
     if (xml.HasAttribute("Description"))
         Description = xml.Attributes["Description"].Value;
     if (xml.HasAttribute("ProductDefinitional"))
         Enum.TryParse<IfcLogicalEnum>(xml.Attributes["ProductDefinitional"].Value,true, out mProductDefinitional);
 }
Beispiel #16
0
        internal override void ParseXml(XmlElement xml)
        {
            base.ParseXml(xml);
            if (xml.HasAttribute("CoordinateSpaceDimension"))
                CoordinateSpaceDimension = int.Parse(xml.Attributes["CoordinateSpaceDimension"].Value);
            if (xml.HasAttribute("Precision"))
                Precision = double.Parse(xml.Attributes["Precision"].Value);

            foreach (XmlNode child in xml.ChildNodes)
            {
                string name = child.Name;
                if (string.Compare(name, "WorldCoordinateSystem") == 0)
                    WorldCoordinateSystem = mDatabase.ParseXml<IfcAxis2Placement3D>(child as XmlElement);
                else if (string.Compare(name, "TrueNorth") == 0)
                    TrueNorth = mDatabase.ParseXml<IfcDirection>(child as XmlElement);
                else if (string.Compare(name, "HasSubContexts") == 0)
                {
                    List<IfcGeometricRepresentationSubContext> subs = new List<IfcGeometricRepresentationSubContext>();
                    foreach (XmlNode node in child.ChildNodes)
                    {
                        IfcGeometricRepresentationSubContext sub = mDatabase.ParseXml<IfcGeometricRepresentationSubContext>(node as XmlElement);
                        if (sub != null)
                            sub.ContainerContext = this;
                    }
                }
                else if (string.Compare(name, "HasCoordinateOperation") == 0)
                    HasCoordinateOperation = mDatabase.ParseXml<IfcCoordinateOperation>(child as XmlElement);
            }
        }
		public override void Load (XmlElement element)
		{
			if (element.HasAttribute ("minVersion"))
				minVersion = Version.Parse (element.GetAttribute ("minVersion"));

			if (element.HasAttribute ("razor"))
				razor = bool.Parse (element.GetAttribute ("razor"));
		}
Beispiel #18
0
 internal override void ParseXml(XmlElement xml)
 {
     base.ParseXml(xml);
     if (xml.HasAttribute("CountValue"))
         CountValue = double.Parse(xml.Attributes["CountValue"].Value);
     if (xml.HasAttribute("Formula"))
         Formula = xml.Attributes["Formula"].Value;
 }
Beispiel #19
0
        /// <summary>
        /// Parses a manifest from XML.
        /// </summary>
        /// <param name="root">The root "mod" node.</param>
        public static ModManifest FromXml(XmlElement root)
        {
            try
            {
                if (root.Name != "mod")
                {
                    throw new InvalidDataException(String.Format("Given '{0}' node, expected 'mod'.",
                        root.Name));
                }

                if (root.HasAttribute("name") == false ||
                    root.HasAttribute("version") == false)
                {
                    throw new InvalidDataException("Attributes 'name' and 'version' are required.");
                }

                String name = root.Attributes["name"].Value;
                String version = root.Attributes["version"].Value;

                ModDefinition definition = ModDefinition.Parse(name, version);
                if (definition.MatchingRule != ModMatchingRule.Exact)
                {
                    throw new InvalidDataException("The version number in a manifest must be an " +
                        "exact one; none of the form '2.x' or '1.5+' are allowed.");
                }

                Int32 major = definition.Major;
                Int32 minor = definition.Minor;

                XmlElement depsNode = root["deps"];

                List<ModDefinition> deps = new List<ModDefinition>();

                if (depsNode != null)
                {
                    foreach (XmlElement e in depsNode)
                    {
                        if (e.HasAttribute("name") == false ||
                            e.HasAttribute("version") == false)
                        {
                            throw new InvalidDataException("Attributes 'name' and 'version' are " +
                                "required on all dependencies.");
                        }

                        deps.Add(ModDefinition.Parse(e.Attributes["name"].Value,
                                                     e.Attributes["version"].Value));
                    }
                }

                return new ModManifest(name, major, minor,
                                       new ReadOnlyCollection<ModDefinition>(deps));
            }
            catch (Exception e)
            {
                throw new ArgumentException("There was a problem with parsing " +
                    "the provided XML node. Check the inner exception for details.", e);
            }
        }
 private void ProcessMapping(XmlElement xmlElement, AN_SemanticsMember member)
 {
     if (xmlElement.HasAttribute("columnName"))
         member.ColumnFormula = xmlElement.Attributes["columnName"].Value;
     if (xmlElement.HasAttribute("schemaName"))
         member.MappingSchema = xmlElement.Attributes["schemaName"].Value;
     if (xmlElement.HasAttribute("columnObjectName"))
         member.MappingObject = xmlElement.Attributes["columnObjectName"].Value;
 }
Beispiel #21
0
        internal StyleSheet(XmlElement styleElement)
        {
            if(styleElement.HasAttribute("href")) _Href = styleElement.Attributes["href"].Value;
            if(styleElement.HasAttribute("type")) _Type = styleElement.Attributes["type"].Value;
            if(styleElement.HasAttribute("title")) _Title = styleElement.Attributes["title"].Value;
            if(styleElement.HasAttribute("media")) _Media = new MediaList(styleElement.Attributes["media"].Value);

            ownerNode = (XmlNode)styleElement;
        }
Beispiel #22
0
        public static Request Parse(XmlElement request)
        {
            if (request == null)
            {
                return null;
            }

            if (request.HasAttribute("Type"))
            {
                string type = request.GetAttribute("Type");
                if (type != Const.REQUEST)
                {
                    throw new Exception("method type error!");
                }
            }
            else
            {
                throw new Exception("method format error!");
            }

            Request result = null;

            if (request.HasAttribute("Name"))
            {
                string name = request.GetAttribute("Name");
                result = new Request(name);
            }
            else
            {
                throw new Exception("method format error!");
            }

            if (request.HasAttribute("Sequence"))
            {
                string sequence = request.GetAttribute("Sequence");
                result.Sequence = (sequence.ToLower() == "true" ? true : false);
            }
            else
            {
                throw new Exception("method format error!");
            }

            XmlNode parameterRoot = request.SelectSingleNode("Parameter");
            if (parameterRoot != null)
            {
                XmlNodeList parameters = parameterRoot.ChildNodes;
                foreach (XmlNode parameter in parameters)
                {
                    Parameter p = Parameter.Parse(parameter as XmlElement);
                    result.AddParameter(p);
                }
            }

            return result;

        }
Beispiel #23
0
 internal override void ParseXml(XmlElement xml)
 {
     base.ParseXml(xml);
     if (xml.HasAttribute("XLength"))
         XLength = double.Parse(xml.Attributes["XLength"].Value);
     if (xml.HasAttribute("YLength"))
         YLength = double.Parse(xml.Attributes["YLength"].Value);
     if (xml.HasAttribute("ZLength"))
         ZLength = double.Parse(xml.Attributes["ZLength"].Value);
 }
Beispiel #24
0
        string GetCType(XmlElement type_elem)
        {
            if (type_elem.HasAttribute ("c:type"))
                return type_elem.GetAttribute ("c:type");
            else if (type_elem.HasAttribute ("name"))
                return SymbolTable.Lookup (type_elem.GetAttribute ("name"));

            Console.WriteLine ("Unexpected type element: " + elem.OuterXml);
            return String.Empty;
        }
Beispiel #25
0
        protected ClassBase(XmlElement ns, XmlElement elem)
            : base(ns, elem)
        {
            if (elem.HasAttribute ("deprecated")) {
                string attr = elem.GetAttribute ("deprecated");
                deprecated = attr == "1" || attr == "true";
            }

            if (elem.HasAttribute ("abstract")) {
                string attr = elem.GetAttribute ("abstract");
                isabstract = attr == "1" || attr == "true";
            }

            foreach (XmlNode node in elem.ChildNodes) {
                if (!(node is XmlElement)) continue;
                XmlElement member = (XmlElement) node;
                if (member.HasAttribute ("hidden"))
                    continue;

                string name;
                switch (node.Name) {
                case "method":
                    name = member.GetAttribute("name");
                    while (methods.ContainsKey(name))
                        name += "mangled";
                    methods.Add (name, new Method (member, this));
                    break;

                case "property":
                    name = member.GetAttribute("name");
                    while (props.ContainsKey(name))
                        name += "mangled";
                    props.Add (name, new Property (member, this));
                    break;

                case "field":
                    name = member.GetAttribute("name");
                    while (fields.ContainsKey (name))
                        name += "mangled";
                    fields.Add (name, new ObjectField (member, this));
                    break;

                case "implements":
                    ParseImplements (member);
                    break;

                case "constructor":
                    ctors.Add (new Ctor (member, this));
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #26
0
    public CreateFileConfigsEntity XmlToObject(System.Xml.XmlElement element)
    {
        if (element.HasAttribute("id") && !string.IsNullOrEmpty(element.GetAttribute("id")))
        {
            id = element.GetAttribute("id");
        }

        if (element.HasAttribute("entityBaseName") && !string.IsNullOrEmpty(element.GetAttribute("entityBaseName")))
        {
            entityBaseName = element.GetAttribute("entityBaseName");
        }

        if (element.HasAttribute("dbModelBaseName") && !string.IsNullOrEmpty(element.GetAttribute("dbModelBaseName")))
        {
            dbModelBaseName = element.GetAttribute("dbModelBaseName");
        }

        if (element.HasAttribute("isCreateReadXmlFun") && !string.IsNullOrEmpty(element.GetAttribute("isCreateReadXmlFun")))
        {
            isCreateReadXmlFun = bool.Parse(element.GetAttribute("isCreateReadXmlFun"));
        }

        if (element.HasAttribute("isCreateReadJsonFun") && !string.IsNullOrEmpty(element.GetAttribute("isCreateReadJsonFun")))
        {
            isCreateReadJsonFun = bool.Parse(element.GetAttribute("isCreateReadJsonFun"));
        }

        if (element.HasAttribute("isCreateXmlFile") && !string.IsNullOrEmpty(element.GetAttribute("isCreateXmlFile")))
        {
            isCreateXmlFile = bool.Parse(element.GetAttribute("isCreateXmlFile"));
        }

        if (element.HasAttribute("isCreateJsonFile") && !string.IsNullOrEmpty(element.GetAttribute("isCreateJsonFile")))
        {
            isCreateJsonFile = bool.Parse(element.GetAttribute("isCreateJsonFile"));
        }

        if (element.HasAttribute("isCreateEntityFile") && !string.IsNullOrEmpty(element.GetAttribute("isCreateEntityFile")))
        {
            isCreateEntityFile = bool.Parse(element.GetAttribute("isCreateEntityFile"));
        }

        if (element.HasAttribute("isCreateDBModelFile") && !string.IsNullOrEmpty(element.GetAttribute("isCreateDBModelFile")))
        {
            isCreateDBModelFile = bool.Parse(element.GetAttribute("isCreateDBModelFile"));
        }

        if (element.HasAttribute("isCreateByteFile") && !string.IsNullOrEmpty(element.GetAttribute("isCreateByteFile")))
        {
            isCreateByteFile = bool.Parse(element.GetAttribute("isCreateByteFile"));
        }

        return(this);
    }
 public CtfEntryInfo(int _id, XmlElement entry)
 {
     id = _id;
     name = entry.Attributes["name"].Value;
     type = entry.Attributes["type"].Value;
     minOperator = entry.GetAttribute("minOperator");
     if (entry.HasAttribute("minFlag"))
     {
         minFlag = Convert.ToInt32(entry.GetAttribute("minFlag"));
     }
     else
     {
         minFlag = -1;
     }
     maxOperator = entry.GetAttribute("maxOperator");
     if (entry.HasAttribute("maxFlag"))
     {
         maxFlag = Convert.ToInt32(entry.GetAttribute("maxFlag"));
     }
     else
     {
         maxFlag = -1;
     }
     if (entry.HasAttribute("refID"))
     {
         refID = Convert.ToInt32(entry.GetAttribute("refID"));
     }
     else
     {
         refID = -1;
     }
     if (entry.HasAttribute("linkID"))
     {
         linkID = Convert.ToInt32(entry.GetAttribute("linkID"));
     }
     else
     {
         linkID = -1;
     }
     readOnly = entry.HasAttribute("readOnly") ? true : false;
     List<string> rVals = new List<string>();
     foreach (XmlElement param in entry)
     {
         if (param.GetAttribute("name") == "description")
         {
             description = param.InnerText;
         }
         else if (param.GetAttribute("name") == "restrictedValue")
         {
             rVals.Add(param.InnerText);
         }
     }
     restrictedValues = rVals.ToArray();
 }
 private static void ProcessPermissionsElement(XmlElement permissionsElement, IDictionary<string, SystemPermissions> permissonsDict)
 {
     SystemPermissions permissions;
     if (permissionsElement.HasAttribute(NameAttr) && permissionsElement.HasAttribute(PermissionsAttr) &&
         BrightstarServiceConfigurationSectionHandler.TryGetSystemPermissionsAttributeValue(permissionsElement,
                                                                                           PermissionsAttr,
                                                                                           out permissions))
     {
         permissonsDict[permissionsElement.GetAttribute(NameAttr)] = permissions;
     }
 }
Beispiel #29
0
		public ReturnValue (XmlElement elem) 
		{
			if (elem != null) {
				is_null_term = elem.HasAttribute ("null_term_array");
				is_array = elem.HasAttribute ("array");
				elements_owned = elem.GetAttribute ("elements_owned") == "true";
				owned = elem.GetAttribute ("owned") == "true";
				ctype = elem.GetAttribute("type");
				element_ctype = elem.GetAttribute ("element_type");
			}
		}
Beispiel #30
0
        public static void ProcessAttachEndPoint(IBlockWeb containerWeb, IConnector connector, XmlElement endpointElement, string blockId)
        {
            string endpointKey = null;

            if (endpointElement.Name == "valueEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    object value = ObjectReader.ReadObject(endpointElement);
                    endpointKey = connector.AttachEndPoint(value);
                }
            }
            else if (endpointElement.Name == "serviceEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    string endpointBlockId = endpointElement.GetAttribute("blockId");
                    string endpointService = endpointElement.GetAttribute("service");

                    if (!endpointElement.HasAttribute("blockId")) endpointBlockId = blockId;

                    endpointKey = connector.AttachEndPoint(endpointBlockId, endpointService);
                }
            }
            else if (endpointElement.Name == "connectorEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    string endpointBlockId = endpointElement.GetAttribute("blockId");
                    string endPointConnectorKey = endpointElement.GetAttribute("connectorKey");

                    if (!endpointElement.HasAttribute("blockId")) endpointBlockId = blockId;

                    endpointKey = connector.AttachConnectorEndPoint(endpointBlockId, endPointConnectorKey);
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            //now process fixed args
            XmlElement fixedArgsElement = endpointElement.SelectSingleNode("fixedArgs") as XmlElement;

            if (fixedArgsElement != null && endpointKey != null)
            {
                List<Connector.EndPoint> fixedArgs = EndPointExtractor.ExtractArguments(fixedArgsElement, containerWeb);

                foreach (Connector.EndPoint endPoint in fixedArgs)
                {
                    connector.AddFixedArg(endpointKey, endPoint);
                }
            }
        }
 public ParsingContext(XmlElement node, ParsingContext parent)
 {
     _parent = parent;
     if (node.HasAttribute("templateNs"))
         TemplateNamespace = node.GetAttribute("templateNs");
     if (node.HasAttribute("ns"))
         Namespace = node.GetAttribute("ns");
     if (node.HasAttribute("dictionary"))
         Dictionary = node.GetAttribute("dictionary");
     if (node.HasAttribute("name"))
         _name = new QName(node.GetAttribute("name"), Namespace);
 }
 public void Initialise(XmlElement xml)
 {
     if (xml.HasAttribute("Size"))
         size = xml.GetAttribute("Size");
     if (xml.HasAttribute("MaxLength"))
         maxLength = xml.GetAttribute("MaxLength");
     if (xml.HasAttribute("FieldName"))
         fieldName = xml.GetAttribute("FieldName");
     if (xml.HasAttribute("Class"))
         classname = xml.GetAttribute("Class");
     if (xml.HasAttribute("Style"))
         style = xml.GetAttribute("Style");
 }
Beispiel #33
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));
            }
        }
        /// <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 = "";
            }
        }
Beispiel #35
0
        public bool CheckProject(string guid)
        {
            bool   ret     = true;
            string metaXML = projectBaseFolder + Path.DirectorySeparatorChar + guid + Path.DirectorySeparatorChar + "meta.xml";

            if (!File.Exists(metaXML))
            {
                ret = false;
            }
            XmlDocument meta_xml = new XmlDocument();

            meta_xml.Load(metaXML);
            System.Xml.XmlElement root = meta_xml.DocumentElement;
            if (root.HasAttribute("xmlns"))
            {
                if (root.GetAttribute("xmlns") != "http://heilbit.de/doTimeTable/meta.xsd")
                {
                    ret = false;
                }
            }
            else
            {
                ret = false;
            }
            //more checks?

            return(ret);
        }
Beispiel #36
0
        public override bool FromXML(System.Xml.XmlElement myElement)
        {
            if (myElement != null)
            {
                this.Type = StringCommon.GetTypeByName(myElement.GetAttribute("type"));
                //value应该在设置Attributes之前
                string level = myElement.GetAttribute("level");
                if (level.Length == 0)
                {
                    this.Level = null;
                }
                else
                {
                    this.Level = (Level?)Enum.Parse(typeof(Level), level);
                }
                this.Attributes.FromXML(myElement);
                this.Name = myElement.GetAttribute("name");

                if (myElement.HasAttribute("print"))
                {
                    this.Print = bool.Parse(myElement.GetAttribute("print"));
                }

                this.Text = myElement.InnerText;
                return(true);
            }
            return(false);
        }
        /// <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);
            }
        }
Beispiel #38
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));
            }
        }
        /// <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>
        /// <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));
            }
        }
        /// <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.URI = xmlElement.GetAttribute("URI");
            }

            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));
        }
Beispiel #42
0
    public GradeStudentEntity XmlToObject(System.Xml.XmlElement element)
    {
        if (element.HasAttribute("id") && !string.IsNullOrEmpty(element.GetAttribute("id")))
        {
            id = element.GetAttribute("id");
        }

        if (element.HasAttribute("grade") && !string.IsNullOrEmpty(element.GetAttribute("grade")))
        {
            grade = element.GetAttribute("grade");
        }

        if (element.HasAttribute("studentId") && !string.IsNullOrEmpty(element.GetAttribute("studentId")))
        {
            studentId = element.GetAttribute("studentId");
        }

        if (element.HasAttribute("studentName") && !string.IsNullOrEmpty(element.GetAttribute("studentName")))
        {
            studentName = element.GetAttribute("studentName");
        }

        return(this);
    }
Beispiel #43
0
    public comptConfigEntity XmlToObject(System.Xml.XmlElement element)
    {
        if (element.HasAttribute("id") && !string.IsNullOrEmpty(element.GetAttribute("id")))
        {
            id = element.GetAttribute("id");
        }

        if (element.HasAttribute("english") && !string.IsNullOrEmpty(element.GetAttribute("english")))
        {
            english = element.GetAttribute("english");
        }

        if (element.HasAttribute("china") && !string.IsNullOrEmpty(element.GetAttribute("china")))
        {
            china = element.GetAttribute("china");
        }

        if (element.HasAttribute("type") && !string.IsNullOrEmpty(element.GetAttribute("type")))
        {
            type = element.GetAttribute("type");
        }

        return(this);
    }
    public SettingConfigEntity XmlToObject(System.Xml.XmlElement element)
    {
        if (element.HasAttribute("id") && !string.IsNullOrEmpty(element.GetAttribute("id")))
        {
            id = element.GetAttribute("id");
        }

        if (element.HasAttribute("key") && !string.IsNullOrEmpty(element.GetAttribute("key")))
        {
            key = element.GetAttribute("key");
        }

        if (element.HasAttribute("value") && !string.IsNullOrEmpty(element.GetAttribute("value")))
        {
            value = element.GetAttribute("value");
        }

        if (element.HasAttribute("desc") && !string.IsNullOrEmpty(element.GetAttribute("desc")))
        {
            desc = element.GetAttribute("desc");
        }

        return(this);
    }
 /// <summary>
 /// Load state from an XML element
 /// </summary>
 /// <param name="xmlElement">XML element containing new state</param>
 public void LoadXml(System.Xml.XmlElement xmlElement)
 {
     if (xmlElement == null)
     {
         throw new ArgumentNullException("xmlElement");
     }
     if (xmlElement.HasAttribute("Algorithm"))
     {
         this.algorithm = xmlElement.GetAttribute("Algorithm");
     }
     else
     {
         this.algorithm = "";
     }
 }
        /// <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;
            }
        }
        /// <summary>
        /// Load state from an XML element
        /// </summary>
        /// <param name="xmlElement">XML element containing new state</param>
        public void LoadXml(System.Xml.XmlElement xmlElement)
        {
            if (xmlElement == null)
            {
                throw new ArgumentNullException(nameof(xmlElement));
            }

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

            this.pkiData = Convert.FromBase64String(xmlElement.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)
        {
            if (xmlElement == null)
            {
                throw new ArgumentNullException("xmlElement");
            }

            if (xmlElement.HasAttribute("Qualifier"))
            {
                this.qualifier = (KnownQualifier)KnownQualifier.Parse(typeof(KnownQualifier), xmlElement.GetAttribute("Qualifier"), true);
            }
            else
            {
                this.qualifier = KnownQualifier.Uninitalized;
            }

            this.identifierUri = xmlElement.InnerText;
        }
Beispiel #49
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));
            }
        }
Beispiel #50
0
        private static Chunk ReadStep(Xml.XmlElement element)
        {
            Chunk newChunk = new Chunk(element.Name);

            foreach (Xml.XmlNode n in element.ChildNodes)
            {
                if (n is Xml.XmlElement)
                {
                    Xml.XmlElement subElement = (Xml.XmlElement)n;

                    if (subElement.Name == "Value")
                    {
                        if (subElement.HasAttribute("Name"))
                        {
                            string valueName = subElement.GetAttribute("Name");
                            newChunk.Values[valueName] = GetElementText(subElement);
                        }
                    }
                }
            }

            // Recurse.
            foreach (Xml.XmlNode n in element.ChildNodes)
            {
                if (n is Xml.XmlElement)
                {
                    Xml.XmlElement subElement = (Xml.XmlElement)n;

                    if (subElement.Name != "Value")
                    {
                        newChunk.Add(ReadStep(subElement));
                    }
                }
            }

            return(newChunk);
        }
Beispiel #51
0
    public QuestionEntity XmlToObject(System.Xml.XmlElement element)
    {
        if (element.HasAttribute("id") && !string.IsNullOrEmpty(element.GetAttribute("id")))
        {
            id = element.GetAttribute("id");
        }

        if (element.HasAttribute("answer") && !string.IsNullOrEmpty(element.GetAttribute("answer")))
        {
            answer = element.GetAttribute("answer");
        }

        if (element.HasAttribute("A") && !string.IsNullOrEmpty(element.GetAttribute("A")))
        {
            A = element.GetAttribute("A");
        }

        if (element.HasAttribute("B") && !string.IsNullOrEmpty(element.GetAttribute("B")))
        {
            B = element.GetAttribute("B");
        }

        if (element.HasAttribute("C") && !string.IsNullOrEmpty(element.GetAttribute("C")))
        {
            C = element.GetAttribute("C");
        }

        if (element.HasAttribute("D") && !string.IsNullOrEmpty(element.GetAttribute("D")))
        {
            D = element.GetAttribute("D");
        }

        if (element.HasAttribute("question") && !string.IsNullOrEmpty(element.GetAttribute("question")))
        {
            question = element.GetAttribute("question");
        }

        return(this);
    }
Beispiel #52
0
        /// <summary>
        /// 是否包含该属性
        /// </summary>
        public static bool HasAttribute(this XmlNode node, string attributeName)
        {
            XmlElement element = node as XmlElement;

            return(element.HasAttribute(attributeName));
        }
Beispiel #53
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;
            IEnumerator                 enumerator;
            XmlElement                  iterationXmlElement;
            EncapsulatedX509Certificate newEncapsulatedX509Certificate;
            OtherCertificate            newOtherCertificate;

            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);

            this.encapsulatedX509CertificateCollection.Clear();
            this.otherCertificateCollection.Clear();

            xmlNodeList = xmlElement.SelectNodes("xades:EncapsulatedX509Certificate", xmlNamespaceManager);
            enumerator  = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newEncapsulatedX509Certificate = new EncapsulatedX509Certificate();
                        newEncapsulatedX509Certificate.LoadXml(iterationXmlElement);
                        this.encapsulatedX509CertificateCollection.Add(newEncapsulatedX509Certificate);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }

            xmlNodeList = xmlElement.SelectNodes("xades:OtherCertificate", xmlNamespaceManager);
            enumerator  = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newOtherCertificate = new OtherCertificate();
                        newOtherCertificate.LoadXml(iterationXmlElement);
                        this.otherCertificateCollection.Add(newOtherCertificate);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
        /// <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;
            IEnumerator         enumerator;
            XmlElement          iterationXmlElement;
            HashDataInfo        newHashDataInfo;

            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("xades", XadesSignedXml.XadesNamespaceUri);

            this.hashDataInfoCollection.Clear();
            xmlNodeList = xmlElement.SelectNodes("xades:HashDataInfo", xmlNamespaceManager);
            enumerator  = xmlNodeList.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    iterationXmlElement = enumerator.Current as XmlElement;
                    if (iterationXmlElement != null)
                    {
                        newHashDataInfo = new HashDataInfo();
                        newHashDataInfo.LoadXml(iterationXmlElement);
                        this.hashDataInfoCollection.Add(newHashDataInfo);
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable disposable)
                {
                    disposable.Dispose();
                }
            }

            xmlNodeList = xmlElement.SelectNodes("xades:EncapsulatedTimeStamp", xmlNamespaceManager);

            if (xmlNodeList.Count != 0)
            {
                this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
                this.encapsulatedTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
                this.xmlTimeStamp = null;
            }
            else
            {
                XmlNode nodeEncapsulatedTimeStamp = null;

                foreach (XmlNode node in xmlElement.ChildNodes)
                {
                    if (node.Name == "EncapsulatedTimeStamp")
                    {
                        nodeEncapsulatedTimeStamp = node;
                        break;
                    }
                }

                if (nodeEncapsulatedTimeStamp != null)
                {
                    this.encapsulatedTimeStamp = new EncapsulatedPKIData("EncapsulatedTimeStamp");
                    this.encapsulatedTimeStamp.LoadXml((XmlElement)nodeEncapsulatedTimeStamp);
                    this.xmlTimeStamp = null;
                }
                else
                {
                    xmlNodeList = xmlElement.SelectNodes("xades:XMLTimeStamp", xmlNamespaceManager);
                    if (xmlNodeList.Count != 0)
                    {
                        this.xmlTimeStamp = new XMLTimeStamp();
                        this.xmlTimeStamp.LoadXml((XmlElement)xmlNodeList.Item(0));
                        this.encapsulatedTimeStamp = null;
                    }
                    else
                    {
                        throw new CryptographicException("EncapsulatedTimeStamp or XMLTimeStamp element is missing");
                    }
                }
            }
        }