示例#1
0
        public void Attributes( string serviceTypeOrUrl, string[] scopes, string[] wantAttributes, AttribFoundCallback cb)
        {
            String scopelist = null;
              String wantlist  = null;
              if ( serviceTypeOrUrl == null )
            throw new ArgumentNullException("serviceTypeOrUrl");
              if ( serviceTypeOrUrl.Equals( string.Empty ) )
            throw new SlpException ( SlpError.TYPE_ERROR );

              if (scopes != null)
            scopelist = String.Join (",", scopes);
              if (wantAttributes != null)
            wantlist = String.Join(",", wantAttributes);

              var err = SlpNativeMethods.FindAttrs( hSlp, serviceTypeOrUrl, scopelist, wantlist,
            delegate (SlpHandle h, string al, SlpError errCode, IntPtr pvCookie) {
              var ret = SlpBoolean.False;
              if ( errCode == SlpError.OK ) {
              if ((cb != null) && cb(al)) ret = SlpBoolean.True;
              }
              return ret;
            }, IntPtr.Zero );
              if (err != SlpError.OK)
            throw new SlpException ( err );
        }
示例#2
0
        public void Attributes(string serviceTypeOrUrl, string[] scopes, string[] wantAttributes, AttribFoundCallback cb)
        {
            String scopelist = null;
            String wantlist  = null;

            if (serviceTypeOrUrl == null)
            {
                throw new ArgumentNullException("serviceTypeOrUrl");
            }
            if (serviceTypeOrUrl.Equals(string.Empty))
            {
                throw new SlpException(SlpError.TYPE_ERROR);
            }

            if (scopes != null)
            {
                scopelist = String.Join(",", scopes);
            }
            if (wantAttributes != null)
            {
                wantlist = String.Join(",", wantAttributes);
            }

            var err = SlpNativeMethods.FindAttrs(hSlp, serviceTypeOrUrl, scopelist, wantlist,
                                                 delegate(SlpHandle h, string al, SlpError errCode, IntPtr pvCookie) {
                var ret = SlpBoolean.False;
                if (errCode == SlpError.OK)
                {
                    if ((cb != null) && cb(al))
                    {
                        ret = SlpBoolean.True;
                    }
                }
                return(ret);
            }, IntPtr.Zero);

            if (err != SlpError.OK)
            {
                throw new SlpException(err);
            }
        }