/// <summary> /// Extracts coefficient of a quadratic formula to compute /// the energy consumed per second by a processor. /// </summary> /// <returns> /// Coefficients of a quadratic formula /// </returns> /// <param name="configFileContent">Content of a configuration file</param> public static List <float> GetCoefficients(string configFileContent) { Regex coefficientsRx = new Regex($@"COEFFICIENT-ID,VALUE(?:{FileParser.NewLineRx})(?:\s*\d+,(-?\d+(?:\.?\d+)?)(?:{FileParser.NewLineRx})?)+"); List <string> coefficients = FileParser.GetCaptureValues(configFileContent, coefficientsRx); return(ListConverter.StringToFloat(coefficients)); }
public static System.Collections.Generic.List <Dynamic.Tekla.Structures.Model.PointCloud> GetPointClouds() { var result = MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.PointCloud", "GetPointClouds"); var _result = ListConverter.FromTSObjects <Dynamic.Tekla.Structures.Model.PointCloud>(result); return(_result); }
private void SelectBedConsumtion() { try { BedConsumtionBLL consume = new BedConsumtionBLL(); List <STP_AdmitedPatientListReportResult> lst = consume.AdmitedPatientListReport(Convert.ToDateTime(txtBillDate.Text), Convert.ToDateTime(txtToDate.Text)); if (lst != null) { lbl.Text = "Admited Patient List Report"; lblFrom.Text = txtBillDate.Text; lblTo.Text = txtToDate.Text; DataTable dt = ListConverter.ToDataTable(lst); dt.Columns.Add("colSrNo"); DataColumn dcol = new DataColumn(); if (dt.Rows.Count > 0) { int count = 1; foreach (DataRow dr in dt.Rows) { dr["colSrNo"] = count; count++; } } dgvTestParameter.DataSource = dt; dgvTestParameter.DataBind(); Session["BedConsump"] = dt; } } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void SelectOutstandingReport() { try { OutstandingBLL consume = new OutstandingBLL(); List <STP_OutstandingReportResult> lst = consume.SearchOutstanding(Convert.ToDateTime(txtBillDate.Text), Convert.ToDateTime(txtToDate.Text)); if (lst != null) { lbl.Text = "Outstanding Report"; lblFrom.Text = txtBillDate.Text; lblTo.Text = txtToDate.Text; DataTable dt = ListConverter.ToDataTable(lst); dt.Columns.Add("colSrNo"); DataColumn dcol = new DataColumn(); if (dt.Rows.Count > 0) { int count = 1; foreach (DataRow dr in dt.Rows) { dr["colSrNo"] = count; count++; } } dgvTestParameter.DataSource = dt; dgvTestParameter.DataBind(); Session["OutstandingReport"] = dt; //txtBillDate.Text = string.Empty; //txtToDate.Text = string.Empty; } } catch (Exception ex) { lblMessage.Text = ex.Message; } }
static Converter() { IsSealed = typeof(T).GetTypeInfo().IsSealed || typeof(T) == typeof(Type); (WriteAction, ReadAction) = typeof(T) switch { Type type when type == typeof(Type) => TypeConverter.GetActions <T>(), Type type when type.IsAbstract() => (null, null), Type type when type.IsArray => ArrayConverter.GetActions <T>(), Type type when type.IsList() => ListConverter.GetActions <T>(), Type type when type.IsDictionary() => DictionaryConverter.GetActions <T>(), Type type when type.IsEnum() => EnumConverter.GetActions <T>(), Type type when type == typeof(char) => GetActions((StreamWriterWrapper w, in char v) => w.Stream.WriteLine(v), s => s[0]), Type type when type == typeof(bool) => GetActions((StreamWriterWrapper w, in bool v) => w.Stream.WriteLine(v), bool.Parse), Type type when type == typeof(sbyte) => GetActions((StreamWriterWrapper w, in sbyte v) => w.Stream.WriteLine(v), i => sbyte.Parse(i)), Type type when type == typeof(byte) => GetActions((StreamWriterWrapper w, in byte v) => w.Stream.WriteLine(v), i => byte.Parse(i)), Type type when type == typeof(short) => GetActions((StreamWriterWrapper w, in short v) => w.Stream.WriteLine(v), i => short.Parse(i)), Type type when type == typeof(ushort) => GetActions((StreamWriterWrapper w, in ushort v) => w.Stream.WriteLine(v), i => ushort.Parse(i)), Type type when type == typeof(int) => GetActions((StreamWriterWrapper w, in int v) => w.Stream.WriteLine(v), i => int.Parse(i)), Type type when type == typeof(uint) => GetActions((StreamWriterWrapper w, in uint v) => w.Stream.WriteLine(v), i => uint.Parse(i)), Type type when type == typeof(long) => GetActions((StreamWriterWrapper w, in long v) => w.Stream.WriteLine(v), i => long.Parse(i)), Type type when type == typeof(ulong) => GetActions((StreamWriterWrapper w, in ulong v) => w.Stream.WriteLine(v), i => ulong.Parse(i)), Type type when type == typeof(decimal) => GetActions((StreamWriterWrapper w, in decimal v) => w.Stream.WriteLine(v), i => decimal.Parse(i)), Type type when type == typeof(double) => GetActions((StreamWriterWrapper w, in double v) => w.Stream.WriteLine(v), i => double.Parse(i)), Type type when type == typeof(float) => GetActions((StreamWriterWrapper w, in float v) => w.Stream.WriteLine(v), i => float.Parse(i)), Type type when type == typeof(string) => StringConverter.GetActions <T>(), Type type when type == typeof(Guid) => GuidConverter.GetActions <T>(), _ => ObjectConverter <T> .GetActions() }; }
public static System.Collections.Generic.List <Dynamic.Tekla.Structures.Drawing.CustomLineType> Get() { var result = MethodInvoker.InvokeStaticMethod("Tekla.Structures.Drawing.CustomLineTypeCatalog", "Get"); var _result = ListConverter.FromTSObjects <Dynamic.Tekla.Structures.Drawing.CustomLineType>(result); return(_result); }
/// <summary> /// Extracts runtimes of each task /// </summary> /// <returns> /// Runtimes of each task /// </returns> /// <param name="configFileContent">Content of a configuration file</param> public static List <float> GetTaskRuntimes(string configFileContent) { Regex runtimesRx = new Regex($@"TASK-ID,RUNTIME(?:{FileParser.NewLineRx})(?:\s*\d+,(\d+(?:\.\d+)?)(?:{FileParser.NewLineRx})?)+"); List <string> runtimes = FileParser.GetCaptureValues(configFileContent, runtimesRx); return(ListConverter.StringToFloat(runtimes)); }
public Tuple <List <TrainModel>, int> Trains(TrainModel model) { var where = new StringBuilder("1=1"); if (!string.IsNullOrWhiteSpace(model.KeyWord)) { where.Append($" and tte.TrainTeacherNames like '%{model.KeyWord}%' "); } var pre = @"select t.Id, (SELECT STUFF((SELECT ','+ Cast(UserId as varchar(100)) FROM TrainTeacher (NOLOCK) where TrainId=t.Id and IsValid=1 for xml path('')),1,1,'')) TrainTeacherIdStr, (SELECT STUFF((SELECT ','+ u.UserName FROM TrainTeacher tt left join [User] u on tt.userid=u.UserId where TrainId=t.Id and tt.IsValid=1 for xml path('')),1,1,'')) TrainTeacherNames into #temp_trainers from Train t;"; var cols = @"select t.*,acc.CateName,c.ClassName, tte.TrainTeacherIdStr,tte.TrainTeacherNames"; var sql = $@"from Train t left join AtomCateConfig acc on t.CourseCode=acc.CateCode left join Classes c on c.Id=t.ClassId left join #temp_trainers tte on tte.Id=t.Id where {where} "; var cntSql = $"{pre} select count(1) {sql} "; var dataSql = $"{pre} {cols} {sql} order by t.EditTime desc OFFSET ({model.Skip}) ROW FETCH NEXT {model.PageSize} rows only "; var cnt = db.Database.SqlQuery <int>(cntSql).First(); var data = db.Database.SqlQuery <TrainModel>(dataSql).ToList(); data.ForEach(t => t.TeacherIds = ListConverter.StringToListInt(t.TrainTeacherIdStr, ',')); return(new Tuple <List <TrainModel>, int>(data, cnt)); }
private void GetDeathDetails() { try { List <EntityDeathCertificate> ldtDeath = mobjDeptBLL.GetAllDeathDetails(); if (ldtDeath.Count > 0) { dgvShift.DataSource = ldtDeath; dgvShift.DataBind(); Session["DepartmentDetail"] = ldtDeath; Session["StartDeathDetails"] = ListConverter.ToDataTable(ldtDeath); int lintRowcount = ldtDeath.Count; lblRowCount.Text = "<b>Total Records:</b> " + lintRowcount.ToString(); } else { dgvShift.DataSource = ldtDeath; dgvShift.DataBind(); Session["DepartmentDetail"] = ldtDeath; Session["StartDeathDetails"] = ListConverter.ToDataTable(ldtDeath); int lintRowcount = ldtDeath.Count; lblRowCount.Text = "<b>Total Records:</b> " + lintRowcount.ToString(); } } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void GetBirthDetails() { try { List <EntityMedicalCertificate> ldtBirth = mobjBirthBLL.GetAllBirthDetails(); if (ldtBirth.Count > 0) { dgvShift.DataSource = ldtBirth; dgvShift.DataBind(); Session["DepartmentDetail"] = ldtBirth; Session["StartBirthDetails"] = ListConverter.ToDataTable(ldtBirth); int lintRowcount = ldtBirth.Count; lblRowCount.Text = "<b>Total Records:</b> " + lintRowcount.ToString(); pnlShow.Style.Add(HtmlTextWriterStyle.Display, ""); hdnPanel.Value = ""; } else { //pnlShow.Style.Add(HtmlTextWriterStyle.Display, "none"); hdnPanel.Value = "none"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } }
/// <summary> /// Extracts frequencies of provided processors. /// </summary> /// <returns> /// Frequencies of processors /// </returns> /// <param name="configFileContent">Content of a configuration file</param> public static List <float> GetProcessorFrequencies(string configFileContent) { Regex frequenciesRx = new Regex($@"PROCESSOR-ID,FREQUENCY(?:{FileParser.NewLineRx})(?:\s*\d+,(\d+(?:\.?\d+)?)(?:{FileParser.NewLineRx})?)+"); List <string> frequencies = FileParser.GetCaptureValues(configFileContent, frequenciesRx); return(ListConverter.StringToFloat(frequencies)); }
public void CanConvertOnlyWhenTypeIsEnumerableOfStrings() { ListConverter converter = new ListConverter(); Assert.False(converter.CanConvert(typeof(int))); Assert.False(converter.CanConvert(typeof(IEnumerable <int>))); Assert.True(converter.CanConvert(typeof(IEnumerable <string>))); }
public void WhenCanConvertCalledWithTypeThenOnlyReturnsToForIEnumerabletypes() { var converter = new ListConverter(); Assert.IsTrue(converter.CanConvert(typeof(List <string>))); Assert.IsTrue(converter.CanConvert(typeof(IEnumerable <string>))); Assert.IsFalse(converter.CanConvert(typeof(Dictionary <string, string>))); }
public static System.Collections.Generic.List <Dynamic.Tekla.Structures.Datatype.Angle> Parse( System.String text) { var result = MethodInvoker.InvokeStaticMethod("Tekla.Structures.Datatype.AngleList", "Parse", text); var _result = ListConverter.FromTSObjects <Dynamic.Tekla.Structures.Datatype.Angle>(result); return(_result); }
public static System.Boolean RemoveFromPourUnit( System.Collections.Generic.List <Dynamic.Tekla.Structures.Model.ModelObject> objectsToBeRemoved_) { var objectsToBeRemoved = ListConverter.ToTSObjects(objectsToBeRemoved_); var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.Operations.Operation", "RemoveFromPourUnit", objectsToBeRemoved); return(result); }
private void SetContents(EditResult result) { rtbDescription.Text = result.GetResultDescription(); foreach (string key in result.Positions.Keys) { lvResult.Items.Add(new ListViewItem( new string[] { key, ListConverter.ListToString(result.Positions[key]) })); } }
private void SelectBedConsumtion() { try { OTScheduleBLL consume = new OTScheduleBLL(); if (string.IsNullOrEmpty(txtBillDate.Text) && string.IsNullOrEmpty(txtToDate.Text)) { List <sp_GetAllBedAllocOTForPatientResult> lst = consume.SearchBedConsumption(); if (lst != null) { lbl.Text = "OT Scheduling Report"; DataTable dt = ListConverter.ToDataTable(lst); dt.Columns.Add("colSrNo"); DataColumn dcol = new DataColumn(); if (dt.Rows.Count > 0) { int count = 1; foreach (DataRow dr in dt.Rows) { dr["colSrNo"] = count; count++; } } dgvTestParameter.DataSource = dt; dgvTestParameter.DataBind(); Session["BedConsump"] = dt; } } if (txtBillDate.Text != null && txtToDate.Text != null) { List <sp_GetAllBedAllocOTForPatientDatewiseResult> lst = consume.SearchDatewiseOTConsumption(Convert.ToDateTime(txtBillDate.Text), Convert.ToDateTime(txtToDate.Text)); if (lst != null) { lbl.Text = "Datewise OT Scheduling Report"; DataTable dt = ListConverter.ToDataTable(lst); dt.Columns.Add("colSrNo"); DataColumn dcol = new DataColumn(); if (dt.Rows.Count > 0) { int count = 1; foreach (DataRow dr in dt.Rows) { dr["colSrNo"] = count; count++; } } dgvTestParameter.DataSource = dt; dgvTestParameter.DataBind(); Session["BedConsump"] = dt; } } } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void cmdBrowseFolders_Click(object sender, EventArgs e) { List <string> folders = BrowseDialoges.BrowseFolders(); if (folders != null) { SetOrAdd(txtFolders, ListConverter.ListToString(folders)); } }
private void cmdFiles_Click(object sender, EventArgs e) { List <string> files = BrowseDialoges.BrowseFiles(); if (files != null) { SetOrAdd(txtFiles, ListConverter.ListToString(files)); } }
public static System.Collections.Generic.List <Dynamic.Tekla.Structures.Model.ModelObject> GetSimilarNumberedObjects( Dynamic.Tekla.Structures.Model.ModelObject ObjectToCompare_) { var ObjectToCompare = Dynamic.Tekla.Structures.Model.ModelObject_.GetTSObject(ObjectToCompare_); var result = MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.Operations.Operation", "GetSimilarNumberedObjects", ObjectToCompare); var _result = ListConverter.FromTSObjects <Dynamic.Tekla.Structures.Model.ModelObject>(result); return(_result); }
public BackupTemplate(string backupName, string pathsToSave, string pathsToExclude, string typeFilter, bool typeInvert) { SplitFileAndFolderPaths(pathsToSave); //PathsBackup = ListConverter.StringToList(pathsToSave); PathsExclude = ListConverter.StringToList(pathsToExclude); BackupName = backupName; TypeFilter = ListConverter.StringToList(typeFilter); TypeInverted = typeInvert; }
public static System.Boolean AddToPourUnit( Dynamic.Tekla.Structures.Model.PourUnit inputPourUnit_, System.Collections.Generic.List <Dynamic.Tekla.Structures.Model.ModelObject> objectsToBeAdded_) { var inputPourUnit = Dynamic.Tekla.Structures.Model.PourUnit_.GetTSObject(inputPourUnit_); var objectsToBeAdded = ListConverter.ToTSObjects(objectsToBeAdded_); var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.Operations.Operation", "AddToPourUnit", inputPourUnit, objectsToBeAdded); return(result); }
public static System.Boolean SetTemporaryState( System.Collections.Generic.List <Dynamic.Tekla.Structures.Identifier> identifiers_, Dynamic.Tekla.Structures.Model.UI.Color color_) { var identifiers = ListConverter.ToTSObjects(identifiers_); var color = Dynamic.Tekla.Structures.Model.UI.Color_.GetTSObject(color_); var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.UI.ModelObjectVisualization", "SetTemporaryState", identifiers, color); return(result); }
public static System.Boolean SetTransparency( System.Collections.Generic.List <Dynamic.Tekla.Structures.Identifier> identifiers_, Dynamic.Tekla.Structures.Model.UI.TemporaryTransparency transparency_) { var identifiers = ListConverter.ToTSObjects(identifiers_); var transparency = Dynamic.Tekla.Structures.Model.UI.TemporaryTransparency_.GetTSObject(transparency_); var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Model.UI.ModelObjectVisualization", "SetTransparency", identifiers, transparency); return(result); }
protected void btnSearch_Click(object sender, EventArgs e) { try { lbl.Text = "STOCK DETAIL REPORT"; lblFrom.Text = ddlProduct.SelectedItem.Text; lblTo.Text = string.Format("{0:dd-MMM-yyyy}", DateTime.Now); lblMessage.Text = string.Empty; EntityProduct entPro = new CustomerTransactionBLL().GetUnitOfMeasurement(ddlProduct.SelectedValue); lblUoM.Text = "U.O.M" + "-" + entPro.UOM; List <tblStockDetail> lst = new CustomerTransactionBLL().GetProductTransByProductId(Convert.ToInt32(ddlProduct.SelectedValue)); tblStockDetail obj = new tblStockDetail() { }; lst.Add(obj); tblStockDetail objReceived = new tblStockDetail() { TransactionType = "Total Inward Amount", InwardAmount = Convert.ToDecimal(lst.Sum(p => p.InwardAmount)) }; lst.Add(objReceived); tblStockDetail objBills = new tblStockDetail() { TransactionType = "Total Outward Amount", OutwardAmount = Convert.ToDecimal(lst.Sum(p => p.OutwardAmount)) }; lst.Add(objBills); tblStockDetail objIqty = new tblStockDetail() { TransactionType = "Total Inward Quntity", InwardQty = Convert.ToInt32(lst.Sum(p => p.InwardQty)) }; lst.Add(objIqty); tblStockDetail objOqty = new tblStockDetail() { TransactionType = "Total Outward Quntity", OutwardQty = Convert.ToInt32(lst.Sum(p => p.OutwardQty)) }; lst.Add(objOqty); tblStockDetail objFinal = new tblStockDetail() { TransactionType = "Balance Quntity", InwardQty = objIqty.InwardQty - objOqty.OutwardQty }; lst.Add(objFinal); dgvTestParameter.DataSource = lst; dgvTestParameter.DataBind(); Session["StockDetailsRep"] = ListConverter.ToDataTable(lst); } catch (Exception ex) { lblMessage.Text = ex.Message; } }
public static System.Collections.Generic.List <Dynamic.Tekla.Structures.Datatype.Angle> Parse( System.String text, System.IFormatProvider formatProvider, Dynamic.Tekla.Structures.Datatype.Angle.UnitType unitType_) { var unitType = Dynamic.Tekla.Structures.Datatype.Angle.UnitType_.GetTSObject(unitType_); var result = MethodInvoker.InvokeStaticMethod("Tekla.Structures.Datatype.AngleList", "Parse", text, formatProvider, unitType); var _result = ListConverter.FromTSObjects <Dynamic.Tekla.Structures.Datatype.Angle>(result); return(_result); }
public override IListConverter <ITargettable> GetAllPotentialTargets() { if (target.predator) { ListConverter <Animal, ITargettable> lookup = new ListConverter <Animal, ITargettable>(AnimalMap.animalMap.animals); return(lookup); } else { return(new ListConverter <Carrot, ITargettable>(AnimalMap.animalMap.carrots)); } }
public void WhenListOfStringConvertedThenReturnsCommaSeparatedValues() { ListConverter converter = new ListConverter(); var convertedValue = converter.Convert(new List <string> { "item1", "item2", "item3" }); Assert.AreEqual("item1,item2,item3", convertedValue); }
protected void btnExcel_Click(object sender, EventArgs e) { try { ListConverter.ToDataTable((List <EntityInsuranceClaim>)Session["ClaimDetails"]); Session["Details"] = ListConverter.ToDataTable((List <EntityInsuranceClaim>)Session["ClaimDetails"]); Response.Redirect("~/ExcelReport/MonthwiseSalExcel.aspx"); } catch (Exception ex) { lblMessage.Text = ex.Message; } }
public static System.Boolean CreateDrawings( Dynamic.Tekla.Structures.Drawing.Automation.AutoDrawingRule Rule_, System.Collections.Generic.List <Dynamic.Tekla.Structures.Identifier> aModelObjectIdentifier_, out Dynamic.Tekla.Structures.Drawing.Automation.AutoDrawingsStatusEnum OperationStatus_) { var Rule = Dynamic.Tekla.Structures.Drawing.Automation.AutoDrawingRule_.GetTSObject(Rule_); var aModelObjectIdentifier = ListConverter.ToTSObjects(aModelObjectIdentifier_); var OperationStatus = Dynamic.Tekla.Structures.Drawing.Automation.AutoDrawingsStatusEnum_.GetTSObject(0); var result = (System.Boolean)MethodInvoker.InvokeStaticMethod("Tekla.Structures.Drawing.Automation.DrawingCreator", "CreateDrawings", Rule, aModelObjectIdentifier, ref OperationStatus); OperationStatus_ = Dynamic.Tekla.Structures.Drawing.Automation.AutoDrawingsStatusEnum_.FromTSObject(OperationStatus); return(result); }
public static void ListConverterSample() { // Create a list of customers. List<Customer> customers = new List<Customer>(); customers.Add(new Customer { Name = "George", Title = "Principal", Active = true }); customers.Add(new Customer { Name = "Jane", Title = "Baker", Active = true }); customers.Add(new Customer { Name = "Yuko", Title = "Firefighter", Active = false }); // The inefficient way - copy the list: List<string> inefficientNames = customers.ConvertAll(c => c.Name); SendGreetings(inefficientNames); // The efficient way - avoid copying the list and convert items on demand: IList<string> efficientNames = customers.ToListConverter(c => c.Name); SendGreetings(efficientNames); // Or, if you don't want to use the extension method: IList<string> efficientNames2 = new ListConverter<Customer, string>(customers, c => c.Name); SendGreetings(efficientNames2); // The same can be done for Collections using CollectionConverter, and for Enumerables using EnumerableConverter. }