public override DataType GetResponseDataType()
        {
            DataType result;

            try
            {
                this.GetResponseStream();
                Match match = WcfStream.contentTypeRegex.Match(this.responseContentType);
                if (!match.Success)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.UnsupportedDataFormat(this.responseContentType), "");
                }
                DataType dataTypeFromString = DataTypes.GetDataTypeFromString(match.Groups["content_type"].Value);
                if (dataTypeFromString == DataType.Undetermined || dataTypeFromString == DataType.Unknown)
                {
                    throw new AdomdUnknownResponseException(XmlaSR.UnsupportedDataFormat(this.responseContentType), "");
                }
                result = dataTypeFromString;
            }
            catch (XmlaStreamException e)
            {
                XmlaClient.UlsWriterLogException(e);
                throw;
            }
            catch (Exception ex)
            {
                XmlaClient.UlsWriterLogException(ex);
                throw new XmlaStreamException(ex);
            }
            return(result);
        }
 internal WcfStream(string dataSource, string serverEndpointAddress, bool specificVersion, string loginName, string databaseId, DataType desiredRequestType, DataType desiredResponseType, string applicationName) : base(desiredRequestType, desiredResponseType)
 {
     try
     {
         this.Init();
         this.spSite = XmlaClient.CreateSPSite(dataSource);
         this.serverEndpointAddress = serverEndpointAddress;
         this.loginName             = loginName;
         this.databaseId            = databaseId;
         this.applicationName       = applicationName;
         this.specificVersion       = specificVersion;
         this.logonWindowsIdentity  = WindowsIdentity.GetCurrent();
         this.logonWindowsPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
         XmlaClient.UlsWriterSetCurrentRequestCategoryToRequestProcessing();
     }
     catch (XmlaStreamException e)
     {
         XmlaClient.UlsWriterLogException(e);
         throw;
     }
     catch (Exception ex)
     {
         XmlaClient.UlsWriterLogException(ex);
         throw new XmlaStreamException(ex);
     }
 }
 private void GetResponseStream()
 {
     if (this.outdatedVersion)
     {
         throw new AdomdConnectionException(XmlaSR.Connection_WorkbookIsOutdated);
     }
     if (this.responseStream == null)
     {
         IPrincipal currentPrincipal = Thread.CurrentPrincipal;
         try
         {
             Thread.CurrentPrincipal = this.logonWindowsPrincipal;
             using (WindowsIdentity current = WindowsIdentity.GetCurrent())
             {
                 if (this.logonWindowsIdentity.User != current.User)
                 {
                     //using (this.logonWindowsIdentity.Impersonate())
                     //{
                     //	this.GetResponseStreamHelper();
                     //	goto IL_71;
                     //}
                 }
                 this.GetResponseStreamHelper();
                 IL_71 :;
             }
             if (this.outdatedVersion)
             {
                 throw new AdomdConnectionException(XmlaSR.Connection_WorkbookIsOutdated);
             }
             this.DetermineNegotiatedOptions();
         }
         catch (XmlaStreamException e)
         {
             XmlaClient.UlsWriterLogException(e);
             throw;
         }
         catch (Exception ex)
         {
             XmlaClient.UlsWriterLogException(ex);
             throw new XmlaStreamException(ex);
         }
         finally
         {
             Thread.CurrentPrincipal = currentPrincipal;
         }
     }
 }
 private void GetResponseStreamHelper()
 {
     this.responseFlags       = "1,0,0,0,0";
     this.responseContentType = "text/xml";
     try
     {
         long num = 0L;
         foreach (byte[] current in this.buffers)
         {
             num += (long)current.Length;
         }
         byte[] array;
         if (1 == this.buffers.Count)
         {
             array = this.buffers[0];
         }
         else
         {
             array = new byte[num];
             long num2 = 0L;
             foreach (byte[] current2 in this.buffers)
             {
                 current2.CopyTo(array, num2);
                 num2 += (long)current2.Length;
             }
         }
         this.responseStream = XmlaClient.GetResponseStreamHelper(this.spSite, new MemoryStream(array), this.serverEndpointAddress, this.loginName, this.databaseId, this.specificVersion, this.isFirstRequest, this.userAgent, this.applicationName, this.userAddress, "1,0,0,0,0", "text/xml", ref this.responseFlags, ref this.responseContentType, ref this.outdatedVersion);
         this.isFirstRequest = false;
     }
     catch (XmlaStreamException e)
     {
         XmlaClient.UlsWriterLogException(e);
         throw;
     }
     catch (Exception ex)
     {
         XmlaClient.UlsWriterLogException(ex);
         throw new XmlaStreamException(ex);
     }
     finally
     {
         if (this.buffers.Count != 0)
         {
             this.buffers = new List <byte[]>();
         }
     }
 }
        public override int Read(byte[] buffer, int offset, int size)
        {
            if (this.disposed)
            {
                throw new ObjectDisposedException(null);
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset");
            }
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("size");
            }
            if (size + offset > buffer.Length)
            {
                throw new ArgumentException(XmlaSR.InvalidArgument, "buffer");
            }
            int result;

            try
            {
                this.GetResponseStream();
                int num = this.responseStream.Read(buffer, offset, size);
                result = num;
            }
            catch (XmlaStreamException e)
            {
                XmlaClient.UlsWriterLogException(e);
                throw;
            }
            catch (Exception ex)
            {
                XmlaClient.UlsWriterLogException(ex);
                throw new XmlaStreamException(ex);
            }
            return(result);
        }
 public override void Skip()
 {
     if (this.disposed)
     {
         throw new ObjectDisposedException(null);
     }
     try
     {
         this.Init();
     }
     catch (XmlaStreamException e)
     {
         XmlaClient.UlsWriterLogException(e);
         throw;
     }
     catch (Exception ex)
     {
         XmlaClient.UlsWriterLogException(ex);
         throw new XmlaStreamException(ex);
     }
 }
 public override void Write(byte[] buffer, int offset, int size)
 {
     if (this.disposed)
     {
         throw new ObjectDisposedException(null);
     }
     try
     {
         byte[] array = new byte[size];
         Array.Copy(buffer, offset, array, 0, size);
         this.buffers.Add(array);
     }
     catch (XmlaStreamException e)
     {
         XmlaClient.UlsWriterLogException(e);
         throw;
     }
     catch (Exception ex)
     {
         XmlaClient.UlsWriterLogException(ex);
         throw new XmlaStreamException(ex);
     }
 }