当前位置: 首页>>代码示例>>C#>>正文


C# XmlReader.IsStartElement方法代码示例

本文整理汇总了C#中XmlReader.IsStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.IsStartElement方法的具体用法?C# XmlReader.IsStartElement怎么用?C# XmlReader.IsStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlReader的用法示例。


在下文中一共展示了XmlReader.IsStartElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _NextToken

    private bool _NextToken(XmlReader reader)
    {
        while (!reader.EOF && reader.Read() && !reader.IsStartElement())
            ;

        return !reader.EOF;
    }
开发者ID:devorchik,项目名称:plcopy,代码行数:7,代码来源:plist.cs

示例2: ReadObject

    private object ReadObject(string classname, List<object> list, XmlReader reader)
    {
        object res = null;
        int count = 0;
        string attribute = null;
        int fieldcount;

            if (classname == null)
            {
                reader.Read();
                if (reader.IsStartElement())
                    classname = XmlConvert.DecodeName(reader.Name);
                count = Convert.ToInt32(reader["count"]);
            }

            if (classname == null)
                return null;
        fieldcount = Convert.ToInt32(reader["fieldcount"]);
        attribute = reader["reference"];
        reader.Read();
        if (reader.IsStartElement() || reader.Value != null)
        {
            Type objtype = Type.GetType(classname);

            if (attribute != null)
            {
                //  string attribute = reader["reference"];
                if (attribute != null)
                {
                    res = list[Convert.ToInt32(attribute)];
                }
            }
            else if (objtype.IsPrimitive)
            {
                res = (object)objtype.InvokeMember("Parse",
                      BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public,
                      null, null, new object[] { XmlConvert.DecodeName(reader.Value.Trim()) });
                list.Add(res);
            }
            else if (objtype.Equals(typeof(string)))
            {
                res = XmlConvert.DecodeName(reader.Value.Trim());
            }
            else
            {
                if (objtype.IsArray)
                {
                    //count = Convert.ToInt32(reader["count"]);
                    int index = 0;
                    res = Activator.CreateInstance(objtype, count);
                    list.Add(res);
                    while (index < count)
                    {
                        //reader.Read();
                        while(!reader.IsStartElement())
                            reader.Read();
                        string s = reader.Name;
                        ((System.Array)res).SetValue(ReadObject(s, list, reader), index++);
                    }
                }
                else
                {
                    res = Activator.CreateInstance(objtype);
                    list.Add(res);
                    int index = 0;
                    //count = Convert.ToInt32(reader["count"]);
                    while (index < fieldcount)
                    {
                        while (!reader.IsStartElement())
                            reader.Read();
                        index++;
                        string fieldname = reader.Name;
                        object fieldobject = ReadObject(null, list, reader);
                        FieldInfo fiendinf = objtype.GetField(fieldname, BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                        if (fiendinf != null)
                            fiendinf.SetValue(res, fieldobject);
                    }

                }
            }
        } 
     return res;
    }
开发者ID:InglouriousBasterd667,项目名称:ISP-labs,代码行数:83,代码来源:XMLSerialize.cs

示例3: _GetToken

 private bool _GetToken(XmlReader reader, out string strToken)
 {
     bool fResult = reader.IsStartElement();
     strToken = fResult ? reader.LocalName : null;
     return fResult;
 }
开发者ID:devorchik,项目名称:plcopy,代码行数:6,代码来源:plist.cs

示例4: ExtractClientConfig

 /* Method to extract the client specific parts of the config file */
 private bool ExtractClientConfig(XmlReader reader)
 {
     try {
         while (reader.Read()) {
             if (reader.IsStartElement()) {
                 if (reader.Name == "client") {
                     client_config.Add(new ClientConfig());
                     while (reader.MoveToNextAttribute()) {
                         if (reader.Name == "name")
                             client_config.Last().name.Add("short_name", reader.Value);
                         else if (reader.Name == "lname")
                             client_config.Last().name.Add("full_name", reader.Value);
                         else
                             Console.WriteLine("Unknown report configuration attribute: " + reader.Name);
                     }
                 }
                 else if (reader.Name == "project")
                     client_config.Last().projects.Add(reader.ReadString());
                 else if (reader.Name == "priority")
                     client_config.Last().priority.Add(reader.ReadString());
                 else if (reader.Name == "email")
                     client_config.Last().email.Add(reader.ReadString());
             }
         }
         return true;
     }
     catch (Exception ex) {
         Console.WriteLine("Exception when extracting client data from config XML: " + ex.Message);
         return false;
     }
 }
开发者ID:philliprowe,项目名称:InternalTools,代码行数:32,代码来源:JiraXMLConfigParse.cs


注:本文中的XmlReader.IsStartElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。