private void InternalInitialize(XmlReader xmlReader, CommandBehavior commandBehavior, IXmlaDataReaderOwner owner) { this.xmlReader = xmlReader; this.commandBehavior = commandBehavior; this.owner = owner; this.sequentialAccess = ((commandBehavior & CommandBehavior.SequentialAccess) != CommandBehavior.Default); this.InitResultData(); this.depth = 0; this.isClosed = false; if (this.parentReader != null) { this.depth = this.parentReader.Depth + 1; } }
private XmlaDataReader(XmlaDataReader parentReader, XmlaDataReader nested) { this.columnNameLookup = new Hashtable(); this.columnXmlNameLookup = new Hashtable(); this.rowsetNames = new List <string>(); this.rowElement = FormattersHelpers.RowElement; this.rowNamespace = FormattersHelpers.RowElementNamespace; this.readersXmlDepth = -1; //base..ctor(); this.xmlReader = nested.xmlReader; this.commandBehavior = (nested.commandBehavior & ~CommandBehavior.SequentialAccess); this.owner = nested.owner; this.schemaTable = nested.schemaTable; this.sequentialAccess = false; this.columnCount = nested.columnCount; this.currentColumn = 0; this.dataReady = false; this.columnNameLookup = nested.columnNameLookup; this.columnXmlNameLookup = nested.columnXmlNameLookup; this.depth = nested.depth; this.isClosed = false; this.parentReader = nested.parentReader; this.dtStore = nested.dtStore; this.currentRow = -1; this.currentParentRow = nested.currentParentRow; this.rowElement = nested.rowElement; this.rowNamespace = nested.rowNamespace; this.nestedDataReaders = new XmlaDataReader[nested.nestedDataReaders.Length]; for (int i = 0; i < nested.nestedDataReaders.Length; i++) { if (nested.nestedDataReaders[i] != null) { this.nestedDataReaders[i] = new XmlaDataReader(nested, nested.nestedDataReaders[i]); } else { this.nestedDataReaders[i] = null; } } }
internal XmlaDataReader(XmlReader xmlReader, CommandBehavior commandBehavior, bool isXmlReaderAtRoot, IXmlaDataReaderOwner owner) { this.columnNameLookup = new Hashtable(); this.columnXmlNameLookup = new Hashtable(); this.rowsetNames = new List <string>(); this.rowElement = FormattersHelpers.RowElement; this.rowNamespace = FormattersHelpers.RowElementNamespace; this.readersXmlDepth = -1; //base..ctor(); try { this.InternalInitialize(xmlReader, commandBehavior, owner); if (!isXmlReaderAtRoot) { XmlaClient.ReadUptoRoot(xmlReader); } this.IsAffectedObjects = XmlaClient.IsAffectedObjectsResponseS(xmlReader); this.isMultipleResult = (this.IsAffectedObjects || XmlaClient.IsMultipleResultResponseS(xmlReader)); this.Results = new XmlaResultCollection(); this.CollectTopLevelAttributes(); if (XmlaClient.IsRowsetResponseS(xmlReader)) { this.RowsetName = xmlReader.GetAttribute("name"); this.rowsetNames.Add(this.RowsetName); this.EnsureResultForNewRowset(); XmlaClient.StartRowsetResponseS(xmlReader); this.LoadResponseSchema(); } else if (XmlaClient.IsMultipleResultResponseS(xmlReader) || XmlaClient.IsAffectedObjectsResponseS(xmlReader)) { XmlaClient.StartElementS(xmlReader, this.IsAffectedObjects ? "AffectedObjects" : "results", "http://schemas.microsoft.com/analysisservices/2003/xmla-multipleresults"); if (XmlaClient.IsRootElementS(xmlReader)) { this.InternalNextResult(true); } else { if (!this.IsAffectedObjects) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, "Expected at least one root element"); } this.StartEmptyAffectedObjects(); } } else { if (XmlaClient.IsDatasetResponseS(xmlReader)) { throw new AdomdUnknownResponseException(XmlaSR.Resultset_IsNotRowset, string.Format(CultureInfo.InvariantCulture, "Got {0}:{1}", new object[] { "urn:schemas-microsoft-com:xml-analysis:mddataset", "root" })); } if (!XmlaClient.IsEmptyResultS(xmlReader)) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Expected {0}:{1}, got {2}", new object[] { "urn:schemas-microsoft-com:xml-analysis:empty", "root", xmlReader.Name })); } XmlaClient.ReadEmptyRootS(xmlReader); throw new AdomdUnknownResponseException(XmlaSR.Resultset_IsNotRowset, string.Format(CultureInfo.InvariantCulture, "Unexpected node {0}", new object[] { xmlReader.Name })); } } catch (AdomdUnknownResponseException) { xmlReader.Close(); throw; } catch (AdomdConnectionException) { throw; } catch (XmlException innerException) { xmlReader.Close(); throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, innerException); } catch (IOException innerException2) { if (this.owner != null) { owner.CloseConnection(false); } throw new AdomdConnectionException(XmlaSR.ConnectionBroken, innerException2); } catch (XmlaException innerException3) { xmlReader.Close(); throw new AdomdErrorResponseException(innerException3); } catch { if (this.owner != null) { owner.CloseConnection(false); } throw; } }