System.Runtime.Serialization.DataContractSerializer.IsStartObject C# (CSharp) Method

IsStartObject() public method

public IsStartObject ( System reader ) : bool
reader System
return bool
        public override bool IsStartObject(System.Xml.XmlDictionaryReader reader) { throw null; }
        public override bool IsStartObject(System.Xml.XmlReader reader) { throw null; }

Usage Example

コード例 #1
0
ファイル: Xml.cs プロジェクト: cquinlan/USBT
        public static IOperation[] loadOpsFile(string path, Type[] knownTypes)
        {
            //Open the operation file.
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read);

            //Read in the file and store each item to a list. Type is "anyType" but this will be cast to IOperation.
            DataContractSerializer serializer = new DataContractSerializer(typeof(IOperation), knownTypes);
            XmlReader read = XmlReader.Create(fs);
            read.ReadToDescendant("z:anyType");

            List<IOperation> opList = new List<IOperation>();

            //Blurahegle
            while (serializer.IsStartObject(read))
            {
                //Check each type when deserializing. Make sure we can cast it.
                try
                {
                    opList.Add((IOperation)serializer.ReadObject(read));
                }
                catch (Exception e)
                {
                    MessageBox.Show("Invalid operation type encountered. Please ensure all required libraies are installed \n" + e.Message, "An error has occured",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    fs.Close();
                    return null;
                }
            }
            fs.Close();
            return opList.ToArray();
            //Done
        }
All Usage Examples Of System.Runtime.Serialization.DataContractSerializer::IsStartObject