Skip to content

Commit

Permalink
Documentation adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Sep 28, 2017
1 parent d5f2347 commit cb028e3
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 236 deletions.
6 changes: 3 additions & 3 deletions src/Unosquare.Swan/Extensions.ByteArrays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public static T[] SubArray<T>(this T[] array, long startIndex, long length)
/// Converts an array of sbytes to an array of bytes
/// </summary>
/// <param name="sbyteArray">The sbyte array.</param>
/// <returns></returns>
/// <returns>The byte array from conversion</returns>
public static byte[] ToByteArray(this sbyte[] sbyteArray)
{
var byteArray = new byte[sbyteArray.Length];
Expand All @@ -506,7 +506,7 @@ public static byte[] ToByteArray(this sbyte[] sbyteArray)
/// Receives a byte array and returns it transformed in an sbyte array
/// </summary>
/// <param name="byteArray">The byte array.</param>
/// <returns></returns>
/// <returns>The sbyte array from conversion</returns>
public static sbyte[] ToSByteArray(this byte[] byteArray)
{
var sbyteArray = new sbyte[byteArray.Length];
Expand All @@ -520,7 +520,7 @@ public static sbyte[] ToSByteArray(this byte[] byteArray)
/// </summary>
/// <param name="encoding">The encoding.</param>
/// <param name="s">The s.</param>
/// <returns>The sbyte array</returns>
/// <returns>The sbyte array from string</returns>
public static sbyte[] GetSBytes(this Encoding encoding, string s)
=> encoding.GetBytes(s).ToSByteArray();

Expand Down
5 changes: 1 addition & 4 deletions src/Unosquare.Swan/Formatters/CsvWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,7 @@ public void WriteHeadings(Type type)
/// Writes the headings.
/// </summary>
/// <typeparam name="T">The type of object to extract heads</typeparam>
public void WriteHeadings<T>()
{
WriteHeadings(typeof(T));
}
public void WriteHeadings<T>() => WriteHeadings(typeof(T));

/// <summary>
/// Writes the headings.
Expand Down
1 change: 0 additions & 1 deletion src/Unosquare.Swan/Networking/Ldap/LdapConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ public virtual LdapConstraints Constraints
var newCons = (LdapSearchConstraints)_defSearchCons.Clone();
newCons.HopLimit = value.HopLimit;
newCons.TimeLimit = value.TimeLimit;
newCons.SetReferralHandler(value.GetReferralHandler());
newCons.ReferralFollowing = value.ReferralFollowing;
var lsc = value.GetControls();
if (lsc != null)
Expand Down
47 changes: 4 additions & 43 deletions src/Unosquare.Swan/Networking/Ldap/LdapConstraints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ namespace Unosquare.Swan.Networking.Ldap
{
using System;
using System.Collections;

/// <summary>
/// Shared ancestor to the two types of referral objects - LdapBindHandler and
/// LdapAuthHandler.
/// </summary>
public interface ILdapReferralHandler
{
}


/// <summary>
/// Defines options controlling Ldap operations on the directory.
/// An LdapConstraints object is always associated with an LdapConnection
Expand All @@ -25,7 +17,6 @@ public class LdapConstraints
private int _msLimit;
private int _hopLimit = 10;
private bool _doReferrals;
private ILdapReferralHandler _refHandler;
private LdapControl[] _controls;
private Hashtable _properties; // Properties

Expand All @@ -40,7 +31,7 @@ public LdapConstraints()
}

/// <summary>
/// Initializes a new instance of the <see cref="LdapConstraints"/> class.
/// Initializes a new instance of the <see cref="LdapConstraints" /> class.
/// Constructs a new LdapConstraints object specifying constraints that
/// control wait time, and referral handling.
/// </summary>
Expand All @@ -59,16 +50,6 @@ public LdapConstraints()
/// The way referrals are followed automatically is
/// determined by the setting of the handler parameter.
/// It is ignored for asynchronous operations.</param>
/// <param name="handler">The custom authentication handler called when
/// LdapConnection needs to authenticate, typically on
/// following a referral. A null may be specified to
/// indicate default authentication processing, i.e.
/// referrals are followed with anonymous authentication.
/// The handler object may be an implemention of either the
/// LdapBindHandler or LdapAuthHandler interface.
/// The implementation of these interfaces determines how
/// authentication is performed when following referrals.
/// It is ignored for asynchronous operations.</param>
/// <param name="hopLimit">The maximum number of referrals to follow in a
/// sequence during automatic referral following.
/// The default value is 10. A value of 0 means no limit.
Expand All @@ -78,11 +59,10 @@ public LdapConstraints()
/// number of referrals in a sequence exceeds the limit.
/// It is ignored for asynchronous operations.</param>
/// <seealso cref="LdapReferralException"></seealso>
public LdapConstraints(int msLimit, bool doReferrals, ILdapReferralHandler handler, int hopLimit)
public LdapConstraints(int msLimit, bool doReferrals, int hopLimit)
{
_msLimit = msLimit;
_doReferrals = doReferrals;
_refHandler = handler;
_hopLimit = hopLimit;
}

Expand Down Expand Up @@ -240,16 +220,7 @@ public virtual void SetProperty(string name, object propertyValue)

_properties[name] = propertyValue;
}

/// <summary>
/// Specifies the object that will process authentication requests
/// during automatic referral following.
/// The default is null.
/// </summary>
/// <param name="handler">An object that implements LdapBindHandler or
/// LdapAuthHandler</param>
public virtual void SetReferralHandler(ILdapReferralHandler handler) => _refHandler = handler;


/// <summary>
/// Clones an LdapConstraints object.
/// </summary>
Expand Down Expand Up @@ -279,16 +250,6 @@ public object Clone()
throw new Exception("Internal error, cannot create clone", ce);
}
}

/// <summary>
/// Returns an object that can process authentication for automatic
/// referral handling.
/// It may be null.
/// </summary>
/// <returns>
/// An LdapReferralHandler object that can process authentication.
/// </returns>
internal virtual ILdapReferralHandler GetReferralHandler() => _refHandler;
}
}

Expand Down
86 changes: 11 additions & 75 deletions src/Unosquare.Swan/Networking/Ldap/LdapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public string[] Referrals
{
get
{
var references = ((RfcSearchResultReference)message.Response).ToArray();
var references = ((RfcSearchResultReference)Message.Response).ToArray();
srefs = new string[references.Length];
for (var i = 0; i < references.Length; i++)
{
Expand Down Expand Up @@ -412,14 +412,14 @@ public LdapSearchConstraints()
/// </summary>
/// <param name="cons">The cons.</param>
public LdapSearchConstraints(LdapConstraints cons)
: base(cons.TimeLimit, cons.ReferralFollowing, cons.GetReferralHandler(), cons.HopLimit)
: base(cons.TimeLimit, cons.ReferralFollowing, cons.HopLimit)
{
var lsc = cons.GetControls();
if (lsc != null)
{
var generated_var = new LdapControl[lsc.Length];
lsc.CopyTo(generated_var, 0);
SetControls(generated_var);
var ldapControl = new LdapControl[lsc.Length];
lsc.CopyTo(ldapControl, 0);
SetControls(ldapControl);
}

var lp = cons.Properties;
Expand All @@ -436,71 +436,7 @@ public LdapSearchConstraints(LdapConstraints cons)
BatchSize = scons.BatchSize;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="LdapSearchConstraints"/> class.
/// Constructs a new LdapSearchConstraints object and allows the
/// specification operational constraints in that object.
/// </summary>
/// <param name="msLimit">The maximum time in milliseconds to wait for results.
/// The default is 0, which means that there is no
/// maximum time limit. This limit is enforced for an
/// operation by the API, not by the server.
/// The operation will be abandoned and terminated by the
/// API with an LdapException.Ldap_TIMEOUT if the
/// operation exceeds the time limit.</param>
/// <param name="serverTimeLimit">The maximum time in seconds that the server
/// should spend returning search results. This is a
/// server-enforced limit. The default of 0 means
/// no time limit.
/// The operation will be terminated by the server with an
/// LdapException.TIME_LIMIT_EXCEEDED if the search
/// operation exceeds the time limit.</param>
/// <param name="dereference">Specifies when aliases should be dereferenced.
/// Must be either DEREF_NEVER, DEREF_FINDING,
/// DEREF_SEARCHING, or DEREF_ALWAYS from this class.
/// Default: DEREF_NEVER</param>
/// <param name="maxResults">The maximum number of search results to return
/// for a search request.
/// The search operation will be terminated by the server
/// with an LdapException.SIZE_LIMIT_EXCEEDED if the
/// number of results exceed the maximum.
/// Default: 1000</param>
/// <param name="doReferrals">Determines whether to automatically follow
/// referrals or not. Specify true to follow
/// referrals automatically, and false to throw
/// an LdapException.REFERRAL if the server responds
/// with a referral.
/// It is ignored for asynchronous operations.
/// Default: false</param>
/// <param name="batchSize">The number of results to return in a batch. Specifying
/// 0 means to block until all results are received.
/// Specifying 1 means to return results one result at a
/// time. Default: 1</param>
/// <param name="handler">The custom authentication handler called when
/// LdapConnection needs to authenticate, typically on
/// following a referral. A null may be specified to
/// indicate default authentication processing, i.e.
/// referrals are followed with anonymous authentication.
/// ThE object may be an implemention of either the
/// the LdapBindHandler or LdapAuthHandler interface.
/// It is ignored for asynchronous operations.</param>
/// <param name="hopLimit">The maximum number of referrals to follow in a
/// sequence during automatic referral following.
/// The default value is 10. A value of 0 means no limit.
/// It is ignored for asynchronous operations.
/// The operation will be abandoned and terminated by the
/// API with an LdapException.REFERRAL_LIMIT_EXCEEDED if the
/// number of referrals in a sequence exceeds the limit.</param>
public LdapSearchConstraints(int msLimit, int serverTimeLimit, int dereference, int maxResults, bool doReferrals, int batchSize, ILdapReferralHandler handler, int hopLimit)
: base(msLimit, doReferrals, handler, hopLimit)
{
ServerTimeLimit = serverTimeLimit;
Dereference = dereference;
MaxResults = maxResults;
BatchSize = batchSize;
}


/// <summary>
/// Returns the number of results to block on during receipt of search
/// results.
Expand Down Expand Up @@ -1188,7 +1124,7 @@ internal LdapResponse(RfcLdapMessage message)
/// <returns>
/// Any error message in the response.
/// </returns>
public string ErrorMessage => exception != null ? exception.LdapErrorMessage : ((IRfcResponse)message.Response).GetErrorMessage().StringValue();
public string ErrorMessage => exception != null ? exception.LdapErrorMessage : ((IRfcResponse)Message.Response).GetErrorMessage().StringValue();

/// <summary>
/// Returns the partially matched DN field from the server response,
Expand All @@ -1197,7 +1133,7 @@ internal LdapResponse(RfcLdapMessage message)
/// <returns>
/// The partially matched DN field, if the response contains one.
/// </returns>
public string MatchedDN => exception != null ? exception.MatchedDN : ((IRfcResponse)message.Response).GetMatchedDN().StringValue();
public string MatchedDN => exception != null ? exception.MatchedDN : ((IRfcResponse)Message.Response).GetMatchedDN().StringValue();

/// <summary>
/// Returns all referrals in a server response, if the response contains any.
Expand All @@ -1210,7 +1146,7 @@ public string[] Referrals
get
{
string[] referrals;
var reference = ((IRfcResponse)message.Response).GetReferral();
var reference = ((IRfcResponse)Message.Response).GetReferral();

if (reference == null)
{
Expand Down Expand Up @@ -1270,10 +1206,10 @@ public LdapStatusCode ResultCode
return exception.ResultCode;
}

if ((IRfcResponse)message.Response is RfcIntermediateResponse)
if ((IRfcResponse)Message.Response is RfcIntermediateResponse)
return LdapStatusCode.Success;

return (LdapStatusCode)((IRfcResponse)message.Response).GetResultCode().IntValue();
return (LdapStatusCode)((IRfcResponse)Message.Response).GetResultCode().IntValue();
}
}

Expand Down
Loading

0 comments on commit cb028e3

Please sign in to comment.