public void DefaultCtorCreatesInstanceWithFactoryOfCustomConverterFactoryType() { var target = new CustomConverter(); Assert.IsNotNull(target.Factory); Assert.IsInstanceOf<CustomConverterFactory>(target.Factory); }
public List <Document> GetDocuments(int packageSize, int lastId) { var documentTypeIds = _dictionaryTypesService.GetDocumentTypeIds(); var oldDocuments = _context.DDDocuments .AsNoTracking() .Where(d => d.Id != 0 && d.Id > lastId && documentTypeIds.Contains(d.DocTypeId)) .OrderBy(d => d.Id) .Take(packageSize) .ToList(); var documents = oldDocuments.Select(d => new Document { Id = d.Id, ExternalId = d.Id, Barcode = d.Id, TypeId = d.DocTypeId, DateCreate = d.DateCreate ?? DateTimeOffset.Now, DateUpdate = d.DateUpdate ?? DateTimeOffset.Now, AddresseeId = d.CustomerId, DepartmentId = d.DepartmentId, DocumentNum = d.DocNum, OutgoingNumber = d.OutNum, IncomingNumber = d.InOutNum, NameRu = d.DescMlRu, NameEn = d.DescMlEn, NameKz = d.DescMlKz, DivisionId = d.DivisionId, ReceiveTypeId = d.SendType, IncomingNumberFilial = d.InNumAdd, IsFinished = CustomConverter.StringToNullableBool(d.IsComplete), IsDeleted = false, }).ToList(); return(documents); }
private Creature BuildCreature(DataRow row) { var creature = new Creature(); creature.guid = row["guid"] != DBNull.Value ? CustomConverter.ToInt32(row["guid"]) : 0; creature.id = row["id"] != DBNull.Value ? CustomConverter.ToInt32(row["id"]) : 0; creature.map = row["map"] != DBNull.Value ? CustomConverter.ToInt32(row["map"]) : 0; creature.spawnMask = row["spawnMask"] != DBNull.Value ? CustomConverter.ToInt32(row["spawnMask"]) : 0; creature.phaseMask = row["phaseMask"] != DBNull.Value ? CustomConverter.ToInt32(row["phaseMask"]) : 0; creature.modelid = row["modelid"] != DBNull.Value ? CustomConverter.ToInt32(row["modelid"]) : 0; creature.equipment_id = row["equipment_id"] != DBNull.Value ? CustomConverter.ToInt32(row["equipment_id"]) : 0; creature.position_x = row["position_x"] != DBNull.Value ? CustomConverter.ToInt32(row["position_x"]) : 0; creature.position_y = row["position_y"] != DBNull.Value ? CustomConverter.ToInt32(row["position_y"]) : 0; creature.position_z = row["position_z"] != DBNull.Value ? CustomConverter.ToInt32(row["position_z"]) : 0; creature.orientation = row["orientation"] != DBNull.Value ? CustomConverter.ToInt32(row["orientation"]) : 0; creature.spawntimesecs = row["spawntimesecs"] != DBNull.Value ? CustomConverter.ToInt32(row["spawntimesecs"]) : 0; creature.spawndist = row["spawndist"] != DBNull.Value ? CustomConverter.ToInt32(row["spawndist"]) : 0; creature.currentwaypoint = row["currentwaypoint"] != DBNull.Value ? CustomConverter.ToInt32(row["currentwaypoint"]) : 0; creature.curhealth = row["curhealth"] != DBNull.Value ? CustomConverter.ToInt32(row["curhealth"]) : 0; creature.curmana = row["curmana"] != DBNull.Value ? CustomConverter.ToInt32(row["curmana"]) : 0; creature.movementType = row["movementType"] != DBNull.Value ? CustomConverter.ToInt32(row["movementType"]) : 0; creature.npcflag = row["npcflag"] != DBNull.Value ? CustomConverter.ToInt32(row["npcflag"]) : 0; creature.unit_flags = row["unit_flags"] != DBNull.Value ? CustomConverter.ToInt32(row["unit_flags"]) : 0; creature.dynamicflags = row["dynamicflags"] != DBNull.Value ? CustomConverter.ToInt32(row["dynamicflags"]) : 0; return(creature); }
public List <ApplicationUser> GetApplicationUsers() { var users = _context.Users .AsNoTracking() .ToList(); var applicatonUsers = users.Select(u => new ApplicationUser { Id = u.Id, DateCreate = u.DateCreate ?? DateTimeOffset.Now, DateUpdate = u.DateChange ?? DateTimeOffset.Now, DepartmentId = u.DepartmentId, PositionId = u.PositionId, NameRu = u.NameRu, NameEn = u.NameEn, NameKz = u.NameKz, XIN = u.IIN, UserName = u.IIN, Email = u.Email, IpAddress = u.IpAddress, IsArchive = CustomConverter.StringToNullableBool(u.IsArchive), IsVirtual = CustomConverter.StringToBool(u.Virtual), Password = string.IsNullOrWhiteSpace(u.Password) == false ? u.Password : DefaultPassword, TemplateUserName = u.TemplateUserName, SecurityStamp = Guid.NewGuid().ToString() }).ToList(); SetHashPasswordOnApplicationUsers(applicatonUsers); return(applicatonUsers); }
public List <ProtectionDocAttorney> GetProtectionDocAttornies() { var protectionDocAttornies = _context.PatentAttorneyses .AsNoTracking() .ToList(); return(protectionDocAttornies.Select(p => new ProtectionDocAttorney { Id = p.Id, DateCreate = DateTimeOffset.Now, DateUpdate = DateTimeOffset.Now, LocationId = p.LocationId, CountryId = p.CountryId, NameFirst = p.Firstname, NameLast = p.Lastname, NameMiddle = p.Middlename, Address = p.Address, CertificateDate = p.CertDate, CertificateNumber = p.CertNum, Description = p.Note, Email = p.EMail, Fax = p.Fax, IsActive = CustomConverter.IntToBool(p.Active), Job = p.Job, KnowledgeArea = p.KnowledgeArea, Language = p.Language, OPS = p.Ops, Phone = p.Phone, RevalidNote = p.RevalidNote, WebSite = p.WebSite, XIN = p.IIN }).ToList()); }
public List <RequestWorkflow> GetRequestWorkflows(List <int> requestIds) { var oldRequestWorkflows = _context.WTPTWorkoffices .AsNoTracking() .Where(w => requestIds.Contains(w.DocumentId)) .OrderBy(w => w.Id) .ToList(); var requestWorkflows = oldRequestWorkflows.Select(w => new RequestWorkflow { IsComplete = CustomConverter.StringToNullableBool(w.IsComplete), OwnerId = w.DocumentId, ControlDate = w.ControlDate, DateCreate = w.DateCreate ?? DateTimeOffset.Now, DateUpdate = w.DateUpdate ?? DateTimeOffset.Now, CurrentStageId = w.ToStageId, CurrentUserId = w.ToUserId, FromStageId = w.FromStageId, FromUserId = w.FromUserId, Description = w.Description, IsMain = true, IsSystem = CustomConverter.StringToNullableBool(w.IsSystem), RouteId = w.TypeId }).ToList(); return(requestWorkflows); }
public List <DicRouteStage> GetDicRouteStages() { var stages = _context.Stages .AsNoTracking() .OrderBy(s => s.Id) .ToList(); return(stages.Select(s => new DicRouteStage { Id = s.Id, Code = s.Code, OnlineRequisitionStatusId = s.OnlineStatusId, Interval = s.Interval, IsFirst = CustomConverter.StringToBool(s.IsFirst), IsLast = CustomConverter.StringToBool(s.IsLast), IsMultiUser = CustomConverter.StringToBool(s.IsMultyUser), IsReturnable = CustomConverter.StringToNullableBool(s.IsReturning), IsSystem = CustomConverter.StringToBool(s.IsSystem), NameRu = s.NameRu, NameEn = s.NameEn, NameKz = s.NameKz, Description = s.Description, RouteId = s.WorktypeId, ExpirationType = Domain.Enums.ExpirationType.CalendarDay, ExpirationValue = (short?)s.IntervalDays, }).ToList()); }
private void buttonSaveCondition_Click(object sender, EventArgs e) { Condition newCondition = new Condition(); newCondition.SourceTypeOrReferenceId = comboBoxConditionSourceTypes.SelectedIndex; newCondition.SourceGroup = CustomConverter.ToInt32(textBoxSourceGroup.Text); newCondition.SourceEntry = CustomConverter.ToInt32(textBoxSourceEntry.Text); newCondition.SourceId = CustomConverter.ToInt32(textBoxSourceId.Text); newCondition.ElseGroup = CustomConverter.ToInt32(textBoxElseGroup.Text); newCondition.ConditionTypeOrReference = comboBoxConditionTypes.SelectedIndex; newCondition.ConditionTarget = comboBoxConditionTarget.SelectedIndex; newCondition.ConditionValue1 = CustomConverter.ToInt32(textBoxCondValue1.Text); newCondition.ConditionValue2 = CustomConverter.ToInt32(textBoxCondValue2.Text); newCondition.ConditionValue3 = CustomConverter.ToInt32(textBoxCondValue3.Text); newCondition.NegativeCondition = checkBoxNegativeCondition.Checked ? 1 : 0; newCondition.ErrorType = CustomConverter.ToInt32(textBoxErrorType.Text); newCondition.ErrorTextId = CustomConverter.ToInt32(textBoxErrorTextId.Text); newCondition.ScriptName = textBoxScriptName.Text; newCondition.Comment = textBoxComment.Text; conditions.Add(newCondition); listViewConditions.AddScript(newCondition, selectNewItem: true); ResetAllFields(); }
public Payment GetPayment(int id) { var oldPayment = _context.WtPlPayments .AsNoTracking() .FirstOrDefault(p => p.Id == id); if (oldPayment == null) { return(null); } return(new Payment { Id = oldPayment.Id, DateCreate = oldPayment.DateCreate ?? DateTimeOffset.Now, DateUpdate = oldPayment.DateCreate ?? DateTimeOffset.Now, CustomerId = oldPayment.CustomerId == 0 ? null : oldPayment.CustomerId, Amount = oldPayment.Amount, AssignmentDescription = oldPayment.UseDsc, PurposeDescription = oldPayment.Dsc, CurrencyAmount = oldPayment.ValSum, CurrencyRate = oldPayment.ExchangeRate, CurrencyType = oldPayment.ValType, IsPrePayment = CustomConverter.StringToNullableBool(oldPayment.IsAvans), Payment1CNumber = oldPayment.Payment1CNumber, PaymentDate = oldPayment.PaymentDate, PaymentNumber = oldPayment.PaymentType }); }
/// <summary> /// /// </summary> /// <param name="st"></param> /// <param name="_sector"></param> /// <returns></returns> private bool decodeSectorTrailer(string st, MifareClassicSectorModel _sector) { byte[] _bytes = new byte[255]; int discarded = 0; string[] sectorTrailer = st.Split(new[] { ',', ';' }); if (sectorTrailer.Count() != 3 || !(CustomConverter.IsInHexFormat(sectorTrailer[1]) && sectorTrailer[1].Length == 8) || !(CustomConverter.IsInHexFormat(sectorTrailer[0]) && sectorTrailer[0].Length == 12) || !(CustomConverter.IsInHexFormat(sectorTrailer[2]) && sectorTrailer[2].Length == 12)) { return(true); } _bytes = CustomConverter.GetBytes(sectorTrailer[1], out discarded); if (!decodeSectorTrailer(_bytes, ref _sector)) { return(false); } else { return(true); } }
private void buttonTestConnection_Click(object sender, EventArgs e) { buttonTestConnection.Enabled = false; MySqlConnectionStringBuilder _connectionString = new MySqlConnectionStringBuilder(); _connectionString.Server = textBoxHost.Text; _connectionString.UserID = textBoxUsername.Text; _connectionString.Port = CustomConverter.ToUInt32(textBoxPort.Text); _connectionString.Database = textBoxWorldDatabase.Text; if (textBoxPassword.Text.Length > 0) { _connectionString.Password = textBoxPassword.Text; } WorldDatabase worldDatabase = null; if (!Settings.Default.UseWorldDatabase) { worldDatabase = new WorldDatabase(Settings.Default.Host, Settings.Default.Port, Settings.Default.User, SAI_Editor_Manager.Instance.GetPasswordSetting(), Settings.Default.Database); } else { worldDatabase = SAI_Editor_Manager.Instance.worldDatabase; } //! If no connection was established, it would throw an error in WorldDatabase.CanConnectToDatabase. if (worldDatabase.CanConnectToDatabase(_connectionString)) { MessageBox.Show("Connection successful!", "Connection status", MessageBoxButtons.OK, MessageBoxIcon.Information); } buttonTestConnection.Enabled = true; }
private SmartScript BuildSmartScript(DataRow row) { var smartScript = new SmartScript(); smartScript.entryorguid = row["entryorguid"] != DBNull.Value ? CustomConverter.ToInt32(row["entryorguid"]) : -1; smartScript.source_type = row["source_type"] != DBNull.Value ? CustomConverter.ToInt32(row["source_type"]) : 0; smartScript.id = row["id"] != DBNull.Value ? CustomConverter.ToInt32(row["id"]) : 0; smartScript.link = row["link"] != DBNull.Value ? CustomConverter.ToInt32(row["link"]) : 0; smartScript.event_type = row["event_type"] != DBNull.Value ? CustomConverter.ToInt32(row["event_type"]) : 0; smartScript.event_phase_mask = row["event_phase_mask"] != DBNull.Value ? CustomConverter.ToInt32(row["event_phase_mask"]) : 0; smartScript.event_chance = row["event_chance"] != DBNull.Value ? CustomConverter.ToInt32(row["event_chance"]) : 0; smartScript.event_flags = row["event_flags"] != DBNull.Value ? CustomConverter.ToInt32(row["event_flags"]) : 0; smartScript.event_param1 = row["event_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param1"]) : 0; smartScript.event_param2 = row["event_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param2"]) : 0; smartScript.event_param3 = row["event_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param3"]) : 0; smartScript.event_param4 = row["event_param4"] != DBNull.Value ? CustomConverter.ToInt32(row["event_param4"]) : 0; smartScript.action_type = row["action_type"] != DBNull.Value ? CustomConverter.ToInt32(row["action_type"]) : 0; smartScript.action_param1 = row["action_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param1"]) : 0; smartScript.action_param2 = row["action_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param2"]) : 0; smartScript.action_param3 = row["action_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param3"]) : 0; smartScript.action_param4 = row["action_param4"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param4"]) : 0; smartScript.action_param5 = row["action_param5"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param5"]) : 0; smartScript.action_param6 = row["action_param6"] != DBNull.Value ? CustomConverter.ToInt32(row["action_param6"]) : 0; smartScript.target_type = row["target_type"] != DBNull.Value ? CustomConverter.ToInt32(row["target_type"]) : 0; smartScript.target_param1 = row["target_param1"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param1"]) : 0; smartScript.target_param2 = row["target_param2"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param2"]) : 0; smartScript.target_param3 = row["target_param3"] != DBNull.Value ? CustomConverter.ToInt32(row["target_param3"]) : 0; smartScript.target_x = row["target_x"] != DBNull.Value ? row["target_x"].ToString() : String.Empty; smartScript.target_y = row["target_y"] != DBNull.Value ? row["target_y"].ToString() : String.Empty; smartScript.target_z = row["target_z"] != DBNull.Value ? row["target_z"].ToString() : String.Empty; smartScript.target_o = row["target_o"] != DBNull.Value ? row["target_o"].ToString() : String.Empty; smartScript.comment = row["comment"] != DBNull.Value ? (string)row["comment"] : String.Empty; return(smartScript); }
public static void Main(string[] args) { Console.WriteLine("--- Original JSON ---"); string json = @"{""keys"":[""foo"",""fizz""],""values"":[""bar"",""bang""]}"; Console.WriteLine(json); // Set up the serializer settings. The same converter instance // is used throughout this example. CustomConverter converter = new CustomConverter(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.Converters.Add(converter); // Here we are reading a JSON object containing two arrays into a dictionary // (custom read) and then writing out the dictionary JSON (standard write) Console.WriteLine("\r\n--- Situation 1 (custom read, standard write) ---"); converter.Behavior = ConverterBehavior.CustomReadStandardWrite; var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(json, settings); json = JsonConvert.SerializeObject(dict, settings); Console.WriteLine(json); // Here we are reading a simple JSON object into a dictionary (standard read) // and then writing out a new JSON object containing arrays (custom write) Console.WriteLine("\r\n--- Situation 2 (standard read, custom write) ---"); converter.Behavior = ConverterBehavior.StandardReadCustomWrite; dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(json, settings); json = JsonConvert.SerializeObject(dict, settings); Console.WriteLine(json); }
protected TItem Parse(string valueString, IFormatProvider formatProvider) { if (CustomConverter != null) { return(CustomConverter.Parse(valueString, formatProvider)); } else if (typeof(TItem) == typeof(FileInfo)) { return((TItem)(object)new FileInfo(valueString)); } else if (typeof(TItem) == typeof(DirectoryInfo)) { return((TItem)(object)new DirectoryInfo(valueString)); } else if (typeof(TItem) == typeof(CultureInfo)) { return((TItem)(object)new CultureInfo(valueString)); } else if (typeof(TItem).IsEnum) { return((TItem)Enum.Parse(typeof(TItem), valueString)); } else { return((TItem)Convert.ChangeType(valueString, typeof(TItem), formatProvider)); } }
public void ReturnsDefaultInt() { // Arrange | Act var result = CustomConverter.GetIntTimesTenOrDefault(""); // Assert Assert.Equal(0, result); }
public void CtorCreatesInstanceWithSpecifiedFactoryInstance() { var mockFactory = new Mock<ICustomConverterFactory>(); var target = new CustomConverter(mockFactory.Object); Assert.IsNotNull(target.Factory); Assert.AreSame(mockFactory.Object, target.Factory); }
[Test] public void CustomTypeIsParsed() { var converter = new CustomConverter(); TypedValue parseResult = TypedValue.Void; Assert.IsTrue(converter.TryParse(processor, typeof(CustomClass), TypedValue.Void, new TreeLeaf <string>("info"), ref parseResult)); var result = parseResult.Value as CustomClass; Assert.IsNotNull(result); Assert.AreEqual("custominfo", result.Info); }
public AreaTrigger BuildAreaTrigger(DataRow row) { var areaTrigger = new AreaTrigger(); areaTrigger.id = row["m_id"] != DBNull.Value ? CustomConverter.ToInt32(row["m_id"]) : -1; areaTrigger.map_id = row["m_mapId"] != DBNull.Value ? CustomConverter.ToInt32(row["m_mapId"]) : 0; areaTrigger.posX = row["m_posX"] != DBNull.Value ? (double)row["m_posX"] : 0; areaTrigger.posY = row["m_posY"] != DBNull.Value ? (double)row["m_posY"] : 0; areaTrigger.posZ = row["m_posZ"] != DBNull.Value ? (double)row["m_posZ"] : 0; return(areaTrigger); }
public async Task <int> GetGameobjectIdByGuid(int guid) { DataTable dt = await ExecuteQuery("SELECT id FROM gameobject WHERE guid = '" + guid + "'"); if (dt.Rows.Count == 0) { return(0); } return(CustomConverter.ToInt32(dt.Rows[0]["id"])); }
public List <Request> GetRequests(int packageSize, int lastId) { _context.Database.SetCommandTimeout(600); var oldRequests = _context.DDDocuments .Include(d => d.Patent) .AsNoTracking() .Where(d => d.Id > lastId && _requestTypeIds.Contains(d.DocTypeId)) .OrderBy(d => d.Id) .Take(packageSize) .ToList(); var requests = oldRequests.Select(r => new Request { Id = r.Id, Barcode = r.Id, ExternalId = r.Id, ProtectionDocTypeId = _dictionaryTypesService.MapOldRequestTypeToProtectionDocType(r.DocTypeId, _protectionDocTypes), DateCreate = r.DateCreate ?? DateTimeOffset.Now, DateUpdate = r.DateUpdate ?? DateTimeOffset.Now, AddresseeId = r.CustomerId, CopyCount = r.CopyCount, PageCount = r.PageCount, DepartmentId = r.DepartmentId, RequestNum = r.DocNum, RequestDate = r.DocDate, OutgoingNumber = r.OutNum, IncomingNumber = r.InOutNum, NameRu = r.DescMlRu, NameEn = r.DescMlEn, NameKz = r.DescMlKz, DivisionId = r.DivisionId, FlDivisionId = r.FlDivisionId, UserId = r.UserId, ReceiveTypeId = r.SendType, IncomingNumberFilial = r.InNumAdd, IsComplete = CustomConverter.StringToBool(r.IsComplete), IsDeleted = false, StatusId = r.Patent?.StatusId, ConventionTypeId = r.Patent?.TypeIiId, SelectionFamily = r.Patent?.SelectionFamily, Referat = r.Patent?.Ref57, Transliteration = r.Patent?.Transliteration, NumberBulletin = r.Patent?.NBy, DisclaimerRu = r.Patent?.DisclamRu, DisclaimerKz = r.Patent?.DisclamKz, TransferDate = r.Patent?.Date85, Image = r.Patent?.Image, PreviewImage = r.Patent?.SysImageSmall, IsImageFromName = false }).ToList(); return(requests); }
public void ReturnsValueTimesTen() { // Arrange var number = "3"; // Act var result = CustomConverter.GetIntTimesTenOrDefault(number); // Assert Assert.Equal(30, result); }
public void NullReturnsProhibited() { var db = FirestoreDb.Create("proj", "db", new FakeFirestoreClient()); var converter = CustomConverter.ForConverterType(typeof(NullReturningConverter), typeof(string)); Assert.Throws <InvalidOperationException>(() => converter.Serialize("")); Assert.Throws <InvalidOperationException>(() => converter.SerializeMap("", new Dictionary <string, Value>())); Assert.Throws <InvalidOperationException>(() => converter.DeserializeValue(db, new Value { StringValue = "" })); Assert.Throws <InvalidOperationException>(() => converter.DeserializeMap(db, new Dictionary <string, Value>())); }
private void LoadScript() { if (listBoxGuids.SelectedItem == null) { return; } ((MainForm)Owner).userControl.textBoxEntryOrGuid.Text = (-CustomConverter.ToInt32(listBoxGuids.SelectedItem.ToString())).ToString(); ((MainForm)Owner).userControl.comboBoxSourceType.SelectedIndex = (int)SourceTypes.SourceTypeCreature; ((MainForm)Owner).userControl.TryToLoadScript(); Close(); }
[Test] public void CustomTypeIsComposed() { var converter = new CustomConverter(); Tree <string> composeResult = null; Assert.IsTrue(converter.TryCompose(processor, new TypedValue(new CustomClass { Info = "stuff" }), ref composeResult)); var result = composeResult.Value; Assert.IsNotNull(result); Assert.AreEqual("mystuff", result); }
/// <summary> /// /// </summary> public MifareUltralightSetupViewModel() { MefHelper.Instance.Container.ComposeParts(this); //Load Plugins chipModel = new MifareUltralightChipModel(string.Format("Task Description: {0}", SelectedTaskDescription), CARD_TYPE.MifareUltralight); childNodeViewModelFromChip = new RFiDChipChildLayerViewModel(pageModel, null, CARD_TYPE.MifareUltralight, null, true); childNodeViewModelTemp = new RFiDChipChildLayerViewModel(pageModel, null, CARD_TYPE.MifareUltralight, null, true); MifareUltralightPages = CustomConverter.GenerateStringSequence(0, 15).ToArray(); SelectedUltralightPageCurrent = "0"; }
[Test] public void CustomTypeIsParsed() { var converter = new CustomConverter { Processor = processor }; Assert.IsTrue(converter.CanParse(typeof(CustomClass), TypedValue.Void, new TreeList <string>("info"))); TypedValue parseResult = converter.Parse(typeof(CustomClass), TypedValue.Void, new TreeList <string>("info")); var result = parseResult.Value as CustomClass; Assert.IsNotNull(result); Assert.AreEqual("custominfo", result.Info); }
public void ChangeTypeUsesFrameworkForNonRegisteredType() { var mockFactory = new Mock<ICustomConverterFactory>(); mockFactory.Setup(x => x.GetConverter(typeof(CustomConverterTests))) .Returns<Func<object, object>>(null); var target = new CustomConverter(mockFactory.Object); var result = target.ChangeType("42", typeof(int)); Assert.IsNotNull(result); Assert.IsInstanceOf<int>(result); Assert.AreEqual(42, result); }
public List <RouteStageOrder> GetRouteStageOrders() { var stageOrders = _context.RfStageNexts.AsNoTracking().OrderBy(s => s.Id).ToList(); return(stageOrders.Select(s => new RouteStageOrder { Id = s.Id, CurrentStageId = s.StageId, NextStageId = s.NextStageId, IsAutomatic = CustomConverter.StringToBool(s.IsAutomatic), IsParallel = CustomConverter.StringToBool(s.IsParallel), IsReturn = CustomConverter.StringToBool(s.IsReturn), }).ToList()); }
public CustomMultiValueFilter() { InitializeComponent(); IsSetFilter = true; IsFilterItemChangedFire = true; CustomConverter converter = new CustomConverter( (v, t, p, c) => { if (v != null) { if ((v as ObservableCollection <FilterItem>).All(x => x.IsChecked)) { return(true); } else if ((v as ObservableCollection <FilterItem>).All(x => x.IsChecked == false)) { return(false); } else { return(null); } } return(null); }, (v, t, p, c) => { if (v != null) { bool newValue = (bool)v; foreach (var item in ItemsSource) { IsFilterItemChangedFire = false; item.IsChecked = newValue; IsFilterItemChangedFire = true; } } return(ItemsSource); }); this.SetBinding(CustomMultiValueFilter.SelectAllProperty, new Binding("ItemsSource") { Source = this, Converter = converter, Mode = BindingMode.TwoWay }); }
public List <DocumentDocumentRelation> GetDocumentDocumentRelations(int packageSize, int lastId) { var documentTypeIds = _dictionaryTypesHelper.GetDocumentTypeIds(); var oldDocumentDocumentRelations = _context.RFMessageDocuments .AsNoTracking() .Where(r => r.Id > lastId && r.RefDocumentId > 0 && r.DocumentId > 0 && documentTypeIds.Contains(r.DDDocument.DocTypeId) && documentTypeIds.Contains(r.RefDDDocument.DocTypeId)) .OrderBy(r => r.Id) .Take(packageSize) .ToList(); var documentDocumentRelations = new List <DocumentDocumentRelation>(); //var newContract = _newContext.Documents.Where(d => oldDocumentDocumentRelations.Any(c => c.DocumentId.Value == d.Id)).Select(d => d.Id); //foreach (var oldDocumentDocumentRelation in oldDocumentDocumentRelations.Where(d => newContract.Contains(d.DocumentId.Value))) foreach (var oldDocumentDocumentRelation in oldDocumentDocumentRelations) { if (!documentDocumentRelations.Any(r => r.ChildId == oldDocumentDocumentRelation.RefDocumentId && r.ParentId == oldDocumentDocumentRelation.DocumentId.Value)) { documentDocumentRelations.Add(new DocumentDocumentRelation { ExternalId = oldDocumentDocumentRelation.Id, DateCreate = oldDocumentDocumentRelation.DateCreate ?? DateTimeOffset.Now, DateUpdate = oldDocumentDocumentRelation.DateCreate ?? DateTimeOffset.Now, ParentId = oldDocumentDocumentRelation.DocumentId.Value, ChildId = oldDocumentDocumentRelation.RefDocumentId, IsAnswer = CustomConverter.StringToNullableBool(oldDocumentDocumentRelation.IsAnswer) }); } } return(documentDocumentRelations); /*return documentDocumentRelations.Select(r => new DocumentDocumentRelation * { * Id = r.Id, * ExternalId = r.Id, * DateCreate = r.DateCreate ?? DateTimeOffset.Now, * DateUpdate = r.DateCreate ?? DateTimeOffset.Now, * ParentId = r.DocumentId.Value, * ChildId = r.RefDocumentId, * IsAnswer = CustomConverter.StringToNullableBool(r.IsAnswer) * }).ToList();*/ }
public void ChangeTypeCallsConverterForRegisteredType() { Func<object, object> converter = x => "Hello World!"; var mockFactory = new Mock<ICustomConverterFactory>(); mockFactory.Setup(x => x.GetConverter(typeof(string))) .Returns(converter); var target = new CustomConverter(mockFactory.Object); var result = target.ChangeType("any value", typeof (string)); Assert.IsNotNull(result); Assert.AreEqual("Hello World!", result); }
private async void buttonSearchForWorldDb_Click(object sender, EventArgs e) { buttonSearchForWorldDb.Enabled = false; WorldDatabase worldDatabase = new WorldDatabase(textBoxHost.Text, CustomConverter.ToUInt32(textBoxPort.Text), textBoxUsername.Text, textBoxPassword.Text, ""); List <string> databaseNames = await SAI_Editor_Manager.Instance.GetDatabasesInConnection(textBoxHost.Text, textBoxUsername.Text, CustomConverter.ToUInt32(textBoxPort.Text), textBoxPassword.Text, worldDatabase); if (databaseNames != null && databaseNames.Count > 0) { using (var selectDatabaseForm = new SelectDatabaseForm(databaseNames, textBoxWorldDatabase)) selectDatabaseForm.ShowDialog(this); } buttonSearchForWorldDb.Enabled = true; }
private TargetTypeInformation BuildTargetTypeInformation(DataRow row) { var targetTypeInformation = new TargetTypeInformation { target_type = row["target_type"] != DBNull.Value ? CustomConverter.ToInt32(row["target_type"]) : -1, tooltip = row["tooltip"] != DBNull.Value ? (string)row["tooltip"] : String.Empty, parameterString1 = row["parameterString1"] != DBNull.Value ? (string)row["parameterString1"] : "Unused Parameter", parameterString2 = row["parameterString2"] != DBNull.Value ? (string)row["parameterString2"] : "Unused Parameter", parameterString3 = row["parameterString3"] != DBNull.Value ? (string)row["parameterString3"] : "Unused Parameter", parameterTooltip1 = row["parameterTooltip1"] != DBNull.Value ? (string)row["parameterTooltip1"] : String.Empty, parameterTooltip2 = row["parameterTooltip2"] != DBNull.Value ? (string)row["parameterTooltip2"] : String.Empty, parameterTooltip3 = row["parameterTooltip3"] != DBNull.Value ? (string)row["parameterTooltip3"] : String.Empty }; return(targetTypeInformation); }
public List <IPCRequest> GetIPCRequests(List <int> requestIds) { var ipcRequests = _context.RfIpcs .AsNoTracking() .Where(i => requestIds.Contains(i.PATENT_ID)) .OrderBy(i => i.U_ID) .ToList(); return(ipcRequests.Select(i => new IPCRequest { Id = i.U_ID, RequestId = i.PATENT_ID, IpcId = i.TYPE_ID, IsMain = CustomConverter.StringToNullableBool(i.flIsMain) ?? false }).ToList()); }