private void SendComplete(uint send_size) { var next_data = (byte[])null; if (send_data_.Length > send_size) { send_data_ = ClassUtil.CloneCopy(send_data_, (int)send_size); next_data = ClassUtil.CloneCopy(send_data_, (int)send_size, int.MaxValue); } /* 送信が完了したデータのみを通知 */ NotifySendComplete("", "", "", send_data_); /* 未送信データを送信データにセット */ send_data_ = next_data; /* 送信遅延を設定 */ send_wait_time_ = (uint)((send_data_ != null) ? (prop_.SendByteWaitTimer.Value) : (prop_.SendPacketWaitTimer.Value)); if (send_wait_time_ > 0) { send_wait_timer_.Restart(); } }
private T Wrap(object element) { BareANY bareAny = (BareANY)ClassUtil.NewInstance(originalElementType); ((BareANYImpl)bareAny).BareValue = element; return((T)bareAny); }
protected byte[] GetSendData() { /* 送信データ準備 */ LoadSendBuffer(); lock (send_data_sync_) { /* 送信データが存在しないときは終了 */ if (send_data_busy_ == null) { return(null); } var send_data = (byte[])null; if (send_data_offset_ == 0) { /* 送信バッファを全てセットするのでオブジェクトをそのまま流用 */ send_data = send_data_busy_; } else { /* 送信バッファの途中から適用するのでバッファを用意 */ send_data = ClassUtil.CloneCopy(send_data_busy_, send_data_offset_, send_data_busy_.Length); } /* 送信バッファをクリア */ send_data_busy_ = null; send_data_offset_ = 0; DebugManager.MessageOut(DebugMessageSender.Device, DebugMessageType.SendEvent, "DeviceInstance.GetSendData"); return(send_data); } }
public void ChangeDevice(GateProperty gatep, DeviceConfig devconf, Guid devc_id, DeviceProperty devp) { if (gatep != null) { gatep_ = gatep; } if (devconf != null) { devconf_ = devconf; } /* いずれかの状態が変化したらデバイスを再構築 */ if ((devi_ == null) || (devc_id != devi_.Class.ID) || (!ClassUtil.Compare(devi_.Config, devconf)) || (!ClassUtil.Compare(devi_.Property, devp)) ) { SetupDevice(DeviceManager.Instance.CreateDeviceObject(devconf, devc_id, devp)); } ApplyGateProperty(); /* 接続コマンドを再構築 */ connect_command_ = HexTextEncoder.ToByteArray(gatep_.ConnectCommand); }
public void Load(SystemConfig sys_conf, UserConfig user_conf, LanguageConfig lang_conf) { AutoTimeStampTrigger = sys_conf.AutoTimeStamp.Trigger.Value; AutoTimeStampValue_LastRecvPeriod = sys_conf.AutoTimeStamp.Value_LastRecvPeriod.Value; AutoSaveDirectory = sys_conf.AutoPacketSave.SaveDirectory.Value; AutoSavePrefix = sys_conf.AutoPacketSave.SavePrefix.Value; AutoSaveFormat = sys_conf.AutoPacketSave.SaveFormat.Value; AutoSaveTarget = sys_conf.AutoPacketSave.SaveTarget.Value; AutoSaveTimming = sys_conf.AutoPacketSave.SaveTimming.Value; AutoSaveValue_Interval = sys_conf.AutoPacketSave.SaveValue_Interval.Value; AutoSaveValue_FileSize = sys_conf.AutoPacketSave.SaveValue_FileSize.Value; AutoSaveValue_PacketCount = sys_conf.AutoPacketSave.SaveValue_PacketCount.Value; RawPacketCountLimit = sys_conf.ApplicationCore.RawPacketCountLimit.Value; Packet_ViewPacketCountLimit = sys_conf.ApplicationCore.Packet_ViewPacketCountLimit.Value; Packet_MsgColor = user_conf.PacketView_Packet_MsgColor.Value; Packet_RecvColor = user_conf.PacketView_Packet_RecvColor.Value; Packet_SendColor = user_conf.PacketView_Packet_SendColor.Value; Sequential_WinApiMode = sys_conf.ApplicationCore.Sequential_WinApiMode.Value; Sequential_ViewCharCountLimitEnable = sys_conf.ApplicationCore.Sequential_ViewCharCountLimitEnable.Value; Sequential_ViewCharCountLimit = sys_conf.ApplicationCore.Sequential_ViewCharCountLimit.Value; Sequential_LineNoVisible = sys_conf.ApplicationCore.Sequential_LineNoVisible.Value; MailList.Clear(); foreach (var config in sys_conf.MailList.Value) { MailList.Add(ClassUtil.Clone(config)); } }
public void Backup(SystemConfig sys_conf, UserConfig user_conf, LanguageConfig lang_conf) { sys_conf.AutoTimeStamp.Trigger.Value = AutoTimeStampTrigger; sys_conf.AutoTimeStamp.Value_LastRecvPeriod.Value = AutoTimeStampValue_LastRecvPeriod; sys_conf.AutoPacketSave.SaveDirectory.Value = AutoSaveDirectory; sys_conf.AutoPacketSave.SavePrefix.Value = AutoSavePrefix; sys_conf.AutoPacketSave.SaveFormat.Value = AutoSaveFormat; sys_conf.AutoPacketSave.SaveTarget.Value = AutoSaveTarget; sys_conf.AutoPacketSave.SaveTimming.Value = AutoSaveTimming; sys_conf.AutoPacketSave.SaveValue_Interval.Value = AutoSaveValue_Interval; sys_conf.AutoPacketSave.SaveValue_FileSize.Value = AutoSaveValue_FileSize; sys_conf.AutoPacketSave.SaveValue_PacketCount.Value = AutoSaveValue_PacketCount; sys_conf.ApplicationCore.RawPacketCountLimit.Value = RawPacketCountLimit; sys_conf.ApplicationCore.Packet_ViewPacketCountLimit.Value = Packet_ViewPacketCountLimit; user_conf.PacketView_Packet_MsgColor.Value = Packet_MsgColor; user_conf.PacketView_Packet_RecvColor.Value = Packet_RecvColor; user_conf.PacketView_Packet_SendColor.Value = Packet_SendColor; sys_conf.ApplicationCore.Sequential_WinApiMode.Value = Sequential_WinApiMode; sys_conf.ApplicationCore.Sequential_ViewCharCountLimitEnable.Value = Sequential_ViewCharCountLimitEnable; sys_conf.ApplicationCore.Sequential_ViewCharCountLimit.Value = Sequential_ViewCharCountLimit; sys_conf.ApplicationCore.Sequential_LineNoVisible.Value = Sequential_LineNoVisible; sys_conf.MailList.Value.Clear(); foreach (var config in MailList) { sys_conf.MailList.Value.Add(ClassUtil.Clone(config)); } }
private void DataOutputExec() { var read_size = 0; while ((!play_complete_) && (read_size < sampling_buffer_.Length)) { read_size += resampler_.Read(sampling_buffer_, read_size, sampling_buffer_.Length - read_size); /* データバッファが一杯にならないときは最初から読み込む */ if (read_size < sampling_buffer_.Length) { if ((devp_.RepeatCount.Value == 0) || ((repeat_count_ + 1) < devp_.RepeatCount.Value)) { /* 繰り返し設定が有効かつ繰り返しが可能のとき */ reader_.Position = 0; repeat_count_++; } else { /* 再生終了 */ play_complete_ = true; } } } if (read_size > 0) { /* データ出力 */ NotifyRecvComplete( "", "", "", (read_size < sampling_buffer_.Length) ? (ClassUtil.CloneCopy(sampling_buffer_, 0, read_size)) : (sampling_buffer_)); } }
/// <summary>Instantiate a bean that models the part under question.</summary> /// <remarks>Instantiate a bean that models the part under question.</remarks> /// <param name="version">- the version code</param> /// <param name="type">- the part type</param> /// <returns>an instance of a bean that represents the part type</returns> public virtual object InstantiateMessagePartBean(VersionNumber version, string type, Interaction interaction) { try { Type partClass = MessageBeanRegistry.GetInstance().GetMessagePartClass(version, type); if (partClass == null) { throw CreateMarshallingException("Did not find", version, type); } else { if (!ClassUtil.IsGeneric(partClass)) { this.log.Debug("Instantiating bean: " + partClass.FullName); return(System.Activator.CreateInstance(partClass)); } else { this.log.Debug("Instantiating parameterized bean: " + partClass.FullName); return(GenericClassUtil.Instantiate(partClass, CreateParameterMap(interaction, version))); } } } catch (MemberAccessException e) { throw CreateMarshallingException("Error instantiating", version, type, e); } catch (Exception e) { throw CreateMarshallingException("Error instantiating", version, type, e); } }
/// <summary> /// /// </summary> /// <typeparam name="TSource"></typeparam> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <param name="exp"></param> /// <param name="optor"></param> /// <param name="dao"></param> /// <param name="conn"></param> /// <param name="trns"></param> /// <returns></returns> private static T QueryAggregate <TSource, T>( TSource model, Expression <Func <TSource, T> > exp, string optor, IDBUtil dao, DbConnection conn = null, DbTransaction trns = null) where TSource : IDBEntity { //要查詢的欄位 string propName = ((MemberExpression)exp.Body).Member.Name; //處理 where 參數 var whereParams = prepareWhereParams(model.GetOperating().WHERE_LIST); var selectColumns = new List <string>(); selectColumns.Add(optor + "(" + propName + ") AS result"); //查詢 var resultList = dao.QueryByTable(model.GetTableName(), selectColumns, whereParams, conn, trns); if (resultList != null && resultList.Count > 0 && !DBNull.Value.Equals(resultList[0]["result"])) { Func <object, object> converter = ClassUtil.GetConvertFuncMap()[typeof(T)]; return((T)converter(resultList[0].SafeGetValue("result"))); } return(default(T)); }
private void SendTaskComplete(IAsyncResult ar) { if (!debug_flag) { var i = 0; } try { if (ar.AsyncState is System.Net.Sockets.UdpClient udp_client) { /* 送信処理完了 */ var send_complete_size = udp_client.EndSend(ar); var send_complete_data = send_data_; if (send_complete_size >= send_data_.Length) { /* 要求した送信データの全送信完了 */ send_data_ = null; } else { /* 要求した送信データの一部のみ送信完了 */ send_complete_data = ClassUtil.CloneCopy(send_data_, send_complete_size); send_data_ = ClassUtil.CloneCopy(send_data_, send_complete_size, send_data_.Length); } /* 送信完了通知(バッファへのセットアップが完了したときに通知する場合) */ // NotifySendComplete("", local_ep_text_, remote_ep_text_, send_complete_data); } } catch { } debug_flag = false; send_task_busy_ = false; }
private void SetValue(BeanProperty property, object value) { if (value == null) { } else { // do nothing if (typeof(ICollection <object>).IsAssignableFrom(value.GetType()) && property.Collection) { foreach (object o in ((ICollection <object>)value)) { Type clazz = GenericClassUtil.GetCollectionContentsType(property); if (clazz == null || clazz.IsAssignableFrom(o.GetType())) { ((ICollection <object>)property.Get()).Add(o); } else { object newInstance = ClassUtil.NewInstance(clazz); AssignAllDefaults(newInstance, o); ((ICollection <object>)property.Get()).Add(newInstance); } } } else { if (property.Collection) { ((ICollection <object>)property.Get()).Add(value); } else { if (typeof(ICollection <object>).IsAssignableFrom(value.GetType())) { foreach (object o in ((ICollection <object>)value)) { property.Set(o); } } else { if (!IsStandardDataType(property)) { CreateBeanInstanceForProperty(property); AssignAllDefaults(property.Get(), value); } else { if (property.Writable) { property.Set(value); } } } } } } }
/// <summary> /// 创建请求表单 /// </summary> /// <returns></returns> public RequestForm CreateRequestForm() { Dictionary <string, object> dict = ClassUtil.ConvertObjectToDictionary(this); RequestForm requestForm = new RequestForm(dict); requestForm.Files = this.files; return(requestForm); }
public IDictionary <Type, Func <object, object> > GetConvertFuncMap() { if (ConvertFuncMap == null) { ConvertFuncMap = ClassUtil.GetConvertFuncMap(); } return(ConvertFuncMap); }
public void CreateListInstance_Return_Valid_Result() { List <Exception> obj = null; Assert.That(() => obj = ClassUtil.CreateListInstance <Exception>(), Throws.Nothing); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.TypeOf <List <Exception> >()); }
public void CreateDictionaryInstance_Return_Valid_Result() { Dictionary <string, Exception> obj = null; Assert.That(() => obj = ClassUtil.CreateDictionaryInstance <string, Exception>(), Throws.Nothing); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.TypeOf <Dictionary <string, Exception> >()); }
public IActionResult Load() { try { var draw = HttpContext.Request.Form["draw"].FirstOrDefault(); // Skiping number of Rows count var start = Request.Form["start"].FirstOrDefault(); // Paging Length 10,20 var length = Request.Form["length"].FirstOrDefault(); // Sort Column Name var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault(); // Sort Column Direction ( asc ,desc) var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault(); // Search Value from (Search box) var searchValue = Request.Form["search[value]"].FirstOrDefault().ToLower(); //Paging Size (10,20,50,100) int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; // Getting all Customer data var times = _timeAppService.GetAll(); var result = times.Select(x => TimeViewModel.ToViewModel(x)); var customerData = result; sortColumn = sortColumn.Equals("Id") || string.IsNullOrEmpty(sortColumn) ? "Nome" : sortColumn; var prop = ClassUtil.GetProperty <TimeViewModel>(sortColumn); if (sortColumnDirection == "asc") { customerData = customerData.OrderBy(prop.GetValue); } else { customerData = customerData.OrderByDescending(prop.GetValue); } //Search if (!string.IsNullOrEmpty(searchValue)) { customerData = customerData.Where(m => m.Nome.ToLower().Contains(searchValue) || m.Sigla.ToLower().Contains(searchValue)); } //total number of rows count recordsTotal = customerData.Count(); //Paging var data = customerData.Skip(skip).Take(pageSize).ToList(); //Returning Json Data return(Json(new { draw, recordsFiltered = recordsTotal, recordsTotal, data })); } catch (Exception) { throw; } }
public void CreateInstance_By_Type_Return_Valid_Result() { Type type = typeof(Exception); Exception obj = null; Assert.That(() => obj = (Exception)ClassUtil.CreateInstance(type), Throws.Nothing); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.TypeOf(type)); }
public override bool Equals(object obj) { if (obj is DeviceConfig obj_c) { return(ClassUtil.Compare(this, obj_c)); } return(base.Equals(obj)); }
public override void PerformSetup(Context context, IState previousState) { base.PerformSetup(context, previousState); // Generate Calamity EnemyDefinition calamityType = HackUtil.GetRandomCalamityClass(); _calamity = ClassUtil.CreateCharacter( calamityType.Id, (uint)Guid.NewGuid().GetHashCode(), calamityType.NameGenerator.GetName(), calamityType.CharacterClass, 30u); // Generate Potential Party Members uint partyId = (uint)NewPartyGuid.GetHashCode(); for (int i = 0; i < 5; i++) { uint id = (uint)(i + 1); PlayerClassDefinition randomClass = HackUtil.GetRandomPlayerClass(); string randomName = randomClass.NameGenerator.GetName(); PlayerCharacter playerCharacter = ClassUtil.CreatePlayerCharacter(id, partyId, randomName, randomClass.PlayerClass); _generatedCharacters.Add(playerCharacter); } // Generate (Unequipped) Starting Equipment int weaponCount = RANDOM.Next(3); for (int i = 0; i < weaponCount; i++) { if (HackUtil.GetRandomWeapon() is var newWeapon) { _generatedInventory.Add(newWeapon.Item); } } int armorCount = RANDOM.Next(3); for (int i = 0; i < armorCount; i++) { if (HackUtil.GetRandomArmor() is var newArmor) { _generatedInventory.Add(newArmor.Item); } } int itemCount = RANDOM.Next(5); for (int i = 0; i < itemCount; i++) { if (HackUtil.GetRandomItem() is var newItem) { _generatedInventory.Add(newItem.Item); } } }
public void ClassUtil_BuildGenericTypeInstance() { var obj = ClassUtil.BuildGenericTypeInstance(typeof(ClassUtilTest <>), typeof(string)); Assert.IsTrue(obj is ClassUtilTest <string>); obj = ClassUtil.BuildGenericTypeInstance(typeof(ClassUtilTest <>), new Type[] { typeof(string) }, "abc"); Assert.IsTrue(obj is ClassUtilTest <string>); }
public void CreateListInstance_By_Type_Return_Valid_Result() { Type type = typeof(Exception); Type expectedType = typeof(List <Exception>); List <Exception> obj = null; Assert.That(() => obj = (List <Exception>)ClassUtil.CreateListInstance(type), Throws.Nothing); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.TypeOf(expectedType)); }
/// <summary> /// 允许删除的判断标注; /// </summary> /// <param name="relateType"></param> /// <param name="propertyName"></param> public AllowDeleteAttribute(Type relateType, string propertyName) { this.relateType = relateType; this.propertyName = propertyName; if (propertyName == null) { } allowDelete = ClassUtil.BuildGenericTypeInstance(typeof(GenericAllowDelete <>), new Type[] { relateType }, propertyName) as IAllowDelete; }
public override void OnInputPacket(PacketObject input, ref List <PacketObject> output) { /* パケットを複製 */ var packet = ClassUtil.Clone(input); /* パラメータを変更 */ packet.Alias = value_; output.Add(packet); }
private bool IsCycleFree(ClassNode parent, ClassNode node) { if (ClassUtil.IsCyclicIfClassIsAccessibleFromParent(parent, node, CurrentProject.Classes)) { MessageBox.Show("Invalid operation because this would create a class cycle.", "Cycle Detected", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }
public void CreateDictionaryInstance_By_Type_Return_Valid_Result() { Type keyType = typeof(string); Type valueType = typeof(Exception); Type expectedType = typeof(Dictionary <string, Exception>); Dictionary <string, Exception> obj = null; Assert.That(() => obj = (Dictionary <string, Exception>)ClassUtil.CreateDictionaryInstance(keyType, valueType), Throws.Nothing); Assert.That(obj, Is.Not.Null); Assert.That(obj, Is.TypeOf(expectedType)); }
public byte[] GetBytes() { if (data_buffer_.Length == data_size_) { return(data_buffer_); } else { return(ClassUtil.CloneCopy(data_buffer_, data_size_)); } }
protected override void SetupProperty(Type beanType, IDatabaseMetaData dbMetaData, IDbms dbms) { if (!IsEntity(beanType)) { base.SetupProperty(beanType, dbMetaData, dbms); return; } Entity entity = (Entity)ClassUtil.NewInstance(beanType); DBMeta dbmeta = entity.DBMeta; foreach (PropertyInfo pi in beanType.GetProperties()) { IPropertyType pt = null; RelnoAttribute relnoAttr = _beanAnnotationReader.GetRelnoAttribute(pi); if (relnoAttr != null) { if (!_relation) { IRelationPropertyType rpt = CreateRelationPropertyType(beanType, pi, relnoAttr, dbMetaData, dbms); AddRelationPropertyType(rpt); } } else { if (pi.CanWrite) { pt = CreatePropertyTypeExtension(pi, dbmeta); if (pt != null) { AddPropertyType(pt); if (pt.IsPrimaryKey) { _primaryKeyList.add(pt); } } } } if (IdentifierGenerator == null) { IDAttribute idAttr = _beanAnnotationReader.GetIdAttribute(pi, dbms); if (idAttr != null) { _identifierGenerator = Seasar.Dao.Id.IdentifierGeneratorFactory.CreateIdentifierGenerator(pi.Name, dbms, idAttr); if (pt != null) { _primaryKeys = new string[] { pt.ColumnName }; pt.IsPrimaryKey = true; } } } } }
public Universe BuildUniverse() { Universe result = new Universe() { Name = "universe 1" }; List <SolarSystem> solarSystems = new List <SolarSystem>(); using (var db = new ASPNetOgameLikeTPContext()) { for (int i = 1; i < this.globalGameConfiguration.SolarSystemNb + 1; i++) { SolarSystem solarSystem = new SolarSystem(); for (int j = 1; j < this.globalGameConfiguration.PlanetsNb + 1; j++) { Planet planet = new Planet(); foreach (var item in this.globalPlanetConfiguration.BuildingsIds) { ResourceGenerator buildingTemp = ConfigurationsUtil.Instance.PlanetResourceGenerators(globalPlanetConfiguration).FirstOrDefault(x => x.Id == item); buildingTemp.Print = DEFAULT_DISPLAY_RESOURCE; buildingTemp.Id = null; planet.Buildings.Add(ClassUtil.Copy(buildingTemp)); } foreach (var item in this.globalPlanetConfiguration.ResourcesIds) { Resource resourceTemp = ConfigurationsUtil.Instance.PlanetResources(globalPlanetConfiguration).FirstOrDefault(x => x.Id == item); resourceTemp.LastUpdate = DateTime.Now; resourceTemp.LastQuantity = 0; resourceTemp.Print = DEFAULT_DISPLAY_RESOURCE; resourceTemp.Id = null; planet.Resources.Add(ClassUtil.Copy(resourceTemp)); } planet.CaseNb = MathUtil.DrawRandom(20 * j % 300, 30 * j % 300); planet.Name = $"Planet{j}"; planet.Print = DEFAULT_DISPLAY_RESOURCE; solarSystem.Planets.Add(planet); } solarSystem.Name = "système solaire " + i; solarSystems.Add(solarSystem); } } result.SolarSystems.AddRange(solarSystems); return(result); }
public ProcessMsg ExportTraySumPartCSV(List <string> trayIds, string filename, List <string> fieldNames) { ProcessMsg msg = new ProcessMsg() { result = false }; try { List <TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(trayIds); // List<TrayPackView> ts = tpv.ToList(); List <string> updateTrayIds = new List <string>(); CSVDataSet ds = new CSVDataSet(); foreach (TrayPackView v in tpv) { CSVDataRecord r = new CSVDataRecord(); List <string> values = ClassUtil.GetModelValues(fieldNames, v); if (values != null) { foreach (string value in values) { r.Add(value); } } //r.Add(v.partNr); //r.Add(v.capa.ToString()); if (TrayPackStatusHelper.CanAddPrefix(v.tstatus)) { r.Add(v.TsStatusCN); } ds.Add(r); if (TrayPackStatusHelper.CanUpdateToExported(v.tstatus)) { updateTrayIds.Add(v.trayId); } } CSVUtil.GenCSVFile(ds, filename); if (updateTrayIds.Count > 0) { TraysHelper.UpdateTraysStatus(updateTrayIds, TrayStatus.Exported); } msg.result = true; msg.AddMessage(ReturnCode.OK, "成功导出CSV文件"); } catch (Exception e) { msg.AddMessage(ReturnCode.Error, e.Message); } return(msg); }
/// <summary> /// Map mutable properties that contains certain keyword in its description to a dictionary /// </summary> /// <param name="keyWord">certain description</param> /// <returns>properties info</returns> public Dictionary <string, Alignment> MapMutablePropertiesWithKeyword(string keyWord) { Dictionary <string, string> properties = ClassUtil.ToStringMap(this, keyWord); Dictionary <string, Alignment> mutableValue = new Dictionary <string, Alignment>(); if (properties.Count > 0) { foreach (KeyValuePair <string, string> item in properties) { mutableValue.Add(item.Value, titleAlignment); } } return(mutableValue); }