예제 #1
0
파일: SimpleMap.cs 프로젝트: zhh007/MyGen
        private static void LoadFromXml(SimpleMapCollection simpleMaps, string filename)
        {
            try
            {
                FileInfo     fileInfo = new FileInfo(filename);
                SimpleMap    map;
                XmlAttribute attr;
                if (fileInfo.Exists)
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.Load(filename);
                    foreach (XmlNode parentnode in xmldoc.ChildNodes)
                    {
                        if (parentnode.HasChildNodes)
                        {
                            foreach (XmlNode node in parentnode.ChildNodes)
                            {
                                if (node.Name.ToLower() == "map")
                                {
                                    map = new SimpleMap();

                                    attr = node.Attributes["source"];
                                    if (attr != null)
                                    {
                                        map.Source = attr.Value;
                                    }

                                    attr = node.Attributes["target"];
                                    if (attr != null)
                                    {
                                        map.Target = attr.Value;
                                    }

                                    attr = node.Attributes["isregexp"];
                                    if (attr != null)
                                    {
                                        map.isRegExp = Convert.ToBoolean(attr.Value);
                                    }

                                    simpleMaps.Add(map);
                                }
                            }
                        }
                    }
                }
            }
            catch            // (Exception ex)
            {
            }
        }
		public int Add(SimpleMap map)
		{
			return simpleMaps.Add(map);
		}
예제 #3
0
		private static void LoadFromXml(SimpleMapCollection simpleMaps, string filename) 
		{
			try 
			{
				FileInfo fileInfo = new FileInfo(filename);
				SimpleMap map;
				XmlAttribute attr;
				if (fileInfo.Exists) 
				{
					XmlDocument xmldoc = new XmlDocument();
					xmldoc.Load(filename);
					foreach (XmlNode parentnode in xmldoc.ChildNodes) 
					{
						if (parentnode.HasChildNodes) 
						{
							foreach (XmlNode node in parentnode.ChildNodes) 
							{
								if (node.Name.ToLower() == "map") 
								{
									map = new SimpleMap();

									attr = node.Attributes["source"];
									if (attr != null) 
									{
										map.Source = attr.Value;
									}

									attr = node.Attributes["target"];
									if (attr != null) 
									{
										map.Target = attr.Value;
									}
									
									attr = node.Attributes["isregexp"];
									if (attr != null) 
									{
										map.isRegExp = Convert.ToBoolean(attr.Value);
									}

									simpleMaps.Add(map);
								}
							}
						}
					}
				}
			}
			catch// (Exception ex)
			{
			}
		}
예제 #4
0
 public int Add(SimpleMap map)
 {
     return(simpleMaps.Add(map));
 }