/// <summary> /// Begin get the collection of attachments within the mime data. /// </summary> /// <param name="mimeMessage">The mime data to parse.</param> /// <param name="callback">The asynchronous call back method.</param> /// <param name="state">The state object value.</param> /// <returns>The asynchronous result.</returns> public virtual IAsyncResult BeginGetAttachments(string mimeMessage, AsyncCallback callback, object state) { if (_asyncAttachments == null) { _asyncAttachments = new Nequeo.Threading.FunctionHandler <List <Attachment>, string>(GetAttachments); } return(_asyncAttachments.BeginInvoke(mimeMessage, callback, state)); }
/// <summary> /// Begin get the whois server for the current domain. /// </summary> /// <param name="domain">The domain name.</param> /// <param name="callback">The asynchronous call back method.</param> /// <param name="state">The state object value.</param> /// <returns>The asynchronous result.</returns> public virtual IAsyncResult BeginGetWhoisServer(string domain, AsyncCallback callback, object state) { if (_whoisServerName == null) { _whoisServerName = new Nequeo.Threading.FunctionHandler <string, string>(GetWhoisServer); } return(_whoisServerName.BeginInvoke(domain, callback, state)); }
/// <summary> /// Executes to delegate function for data table projection. /// </summary> /// <param name="dataTable">The table to project.</param> /// <param name="conversionType">The type to convert to.</param> /// <param name="function">The delegate function to execute.</param> /// <returns>The array of data entities.</returns> private Object ListGenericTypeProjector( DataTable dataTable, Type conversionType, Nequeo.Threading.FunctionHandler <Object, DataTable, Type> function) { if (dataTable == null) { throw new ArgumentNullException("dataTable"); } // Call the function delegate with table parameter // to execute the method. return(function(dataTable, conversionType)); }
/// <summary> /// Executes to delegate function for data table projection. /// </summary> /// <typeparam name="TEntity">The entity type to examine.</typeparam> /// <param name="table">The table to project.</param> /// <param name="function">The delegate function to execute.</param> /// <returns>The array of data entities.</returns> private TEntity[] Projector <TEntity>(DataTable table, Nequeo.Threading.FunctionHandler <TEntity[], DataTable> function) where TEntity : class, new() { if (table == null) { throw new ArgumentNullException("table"); } // Call the function delegate with table parameter // to execute the method. return(function(table)); }
/// <summary> /// Execute a select action /// </summary> /// <typeparam name="TResult">The data type to execute the action on.</typeparam> /// <param name="action">The select action to execute.</param> /// <returns>The execute action return type.</returns> public TResult Select <TResult>(Nequeo.Threading.FunctionHandler <TResult, ISelectDataSetGenericBase <TDataContext, TDataTable> > action) { // Check to see if the critical parameters // have been set, throw exception on each. if (action == null) { throw new ArgumentNullException("action"); } if (_selectInstance == null) { throw new ArgumentNullException("selectInstance"); } _selectInstance.ConfigurationDatabaseConnection = _configurationDatabaseConnection; return(action(_selectInstance)); }
/// <summary> /// Execute an update action /// </summary> /// <typeparam name="TResult">The data type to execute the action on.</typeparam> /// <param name="action">The update action to execute.</param> /// <returns>The execute action return type.</returns> public TResult Update <TResult>(Nequeo.Threading.FunctionHandler <TResult, IUpdateEdmGenericBase <TDataContext, TLinqEntity> > action) { // Check to see if the critical parameters // have been set, throw exception on each. if (action == null) { throw new ArgumentNullException("action"); } if (_updateInstance == null) { throw new ArgumentNullException("updateInstance"); } _updateInstance.DataContext = new TDataContext(); _updateInstance.DataContext.Database.Connection.ConnectionString = _insertInstance.DefaultConnection(_configurationDatabaseConnection); return(action(_updateInstance)); }
/// <summary> /// Translate a data table to the corresponding data entity. /// </summary> /// <typeparam name="TEntity">The entity type to examine.</typeparam> /// <param name="table">The table to translate.</param> /// <returns>The array of data entities.</returns> /// <exception cref="System.ArgumentNullException"></exception> public TEntity[] Translator <TEntity>(DataTable table) where TEntity : class, new() { // Check to see if the critical parameters // have been set, throw exception on each. if (table == null) { throw new ArgumentNullException("table"); } // Create the delegate function. Nequeo.Threading.FunctionHandler <TEntity[], DataTable> function = (DataTable data) => this.Mapper <TEntity>(data); // Project the data table. return(Projector <TEntity>(table, function)); }
/// <summary> /// Execute a select action /// </summary> /// <typeparam name="TResult">The data type to execute the action on.</typeparam> /// <param name="action">The select action to execute.</param> /// <param name="lazyLoading">Should lazy loading of references be applied.</param> /// <returns>The execute action return type.</returns> public TResult Select <TResult>(Nequeo.Threading.FunctionHandler <TResult, ISelectEdmGenericBase <TDataContext, TLinqEntity> > action, Boolean lazyLoading = false) { // Check to see if the critical parameters // have been set, throw exception on each. if (action == null) { throw new ArgumentNullException("action"); } if (_selectInstance == null) { throw new ArgumentNullException("selectInstance"); } _selectInstance.DataContext = new TDataContext(); _selectInstance.DataContext.Configuration.LazyLoadingEnabled = lazyLoading; _selectInstance.DataContext.Database.Connection.ConnectionString = _insertInstance.DefaultConnection(_configurationDatabaseConnection); return(action(_selectInstance)); }
/// <summary> /// Perform a reverse dns lookup on the specified ip address. /// </summary> /// <param name="ipAddress">The ip address to resolve.</param> /// <param name="timeout">The time to wait for a response (milliseconds).</param> /// <returns>IP host entry for the ip address else null.</returns> /// <remarks>This method blocks the current thread for the specified time.</remarks> public static IPHostEntry ReverseDnsLookup(string ipAddress, int timeout) { // Validate the inputs. if (String.IsNullOrEmpty(ipAddress)) { throw new System.ArgumentNullException("IP Address can not be null.", new System.Exception("A valid ip address should be specified.")); } try { // Parse the ip address to a valid // ip address, get the host for // the ip address do lookup. IPAddress ip = IPAddress.Parse(ipAddress); // Create a new function call back delegate // for the dns get host entry method. Nequeo.Threading.FunctionHandler <IPHostEntry, IPAddress> callback = new Nequeo.Threading.FunctionHandler <IPHostEntry, IPAddress>(System.Net.Dns.GetHostEntry); // Start the async operation. IAsyncResult ar = callback.BeginInvoke(ip, null, null); // If the operation has not timed out // then return the host entry. if (ar.AsyncWaitHandle.WaitOne(timeout, false)) { // Return the host entry object. return(callback.EndInvoke(ar)); } else { // Return the null. return(null); } } catch { // Return a null. return(null); } }
/// <summary> /// Gets the list generic collection of the conversion type from the data table. /// </summary> /// <param name="dataTable">The datatable containing the data.</param> /// <param name="conversionType">The type to convert to.</param> /// <returns>The list generic conversion type object.</returns> /// <remarks>The return object is of type 'List[conversionType]'.</remarks> /// <exception cref="System.ArgumentNullException"></exception> public object ListGenericTypeTranslator(DataTable dataTable, Type conversionType) { // Check to see if the critical parameters // have been set, throw exception on each. if (dataTable == null) { throw new ArgumentNullException("dataTable"); } if (conversionType == null) { throw new ArgumentNullException("conversionType"); } // Create the delegate function. Nequeo.Threading.FunctionHandler <Object, DataTable, Type> function = (DataTable data, Type type) => this.ListGenericTypeMapper(data, type); // Project the data table. return(ListGenericTypeProjector(dataTable, conversionType, function)); }