public WasFoundTest(LookupBase lookup) { mLookup = lookup; mWasFound = mLookup.WasFound; mLookup.mWasFound = false; }
/// <summary> /// Add common parameters before calling a procedure /// </summary> /// <param name="cmd">command object, where parameters will be added</param> /// <param name="lookupObject"></param> private void AddCommonParams(SqlCommand cmd, LookupBase lookupObject) { AddParameter(cmd, pNVarChar(LookupBase.Property_ParentDataKey, 250, lookupObject.ParentDataKey)); AddParameter(cmd, pNVarChar(LookupBase.Property_DataKey, 250, lookupObject.DataKey)); AddParameter(cmd, pNVarChar(LookupBase.Property_DisplayText, 250, lookupObject.DisplayText)); AddParameter(cmd, pNVarChar(LookupBase.Property_DataValue, 250, lookupObject.DataValue)); AddParameter(cmd, pInt32(LookupBase.Property_DataOrder, lookupObject.DataOrder)); AddParameter(cmd, pBool(LookupBase.Property_IsActive, lookupObject.IsActive)); AddParameter(cmd, pNVarChar(LookupBase.Property_AlterDisplayText, 250, lookupObject.AlterDisplayText)); AddParameter(cmd, pNVarChar(LookupBase.Property_AlterDisplayText1, 250, lookupObject.AlterDisplayText1)); }
public static string GetString(this LookupBase lookupBase, CultureInfo cultureInfo) { if (cultureInfo.Equals(new CultureInfo(Language1))) { return(lookupBase?.NameLanguage1); } if (cultureInfo.Equals(new CultureInfo(Language2))) { return(lookupBase?.NameLanguage2); } return(lookupBase?.Name); }
/// <summary> /// Iteratively tries to find a list of <see cref="IContact" />s in the DHT. /// </summary> /// <param name="key"></param> /// <returns></returns> IEnumerable <IContact> INode.IterativeFindNode(string key) { if (string.IsNullOrEmpty(key)) { throw new ArgumentNullException("key"); } LookupBase lookup = LookupFactory.GetLookup(this, key, true); IResult result = lookup.LookupAsync(); return(result != null ? result.Contacts : null); }
/// <summary> /// Iteratively tries to find a value in the DHT. /// </summary> /// <param name="key"></param> /// <returns></returns> IEnumerable <IContact> INode.IterativeFindValue(string key) { if (string.IsNullOrEmpty(key)) { throw new ArgumentNullException("key"); } IResult result = (this as IKademlia).FindValue(key); if (result != null && result.Entries != null) { return(result.Entries.Select(x => x.Contact).ToList()); } LookupBase lookup = LookupFactory.GetLookup(this, key, false); result = lookup.LookupAsync(); return(result != null && result.Entries != null?result.Entries.Select(x => x.Contact).ToList() : null); }
/// <summary> /// Updates Lookup /// </summary> /// <param name="lookupObject">Object to be updated</param> /// <returns>Number of rows affected</returns> public long Update(LookupBase lookupObject) { try { SqlCommand cmd = GetSPCommand(UPDATELOOKUP); AddParameter(cmd, pInt32(LookupBase.Property_Id, lookupObject.Id)); AddCommonParams(cmd, lookupObject); long result = UpdateRecord(cmd); if (result > 0) { lookupObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; } return(result); } catch (SqlException x) { throw new ObjectUpdateException(lookupObject, x); } }
/// <summary> /// Fills Lookup object /// </summary> /// <param name="lookupObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> /// <param name="start">The ordinal position from which to start reading the reader</param> protected void FillObject(LookupBase lookupObject, SqlDataReader reader, int start) { lookupObject.Id = reader.GetInt32(start + 0); if (!reader.IsDBNull(1)) { lookupObject.ParentDataKey = reader.GetString(start + 1); } if (!reader.IsDBNull(2)) { lookupObject.DataKey = reader.GetString(start + 2); } if (!reader.IsDBNull(3)) { lookupObject.DisplayText = reader.GetString(start + 3); } if (!reader.IsDBNull(4)) { lookupObject.DataValue = reader.GetString(start + 4); } if (!reader.IsDBNull(5)) { lookupObject.DataOrder = reader.GetInt32(start + 5); } if (!reader.IsDBNull(6)) { lookupObject.IsActive = reader.GetBoolean(start + 6); } if (!reader.IsDBNull(7)) { lookupObject.AlterDisplayText = reader.GetString(start + 7); } if (!reader.IsDBNull(8)) { lookupObject.AlterDisplayText1 = reader.GetString(start + 8); } FillBaseObject(lookupObject, reader, (start + 9)); lookupObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; }
/// <summary> /// Inserts Lookup /// </summary> /// <param name="lookupObject">Object to be inserted</param> /// <returns>Number of rows affected</returns> public long Insert(LookupBase lookupObject) { try { SqlCommand cmd = GetSPCommand(INSERTLOOKUP); AddParameter(cmd, pInt32Out(LookupBase.Property_Id)); AddCommonParams(cmd, lookupObject); long result = InsertRecord(cmd); if (result > 0) { lookupObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow; lookupObject.Id = (Int32)GetOutParameter(cmd, LookupBase.Property_Id); } return(result); } catch (SqlException x) { throw new ObjectInsertException(lookupObject, x); } }
/// <summary> /// Fills Lookup object /// </summary> /// <param name="lookupObject">The object to be filled</param> /// <param name="reader">The reader to use to fill a single object</param> protected void FillObject(LookupBase lookupObject, SqlDataReader reader) { FillObject(lookupObject, reader, 0); }
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static void BindService(grpc::ServiceBinderBase serviceBinder, LookupBase serviceImpl) { serviceBinder.AddMethod(__Method_GetLookupById, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcLookup.LookupRequest, global::GrpcLookup.CustomerLookupResponse>(serviceImpl.GetLookupById)); serviceBinder.AddMethod(__Method_UpdateLookup, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcLookup.CustomerLookupRequest, global::GrpcLookup.CustomerLookupResponse>(serviceImpl.UpdateLookup)); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(LookupBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_GetLookupById, serviceImpl.GetLookupById) .AddMethod(__Method_UpdateLookup, serviceImpl.UpdateLookup).Build()); }