コード例 #1
0
        private SmiContextFactory()
        {
            if (InOutOfProcHelper.InProc)
            {
                Type smiLinkType = Type.GetType("Microsoft.SqlServer.Server.InProcLink, SqlAccess, PublicKeyToken=89845dcd8080cc91");

                if (null == smiLinkType)
                {
                    Debug.Assert(false, "could not get InProcLink type");
                    throw SQL.ContextUnavailableOutOfProc();    // Must not be a valid version of Sql Server.
                }

                System.Reflection.FieldInfo instanceField = GetStaticField(smiLinkType, "Instance");
                if (instanceField != null)
                {
                    _smiLink = (SmiLink)GetValue(instanceField);
                }
                else
                {
                    Debug.Assert(false, "could not get InProcLink.Instance");
                    throw SQL.ContextUnavailableOutOfProc();    // Must not be a valid version of Sql Server.
                }

                System.Reflection.FieldInfo buildVersionField = GetStaticField(smiLinkType, "BuildVersion");
                if (buildVersionField != null)
                {
                    UInt32 buildVersion = (UInt32)GetValue(buildVersionField);

                    _majorVersion  = (byte)(buildVersion >> 24);
                    _minorVersion  = (byte)((buildVersion >> 16) & 0xff);
                    _buildNum      = (short)(buildVersion & 0xffff);
                    _serverVersion = (String.Format((IFormatProvider)null, "{0:00}.{1:00}.{2:0000}", _majorVersion, (short)_minorVersion, _buildNum));
                }
                else
                {
                    _serverVersion = String.Empty;  // default value if nothing exists.
                }
                _negotiatedSmiVersion = _smiLink.NegotiateVersion(SmiLink.InterfaceVersion);
                bool isSupportedVersion = false;
                for (int i = 0; !isSupportedVersion && i < __supportedSmiVersions.Length; i++)
                {
                    if (__supportedSmiVersions[i] == _negotiatedSmiVersion)
                    {
                        isSupportedVersion = true;
                    }
                }

                // Disconnect if we didn't get a supported version!!
                if (!isSupportedVersion)
                {
                    _smiLink = null;
                }

                _eventSinkForGetCurrentContext = new SmiEventSink_Default();
            }
        }
コード例 #2
0
        private SmiContextFactory() {
            if (InOutOfProcHelper.InProc) {
                Type smiLinkType = Type.GetType("Microsoft.SqlServer.Server.InProcLink, SqlAccess, PublicKeyToken=89845dcd8080cc91");

                if (null == smiLinkType) {
                    Debug.Assert(false, "could not get InProcLink type");
                    throw SQL.ContextUnavailableOutOfProc();    // Must not be a valid version of Sql Server.
                }

                System.Reflection.FieldInfo instanceField = GetStaticField(smiLinkType, "Instance");
                if (instanceField != null) {
                    _smiLink = (SmiLink)GetValue(instanceField);
                }
                else {
                    Debug.Assert(false, "could not get InProcLink.Instance");
                    throw SQL.ContextUnavailableOutOfProc();    // Must not be a valid version of Sql Server.
                }
                
                System.Reflection.FieldInfo buildVersionField = GetStaticField(smiLinkType, "BuildVersion");
                if (buildVersionField != null) {
                    UInt32 buildVersion = (UInt32)GetValue(buildVersionField);

                    _majorVersion = (byte)(buildVersion >> 24);
                    _minorVersion = (byte)((buildVersion >> 16) & 0xff);
                    _buildNum     = (short)(buildVersion & 0xffff);
                    _serverVersion = (String.Format((IFormatProvider)null, "{0:00}.{1:00}.{2:0000}", _majorVersion, (short) _minorVersion, _buildNum));
                }
                else {
                    _serverVersion = String.Empty;  // default value if nothing exists.
                }
                _negotiatedSmiVersion          = _smiLink.NegotiateVersion(SmiLink.InterfaceVersion);
                bool isSupportedVersion = false;
                for(int i=0; !isSupportedVersion && i<__supportedSmiVersions.Length; i++) {
                    if (__supportedSmiVersions[i] == _negotiatedSmiVersion) {
                        isSupportedVersion = true;
                    }
                }

                // Disconnect if we didn't get a supported version!!
                if (!isSupportedVersion) {
                    _smiLink = null;
                }

                _eventSinkForGetCurrentContext = new SmiEventSink_Default();
            }
        }
コード例 #3
0
 private SmiContextFactory()
 {
     if (InOutOfProcHelper.InProc)
     {
         Type aType = Type.GetType("Microsoft.SqlServer.Server.InProcLink, SqlAccess, PublicKeyToken=89845dcd8080cc91");
         if (null == aType)
         {
             throw SQL.ContextUnavailableOutOfProc();
         }
         FieldInfo staticField = this.GetStaticField(aType, "Instance");
         if (staticField == null)
         {
             throw SQL.ContextUnavailableOutOfProc();
         }
         this._smiLink = (SmiLink)this.GetValue(staticField);
         FieldInfo fieldInfo = this.GetStaticField(aType, "BuildVersion");
         if (fieldInfo != null)
         {
             uint num2 = (uint)this.GetValue(fieldInfo);
             this._majorVersion  = (byte)(num2 >> 0x18);
             this._minorVersion  = (byte)((num2 >> 0x10) & 0xff);
             this._buildNum      = (short)(num2 & 0xffff);
             this._serverVersion = string.Format(null, "{0:00}.{1:00}.{2:0000}", new object[] { this._majorVersion, (short)this._minorVersion, this._buildNum });
         }
         else
         {
             this._serverVersion = string.Empty;
         }
         this._negotiatedSmiVersion = this._smiLink.NegotiateVersion(210L);
         bool flag = false;
         for (int i = 0; !flag && (i < this.__supportedSmiVersions.Length); i++)
         {
             if (this.__supportedSmiVersions[i] == this._negotiatedSmiVersion)
             {
                 flag = true;
             }
         }
         if (!flag)
         {
             this._smiLink = null;
         }
         this._eventSinkForGetCurrentContext = new SmiEventSink_Default();
     }
 }