Inheritance: XmlNamedNodeMap, ICollection
	// Constructor.
	internal XmlElement(XmlNode parent, NameCache.NameInfo name)
			: base(parent)
			{
				this.name = name;
				this.attributes = null;
				this.isEmpty = true;
			}
Example #2
0
        public static void CreateFromXML(Scene scene, XmlAttributeCollection attributes)
        {
            int playerNumber = attributes.Int("player", 0);

            Session playerSession;
            Color color = Color.None;

            if (playerNumber == 0)
            {
                playerSession = Global.PlayerOneSession;
                color = Color.White;
            }
            else if (playerNumber == 1)
            {
                playerSession = Global.PlayerTwoSession;
                color = Color.Yellow;
            }
            else if (playerNumber == 2)
            {
                playerSession = Global.PlayerThreeSession;
                color = Color.Blue;
            }
            else
            {
                playerSession = Global.PlayerFourSession;
                color = Color.Grey;
            }

            Bomberman player = new Bomberman(playerSession, color);

            player.SetPosition(attributes.Int("x", 0), attributes.Int("y", 0));

            scene.Add(player);
        }
Example #3
0
		public bool AreEqualAttribs (XmlAttributeCollection expected, XmlAttributeCollection actual)
		{
			if (expected.Count != actual.Count)
				return false;
			for (int i=0; i<expected.Count; i++) {
				if ((flags & Flags.IgnoreAttribOrder) != 0) {
					string ln = expected[i].LocalName;
					string ns = expected[i].NamespaceURI;
					string val = expected[i].Value;
					_expected = ns+":"+ln+"="+val;
					XmlAttribute atr2 = actual[ln, ns];
					_actual = atr2 == null ? "<<missing>>" : ns + ":" + ln + "=" + atr2.Value;
					if (atr2 == null || atr2.Value.Trim().ToLower() != val.Trim().ToLower())
						return false;
				} else {
					if (expected [i].LocalName != actual [i].LocalName)
						return false;
					if (expected [i].NamespaceURI != actual [i].NamespaceURI)
						return false;
					if (expected [i].Value.Trim().ToLower() != actual [i].Value.Trim().ToLower())
						return false;
				}
			}
			return true;
		}
Example #4
0
        internal static void SetProperties(Object instance, XmlAttributeCollection attrs) {
            // This is called from both XSD and XDR schemas. 
            // Do we realy need it in XSD ???
            for (int i = 0; i < attrs.Count; i++) {
                if (attrs[i].NamespaceURI == Keywords.MSDNS) {
                    string name  = attrs[i].LocalName;
                    string value = attrs[i].Value;

                    if (name == "DefaultValue" || name == "RemotingFormat")
                        continue;
// Webdata 97925, skipp expressions, we will handle them after SetProperties (in xdrschema)
                    if (name == "Expression" &&  instance is DataColumn)
                        continue;

                    PropertyDescriptor pd = TypeDescriptor.GetProperties(instance)[name];
                    if (pd != null) {
                        // Standard property
                        Type type = pd.PropertyType;

                        TypeConverter converter = XMLSchema.GetConverter(type);
                        object propValue;
                        if (converter.CanConvertFrom(typeof(string))) {
                            propValue = converter.ConvertFromString(value);
                        }else if (type == typeof(Type)) {
                            propValue = DataStorage.GetType(value);
                        }else if (type == typeof(CultureInfo)) {
                            propValue = new CultureInfo(value);
                        }else {
                            throw ExceptionBuilder.CannotConvert(value,type.FullName);
                        }
                        pd.SetValue(instance, propValue);
                    }
                }
            }
        }// SetProperties
Example #5
0
 public LinkBehavior(XmlAttributeCollection collection)
     : base(collection)
 {
     fileNode = null;
     contextNode = null;
     typeNode = null;
 }
Example #6
0
 public GatewayProvider(XmlAttributeCollection attributes)
 {
     if (attributes == null)
     {
         throw new ArgumentNullException("attributes");
     }
     this.name = attributes["name"].Value.ToLower();
     this.requestType = attributes["requestType"].Value;
     this.notifyType = attributes["notifyType"].Value;
     this.displayName = attributes["displayName"].Value;
     string[] strArray = attributes["supportedCurrency"].Value.Split(new char[] { ',' });
     this.supportedCurrencys = new List<string>();
     foreach (string str in strArray)
     {
         this.supportedCurrencys.Add(str);
     }
     this.providerAttributes = new NameValueCollection();
     foreach (XmlAttribute attribute in attributes)
     {
         if ((((attribute.Name != "name") && (attribute.Name != "displayName")) && ((attribute.Name != "requestType") && (attribute.Name != "notifyType"))) && (attribute.Name != "supportedCurrency"))
         {
             this.providerAttributes.Add(attribute.Name, attribute.Value);
         }
     }
 }
Example #7
0
        protected virtual void AddPagePropertiesToAudioNode(TreeNode audioWrapperNode, XmlNode pageTargetNode)
        {
            TextMedia textMedia = audioWrapperNode.Presentation.MediaFactory.CreateTextMedia();

            textMedia.Text = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(pageTargetNode, true, "text", pageTargetNode.NamespaceURI).InnerText;
            ChannelsProperty cProp = audioWrapperNode.Presentation.PropertyFactory.CreateChannelsProperty();

            cProp.SetMedia(audioWrapperNode.Presentation.ChannelsManager.GetOrCreateTextChannel(), textMedia);
            audioWrapperNode.AddProperty(cProp);
            System.Xml.XmlAttributeCollection pageAttributes = pageTargetNode.Attributes;
            if (pageAttributes != null)
            {
                XmlProperty xmlProp = audioWrapperNode.GetXmlProperty();
                xmlProp.SetQName("pagenum", "");
                string nsUri = audioWrapperNode.GetXmlNamespaceUri();
                foreach (System.Xml.XmlAttribute attr in pageAttributes)
                {
                    string uri = "";
                    if (!string.IsNullOrEmpty(attr.NamespaceURI))
                    {
                        if (attr.NamespaceURI != nsUri)
                        {
                            uri = attr.NamespaceURI;
                        }
                    }

                    xmlProp.SetAttribute(attr.Name, uri, attr.Value);
                }
            }
        }
        private static bool IsEqual(XmlAttributeCollection left, XmlAttributeCollection right)
        {
            if (left == null)
            {
                return right == null;
            }

            if (right == null)
            {
                return false;
            }

            if (left.Count != right.Count)
            {
                return false;
            }

            foreach (XmlAttribute attr in left)
            {
                var rightAttrNode = right.GetNamedItem(attr.Name);

                if (rightAttrNode == null)
                {
                    return false;
                }

                if ((rightAttrNode as XmlAttribute).Value != attr.Value)
                {
                    return false;
                }
            }

            return true;
        }
        public override void Setup(System.Xml.XmlAttributeCollection xmlAttributes, BehaviorTree baseTree)
        {
            base.Setup(xmlAttributes, baseTree);

            m_Animator  = baseTree == null ? null : baseTree.GetComponentInChildren <Animator>();
            m_StateHash = Animator.StringToHash(m_StateName);
        }
Example #10
0
		public static String AttributeValue( XmlAttributeCollection attrs, String name )
		{
			XmlNode n = attrs[name];
			if( n != null )
				return n.Value;
			return null;
		}
Example #11
0
        /// <summary>
        /// Initializes a new instance of the InvokeStep class
        /// </summary>
        /// <param name="attributes">Xml attributes from the BPEL file
        /// when invoking execution of workflow activities</param>
        public InvokeStep(XmlAttributeCollection attributes)
        {
            InvokeContext = new InvokeContextModel();
            // this.type = InvokeType.Unknown;
            foreach (XmlAttribute attrib in attributes)
            {
                switch (attrib.LocalName.ToLower())
                {
                    case "operation":
                        InvokeContext.Operation = attrib.Value;
                        break;
                    case "name":
                        InvokeContext.Name = attrib.Value;
                        StepId = attrib.Value;
                        break;
                    case "partnerlink":
                        InvokeContext.PartnerLink = attrib.Value;
                        break;
                    case "porttype":
                        InvokeContext.PortType = attrib.Value;
                        break;
                    case "inputvariable":
                        InvokeContext.InputVariable = attrib.Value;
                        break;
                    default:
                        break;
                }
            }

        }
Example #12
0
 public Rectangle(XmlAttributeCollection fontAttrs, XmlAttributeCollection rectAttrs)
 {
     this._rectangleAttrs = rectAttrs;
     FontAttributes = fontAttrs;
     
     init();
 }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the OnMessageStep class
        /// </summary>
        /// <param name="attributes">Xml attributes from the BPEL file</param>
        public OnEventStep(XmlAttributeCollection attributes)
        {
            // read attributes
            foreach (XmlAttribute attrib in attributes)
            {
                switch (attrib.LocalName)
                {
                    case "name":
                        StepId = attrib.Value;
                        break;
                    case "operation":
                        switch (attrib.Value)
                        {
                            case "messageTimeout":
                                //  EventType = WorkflowEventType.Timeout;
                                break;
                            case "cancel":
                                // EventType = WorkflowEventType.Cancel;
                                break;
                            default:
                                // var ex = ErrorAndExceptionService.CreateLocutusException(this, "E67.01", null);
                                // throw ex;
                                return;
                        }
                        break;
                    case "variable":
                        if (string.IsNullOrEmpty(attrib.Value))
                        {

                        }
                        EventKey = attrib.Value;
                        break;
                }
            }
        }
Example #14
0
        public PrepareHtmlClass(XmlAttributeCollection attributes, ref Dictionary<String, HtmlClass> liststylesheets, Dictionary<String, HtmlClass> listalreadystylesheets)
        {
            string csstext = string.Empty;
            if (attributes["href"] != null)
            {
                string namefile = attributes["href"].Value;
                if (namefile.StartsWith(@"https:/") || namefile.StartsWith(@"http:/"))
                    csstext = readcssfromnet(namefile);
                else
                {
                    //falta direfenciar si viene desde http, https, o sin dirección(solo el nombre o ruta del archivo)
                }
                if (csstext != string.Empty)
                    if (!liststylesheets.Keys.Contains(namefile))
                    {
                        if (listalreadystylesheets != null)
                            if (listalreadystylesheets.Keys.Contains(namefile))//style sheet has already been read before, no need to read it again
                            {
                                liststylesheets.Add(csstext, listalreadystylesheets[namefile]);
                                return;
                            }

                        HtmlClass css = new CssParser().Parser(csstext);
                        css.IdHtmlClass = namefile;
                        liststylesheets.Add(namefile, css);

                    }
            }
        }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the ReceiveStep class
        /// </summary>
        /// <param name="attributes">Xml attributes from the BPEL file</param>
        public ReceiveStep(XmlAttributeCollection attributes)
        {
            if (attributes != null)
            {
                foreach (XmlAttribute attrib in attributes)
                {
                    if (attrib.LocalName == "name")
                    {
                        StepId = attrib.Value;
                    }
                    else if (attrib.LocalName == "variable")
                    {
                        this.variableName = attrib.Value;
                    }
                }
            }


            if (this.variableName.Equals("subWorkflowComplete", StringComparison.OrdinalIgnoreCase))
            {

            }
            else
            {
                // message name so use variableName in search criteria
                this._messageName = this.variableName;
            }
        }
       /// <summary>
       /// Constructor
       /// </summary>
       /// <param name="fontAttrs"></param>
       /// <param name="elementAttrs"></param>
       /// <param name="vars"></param>
       public DefaultCustomElement(  XmlAttributeCollection fontAttrs, XmlAttributeCollection elementAttrs, List<Variable> vars):base(fontAttrs, elementAttrs, vars)
        {
//        	FontAttributes = fontAttrs;
//           // this._elementAttrs = elementAttrs;
//           base.Attributes = elementAttrs;       
//            base.Vars = vars;
        }
        private TableCell BuildTableCell(XmlNode node, XmlAttributeCollection fontAttrs)
        {
            TableCell tableCell = new TableCell(node.Attributes, fontAttrs);
            BuildTableCellChildElement(tableCell, node, fontAttrs);

            return tableCell;
        }
Example #18
0
        public void SetValue(XmlAttributeCollection inValue)
        {
            constructList.Add(new ItemConstruct());

            // 构造函数
            ItemConstruct construct = new ItemConstruct(new List<string>() { "System.String" });
            construct.Struct.Statements.Add(Line("string[] ss", "inArg0.Split(\'^\')"));

            classer.CustomAttributes.Add(new CodeAttributeDeclaration("ProtoContract"));
            for (int i = 0; i < inValue.Count; i++)
            {
                fieldList.Add(new ItemField(inValue[i].Name, inValue[i].Value, MemberAttributes.Private));

                ItemProperty item = new ItemProperty(inValue[i].Name);
                item.SetGetName();
                item.SetSetName();
                item.SetValueType(inValue[i].Value);
                item.SetModifier(MemberAttributes.Public | MemberAttributes.Final);
                item.SetField("ProtoMember", (i + 1).ToString());
                propertyList.Add(item);

                Type t = Stringer.ToType(inValue[i].Value);

                string right = t == typeof(System.String) ? "ss[" + i + "]" :
                               t == typeof(System.UInt32) ? "uint.Parse(ss[" + i + "])" :
                               t == typeof(System.Single) ? "float.Parse(ss[" + i + "])" : "new " + t.ToString() + "(inValues[" + i + "])";
                construct.Struct.Statements.Add(Line("_" + Stringer.FirstLetterLower(inValue[i].Name), right));
            }
            constructList.Add(construct);
            Create();
        }
Example #19
0
        public CEntityTransition(CMap map, XmlAttributeCollection attributes, XmlNodeList properties)
        {
            m_map = map;

            int l = Convert.ToInt16(attributes["x"].Value);
            int t = Convert.ToInt16(attributes["y"].Value);
            int w = Convert.ToInt16(attributes["width"].Value);
            int h = Convert.ToInt16(attributes["height"].Value);
            m_rect = new Rectangle(l, t, w, h);

            foreach (XmlNode node in properties) {
                switch (node.Attributes["name"].Value) {
                    case "Map":
                        newmap = node.InnerText.Trim();
                        break;
                    case "X":
                        newx = Convert.ToInt16(node.InnerText.Trim());
                        break;
                    case "Y":
                        newy = Convert.ToInt16(node.InnerText.Trim());
                        break;
                }
            }
            map.Entities.AddLast(this);
        }
 internal void UpdatePreservationInfo(XmlAttributeCollection updatedAttributes, XmlFormatter formatter)
 {
     if (updatedAttributes.Count == 0)
     {
         if (this.orderedAttributes.Count <= 0)
             return;
         this.leadingSpaces.Clear();
         this.orderedAttributes.Clear();
     }
     else
     {
         Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
         foreach (string index in this.orderedAttributes)
             dictionary[index] = false;
         foreach (XmlAttribute xmlAttribute in (XmlNamedNodeMap)updatedAttributes)
         {
             if (!dictionary.ContainsKey(xmlAttribute.Name))
                 this.orderedAttributes.Add(xmlAttribute.Name);
             dictionary[xmlAttribute.Name] = true;
         }
         bool flag1 = true;
         string str = (string)null;
         foreach (string key in this.orderedAttributes)
         {
             bool flag2 = dictionary[key];
             if (!flag2)
             {
                 if (this.leadingSpaces.ContainsKey(key))
                 {
                     string space = this.leadingSpaces[key];
                     if (flag1)
                     {
                         if (str == null)
                             str = space;
                     }
                     else if (this.ContainsNewLine(space))
                         str = space;
                     this.leadingSpaces.Remove(key);
                 }
             }
             else if (str != null)
             {
                 if (flag1 || !this.leadingSpaces.ContainsKey(key) || !this.ContainsNewLine(this.leadingSpaces[key]))
                     this.leadingSpaces[key] = str;
                 str = (string)null;
             }
             else if (!this.leadingSpaces.ContainsKey(key))
             {
                 if (flag1)
                     this.leadingSpaces[key] = " ";
                 else if (this.OneAttributePerLine)
                     this.leadingSpaces[key] = this.GetAttributeNewLineString(formatter);
                 else
                     this.EnsureAttributeNewLineString(formatter);
             }
             flag1 = flag1 && !flag2;
         }
     }
 }
		public XmlAttributeTypeDescriptor(XmlAttributeCollection xmlAttributes)
		{
			if (xmlAttributes != null) {
				properties = XmlAttributePropertyDescriptor.GetProperties(xmlAttributes);
			} else {
				properties = new PropertyDescriptorCollection(new XmlAttributePropertyDescriptor[0]);
			}
		}
        public TestSuiteResult(XmlAttributeCollection attributes)
        {
            children = new List<ITestSuiteChildResult>();

            name = attributes["name"].Value;
            filename = attributes["file"].Value;
            line = int.Parse(attributes["line"].Value);
        }
Example #23
0
 public Motherboard(XmlAttributeCollection attributes)
 {
     Brand = attributes[0].InnerXml.ToString();
     Size = attributes[1].InnerXml.ToString();
     CPUSocket = attributes[2].InnerXml.ToString();
     RAMType = attributes[3].InnerXml.ToString();
     RAMSlots = int.Parse(attributes[4].InnerXml);
 }
Example #24
0
		public static string GetAttribute(XmlAttributeCollection attributes, string name)
		{
			XmlNode attr = attributes.GetNamedItem(name);
			if (attr == null)
				return "";

			return attr.Value;
		}
Example #25
0
        public static void CreateFromXML(Scene scene, XmlAttributeCollection attributes)
        {
            Brick brick = new Brick();
            brick.SetPosition(attributes.Int("x", 0), attributes.Int("y", 0));
            brick.Graphic = new Image("Assets/Images/grasses.png", new Rectangle(256, 0, Global.GridSize, Global.GridSize));

            scene.Add(brick);
        }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="attrs"></param>
		public SingleTextBoxStyle( XmlAttributeCollection attrs ){
			
			if(attrs != null){
				if( PDFDraw.Helper.GetAttributeValue( BackgroundColorAttributeConstant , attrs, null ) != null ){
				   	BackgroundColor = PDFDraw.Helper.GetAttributeColor(BackgroundColorAttributeConstant, attrs, "White");
				}           
			}
		}
Example #27
0
 public VideoCard(XmlAttributeCollection attributes)
 {
     Type = attributes[0].InnerXml.ToString();
     Brand = attributes[1].InnerXml.ToString();
     VramInMB = int.Parse(attributes[2].InnerXml);
     SocketType = attributes[3].InnerXml.ToString();
     Cooling = attributes[4].InnerXml.ToString();
 }
Example #28
0
 public Processor(XmlAttributeCollection attributes)
 {
     Name = attributes[0].InnerXml.ToString();
     Brand = attributes[1].InnerXml.ToString();
     Socket = attributes[2].InnerXml.ToString();
     SpeedInGhz = decimal.Parse(attributes[3].InnerXml);
     Cooling = attributes[4].InnerXml.ToString();
 }
		/// <summary>
		/// Gets the property descriptors for the specified attributes.
		/// </summary>
		public static PropertyDescriptorCollection GetProperties(XmlAttributeCollection xmlAttributes)
		{
			List<PropertyDescriptor> properties = new List<PropertyDescriptor>();
			foreach (XmlAttribute xmlAttribute in xmlAttributes) {
				properties.Add(new XmlAttributePropertyDescriptor(xmlAttribute));
			}
			return new PropertyDescriptorCollection(properties.ToArray());
		}
Example #30
0
//		/// <summary>
//		/// Constructor
//		/// </summary>
//		/// <param name="fontAttrs"></param>
//		/// <param name="elementAttrs"></param>
//		protected DrawElement(XmlAttributeCollection fontAttrs, XmlAttributeCollection elementAttrs)
//		{
//			_fontAttributes = fontAttrs;
//			_attributes = elementAttrs;
//		}

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="fontAttrs"></param>
        /// <param name="elementAttrs"></param>
        /// <param name="vars"></param>
        public DrawElement(XmlAttributeCollection fontAttrs, XmlAttributeCollection elementAttrs, List <Variable> vars)
        {
            _fontAttributes = fontAttrs;
            _attributes     = elementAttrs;
            if (vars != null)
            {
                _vars.AddRange(vars);
            }
        }
Example #31
0
        public INode(XmlAttributeCollection collection)
        {
            children = new List<INode>();

            attributes = collection;

            id = GetAttribute( "ptr" );
            name = GetAttribute( "name" );
        }
Example #32
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="text"></param>
		/// <param name="fontAttrs"></param>
		/// <param name="textAttrs"></param>
		public TextBox(string text, XmlAttributeCollection fontAttrs, XmlAttributeCollection textAttrs):base( fontAttrs,  textAttrs, null)
		{
			Text = text;
//			FontAttributes = fontAttrs;
//			Attributes = textAttrs;
//			
			
			init();
		}
Example #33
0
 private void SetCurrentPosition( DocumentXPathNavigator other ) {
     this._curNode = other.CurNode;
     //Debug.Assert( _curNode.NodeType == XmlNodeType.Document || _doc == _curNode.OwnerDocument );
     this._doc = other.Document;
     //this._root = other.Root;
     this._attrInd = other.CurAttrInd;
     this._attrs = other._attrs;
     this._parentOfNS = other.ParentOfNS;
     this.attrXmlNS = other.attrXmlNS; 
 }
Example #34
0
        public void AddList(System.Xml.XmlAttributeCollection attributes)
        {
            if (attributes == null)
            {
                return;
            }

            foreach (XmlAttribute Attribute in attributes)
            {
                this.Add(Attribute);
            }
        }
Example #35
0
        private XmlNode LoadNode(bool skipOverWhitespace)
        {
            XmlReader  r      = this.reader;
            XmlNode    parent = null;
            XmlElement element;

            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    bool fEmptyElement = r.IsEmptyElement;
                    element         = doc.CreateElement(r.Prefix, r.LocalName, r.NamespaceURI);
                    element.IsEmpty = fEmptyElement;

                    if (r.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        do
                        {
                            XmlAttribute attr = LoadAttributeNode();
                            attributes.Append(attr);     // special case for load
                        }while (r.MoveToNextAttribute());
                        r.MoveToElement();
                    }

                    // recursively load all children.
                    if (!fEmptyElement)
                    {
                        if (parent != null)
                        {
                            parent.AppendChildForLoad(element, doc);
                        }
                        parent = element;
                        continue;
                    }
                    else
                    {
                        node = element;
                        break;
                    }

                case XmlNodeType.EndElement:
                    if (parent == null)
                    {
                        return(null);
                    }
                    Debug.Assert(parent.NodeType == XmlNodeType.Element);
                    if (parent.ParentNode == null)
                    {
                        return(parent);
                    }
                    parent = parent.ParentNode;
                    continue;

                case XmlNodeType.EntityReference:
                    node = LoadEntityReferenceNode(false);
                    break;

                case XmlNodeType.EndEntity:
                    Debug.Assert(parent == null);
                    return(null);

                case XmlNodeType.Attribute:
                    node = LoadAttributeNode();
                    break;

                case XmlNodeType.Text:
                    node = doc.CreateTextNode(r.Value);
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = doc.CreateSignificantWhitespace(r.Value);
                    break;

                case XmlNodeType.Whitespace:
                    if (preserveWhitespace)
                    {
                        node = doc.CreateWhitespace(r.Value);
                        break;
                    }
                    else if (parent == null && !skipOverWhitespace)
                    {
                        // if called from LoadEntityReferenceNode, just return null
                        return(null);
                    }
                    else
                    {
                        continue;
                    }

                case XmlNodeType.CDATA:
                    node = doc.CreateCDataSection(r.Value);
                    break;


                case XmlNodeType.XmlDeclaration:
                    node = LoadDeclarationNode();
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node = doc.CreateProcessingInstruction(r.Name, r.Value);
                    break;

                case XmlNodeType.Comment:
                    node = doc.CreateComment(r.Value);
                    break;

                case XmlNodeType.DocumentType:
                    node = LoadDocumentTypeNode();
                    break;

                default:
                    throw UnexpectedNodeType(r.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, doc);
                }
                else
                {
                    return(node);
                }
            }while (r.Read());

            // when the reader ended before full subtree is read, return whatever we have created so far
            if (parent != null)
            {
                while (parent.ParentNode != null)
                {
                    parent = parent.ParentNode;
                }
            }
            return(parent);
        }
        private void ValidateElement()
        {
            nsManager.PushScope();
            XmlElement elementNode = currentNode as XmlElement;

            Debug.Assert(elementNode != null);

            XmlAttributeCollection attributes = elementNode.Attributes;
            XmlAttribute           attr       = null;

            //Find Xsi attributes that need to be processed before validating the element
            string xsiNil  = null;
            string xsiType = null;

            for (int i = 0; i < attributes.Count; i++)
            {
                attr = attributes[i];
                string objectNs   = attr.NamespaceURI;
                string objectName = attr.LocalName;
                Debug.Assert(nameTable.Get(attr.NamespaceURI) != null);
                Debug.Assert(nameTable.Get(attr.LocalName) != null);

                if (Ref.Equal(objectNs, NsXsi))
                {
                    if (Ref.Equal(objectName, XsiType))
                    {
                        xsiType = attr.Value;
                    }
                    else if (Ref.Equal(objectName, XsiNil))
                    {
                        xsiNil = attr.Value;
                    }
                }
                else if (Ref.Equal(objectNs, NsXmlNs))
                {
                    nsManager.AddNamespace(attr.Prefix.Length == 0 ? string.Empty : attr.LocalName, attr.Value);
                }
            }
            validator.ValidateElement(elementNode.LocalName, elementNode.NamespaceURI, schemaInfo, xsiType, xsiNil, null, null);
            ValidateAttributes(elementNode);
            validator.ValidateEndOfAttributes(schemaInfo);

            //If element has children, drill down
            for (XmlNode child = elementNode.FirstChild; child != null; child = child.NextSibling)
            {
                ValidateNode(child);
            }
            //Validate end of element
            currentNode = elementNode; //Reset current Node for validation call back
            validator.ValidateEndElement(schemaInfo);
            //Get XmlName, as memberType / validity might be set now
            if (psviAugmentation)
            {
                elementNode.XmlName = document.AddXmlName(elementNode.Prefix, elementNode.LocalName, elementNode.NamespaceURI, schemaInfo);
                if (schemaInfo.IsDefault)   //the element has a default value
                {
                    XmlText textNode = document.CreateTextNode(schemaInfo.SchemaElement.ElementDecl.DefaultValueRaw);
                    elementNode.AppendChild(textNode);
                }
            }

            nsManager.PopScope(); //Pop current namespace scope
        }
Example #37
0
        internal string GetNamespaceOfPrefixStrict(string prefix)
        {
            XmlDocument doc = Document;

            if (doc != null)
            {
                prefix = doc.NameTable.Get(prefix);
                if (prefix == null)
                {
                    return(null);
                }

                XmlNode node = this;
                while (node != null)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        XmlElement elem = (XmlElement)node;
                        if (elem.HasAttributes)
                        {
                            XmlAttributeCollection attrs = elem.Attributes;
                            if (prefix.Length == 0)
                            {
                                for (int iAttr = 0; iAttr < attrs.Count; iAttr++)
                                {
                                    XmlAttribute attr = attrs[iAttr];
                                    if (attr.Prefix.Length == 0)
                                    {
                                        if (Ref.Equal(attr.LocalName, doc.strXmlns))
                                        {
                                            return(attr.Value); // found xmlns
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int iAttr = 0; iAttr < attrs.Count; iAttr++)
                                {
                                    XmlAttribute attr = attrs[iAttr];
                                    if (Ref.Equal(attr.Prefix, doc.strXmlns))
                                    {
                                        if (Ref.Equal(attr.LocalName, prefix))
                                        {
                                            return(attr.Value); // found xmlns:prefix
                                        }
                                    }
                                    else if (Ref.Equal(attr.Prefix, prefix))
                                    {
                                        return(attr.NamespaceURI); // found prefix:attr
                                    }
                                }
                            }
                        }
                        if (Ref.Equal(node.Prefix, prefix))
                        {
                            return(node.NamespaceURI);
                        }
                        node = node.ParentNode;
                    }
                    else if (node.NodeType == XmlNodeType.Attribute)
                    {
                        node = ((XmlAttribute)node).OwnerElement;
                    }
                    else
                    {
                        node = node.ParentNode;
                    }
                }
                if (Ref.Equal(doc.strXml, prefix))
                { // xmlns:xml
                    return(doc.strReservedXml);
                }
                else if (Ref.Equal(doc.strXmlns, prefix))
                { // xmlns:xmlns
                    return(doc.strReservedXmlns);
                }
            }
            return(null);
        }
Example #38
0
        internal string GetPrefixOfNamespaceStrict(string namespaceURI)
        {
            XmlDocument doc = Document;

            if (doc != null)
            {
                namespaceURI = doc.NameTable.Add(namespaceURI);

                XmlNode node = this;
                while (node != null)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        XmlElement elem = (XmlElement)node;
                        if (elem.HasAttributes)
                        {
                            XmlAttributeCollection attrs = elem.Attributes;
                            for (int iAttr = 0; iAttr < attrs.Count; iAttr++)
                            {
                                XmlAttribute attr = attrs[iAttr];
                                if (attr.Prefix.Length == 0)
                                {
                                    if (Ref.Equal(attr.LocalName, doc.strXmlns))
                                    {
                                        if (attr.Value == namespaceURI)
                                        {
                                            return(string.Empty); // found xmlns="namespaceURI"
                                        }
                                    }
                                }
                                else if (Ref.Equal(attr.Prefix, doc.strXmlns))
                                {
                                    if (attr.Value == namespaceURI)
                                    {
                                        return(attr.LocalName); // found xmlns:prefix="namespaceURI"
                                    }
                                }
                                else if (Ref.Equal(attr.NamespaceURI, namespaceURI))
                                {
                                    return(attr.Prefix); // found prefix:attr
                                                         // with prefix bound to namespaceURI
                                }
                            }
                        }
                        if (Ref.Equal(node.NamespaceURI, namespaceURI))
                        {
                            return(node.Prefix);
                        }
                        node = node.ParentNode;
                    }
                    else if (node.NodeType == XmlNodeType.Attribute)
                    {
                        node = ((XmlAttribute)node).OwnerElement;
                    }
                    else
                    {
                        node = node.ParentNode;
                    }
                }
                if (Ref.Equal(doc.strReservedXml, namespaceURI))
                { // xmlns:xml
                    return(doc.strXml);
                }
                else if (Ref.Equal(doc.strReservedXmlns, namespaceURI))
                { // xmlns:xmlns
                    return(doc.strXmlns);
                }
            }
            return(null);
        }
Example #39
0
        private void RemoveDuplicateNamespace(XmlElement elem, XmlNamespaceManager mgr, bool fCheckElemAttrs)
        {
            //remove the duplicate attributes on current node first
            mgr.PushScope();
            XmlAttributeCollection attrs = elem.Attributes;
            int cAttrs = attrs.Count;

            if (fCheckElemAttrs && cAttrs > 0)
            {
                for (int i = cAttrs - 1; i >= 0; --i)
                {
                    XmlAttribute attr = attrs[i];
                    if (attr.Prefix == XmlDocument.strXmlns)
                    {
                        string nsUri = mgr.LookupNamespace(attr.LocalName);
                        if (nsUri != null)
                        {
                            if (attr.Value == nsUri)
                            {
                                elem.Attributes.RemoveNodeAt(i);
                            }
                        }
                        else
                        {
                            // Add this namespace, so it we will behave corectly when setting "<bar xmlns:p="BAR"><foo2 xmlns:p="FOO"/></bar>" as
                            // InnerXml on this foo elem where foo is like this "<foo xmlns:p="FOO"></foo>"
                            // If do not do this, then we will remove the inner p prefix definition and will let the 1st p to be in scope for
                            // the subsequent InnerXml_set or setting an EntRef inside.
                            mgr.AddNamespace(attr.LocalName, attr.Value);
                        }
                    }
                    else if (attr.Prefix == String.Empty && attr.LocalName == XmlDocument.strXmlns)
                    {
                        string nsUri = mgr.DefaultNamespace;
                        if (nsUri != null)
                        {
                            if (attr.Value == nsUri)
                            {
                                elem.Attributes.RemoveNodeAt(i);
                            }
                        }
                        else
                        {
                            // Add this namespace, so it we will behave corectly when setting "<bar xmlns:p="BAR"><foo2 xmlns:p="FOO"/></bar>" as
                            // InnerXml on this foo elem where foo is like this "<foo xmlns:p="FOO"></foo>"
                            // If do not do this, then we will remove the inner p prefix definition and will let the 1st p to be in scope for
                            // the subsequent InnerXml_set or setting an EntRef inside.
                            mgr.AddNamespace(attr.LocalName, attr.Value);
                        }
                    }
                }
            }
            //now recursively remove the duplicate attributes on the children
            XmlNode child = elem.FirstChild;

            while (child != null)
            {
                XmlElement childElem = child as XmlElement;
                if (childElem != null)
                {
                    RemoveDuplicateNamespace(childElem, mgr, true);
                }
                child = child.NextSibling;
            }
            mgr.PopScope();
        }
        protected AbstractOsmNode(System.Xml.XmlAttributeCollection attributes)
        {
            Tags = new Dictionary <TagKeyEnum, string>();

            this.Id = long.Parse(attributes["id"].Value);
        }
Example #41
0
        // LoadNodeDirect does not use creator functions on XmlDocument. It is used loading nodes that are children of entity nodes,
        // becaouse we do not want to let users extend these (if we would allow this, XmlDataDocument would have a problem, becaouse
        // they do not know that those nodes should not be mapped). It can be also used for an optimized load path when if the
        // XmlDocument is not extended if XmlDocumentType and XmlDeclaration handling is added.
        private XmlNode LoadNodeDirect()
        {
            XmlReader r      = this.reader;
            XmlNode   parent = null;

            do
            {
                XmlNode node = null;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                    bool       fEmptyElement = reader.IsEmptyElement;
                    XmlElement element       = new XmlElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, this.doc);
                    element.IsEmpty = fEmptyElement;

                    if (reader.MoveToFirstAttribute())
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        do
                        {
                            XmlAttribute attr = LoadAttributeNodeDirect();
                            attributes.Append(attr);     // special case for load
                        } while (r.MoveToNextAttribute());
                    }

                    // recursively load all children.
                    if (!fEmptyElement)
                    {
                        parent.AppendChildForLoad(element, doc);
                        parent = element;
                        continue;
                    }
                    else
                    {
                        node = element;
                        break;
                    }

                case XmlNodeType.EndElement:
                    Debug.Assert(parent.NodeType == XmlNodeType.Element);
                    if (parent.ParentNode == null)
                    {
                        return(parent);
                    }
                    parent = parent.ParentNode;
                    continue;

                case XmlNodeType.EntityReference:
                    node = LoadEntityReferenceNode(true);
                    break;

                case XmlNodeType.EndEntity:
                    continue;

                case XmlNodeType.Attribute:
                    node = LoadAttributeNodeDirect();
                    break;

                case XmlNodeType.SignificantWhitespace:
                    node = new XmlSignificantWhitespace(reader.Value, this.doc);
                    break;

                case XmlNodeType.Whitespace:
                    if (preserveWhitespace)
                    {
                        node = new XmlWhitespace(reader.Value, this.doc);
                    }
                    else
                    {
                        continue;
                    }
                    break;

                case XmlNodeType.Text:
                    node = new XmlText(reader.Value, this.doc);
                    break;

                case XmlNodeType.CDATA:
                    node = new XmlCDataSection(reader.Value, this.doc);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    node = new XmlProcessingInstruction(reader.Name, reader.Value, this.doc);
                    break;

                case XmlNodeType.Comment:
                    node = new XmlComment(reader.Value, this.doc);
                    break;

                default:
                    throw UnexpectedNodeType(reader.NodeType);
                }

                Debug.Assert(node != null);
                if (parent != null)
                {
                    parent.AppendChildForLoad(node, doc);
                }
                else
                {
                    return(node);
                }
            }while (r.Read());

            return(null);
        }
Example #42
0
        /// <summary>
        /// 获取设置的样式集合
        /// </summary>
        /// <param name="parentNode"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        private List <MB.XWinLib.DesignEditor.XtraStyleConditionInfo> createStyleInfoList(XmlNode parentNode, object obj)
        {
            List <MB.XWinLib.DesignEditor.XtraStyleConditionInfo> nodeStylesList = new List <MB.XWinLib.DesignEditor.XtraStyleConditionInfo>();

            try
            {
                foreach (XmlNode node in parentNode.ChildNodes)
                {
                    System.Xml.XmlAttributeCollection nodeAttList = node.Attributes;
                    MB.XWinLib.DesignEditor.XtraStyleConditionInfo newStyleInfo = new XtraStyleConditionInfo();
                    Type           t      = newStyleInfo.GetType();
                    PropertyInfo[] pInfos = t.GetProperties();

                    if (newStyleInfo == null)
                    {
                        continue;
                    }
                    foreach (XmlNode xmlNode in node.ChildNodes)
                    {
                        PropertyInfo propValue = t.GetProperty(xmlNode.Name);
                        if (propValue == null)
                        {
                            continue;
                        }
                        if (string.Compare(propValue.PropertyType.Name, "string", true) == 0)
                        {
                            propValue.SetValue(newStyleInfo, xmlNode.InnerText, null);
                        }
                        else if (propValue.PropertyType.IsEnum && string.Compare(xmlNode.Name, "Condition", true) == 0)
                        {
                            propValue.SetValue(newStyleInfo, FromName(xmlNode.InnerText), null);
                        }
                        else
                        {
                            switch (propValue.PropertyType.Name)
                            {
                            case "Color":
                                // 原来的代码保存的是Argb,读取的是FormName.改成一致使用Argb.XiaoMin
                                int argb = 0;
                                if (int.TryParse(xmlNode.InnerText, out argb))
                                {
                                    propValue.SetValue(newStyleInfo, Color.FromArgb(argb), null);
                                }
                                else
                                {
                                    // 写入日志,颜色转换有误
                                }
                                break;

                            case "Font":
                                object f = createFont(xmlNode);
                                if (f != null)
                                {
                                    propValue.SetValue(newStyleInfo, f, null);
                                }
                                break;

                            case "Image":
                                if (!string.IsNullOrEmpty(xmlNode.InnerText))
                                {
                                    propValue.SetValue(newStyleInfo, MB.Util.MyConvert.Instance.Base64StringToImage(xmlNode.InnerText), null);
                                }
                                break;

                            default:
                                if (propValue.PropertyType.IsValueType)
                                {
                                    propValue.SetValue(newStyleInfo, Convert.ChangeType(xmlNode.InnerText, propValue.PropertyType), null);
                                }
                                else
                                {
                                    Debug.Assert(false, "类型" + xmlNode.Name + "还没有处理.");
                                }
                                break;
                            }
                        }
                    }
                    nodeStylesList.Add(newStyleInfo);
                }
            }
            catch (TypeLoadException)
            {
            }
            return(nodeStylesList);
        }