MoveToAttribute() public abstract method

public abstract MoveToAttribute ( string name ) : bool
name string
return bool
Exemplo n.º 1
0
 public void ReadLog(XmlReader reader)
 {
     while (reader.Read() && reader.NodeType != XmlNodeType.EndElement)
     {
         Dictionary<string, string> attributes = new Dictionary<string, string>();
         if (reader.Name == "ME")
         {
             if (reader.HasAttributes)
             {
                 for (int i = 0; i < reader.AttributeCount; i++)
                 {
                     reader.MoveToAttribute(i);
                     attributes.Add(reader.Name, reader.Value);
                 }
             }
             MouseEvent e = new MouseEvent(attributes);
             Evnts.AddLast(e);
             //do shit here
         }
         else if (reader.Name == "Clickthrough")
         {
                 if (reader.HasAttributes)
                 {
                     for (int i = 0; i < reader.AttributeCount; i++)
                     {
                         reader.MoveToAttribute(i);
                         attributes.Add(reader.Name, reader.Value);
                     }
                 }
             Clickthrough c = new Clickthrough(attributes);
             c.ReadLog(reader);
             Evnts.AddLast(c);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Recupera os dados do xml.
 /// </summary>
 /// <param name="reader"></param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("name"))
     {
         Name = reader.ReadContentAsString();
         reader.MoveToElement();
     }
     if (reader.MoveToAttribute("address"))
     {
         Address = reader.ReadContentAsString();
         reader.MoveToElement();
     }
     reader.ReadStartElement();
     while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         if (reader.Name == "Configuration")
         {
             if (!reader.IsEmptyElement)
             {
                 var config = new ServiceAddressNode();
                 config.ReadXml(reader);
                 Configuration = config;
             }
             else
             {
                 reader.Skip();
             }
         }
         else
         {
             reader.Skip();
         }
     }
     reader.ReadEndElement();
 }
Exemplo n.º 3
0
    public void ReadXml(System.Xml.XmlReader reader)
    {
        reader.MoveToAttribute("Width");
        Width = reader.ReadContentAsInt();
        reader.MoveToAttribute("Height");
        Height = reader.ReadContentAsInt();
        reader.MoveToElement();

        SetupWorld(Width, Height);

        while (reader.Read())
        {
            switch (reader.Name)
            {
            case "Tiles":
                ReadXML_Tiles(reader);
                break;

            case "StaticObjects":
                ReadXml_StaticObjects(reader);
                break;

            case "Characters":
                ReadXml_Characters(reader);
                break;
            }
        }
    }
        private static void read_microservices_client_details(XmlReader readerXml, MicroservicesClient_Configuration config, string SystemBaseUrl)
        {
            // Just step through the subtree of this
            while (readerXml.Read())
            {
                if (readerXml.NodeType == XmlNodeType.Element)
                {
                    switch (readerXml.Name.ToLower())
                    {
                        case "add":
                            string key = String.Empty;
                            string url = String.Empty;
                            string protocol = "JSON";
                            if (readerXml.MoveToAttribute("Key"))
                                key = readerXml.Value;
                            if (readerXml.MoveToAttribute("URL"))
                                url = readerXml.Value.Replace("[BASEURL]", SystemBaseUrl);
                            if (readerXml.MoveToAttribute("Protocol"))
                                protocol = readerXml.Value;

                            if (( !String.IsNullOrEmpty(key)) && ( !String.IsNullOrEmpty(url)))
                                config.Add_Endpoint(key, url, protocol);
                            break;
                    }
                }
            }
        }
Exemplo n.º 5
0
  public Mass(Model model, XmlReader xml) : base(model,xml) {//throws Exception {
    //super(model, xml);
      //foreach(XmlAttribute attribute in xml.Attributes)
      //{
          //string key = attribute.Name;
      if (xml.MoveToAttribute("VX".ToLower()))
      {
        velocityX = double.Parse(xml.ReadContentAsString());
      }
      if (xml.MoveToAttribute("VY".ToLower()))
      {
          velocityY = double.Parse(xml.ReadContentAsString());
      }



      //}
    //Enumeration enum = xml.enumerateAttributeNames();
    //while (enum.hasMoreElements()) {
    //  String key = enum.nextElement().toString();
    //  if (key.equals("VX")) {
    //    velocityX = xml.getDoubleAttribute(key);
    //  }
    //  if (key.equals("VY")) {
    //    velocityY = xml.getDoubleAttribute(key);
    //  }
    //}
  }
Exemplo n.º 6
0
        private static void ReadAscii(XmlReader reader, string name, uint offset, bool visible, IPluginVisitor visitor, uint pluginLine)
        {
            int size = 0;

            if (reader.MoveToAttribute("size") || reader.MoveToAttribute("length"))
                size = ParseInt(reader.Value);

            visitor.VisitAscii(name, offset, visible, size, pluginLine);
        }
Exemplo n.º 7
0
 public MarkerModel(XmlReader reader, Set set)
 {
     reader.MoveToAttribute("name");
     name = reader.Value;
     reader.MoveToAttribute("id");
     id = new Guid(reader.Value);
     reader.Read();  // <marker />
     this.set = set;
 }
Exemplo n.º 8
0
        private static ClassEntry BuildClassEntry(XmlReader xmlReader, string fileName, string assemblyName, string @namespace, Assembly assembly)
		{
			xmlReader.MoveToAttribute("name");
			string className = xmlReader.Value;

			string extends = null;
			if (xmlReader.MoveToAttribute("extends"))
			{
				extends = xmlReader.Value;
			}

			return new ClassEntry(extends, className, assemblyName, @namespace, fileName, assembly);
		}
Exemplo n.º 9
0
		public void Load (XmlReader x)
		{
			if(x.MoveToAttribute("ShowParameters"))
				ShowFuncParams = Boolean.Parse(x.ReadContentAsString());
			if(x.MoveToAttribute("ShowVariables"))
				ShowFuncVariables = Boolean.Parse(x.ReadContentAsString());
			if(x.MoveToAttribute("ShowTypes"))
				ShowBaseTypes = Boolean.Parse(x.ReadContentAsString());
			if(x.MoveToAttribute("GrayOutNonPublic"))
				GrayOutNonPublic = Boolean.Parse(x.ReadContentAsString());
			if(x.MoveToAttribute("ExpansionBehaviour"))
				Enum.TryParse(x.ReadContentAsString(),out ExpansionBehaviour);
		}
		protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
		{
			reader.MoveToAttribute("name");
			Name = reader.Value;

			ConnectionStringName = reader.MoveToAttribute("connectionStringName") ? reader.Value : null;

			while (reader.Read())
			{
				if (reader.NodeType == XmlNodeType.EndElement) break;
				if (reader.NodeType == XmlNodeType.CDATA) Select = reader.Value;
			}
		}
Exemplo n.º 11
0
 /// <summary>
 /// Recupera os dados do xml.
 /// </summary>
 /// <param name="reader"></param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("name"))
     {
         Name = reader.ReadContentAsString();
         reader.MoveToElement();
     }
     if (reader.MoveToAttribute("value"))
     {
         Value = reader.ReadContentAsString();
         reader.MoveToElement();
     }
     reader.Skip();
 }
Exemplo n.º 12
0
 public static Firewall load(XmlReader reader)
 {
     while (reader.Name != "firewall")
         reader.Read();
     var complexity = 0;
     string solution = null;
     var additionalTime = 0.0f;
     if (reader.MoveToAttribute("complexity"))
         complexity = reader.ReadContentAsInt();
     if (reader.MoveToAttribute("solution"))
         solution = reader.ReadContentAsString();
     if (reader.MoveToAttribute("additionalDelay"))
         additionalTime = reader.ReadContentAsFloat();
     return new Firewall(complexity, solution, additionalTime);
 }
Exemplo n.º 13
0
 public static UserDetail loadUserDetail(XmlReader reader)
 {
     reader.MoveToAttribute("name");
     var user = reader.ReadContentAsString();
     reader.MoveToAttribute("pass");
     var password = reader.ReadContentAsString();
     reader.MoveToAttribute("type");
     var accountType = (byte) reader.ReadContentAsInt();
     reader.MoveToAttribute("known");
     var flag = reader.ReadContentAsString().ToLower().Equals("true");
     return new UserDetail(user, password, accountType)
     {
         known = flag
     };
 }
Exemplo n.º 14
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.MoveToAttribute("Disabled"))
            {
                Disabled = reader.Value == "1";
            }

            reader.ReadStartElement("RuleList");
            while (reader.IsStartElement())
            {
                IXmlSerializable r = null;
                switch (reader.Name)
                {
                case "RegExpRule":
                    r = new RegExpRule();
                    break;

                case "HostRule":
                    r = new HostRule();
                    break;

                case "PathRule":
                    r = new PathRule();
                    break;
                }
                if (r != null)
                {
                    r.ReadXml(reader.ReadSubtree());
                    this.Add((IRule)r);
                }
                reader.ReadEndElement();
            }
        }
Exemplo n.º 15
0
        public override void ReadXml(XmlReader reader)
        {
            if (reader.MoveToAttribute("Description"))
                Description = reader.Value;

            base.ReadXml(reader);
        }
Exemplo n.º 16
0
        public void Restore(XmlReader reader)
        {
            int count = reader.AttributeCount;
            for (int i = 0; i < count; ++i)
            {
                reader.MoveToAttribute(i);
                switch (reader.Name)
                {
                    case "top":
                        Top = reader.ReadContentAsDouble();
                        break;

                    case "left":
                        Left = reader.ReadContentAsDouble();
                        break;

                    case "width":
                        Width = reader.ReadContentAsDouble();
                        break;

                    case "height":
                        Height = reader.ReadContentAsDouble();
                        break;

                    case "state":
                        State = (WindowState) Enum.Parse(typeof (WindowState), reader.Value);
                        break;
                }
            }
        }
Exemplo n.º 17
0
 internal void ConfigureEmulator(XmlReader reader)
 {
     while (true)
     {
         reader.Read();
         if (reader.IsStartElement())
         {
             switch (reader.Name.ToLower())
             {
                 case "import":
                     reader.MoveToAttribute( "filename" );
                     _emulator.ApplyConfig(reader.Value);
                     break;
                 case "types":
                     ProcessTypes( reader );
                     break;
                 case "emulatorcomponents":
                     ProcessEmulatorComponents( reader );
                     break;
                 default:
                     throw new Exception( "Unknown element: " + reader.Name );
             }
         }
         else
         {
             break;
         }
     }
 }
Exemplo n.º 18
0
    public void ReadXml(XmlReader reader)
    {
      if (!reader.MoveToAttribute("State"))
        throw new ArgumentException("State attribute not present");

      InitFromString(reader.Value);
    }
        public static Quaternion ParseQuaternion(XmlReader r)
        {
            float w = 0;
            float x = 0;
            float y = 0;
            float z = 0;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {

                    case "w":
                        w = float.Parse(r.Value);
                        break;
                    case "x":
                        x = float.Parse(r.Value);
                        break;
                    case "y":
                        y = float.Parse(r.Value);
                        break;
                    case "z":
                        z = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            return new Quaternion(w, x, y, z);
        }
        public static ColorEx ParseColorAttributes(XmlReader r)
        {
            float R = 0;
            float G = 0;
            float B = 0;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "R":
                        R = float.Parse(r.Value);
                        break;
                    case "G":
                        G = float.Parse(r.Value);
                        break;
                    case "B":
                        B = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            r.MoveToElement(); //Moves the reader back to the element node.
            if (R > 1 || G > 1 || B > 1)
            {
                R = R / 255;
                G = G / 255;
                B = B / 255;
            }
            return new ColorEx(R, G, B);
        }
Exemplo n.º 21
0
    void IXmlSerializable.ReadXml(XmlReader reader)
    {
      try
      {
        // First read attributes, then check for empty start element
        if (!reader.MoveToAttribute("Id"))
          throw new ArgumentException("Id attribute not present");
        _id = new Guid(reader.Value);
        if (reader.IsEmptyElement)
          return;
      }
      finally
      {
        reader.ReadStartElement();
      }

      _additionalProperties = reader.DeserializeXml<Dictionary>();
      _timeshiftContexes = reader.DeserializeXml<List<ITimeshiftContext>>();


      while (reader.NodeType != XmlNodeType.EndElement)
      {
        MediaItemAspect mia = MediaItemAspect.Deserialize(reader);
        _aspects[mia.Metadata.AspectId] = mia;
      }
      reader.ReadEndElement(); // MI
    }
Exemplo n.º 22
0
		public static IFeed GetFeed(Uri url, XmlReader reader) {
			reader.MoveToContent();
			string language = string.Empty;
			FeedType feedType;
			string namespaceUri = reader.NamespaceURI;
			if(reader.LocalName.Equals("RDF") &&
				reader.NamespaceURI.Equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#")) {
				feedType = FeedType.Rdf;
				reader.Read();
				reader.MoveToContent();
			} else if(reader.LocalName.Equals("rss")) {
				feedType = FeedType.Rss;

				do {
					reader.Read();
					reader.MoveToContent();
				} while(!reader.LocalName.Equals("channel") && !reader.LocalName.Equals("rss"));
			} else if(reader.NamespaceURI.Equals("http://purl.org/atom/ns#") && reader.LocalName.Equals("feed")) {
				if(reader.MoveToAttribute("version") && reader.Value.Equals("0.3")) {
					feedType = FeedType.Atom;
					language = reader.XmlLang;
					reader.MoveToElement();
				} else {
					throw new ApplicationException(string.Format("Unsupported Atom Version {0}", reader.Value));
				}
			} else if(reader.NamespaceURI.Equals("http://www.w3.org/2005/Atom") && reader.LocalName.Equals("feed")) {
				feedType = FeedType.Atom;
				language = reader.XmlLang;
			} else {
				throw new ApplicationException("Unknown Xml Dialect");
			}
			return PopulateFeed(url, reader, namespaceUri, feedType, language);
		}
Exemplo n.º 23
0
 /// <summary>Initializes a new instance of OpmlOutline</summary>
 public OpmlOutline(System.Xml.XmlReader xmlTextReader) : this()
 {
     if (!xmlTextReader.HasAttributes)
     {
         return;
     }
     // get attributes
     System.Reflection.PropertyInfo propertyInfo = null;
     for (int i = 0; i < xmlTextReader.AttributeCount; i++)
     {
         xmlTextReader.MoveToAttribute(i);
         // try to find some common used alias names for attributes
         string attributeName = xmlTextReader.Name;
         if (attributeName.IndexOf("url") != -1)
         {
             attributeName = "xmlUrl";
         }
         if (attributeName.IndexOf("title") != -1)
         {
             attributeName = "text";
         }
         // find related property by name
         propertyInfo = GetType().GetProperty(attributeName, System.Reflection.BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
         if (propertyInfo != null)
         {
             propertyInfo.SetValue(this, System.ComponentModel.TypeDescriptor.GetConverter(propertyInfo.PropertyType).ConvertFromString(xmlTextReader.ReadInnerXml().Trim()), null);
         }
     }
 }
Exemplo n.º 24
0
        /// <summary>
        ///     Parses an XML plugin, calling the corresponding method in
        ///     IPluginVisitor for each XML tag it encounters.
        /// </summary>
        /// <param name="reader">The XmlReader to read the plugin XML from.</param>
        /// <param name="visitor">The IPluginVisitor to call for each XML tag.</param>
        public static void LoadPlugin(XmlReader reader, IPluginVisitor visitor)
        {
            if (!reader.ReadToNextSibling("plugin"))
                throw new ArgumentException("The XML file is missing a <plugin> tag.");

            int baseSize = 0;
            if (reader.MoveToAttribute("headersize") || reader.MoveToAttribute("baseSize"))
                baseSize = ParseInt(reader.Value);

            if (visitor.EnterPlugin(baseSize))
            {
                var loader = new UniversalPluginLoader();
                loader.ReadElements(reader, true, visitor);
                visitor.LeavePlugin();
            }
        }
Exemplo n.º 25
0
 public bool IsSatisfiedBy(IIdentity parameter)
 =>
 _reader.HasAttributes &&
 _reader.MoveToAttribute(parameter.Name,
                         parameter.Identifier == _defaultNamespace
                                                         ? string.Empty
                                                         : parameter.Identifier);
        public HeightfieldTerrainGenerator(XmlReader r)
        {
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);
                switch (r.Name)
                {
                    case "Type":
                        string type = r.Value;
                        Debug.Assert(type == "HeightfieldMosaic");
                        break;
                    case "MosaicName":
                        heightfieldName = r.Value;
                        break;
                    case "PreloadRadius":
                        preloadRadius = int.Parse(r.Value);
                        break;
                    case "OutsideHeight":
                        outsideHeight = float.Parse(r.Value);
                        break;
                }
            }
            r.MoveToElement();
            if (!r.IsEmptyElement)
            {
                do
                {
                    r.Read();
                } while (r.NodeType != XmlNodeType.EndElement);
            }

            Mosaic = new HeightfieldMosaic(heightfieldName, preloadRadius, outsideHeight);
            Mosaic.MosaicModificationStateChanged += Mosaic_OnMosaicModificationStateChanged;
            Mosaic.MosaicChanged += Mosaic_OnMosaicChanged;
        }
Exemplo n.º 27
0
        /// <summary>
        /// reader ��g�p���� XML �h�L�������g�Ƃ��č\����͂��܂��B
        /// </summary>
        /// <param name="reader">XML �h�L�������g�̃��[�h�C�e���[�^�B</param>
        /// <returns>��͌�� XmlDocument �I�u�W�F�N�g�B</returns>
        public XmlDocument parse(XmlReader reader)
        {
            if ( reader == null )
                throw new ArgumentNullException( "reader" );

            XmlNode current;
            XmlAttribute attribute;

            Stack<XmlNode> node_stack = new Stack<XmlNode>();

            node_stack.Push( this.document_ );
            while ( reader.Read() ) {
                if ( reader.NodeType == XmlNodeType.Whitespace )
                    continue;

                switch ( reader.NodeType ) {
                    case XmlNodeType.XmlDeclaration:
                        if ( reader.HasAttributes ) {
                            this.document_.AppendChild( this.document_.CreateXmlDeclaration( reader.GetAttribute( "version" ),
                                                                                             reader.GetAttribute( "encoding" ),
                                                                                             "no"
                                                                                             )
                                                        );
                        }
                        break;

                    case XmlNodeType.Element:
                        node_stack.Push( this.document_.CreateElement( reader.Name ) );

                        if ( reader.HasAttributes ) {
                            current = node_stack.Peek();

                            for ( int i = 0; i < reader.AttributeCount; ++i ) {
                                reader.MoveToAttribute( i );

                                attribute = this.document_.CreateAttribute( reader.Name );
                                attribute.Value = reader.Value;

                                current.Attributes.Append( attribute );
                            }
                        }

                        if ( reader.IsEmptyElement ) {
                            foldElement( node_stack );
                        }
                        break;

                    case XmlNodeType.Text:
                        current = node_stack.Peek();
                        current.AppendChild( this.document_.CreateTextNode( reader.Value ) );
                        break;

                    case XmlNodeType.EndElement:
                        foldElement( node_stack );
                        break;
                }
            }
            return this.document_;
        }
Exemplo n.º 28
0
		public override bool Matches(XmlReader reader, IXmlNamespaceResolver resolver)
		{
			bool preCondition = false;

			switch (mode)
			{
				case MatchMode.StartElement:
					preCondition = reader.NodeType == XmlNodeType.Element;
					break;
				case MatchMode.StartElementClosed:
					if (reader.NodeType == XmlNodeType.Attribute)
					{
						string name = reader.LocalName;
						string ns = reader.NamespaceURI;
						if (reader.MoveToNextAttribute())
						{
							// If we moved, we didn't match and 
							// we restore the cursor.
							reader.MoveToAttribute(name, ns);
							preCondition = false;
						}
						else
						{
							// We need to evaluate the element name/ns match from 
							// the base here, moving to the element first
							reader.MoveToElement();
							preCondition = base.Matches(reader, resolver);
							// Restore cursor always.
							reader.MoveToAttribute(name, ns);
							return preCondition;
						}
					}
					else if (reader.NodeType == XmlNodeType.Element)
					{
						// Matches the same as StartElement if there are no attributes
						preCondition = !reader.HasAttributes;
					}
					break;
				case MatchMode.EndElement:
					preCondition = reader.NodeType == XmlNodeType.EndElement;
					break;
			}

			return preCondition && base.Matches(reader, resolver);
		}
Exemplo n.º 29
0
 private static void ReadAttributes(ZXmlNode Node, XmlReader rd)
 {
     for (int i = 0; i < rd.AttributeCount; i++)
     {
         rd.MoveToAttribute(i);
         Node.Attributes.Add(rd.Name, rd.Value);
     }
     rd.MoveToElement();
 }
    public void AddAttr(XmlReader reader)
    {
      for (int i = 0; i < reader.AttributeCount; ++i)
      {
        reader.MoveToAttribute(i);

        _attributes.Add(new KeyValuePair<string, string>(reader.Name, reader.Value));
      }
    }
Exemplo n.º 31
0
		public void Parse (XmlReader reader)
		{
			while (reader.Read ()) {
				if (reader.NodeType == XmlNodeType.Element) {
					var attrs = Enumerable.Range (0, reader.AttributeCount).ToDictionary (i => {
						reader.MoveToAttribute (i);
						return reader.Name;
					}, i => {
						reader.MoveToAttribute (i);
						return reader.Value;
					});
					reader.MoveToElement ();
					startElement (reader.LocalName, reader.Name, attrs);
				} else if (reader.NodeType == XmlNodeType.EndElement) {
					endElement (reader.LocalName, reader.Name);
				}
			}
		}
Exemplo n.º 32
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("Title"))
     {
         mTitle = reader.Value;
     }
     else
     {
         throw new Exception();
     }
     if (reader.MoveToAttribute("Path"))
     {
         mPath = reader.Value;
     }
     else
     {
         throw new Exception();
     }
 }
        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
        {
            reader.MoveToAttribute("name");
            Name = reader.Value;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement) break;
            }
        }
Exemplo n.º 34
0
        public object DeserializeObject(XmlReader reader)
        {
            if (reader.MoveToAttribute(_attributeName))
            {
                var value = _parseValue(reader.Value);
                reader.MoveToElement();
                return value;
            }

            return null;
        }
Exemplo n.º 35
0
Arquivo: Rope.cs Projeto: samgoat/NC
 public void ReadXml(XmlReader reader)
 {
     reader.MoveToAttribute("span");
       if (reader.NodeType == XmlNodeType.Attribute)
     Span = (int)reader.ReadContentAsDouble();
       reader.MoveToElement();
       Text = reader.ReadElementContentAsString();
       double length;
       if (double.TryParse(Text, out length))
     Length = length;
 }
Exemplo n.º 36
0
        Record ReadRow(System.Xml.XmlReader rdr)
        {
            var record = _file.CreateRecord();

            for (Int32 i = 0; i < rdr.AttributeCount; i++)
            {
                rdr.MoveToAttribute(i);
                ReadValue(record, rdr.Name, rdr.Value);
            }
            return(record);
        }
Exemplo n.º 37
0
        /// <summary>
        /// Generates a collection from its XML representation.
        /// </summary>
        /// <param name="reader">System.Xml.XmlReader</param>
        public void ReadXml(XmlReader reader)
        {
            this.Clear();
              if (reader.ReadToDescendant("SerializableStringDictionary"))
              {
              if (reader.ReadToDescendant("DictionaryEntry"))
              {
                  do
                  {
                      reader.MoveToAttribute("Key");
                      string key = reader.ReadContentAsString();
                      reader.MoveToAttribute("Value");
                      string value = reader.ReadContentAsString();

                      this.Add(key, value);

                  } while (reader.ReadToNextSibling("DictionaryEntry"));
              }
              }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostOpportunityUpdate"/> class.
        /// </summary>
        /// <param name="unsecure">Contains public (unsecure) configuration information.</param>
        /// <param name="secure">Contains non-public (secure) configuration information.
        /// When using Microsoft Dynamics CRM for Outlook with Offline Access,
        /// the secure string is not passed to a plug-in that executes while the client is offline.</param>
        public PostOpportunityUpdate(string unsecure, string secure)
            : base(typeof(PostOpportunityUpdate))
        {
            base.RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(40, "Update", "opportunity", new Action <LocalPluginContext>(ExecutePostOpportunityUpdate)));

            // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination.
            // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change.


            try
            {
                // TODO: Implement your custom configuration handling.
                using (System.Xml.XmlReader reader = XmlReader.Create(new StringReader(unsecure)))
                {
                    // Load fields from settings
                    reader.MoveToContent();

                    reader.MoveToAttribute("APIKey");
                    NexmoApiKey = Convert.ToString(reader.GetAttribute("APIKey"));

                    reader.MoveToAttribute("APISecret");
                    NexmoApiSecret = Convert.ToString(reader.GetAttribute("APISecret"));

                    //reader.MoveToAttribute("FromUser");
                    //FromUser = Convert.ToString(reader.GetAttribute("FromUser"));

                    reader.MoveToAttribute("EnableNexmoSMS");
                    EnableSMS = Convert.ToString(reader.GetAttribute("EnableNexmoSMS"));

                    reader.MoveToAttribute("Threshold");
                    if (!string.IsNullOrEmpty(reader.GetAttribute("Threshold")))
                    {
                        Threshold = Convert.ToDouble(reader.GetAttribute("Threshold"));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(string.Format("An error occured in ExecutePostOpportunityCreate plugin: {0} {1} {2}", ex.ToString(), ex.InnerException, ex.StackTrace));
            }
        }
Exemplo n.º 39
0
        public static Settings LoadFromXml( XmlReader xmlReader )
        {
            Settings settings = new Settings();
            xmlReader.MoveToAttribute( 0 );
            do
            {
                switch ( xmlReader.Name.ToLower() )
                {
                    case "paddingwidth":
                        {
                            int pw = 0;
                            if ( !int.TryParse( xmlReader.Value, out pw ) )
                                throw new Exception( "Failed to parse paddingwidth" );
                            settings.Padding.Width = pw;
                        }
                        break;
                    case "paddingheight":
                        {
                            int ph = 0;
                            if ( !int.TryParse( xmlReader.Value, out ph ) )
                                throw new Exception( "Failed to parse paddingheight" );
                            settings.Padding.Height = ph;
                        }
                        break;
                    case "outputwidth":
                        {
                            int ow = 0;
                            if ( !int.TryParse( xmlReader.Value, out ow ) )
                                throw new Exception( "Failed to parse outputwidth" );
                            settings.OutputBitmapSize.Width = ow;
                        }
                        break;
                    case "outputheight":
                        {
                            int oh = 0;
                            if ( !int.TryParse( xmlReader.Value, out oh ) )
                                throw new Exception( "Failed to parse outputheight" );
                            settings.OutputBitmapSize.Height = oh;
                        }
                        break;
                    case "allowrotation":
                        {
                            bool ar = false;
                            if ( !bool.TryParse( xmlReader.Value, out ar ) )
                                throw new Exception( "Failed to parse allowrotation" );
                            settings.AllowRotation = ar;
                        }
                        break;
                }
            } while ( xmlReader.MoveToNextAttribute() );

            return settings;
        }
Exemplo n.º 40
0
        private bool DeterminVisible(System.Xml.XmlReader reader)
        {
            bool result = true;

            if (reader.MoveToAttribute("visible"))
            {
                if (reader.HasValue)
                {
                    result = reader.ReadContentAsBoolean();
                }
            }

            return(result);
        }
Exemplo n.º 41
0
 public void DoSearch(string[] parts, ArrayList result, System.Xml.XmlReader reader, bool securityTrimmingEnabled)
 {
     if (reader.ReadToFollowing("category", ns) && reader.MoveToAttribute("name") && reader.Value == "Root" && reader.MoveToElement())
     {
         int i = 1;
         if (i < parts.Length)
         {
             ReadSubElements(reader, parts, i, result, securityTrimmingEnabled);
         }
         else
         {
             ReadSubItems(reader, result, securityTrimmingEnabled);
         }
     }
 }
Exemplo n.º 42
0
        public bool LoadFrom(DCompilerConfiguration cmpCfg, System.Xml.XmlReader x)
        {
            if (x.ReadState == ReadState.Initial)
            {
                x.Read();
            }

            if (x.MoveToAttribute("Target") &&
                !Enum.TryParse(x.ReadContentAsString(), true, out TargetType))
            {
                return(false);
            }

            while (x.Read())
            {
                switch (x.LocalName)
                {
                // For backward compatibility keep on parsing this
                case "CompilerCommand":
                    cmpCfg.SourceCompilerCommand = x.ReadString();
                    break;

                case "LinkerCommand":
                    Linker = x.ReadString();
                    break;

                case "Patterns":                 // ditto
                    var s = x.ReadSubtree();
                    cmpCfg.ArgumentPatterns.ReadFrom(s);
                    s.Close();
                    break;

                case "DebugArgs":
                    s = x.ReadSubtree();
                    DebugArguments.ReadFrom(cmpCfg, s);
                    s.Close();
                    break;

                case "ReleaseArgs":
                    s = x.ReadSubtree();
                    ReleaseArguments.ReadFrom(cmpCfg, s);
                    s.Close();
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 43
0
        public void LoadFrom(System.Xml.XmlReader x)
        {
            if (x.ReadState == ReadState.Initial)
            {
                x.Read();
            }

            if (x.MoveToAttribute("Target"))
            {
                TargetType = (DCompileTarget)Enum.Parse(typeof(DCompileTarget), x.ReadContentAsString());
            }

            while (x.Read())
            {
                switch (x.LocalName)
                {
                case "CompilerCommand":
                    Compiler = x.ReadString();
                    break;

                case "LinkerCommand":
                    Linker = x.ReadString();
                    break;

                case "ObjectLinkPattern":
                    ObjectFileLinkPattern = x.ReadString();
                    break;

                case "IncludePathPattern":
                    IncludePathPattern = x.ReadString();
                    break;

                case "DebugArgs":
                    var s = x.ReadSubtree();
                    DebugArguments.ReadFrom(s);
                    s.Close();
                    break;

                case "ReleaseArgs":
                    var s2 = x.ReadSubtree();
                    ReleaseArguments.ReadFrom(s2);
                    s2.Close();
                    break;
                }
            }
        }
Exemplo n.º 44
0
 /// <summary>
 /// Recupera os dados contidos no xml informado.
 /// </summary>
 /// <param name="reader"></param>
 public void ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("name"))
     {
         Name = reader.ReadContentAsString();
     }
     reader.MoveToElement();
     reader.ReadStartElement();
     while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         if (reader.Name == "Parameters")
         {
             if (!reader.IsEmptyElement)
             {
                 ((System.Xml.Serialization.IXmlSerializable)Parameters).ReadXml(reader);
             }
             else
             {
                 reader.Skip();
             }
         }
         else if (reader.Name == "Children")
         {
             if (!reader.IsEmptyElement)
             {
                 ReadChildrenXml(reader);
             }
             else
             {
                 reader.Skip();
             }
         }
         else
         {
             reader.Skip();
         }
     }
     reader.ReadEndElement();
 }
Exemplo n.º 45
0
        private void ReadSubElements(System.Xml.XmlReader reader, string[] parts, int i, ArrayList result, bool securityTrimmingEnabled)
        {
            string nextName = parts[i];
            int    depth    = reader.Depth + 1;

            while (reader.Read())
            {
                if (reader.Depth == depth)
                {
                    switch (reader.NodeType)
                    {
                    case System.Xml.XmlNodeType.Attribute:
                    case System.Xml.XmlNodeType.CDATA:
                    case System.Xml.XmlNodeType.Comment:
                    case System.Xml.XmlNodeType.Whitespace:
                        continue;

                    case System.Xml.XmlNodeType.EndElement:
                        break;

                    case System.Xml.XmlNodeType.Element:
                        break;

                    default:
                        throw new System.Xml.XmlException("读取到错误的节点");
                    }

                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        bool hit = false;
                        if (reader.MoveToAttribute("name"))
                        {
                            hit = reader.Value == nextName;

                            if (hit)
                            {
                                hit = DeterminVisible(reader);
                            }
                            reader.MoveToElement();
                        }

                        if (hit)
                        {
                            i++;
                            if (i < parts.Length)
                            {
                                ReadSubElements(reader, parts, i, result, securityTrimmingEnabled);
                            }
                            else
                            {
                                ReadSubItems(reader, result, securityTrimmingEnabled);
                            }

                            break;
                        }
                        else
                        {
                            //reader.Skip();
                        }
                    }
                }
                else if (reader.Depth > depth)
                {
                    reader.Skip();
                }
                else
                {
                    break;
                }
            }
        }
Exemplo n.º 46
0
        public virtual void WriteNode(XmlReader reader, bool defattr)
        {
            if (reader == null)
            {
                throw new ArgumentException();
            }

            if (reader.ReadState == ReadState.Initial)
            {
                reader.Read();
                do
                {
                    WriteNode(reader, defattr);
                } while (!reader.EOF);
                return;
            }

            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
#if false
                WriteAttributes(reader, defattr);
                reader.MoveToElement();
#else
                // Well, I found that MS.NET took this way, since
                // there was a error-prone SgmlReader that fails
                // MoveToNextAttribute().
                if (reader.HasAttributes)
                {
                    for (int i = 0; i < reader.AttributeCount; i++)
                    {
                        reader.MoveToAttribute(i);
                        WriteAttribute(reader, defattr);
                    }
                    reader.MoveToElement();
                }
#endif
                if (reader.IsEmptyElement)
                {
                    WriteEndElement();
                }
                else
                {
                    int depth = reader.Depth;
                    reader.Read();
                    if (reader.NodeType != XmlNodeType.EndElement)
                    {
                        do
                        {
                            WriteNode(reader, defattr);
                        } while (depth < reader.Depth);
                    }
                    WriteFullEndElement();
                }
                break;

            // In case of XmlAttribute, don't proceed reader, and it will never be written.
            case XmlNodeType.Attribute:
                return;

            case XmlNodeType.Text:
                WriteString(reader.Value);
                break;

            case XmlNodeType.CDATA:
                WriteCData(reader.Value);
                break;

            case XmlNodeType.EntityReference:
                WriteEntityRef(reader.Name);
                break;

            case XmlNodeType.XmlDeclaration:
            // LAMESPEC: It means that XmlWriter implementation _must not_ check
            // whether PI name is "xml" (it is XML error) or not.
            case XmlNodeType.ProcessingInstruction:
                WriteProcessingInstruction(reader.Name, reader.Value);
                break;

            case XmlNodeType.Comment:
                WriteComment(reader.Value);
                break;

            case XmlNodeType.DocumentType:
                WriteDocType(reader.Name,
                             reader ["PUBLIC"], reader ["SYSTEM"], reader.Value);
                break;

            case XmlNodeType.SignificantWhitespace:
                goto case XmlNodeType.Whitespace;

            case XmlNodeType.Whitespace:
                WriteWhitespace(reader.Value);
                break;

            case XmlNodeType.EndElement:
                WriteFullEndElement();
                break;

            case XmlNodeType.EndEntity:
                break;

            case XmlNodeType.None:
                break;                  // Do nothing, nor reporting errors.

            default:
                throw new XmlException("Unexpected node " + reader.Name + " of type " + reader.NodeType);
            }
            reader.Read();
        }
Exemplo n.º 47
0
        private CategoryDirectory ReadResult(System.Xml.XmlReader reader, bool securityTrimmingEnabled)
        {
            CategoryDirectory result = null;

            if (reader.NodeType == System.Xml.XmlNodeType.Element)
            {
                if (reader.LocalName == "category" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryDirectory();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }

                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }

                        reader.MoveToElement();
                    }
                }
                else if (reader.LocalName == "item" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryLink();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }
                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }
                        if (reader.MoveToAttribute("group"))
                        {
                            ((CategoryLink)result).Group = reader.ReadContentAsInt();
                        }
                        if (reader.MoveToAttribute("href"))
                        {
                            ((CategoryLink)result).Url = reader.Value;
                        }
                        if (reader.MoveToAttribute("role"))
                        {
                            ((CategoryLink)result).Role = reader.Value;
                        }
                        if (reader.MoveToAttribute("feature"))
                        {
                            ((CategoryLink)result).Feature = reader.Value;
                        }
                    }
                }
                else if (reader.LocalName == "group" && reader.NamespaceURI == ns)
                {
                    if (DeterminVisible(reader) && DeterminSecure(securityTrimmingEnabled, reader))
                    {
                        result = new CategoryGroup();
                        if (reader.MoveToAttribute("name"))
                        {
                            result.Name = reader.Value;
                        }
                        if (reader.MoveToAttribute("title"))
                        {
                            result.Title = reader.Value;
                        }
                        reader.MoveToElement();
                        ArrayList list = new ArrayList();

                        ReadSubItems(reader, list, securityTrimmingEnabled);
                        ((CategoryGroup)result).Categories = (CategoryDirectory[])list.ToArray(typeof(CategoryDirectory));
                    }
                    else
                    {
                        var level = reader.Depth;
                        while (reader.Read() && reader.Depth > level)
                        {
                            reader.Skip(); //跳过其任何子节点
                        }
                    }
                }
            }

            reader.MoveToElement();

            return(result);
        }
Exemplo n.º 48
0
 public override bool MoveToAttribute(string name)
 {
     CheckAsync();
     return(_coreReader.MoveToAttribute(name));
 }