How to use EnumExtensions class of System package

Best FlaUI code snippet using System.EnumExtensions

CatalogueModel.cs

Source:CatalogueModel.cs Github

copy

Full Screen

2using System;3using System.Collections.Generic;4using System.Linq;5using System.Web;6using EnumExtensions;7using Core.DataWrapper;8using Core.WebExtensions;9using System.Data.Odbc;10using System.Text;11using Core.Utils;12using Core.CustomExceptions;13namespace Core.Models14{15 public static class CatalogueModel16 {17 /// <summary>18 /// Applys the model definitions to page19 /// </summary>20 /// <param name="page"></param>21 public static void ApplyModel(System.Web.UI.Page page, ref StringBuilder js, params string[] jsFunctionNames)22 {23 string transactionName, errorLst = null;24 System.Web.UI.Control placeHolder;25 transactionName = page.Request.QueryString["transacao"];26 placeHolder = page.Master.FindControl("CPH");27 try28 {29 using (OdbcDbConnection db2Con = new OdbcDbConnection("Dsn=DEV_MST;uid=db2tuser;mode=SHARE;dbalias=DEV_MST;pwd=12letmein"))30 {31 errorLst = IterateModelElements(placeHolder, transactionName, db2Con, ref js, jsFunctionNames);32 }33 }34 catch (Exception)35 {36 if (errorLst != null && errorLst.Length > 0)37 throw new InvalidFieldsException(errorLst);38 else39 throw;40 }41 if (errorLst.Length > 0)42 throw new InvalidFieldsException(errorLst);43 }44 private static string IterateModelElements(System.Web.UI.Control placeHolder45 , string transactionName46 , OdbcDbConnection db2Con47 , ref StringBuilder js48 , params string[] jsFunctionNames)49 {50 string fieldName, clientID;51 StringBuilder errorLst = new StringBuilder();52 var lst = DataManager.ModelDb2(transactionName);53 List<KeyValuePair<string, string>> tabelaLst = null;54 System.Web.UI.Control curControl = null;55 foreach (var itm in lst)56 {57 if (String.IsNullOrEmpty(itm.CopyBook))58 continue;59 switch (itm.TipoDeCampo)60 {61 case TipoCampoEnum.String:62 case TipoCampoEnum.Decimal:63 case TipoCampoEnum.Data:64 fieldName = "txt" + itm.CopyBook;65 curControl = placeHolder.FindControl(fieldName);66 if (curControl != null && itm.Tamanho.HasValue && (curControl is System.Web.UI.WebControls.TextBox))67 (curControl as System.Web.UI.WebControls.TextBox).MaxLength = (int)itm.Tamanho;68 else69 errorLst.Append(fieldName).Append("\n");70 if (itm.DescricaoLbl != null)71 {72 fieldName = "lbl" + itm.CopyBook;73 curControl = placeHolder.FindControl(fieldName);74 if (curControl != null && (curControl is System.Web.UI.WebControls.Label))75 (curControl as System.Web.UI.WebControls.Label).Text = itm.DescricaoLbl;76 else77 errorLst.Append(fieldName).Append("\n");78 }79 break;80 case TipoCampoEnum.ComboBox:81 if (itm.DescricaoLbl != null)82 {83 fieldName = "lbl" + itm.CopyBook;84 curControl = placeHolder.FindControl(fieldName);85 if (curControl != null && (curControl is System.Web.UI.WebControls.Label))86 (curControl as System.Web.UI.WebControls.Label).Text = itm.DescricaoLbl;87 else88 errorLst.Append(fieldName).Append("\n");89 }90 fieldName = "cmb" + itm.CopyBook;91 curControl = placeHolder.FindControl(fieldName);92 if (curControl == null || !(curControl is System.Web.UI.HtmlControls.HtmlSelect))93 errorLst.Append(fieldName).Append("\n");94 else if (itm.Tabela != TabelaEnum.NULL)95 {96 var cmb = (curControl as System.Web.UI.HtmlControls.HtmlSelect);97 clientID = cmb.ClientID;98 tabelaLst = Db2DAL.GetDb2Lst(itm.Tabela, db2Con, itm.IDCol, itm.DescCol);99 if (tabelaLst?.Count > 0)100 {101 cmb.LoadWithList(false, tabelaLst);102 JsUtil.ExecJsFunction(jsFunctionNames[0], js, clientID.Replace("cmb", "txt"), clientID); //aplica fLookupCmbOnChange103 }104 }105 break;106 case TipoCampoEnum.CustomMask:107 if (itm.DescricaoLbl != null)108 {109 fieldName = "lbl" + itm.CopyBook;110 curControl = placeHolder.FindControl(fieldName);111 if (curControl != null && (curControl is System.Web.UI.WebControls.Label))112 (curControl as System.Web.UI.WebControls.Label).Text = itm.DescricaoLbl;113 else114 errorLst.Append(fieldName).Append("\n");115 }116 fieldName = "txt" + itm.CopyBook;117 curControl = placeHolder.FindControl(fieldName);118 if (curControl != null && itm.Tamanho.HasValue)119 (curControl as System.Web.UI.WebControls.TextBox).MaxLength = (int)itm.Tamanho;120 else121 errorLst.Append(fieldName).Append("\n");122 break;123 }124 }125 return errorLst.ToString();126 }127 public static string Terminal { get; set; }128 public static string Familia { get; set; }129 public static string SubFamilia { get; set; }130 public static string EmComercialzacao { get; set; }131 public static string Estado { get; set; }132 public static string Produto { get; set; }133 public static string TransactionType134 {135 get;136 set;137 }138 public static List<KeyValuePair<string, string>> ListFamilia139 {140 get141 {142 return toDropDownList(new string[][] {143 new string[] { "", "" },144 new string[] { "AP34", "Em Criação" },145 new string[] { "CA29", "Activos" },146 new string[] { "VC39", "Em Modificação" },147 new string[] { "TI96", "Inactivo" }148 });149 }150 }151 public static List<KeyValuePair<string, string>> ListSubFamilia152 {153 get154 {155 return toDropDownList(new string[][] {156 new string[] { "", "" },157 new string[] { "1", "SubFamilia 1" },158 new string[] { "2", "SubFamilia 2" },159 new string[] { "3", "SubFamilia 3" },160 new string[] { "4", "SubFamilia 4" }161 });162 }163 }164 public static List<KeyValuePair<string, string>> ListEstado165 {166 get167 {168 EstadoEnum en;169 var lst = new List<KeyValuePair<string, string>>();170 en = EstadoEnum.Activo;171 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)172 , EnumExtensions.EnumExtensions.GetDesc(en)));173 en = EstadoEnum.Criacao;174 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)175 , EnumExtensions.EnumExtensions.GetDesc(en)));176 en = EstadoEnum.Modificacao;177 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)178 , EnumExtensions.EnumExtensions.GetDesc(en)));179 en = EstadoEnum.Inactivo;180 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)181 , EnumExtensions.EnumExtensions.GetDesc(en)));182 return lst;183 }184 }185 public static List<KeyValuePair<string, string>> ListProduto186 {187 get188 {189 return toDropDownList(new string[][] {190 new string[] { "", "" },191 new string[] { "1", "Produto 1" },192 new string[] { "2", "Produto 2" },193 new string[] { "3", "Produto 3" },194 new string[] { "4", "Produto 4" }195 });196 }197 }198 public static List<KeyValuePair<string, string>> ListMicroFamilias199 {200 get201 {202 return toDropDownList(new string[][] {203 new string[] { "", "" },204 new string[] { "AP34", "(AP34) Depósitos Estruturados" },205 new string[] { "CA29", "(CA29) Fundos" },206 //new string[] { "VC39", "(VC39) Seguros" },207 new string[] { "TI96", "(TI96) Papel Comercial" },208 new string[] { "TI97", "(TI97) Titulos" }209 });210 }211 }212 public static List<KeyValuePair<string, string>> ListSimNaoExclusivo213 {214 get215 {216 SimNaoEnum en;217 var lst = new List<KeyValuePair<string, string>>();218 en = SimNaoEnum.Empty;219 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)220 , EnumExtensions.EnumExtensions.GetDesc(en)));221 en = SimNaoEnum.Sim;222 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)223 , EnumExtensions.EnumExtensions.GetDesc(en)));224 en = SimNaoEnum.Nao;225 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)226 , EnumExtensions.EnumExtensions.GetDesc(en)));227 return lst;228 }229 }230 public static List<KeyValuePair<string, string>> ListSimNao231 {232 get233 {234 SimNaoEnum en;235 var lst = new List<KeyValuePair<string, string>>();236 en = SimNaoEnum.Sim;237 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)238 , EnumExtensions.EnumExtensions.GetDesc(en)));239 en = SimNaoEnum.Nao;240 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)241 , EnumExtensions.EnumExtensions.GetDesc(en)));242 return lst;243 }244 }245 public static List<KeyValuePair<string, string>> ListActive246 {247 get248 {249 ActivoInactivoEnum en;250 var lst = new List<KeyValuePair<string, string>>();251 en = ActivoInactivoEnum.Empty;252 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)253 , EnumExtensions.EnumExtensions.GetDesc(en)));254 en = ActivoInactivoEnum.Activo;255 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)256 , EnumExtensions.EnumExtensions.GetDesc(en)));257 en = ActivoInactivoEnum.Inactivo;258 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)259 , EnumExtensions.EnumExtensions.GetDesc(en)));260 return lst;261 }262 }263 public static List<KeyValuePair<string, string>> ListActiveExclusivo264 {265 get266 {267 ActivoInactivoEnum en;268 var lst = new List<KeyValuePair<string, string>>();269 en = ActivoInactivoEnum.Activo;270 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)271 , EnumExtensions.EnumExtensions.GetDesc(en)));272 en = ActivoInactivoEnum.Inactivo;273 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)274 , EnumExtensions.EnumExtensions.GetDesc(en)));275 return lst;276 }277 }278 public static List<KeyValuePair<string, string>> ListPricing279 {280 get281 {282 PricingEnum en;283 var lst = new List<KeyValuePair<string, string>>();284 en = PricingEnum.Empty;285 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)286 , EnumExtensions.EnumExtensions.GetDesc(en)));287 en = PricingEnum.Clean;288 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)289 , EnumExtensions.EnumExtensions.GetDesc(en)));290 en = PricingEnum.Dirty;291 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)292 , EnumExtensions.EnumExtensions.GetDesc(en)));293 return lst;294 }295 }296 public static List<KeyValuePair<string, string>> ListTipoArredon297 {298 get299 {300 TipoArredonEnum en;301 var lst = new List<KeyValuePair<string, string>>();302 en = TipoArredonEnum.Empty;303 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)304 , EnumExtensions.EnumExtensions.GetDesc(en)));305 en = TipoArredonEnum.Defeito;306 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)307 , EnumExtensions.EnumExtensions.GetDesc(en)));308 en = TipoArredonEnum.Excesso;309 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)310 , EnumExtensions.EnumExtensions.GetDesc(en)));311 return lst;312 }313 }314 public static List<KeyValuePair<string, string>> ListTipoWarrant315 {316 get317 {318 TipoWarrantEnum en;319 var lst = new List<KeyValuePair<string, string>>();320 en = TipoWarrantEnum.Empty;321 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)322 , EnumExtensions.EnumExtensions.GetDesc(en)));323 en = TipoWarrantEnum.Call;324 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)325 , EnumExtensions.EnumExtensions.GetDesc(en)));326 en = TipoWarrantEnum.Put;327 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)328 , EnumExtensions.EnumExtensions.GetDesc(en)));329 return lst;330 }331 }332 public static List<KeyValuePair<string, string>> ListEstiloWarrant333 {334 get335 {336 EstiloWarrantEnum en;337 var lst = new List<KeyValuePair<string, string>>();338 en = EstiloWarrantEnum.Empty;339 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)340 , EnumExtensions.EnumExtensions.GetDesc(en)));341 en = EstiloWarrantEnum.Europeu;342 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)343 , EnumExtensions.EnumExtensions.GetDesc(en)));344 en = EstiloWarrantEnum.Americano;345 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)346 , EnumExtensions.EnumExtensions.GetDesc(en)));347 return lst;348 }349 }350 public static List<KeyValuePair<string, string>> ListTipoExercicio351 {352 get353 {354 TipoExercicioEnum en;355 var lst = new List<KeyValuePair<string, string>>();356 en = TipoExercicioEnum.Empty;357 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)358 , EnumExtensions.EnumExtensions.GetDesc(en)));359 en = TipoExercicioEnum.Automatico;360 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)361 , EnumExtensions.EnumExtensions.GetDesc(en)));362 en = TipoExercicioEnum.NaoAutomatico;363 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)364 , EnumExtensions.EnumExtensions.GetDesc(en)));365 return lst;366 }367 }368 public static List<KeyValuePair<string, string>> ListTipoLiquida369 {370 get371 {372 TipoLiquidaEnum en;373 var lst = new List<KeyValuePair<string, string>>();374 en = TipoLiquidaEnum.Empty;375 lst.Add(new KeyValuePair<string, string>(string.Empty376 , EnumExtensions.EnumExtensions.GetDesc(en)));377 en = TipoLiquidaEnum.FIS;378 lst.Add(new KeyValuePair<string, string>(en.ToString()379 , EnumExtensions.EnumExtensions.GetDesc(en)));380 en = TipoLiquidaEnum.FIN;381 lst.Add(new KeyValuePair<string, string>(en.ToString()382 , EnumExtensions.EnumExtensions.GetDesc(en)));383 return lst;384 }385 }386 public static List<KeyValuePair<string, string>> ListPrazoAbsoluto387 {388 get389 {390 PrazoAbsolutoEnum en;391 var lst = new List<KeyValuePair<string, string>>();392 en = PrazoAbsolutoEnum.Empty;393 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)394 , EnumExtensions.EnumExtensions.GetDesc(en)));395 en = PrazoAbsolutoEnum.A;396 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)397 , EnumExtensions.EnumExtensions.GetDesc(en)));398 en = PrazoAbsolutoEnum.D;399 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)400 , EnumExtensions.EnumExtensions.GetDesc(en)));401 en = PrazoAbsolutoEnum.P;402 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)403 , EnumExtensions.EnumExtensions.GetDesc(en)));404 return lst;405 }406 }407 public static List<KeyValuePair<string, string>> ListH2527408 {409 get410 {411 H2527Enum en;412 var lst = new List<KeyValuePair<string, string>>();413 en = H2527Enum.NULL;414 lst.Add(new KeyValuePair<string, string>(en.ToString()415 , en.ToString()));416 en = H2527Enum.ACC;417 lst.Add(new KeyValuePair<string, string>(en.ToString()418 , en.ToString()));419 en = H2527Enum.IND;420 lst.Add(new KeyValuePair<string, string>(en.ToString()421 , en.ToString()));422 en = H2527Enum.TJC;423 lst.Add(new KeyValuePair<string, string>(en.ToString()424 , en.ToString()));425 en = H2527Enum.TJL;426 lst.Add(new KeyValuePair<string, string>(en.ToString()427 , en.ToString()));428 en = H2527Enum.TCB;429 lst.Add(new KeyValuePair<string, string>(en.ToString()430 , en.ToString()));431 en = H2527Enum.CDV;432 lst.Add(new KeyValuePair<string, string>(en.ToString()433 , en.ToString()));434 en = H2527Enum.MEC;435 lst.Add(new KeyValuePair<string, string>(en.ToString()436 , en.ToString()));437 en = H2527Enum.OUT;438 lst.Add(new KeyValuePair<string, string>(en.ToString()439 , en.ToString()));440 return lst;441 }442 }443 public static List<KeyValuePair<string, string>> ListTipoMercado444 {445 get446 {447 TipoMercadoEnum en;448 var lst = new List<KeyValuePair<string, string>>();449 en = TipoMercadoEnum.Empty;450 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)451 , EnumExtensions.EnumExtensions.GetDesc(en)));452 en = TipoMercadoEnum.MER;453 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)454 , EnumExtensions.EnumExtensions.GetDesc(en)));455 en = TipoMercadoEnum.MNR;456 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)457 , EnumExtensions.EnumExtensions.GetDesc(en)));458 en = TipoMercadoEnum.NAN;459 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)460 , EnumExtensions.EnumExtensions.GetDesc(en)));461 return lst;462 }463 }464 public static List<KeyValuePair<string, string>> ListRiscoProduto465 {466 get467 {468 RiscoProdutoEnum en;469 var lst = new List<KeyValuePair<string, string>>();470 en = RiscoProdutoEnum.Empty;471 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)472 , EnumExtensions.EnumExtensions.GetDesc(en)));473 en = RiscoProdutoEnum.Nivel1;474 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)475 , EnumExtensions.EnumExtensions.GetDesc(en)));476 en = RiscoProdutoEnum.Nivel2;477 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)478 , EnumExtensions.EnumExtensions.GetDesc(en)));479 en = RiscoProdutoEnum.Nivel3;480 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)481 , EnumExtensions.EnumExtensions.GetDesc(en)));482 en = RiscoProdutoEnum.Nivel4;483 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)484 , EnumExtensions.EnumExtensions.GetDesc(en)));485 en = RiscoProdutoEnum.Nivel5;486 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)487 , EnumExtensions.EnumExtensions.GetDesc(en)));488 return lst;489 }490 }491 public static List<KeyValuePair<string, string>> ListTipoAmortizacao492 {493 get494 {495 TipoAmortizacaoEnum en;496 var lst = new List<KeyValuePair<string, string>>();497 en = TipoAmortizacaoEnum.Empty;498 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)499 , EnumExtensions.EnumExtensions.GetDesc(en)));500 en = TipoAmortizacaoEnum.Q;501 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)502 , EnumExtensions.EnumExtensions.GetDesc(en)));503 en = TipoAmortizacaoEnum.T;504 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)505 , EnumExtensions.EnumExtensions.GetDesc(en)));506 en = TipoAmortizacaoEnum.A;507 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)508 , EnumExtensions.EnumExtensions.GetDesc(en)));509 return lst;510 }511 }512 public static List<KeyValuePair<string, string>> ListTipoSubscricao513 {514 get515 {516 TipoSubscricaoEnum en;517 var lst = new List<KeyValuePair<string, string>>();518 en = TipoSubscricaoEnum.Empty;519 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)520 , EnumExtensions.EnumExtensions.GetDesc(en)));521 en = TipoSubscricaoEnum.T;522 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)523 , EnumExtensions.EnumExtensions.GetDesc(en)));524 en = TipoSubscricaoEnum.O;525 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)526 , EnumExtensions.EnumExtensions.GetDesc(en)));527 en = TipoSubscricaoEnum.S;528 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)529 , EnumExtensions.EnumExtensions.GetDesc(en)));530 en = TipoSubscricaoEnum.R;531 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)532 , EnumExtensions.EnumExtensions.GetDesc(en)));533 return lst;534 }535 }536 public static List<KeyValuePair<string, string>> ListTipoResgate537 {538 get539 {540 TipoResgateEnum en;541 var lst = new List<KeyValuePair<string, string>>();542 en = TipoResgateEnum.Empty;543 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)544 , EnumExtensions.EnumExtensions.GetDesc(en)));545 en = TipoResgateEnum.Q;546 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)547 , EnumExtensions.EnumExtensions.GetDesc(en)));548 en = TipoResgateEnum.T;549 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)550 , EnumExtensions.EnumExtensions.GetDesc(en)));551 en = TipoResgateEnum.A;552 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)553 , EnumExtensions.EnumExtensions.GetDesc(en)));554 return lst;555 }556 }557 public static List<KeyValuePair<string, string>> ListTipoResgateExclusivo558 {559 get560 {561 TipoResgateEnum en;562 var lst = new List<KeyValuePair<string, string>>();563 en = TipoResgateEnum.Q;564 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)565 , EnumExtensions.EnumExtensions.GetDesc(en)));566 en = TipoResgateEnum.T;567 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)568 , EnumExtensions.EnumExtensions.GetDesc(en)));569 en = TipoResgateEnum.A;570 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)571 , EnumExtensions.EnumExtensions.GetDesc(en)));572 return lst;573 }574 }575 public static List<KeyValuePair<string, string>> ListPeriodoCoracao576 {577 get578 {579 PeriodoCoracaoEnum en;580 var lst = new List<KeyValuePair<string, string>>();581 en = PeriodoCoracaoEnum.Empty;582 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)583 , EnumExtensions.EnumExtensions.GetDesc(en)));584 en = PeriodoCoracaoEnum.D;585 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)586 , EnumExtensions.EnumExtensions.GetDesc(en)));587 en = PeriodoCoracaoEnum.W;588 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)589 , EnumExtensions.EnumExtensions.GetDesc(en)));590 en = PeriodoCoracaoEnum.Q;591 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)592 , EnumExtensions.EnumExtensions.GetDesc(en)));593 en = PeriodoCoracaoEnum.M;594 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)595 , EnumExtensions.EnumExtensions.GetDesc(en)));596 en = PeriodoCoracaoEnum.A;597 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)598 , EnumExtensions.EnumExtensions.GetDesc(en)));599 return lst;600 }601 }602 public static List<KeyValuePair<string, string>> ListTipoValoracao603 {604 get605 {606 TipoValoracaoEnum en;607 var lst = new List<KeyValuePair<string, string>>();608 en = TipoValoracaoEnum.Empty;609 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)610 , EnumExtensions.EnumExtensions.GetDesc(en)));611 en = TipoValoracaoEnum.F;612 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)613 , EnumExtensions.EnumExtensions.GetDesc(en)));614 en = TipoValoracaoEnum.L;615 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)616 , EnumExtensions.EnumExtensions.GetDesc(en)));617 return lst;618 }619 }620 public static List<KeyValuePair<string, string>> ListCustodia621 {622 get623 {624 CustodiaEnum en;625 var lst = new List<KeyValuePair<string, string>>();626 en = CustodiaEnum.Empty;627 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)628 , EnumExtensions.EnumExtensions.GetDesc(en)));629 en = CustodiaEnum.C;630 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)631 , EnumExtensions.EnumExtensions.GetDesc(en)));632 en = CustodiaEnum.D;633 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)634 , EnumExtensions.EnumExtensions.GetDesc(en)));635 return lst;636 }637 }638 public static List<KeyValuePair<string, string>> ListElegivel639 {640 get641 {642 ElegivelEnum en;643 var lst = new List<KeyValuePair<string, string>>();644 en = ElegivelEnum.Empty;645 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)646 , EnumExtensions.EnumExtensions.GetDesc(en)));647 en = ElegivelEnum.Nivel0;648 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)649 , EnumExtensions.EnumExtensions.GetDesc(en)));650 en = ElegivelEnum.Nivel100;651 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)652 , EnumExtensions.EnumExtensions.GetDesc(en)));653 return lst;654 }655 }656 public static List<KeyValuePair<string, string>> ListRiscoKidd657 {658 get659 {660 RiscoKiddEnum en;661 var lst = new List<KeyValuePair<string, string>>();662 en = RiscoKiddEnum.Empty;663 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)664 , EnumExtensions.EnumExtensions.GetDesc(en)));665 en = RiscoKiddEnum.Nivel1;666 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)667 , EnumExtensions.EnumExtensions.GetDesc(en)));668 en = RiscoKiddEnum.Nivel2;669 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)670 , EnumExtensions.EnumExtensions.GetDesc(en)));671 en = RiscoKiddEnum.Nivel3;672 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)673 , EnumExtensions.EnumExtensions.GetDesc(en)));674 en = RiscoKiddEnum.Nivel4;675 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)676 , EnumExtensions.EnumExtensions.GetDesc(en)));677 en = RiscoKiddEnum.Nivel5;678 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)679 , EnumExtensions.EnumExtensions.GetDesc(en)));680 en = RiscoKiddEnum.Nivel6;681 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)682 , EnumExtensions.EnumExtensions.GetDesc(en)));683 en = RiscoKiddEnum.Nivel7;684 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)685 , EnumExtensions.EnumExtensions.GetDesc(en)));686 return lst;687 }688 }689 public static List<KeyValuePair<string, string>> ListEstadoFundo690 {691 get692 {693 EstadoFundoEnum en;694 var lst = new List<KeyValuePair<string, string>>();695 en = EstadoFundoEnum.Empty;696 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)697 , EnumExtensions.EnumExtensions.GetDesc(en)));698 en = EstadoFundoEnum.I;699 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)700 , EnumExtensions.EnumExtensions.GetDesc(en)));701 en = EstadoFundoEnum.A;702 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)703 , EnumExtensions.EnumExtensions.GetDesc(en)));704 return lst;705 }706 }707 public static List<KeyValuePair<string, string>> ListSitsNegociavel708 {709 get710 {711 SitsNegociavelEnum en;712 var lst = new List<KeyValuePair<string, string>>();713 en = SitsNegociavelEnum.Empty;714 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)715 , EnumExtensions.EnumExtensions.GetDesc(en)));716 en = SitsNegociavelEnum.N;717 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)718 , EnumExtensions.EnumExtensions.GetDesc(en)));719 en = SitsNegociavelEnum.P;720 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)721 , EnumExtensions.EnumExtensions.GetDesc(en)));722 en = SitsNegociavelEnum.O;723 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)724 , EnumExtensions.EnumExtensions.GetDesc(en)));725 en = SitsNegociavelEnum.X;726 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)727 , EnumExtensions.EnumExtensions.GetDesc(en)));728 return lst;729 }730 }731 public static List<KeyValuePair<string, string>> ListIbanNet732 {733 get734 {735 IbanNetEnum en;736 var lst = new List<KeyValuePair<string, string>>();737 en = IbanNetEnum.Empty;738 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)739 , EnumExtensions.EnumExtensions.GetDesc(en)));740 en = IbanNetEnum.Nivel1;741 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)742 , EnumExtensions.EnumExtensions.GetDesc(en)));743 en = IbanNetEnum.Nivel2;744 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)745 , EnumExtensions.EnumExtensions.GetDesc(en)));746 en = IbanNetEnum.Nivel3;747 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)748 , EnumExtensions.EnumExtensions.GetDesc(en)));749 return lst;750 }751 }752 public static List<KeyValuePair<string, string>> ListNegociavel753 {754 get755 {756 NegociavelEnum en;757 var lst = new List<KeyValuePair<string, string>>();758 en = NegociavelEnum.Empty;759 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)760 , EnumExtensions.EnumExtensions.GetDesc(en)));761 en = NegociavelEnum.S;762 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)763 , EnumExtensions.EnumExtensions.GetDesc(en)));764 en = NegociavelEnum.N;765 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)766 , EnumExtensions.EnumExtensions.GetDesc(en)));767 en = NegociavelEnum.N;768 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)769 , EnumExtensions.EnumExtensions.GetDesc(en)));770 en = NegociavelEnum.V;771 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)772 , EnumExtensions.EnumExtensions.GetDesc(en)));773 return lst;774 }775 }776 public static List<KeyValuePair<string, string>> ListElegibilidade777 {778 get779 {780 ElegibilidadeEnum en;781 var lst = new List<KeyValuePair<string, string>>();782 en = ElegibilidadeEnum.Empty;783 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)784 , EnumExtensions.EnumExtensions.GetDesc(en)));785 en = ElegibilidadeEnum.BOE;786 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)787 , EnumExtensions.EnumExtensions.GetDesc(en)));788 en = ElegibilidadeEnum.ECB;789 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)790 , EnumExtensions.EnumExtensions.GetDesc(en)));791 en = ElegibilidadeEnum.FED;792 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)793 , EnumExtensions.EnumExtensions.GetDesc(en)));794 en = ElegibilidadeEnum.LCB;795 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)796 , EnumExtensions.EnumExtensions.GetDesc(en)));797 en = ElegibilidadeEnum.MKT;798 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)799 , EnumExtensions.EnumExtensions.GetDesc(en)));800 return lst;801 }802 }803 public static List<KeyValuePair<string, string>> ListTipoJuro804 {805 get806 {807 TipoJuroEnum en;808 var lst = new List<KeyValuePair<string, string>>();809 en = TipoJuroEnum.Empty;810 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)811 , EnumExtensions.EnumExtensions.GetDesc(en)));812 en = TipoJuroEnum.Fixo;813 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)814 , EnumExtensions.EnumExtensions.GetDesc(en)));815 en = TipoJuroEnum.Var;816 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)817 , EnumExtensions.EnumExtensions.GetDesc(en)));818 en = TipoJuroEnum.Outro;819 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)820 , EnumExtensions.EnumExtensions.GetDesc(en)));821 return lst;822 }823 }824 public static List<KeyValuePair<string, string>> ListModalidade825 {826 get827 {828 ModalidadeEnum en;829 var lst = new List<KeyValuePair<string, string>>();830 en = ModalidadeEnum.Empty;831 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)832 , EnumExtensions.EnumExtensions.GetDesc(en)));833 en = ModalidadeEnum.C;834 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)835 , EnumExtensions.EnumExtensions.GetDesc(en)));836 en = ModalidadeEnum.D;837 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)838 , EnumExtensions.EnumExtensions.GetDesc(en)));839 return lst;840 }841 }842 public static List<KeyValuePair<string, string>> ListTipoCalculoJuros843 {844 get845 {846 TipoCalculoJurosEnum en;847 var lst = new List<KeyValuePair<string, string>>();848 en = TipoCalculoJurosEnum.Empty;849 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)850 , EnumExtensions.EnumExtensions.GetDesc(en)));851 en = TipoCalculoJurosEnum.Mes;852 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)853 , EnumExtensions.EnumExtensions.GetDesc(en)));854 en = TipoCalculoJurosEnum.Dias;855 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)856 , EnumExtensions.EnumExtensions.GetDesc(en)));857 return lst;858 }859 }860 public static List<KeyValuePair<string, string>> ListSenioridade861 {862 get863 {864 SenioridadeEnum en;865 var lst = new List<KeyValuePair<string, string>>();866 en = SenioridadeEnum.Empty;867 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)868 , EnumExtensions.EnumExtensions.GetDesc(en)));869 en = SenioridadeEnum.S;870 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)871 , EnumExtensions.EnumExtensions.GetDesc(en)));872 en = SenioridadeEnum.J;873 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)874 , EnumExtensions.EnumExtensions.GetDesc(en)));875 return lst;876 }877 }878 public static List<KeyValuePair<string, string>> ListNumAno879 {880 get881 {882 NumAnoEnum en;883 var lst = new List<KeyValuePair<string, string>>();884 en = NumAnoEnum.Empty;885 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)886 , EnumExtensions.EnumExtensions.GetDesc(en)));887 en = NumAnoEnum.N1;888 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)889 , EnumExtensions.EnumExtensions.GetDesc(en)));890 en = NumAnoEnum.N2;891 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)892 , EnumExtensions.EnumExtensions.GetDesc(en)));893 en = NumAnoEnum.N3;894 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)895 , EnumExtensions.EnumExtensions.GetDesc(en)));896 en = NumAnoEnum.N4;897 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)898 , EnumExtensions.EnumExtensions.GetDesc(en)));899 en = NumAnoEnum.N5;900 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)901 , EnumExtensions.EnumExtensions.GetDesc(en)));902 en = NumAnoEnum.N6;903 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)904 , EnumExtensions.EnumExtensions.GetDesc(en)));905 en = NumAnoEnum.N12;906 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)907 , EnumExtensions.EnumExtensions.GetDesc(en)));908 return lst;909 }910 }911 public static List<KeyValuePair<string, string>> ListIndiceActivoSubjacente912 {913 get914 {915 IndiceActivoSubjacenteEnum en;916 var lst = new List<KeyValuePair<string, string>>();917 en = IndiceActivoSubjacenteEnum.Empty;918 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)919 , EnumExtensions.EnumExtensions.GetDesc(en)));920 en = IndiceActivoSubjacenteEnum.A;921 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)922 , EnumExtensions.EnumExtensions.GetDesc(en)));923 en = IndiceActivoSubjacenteEnum.I;924 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)925 , EnumExtensions.EnumExtensions.GetDesc(en)));926 en = IndiceActivoSubjacenteEnum.T;927 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)928 , EnumExtensions.EnumExtensions.GetDesc(en)));929 return lst;930 }931 }932 public static List<KeyValuePair<string, string>> ListOnOffRegular933 {934 get935 {936 OnOffRegularEnum en;937 var lst = new List<KeyValuePair<string, string>>();938 en = OnOffRegularEnum.Empty;939 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)940 , EnumExtensions.EnumExtensions.GetDesc(en)));941 en = OnOffRegularEnum.O;942 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)943 , EnumExtensions.EnumExtensions.GetDesc(en)));944 en = OnOffRegularEnum.R;945 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)946 , EnumExtensions.EnumExtensions.GetDesc(en)));947 return lst;948 }949 }950 public static List<KeyValuePair<string, string>> ListZeroOrOne951 {952 get953 {954 ZeroOrOneEnum en;955 var lst = new List<KeyValuePair<string, string>>();956 en = ZeroOrOneEnum.Empty;957 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)958 , EnumExtensions.EnumExtensions.GetDesc(en)));959 en = ZeroOrOneEnum.Zero;960 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)961 , EnumExtensions.EnumExtensions.GetDesc(en)));962 en = ZeroOrOneEnum.One;963 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)964 , EnumExtensions.EnumExtensions.GetDesc(en)));965 return lst;966 }967 }968 public static List<KeyValuePair<string, string>> Ivaldur969 {970 get971 {972 IvaldurEnum en;973 var lst = new List<KeyValuePair<string, string>>();974 en = IvaldurEnum.Empty;975 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)976 , EnumExtensions.EnumExtensions.GetDesc(en)));977 en = IvaldurEnum.I;978 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)979 , EnumExtensions.EnumExtensions.GetDesc(en)));980 en = IvaldurEnum.D;981 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)982 , EnumExtensions.EnumExtensions.GetDesc(en)));983 return lst;984 }985 }986 public static List<KeyValuePair<string, string>>Itiporev987 {988 get989 {990 ItiporevEnum en;991 var lst = new List<KeyValuePair<string, string>>();992 en = ItiporevEnum.Empty;993 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)994 , EnumExtensions.EnumExtensions.GetDesc(en)));995 en = ItiporevEnum.Credito;996 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)997 , EnumExtensions.EnumExtensions.GetDesc(en)));998 en = ItiporevEnum.Normal;999 lst.Add(new KeyValuePair<string, string>(EnumExtensions.EnumExtensions.GetValue(en)1000 , EnumExtensions.EnumExtensions.GetDesc(en)));1001 return lst;1002 }1003 }1004 static CatalogueModel()1005 {1006 }1007 static List<KeyValuePair<string, string>> toDropDownList(string[][] lista,1008 string defaultLabel = null, bool append = false)1009 {1010 List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();1011 if (defaultLabel != null && lista != null) // && lista.Count() > 1)1012 {1013 list.Add(new KeyValuePair<string, string>("", defaultLabel));1014 }...

Full Screen

Full Screen

EnumExtensions.cs

Source:EnumExtensions.cs Github

copy

Full Screen

...4using System.Reflection;5using System.Web.Mvc;6namespace System7{8 public static class EnumExtensions9 {10 public static string GetEnumDesc(this Type e, string value)11 {12 try13 {14 if (string.IsNullOrEmpty(value))15 throw new Exception("");16 FieldInfo field = e.GetField(value, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);17 if (field == (FieldInfo)null)18 return "";19 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false);20 if (customAttributes.Length > 0)21 return customAttributes[0].Description;22 return e.ToString();23 }24 catch25 {26 return "";27 }28 }29 public static string GetEnumDesc(this Type e, int? value)30 {31 try32 {33 FieldInfo[] fields = e.GetFields();34 int index = 1;35 for (int length = fields.Length; index < length; ++index)36 {37 int num = (int)Enum.Parse(e, fields[index].Name);38 int? nullable = value;39 if ((num != nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0)40 {41 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])fields[index].GetCustomAttributes(typeof(DescriptionAttribute), false);42 if (customAttributes.Length > 0)43 return customAttributes[0].Description;44 }45 }46 return "";47 }48 catch49 {50 return "";51 }52 }53 public static IEnumerable<SelectListItem> ListItem(this Type e)54 {55 List<SelectListItem> selectListItemList = new List<SelectListItem>();56 FieldInfo[] fields = e.GetFields();57 int index = 1;58 for (int length = fields.Length; index < length; ++index)59 {60 string str1 = "";61 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])fields[index].GetCustomAttributes(typeof(DescriptionAttribute), false);62 if (customAttributes.Length > 0)63 str1 = customAttributes[0].Description;64 string str2 = ((int)Enum.Parse(e, fields[index].Name)).ToString();65 selectListItemList.Add(new SelectListItem()66 {67 Text = str1,68 Value = str269 });70 }71 return (IEnumerable<SelectListItem>)selectListItemList;72 }73 public static IEnumerable<SelectListItem> ListItemByName(this Type e)74 {75 List<SelectListItem> selectListItemList = new List<SelectListItem>();76 FieldInfo[] fields = e.GetFields();77 int index = 1;78 for (int length = fields.Length; index < length; ++index)79 {80 string str1 = "";81 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])fields[index].GetCustomAttributes(typeof(DescriptionAttribute), false);82 if (customAttributes.Length > 0)83 str1 = customAttributes[0].Description;84 string str2 = Enum.Parse(e, fields[index].Name).ToString();85 selectListItemList.Add(new SelectListItem()86 {87 Text = str1,88 Value = str289 });90 }91 return (IEnumerable<SelectListItem>)selectListItemList;92 }93 public static string GetEnumDesc(this Enum e)94 {95 try96 {97 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])e.GetType().GetField(e.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);98 if (customAttributes.Length > 0)99 return customAttributes[0].Description;100 return e.ToString();101 }102 catch103 {104 return "";105 }106 }107 public static MvcHtmlString GetEnumJson(this HtmlHelper Html, Type enumType)108 {109 return MvcHtmlString.Create("({" + string.Join(",", enumType.GetEnumListItem().Select<EnumExtensions.EnumItem, string>((Func<EnumExtensions.EnumItem, string>)(enumItem_0 => string.Format("{0}:\\\"{1}\\\"", (object)enumItem_0.IntValue, (object)enumItem_0.Description)))) + "})");110 }111 public static MvcHtmlString GetEnumNameJson(this HtmlHelper Html, Type enumType)112 {113 return MvcHtmlString.Create("({" + string.Join(",", enumType.GetEnumListItem().Select<EnumExtensions.EnumItem, string>((Func<EnumExtensions.EnumItem, string>)(enumItem_0 => string.Format("\\\"{0}\\\":\\\"{1}\\\"", (object)enumItem_0.Name, (object)enumItem_0.Description)))) + "})");114 }115 public static MvcHtmlString GetDictionaryJson<T, TKey, TValue>(this IEnumerable<T> list, Func<T, TKey> funcTkey, Func<T, TValue> func_3)116 {117 string empty = string.Empty;118 Dictionary<TKey, TValue> jsonObject = new Dictionary<TKey, TValue>();119 foreach (T obj in list)120 jsonObject.Add(funcTkey(obj), func_3(obj));121 return MvcHtmlString.Create(jsonObject.ToJson());122 }123 public static List<EnumExtensions.EnumItem> GetEnumListItem(this Type enumType)124 {125 List<EnumExtensions.EnumItem> enumItemList = new List<EnumExtensions.EnumItem>();126 foreach (FieldInfo fieldInfo in ((IEnumerable<FieldInfo>)enumType.GetFields()).Where<FieldInfo>((Func<FieldInfo, bool>)(fieldInfo_0 => fieldInfo_0.Name != "value__")).ToArray<FieldInfo>())127 {128 EnumExtensions.EnumItem enumItem = new EnumExtensions.EnumItem();129 enumItem.Name = fieldInfo.Name;130 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);131 if (customAttributes != null && customAttributes.Length > 0)132 enumItem.Description = customAttributes[0].Description;133 enumItem.IntValue = (int)Enum.Parse(enumType, fieldInfo.Name);134 enumItemList.Add(enumItem);135 }136 return enumItemList;137 }138 public static List<EnumExtensions.EnumItem<T>> GetEnumListItem<T>(this Type enumType) where T : Attribute139 {140 List<EnumExtensions.EnumItem<T>> enumItemList = new List<EnumExtensions.EnumItem<T>>();141 foreach (FieldInfo fieldInfo in ((IEnumerable<FieldInfo>)enumType.GetFields()).Where<FieldInfo>((Func<FieldInfo, bool>)(fieldInfo_0 => fieldInfo_0.Name != "value__")).ToArray<FieldInfo>())142 {143 EnumExtensions.EnumItem<T> enumItem = new EnumExtensions.EnumItem<T>();144 enumItem.Name = fieldInfo.Name;145 DescriptionAttribute[] customAttributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);146 if (customAttributes != null && customAttributes.Length > 0)147 enumItem.Description = customAttributes[0].Description;148 enumItem.Attribute = (T[])fieldInfo.GetCustomAttributes(typeof(T), false);149 enumItem.IntValue = (int)Enum.Parse(enumType, fieldInfo.Name);150 enumItemList.Add(enumItem);151 }152 return enumItemList;153 }154 public static EnumExtensions.EnumItem<T> GetEnumItem<T>(this Enum e) where T : Attribute155 {156 EnumExtensions.EnumItem<T> enumItem = new EnumExtensions.EnumItem<T>();157 FieldInfo field = e.GetType().GetField(e.ToString());158 enumItem.IntValue = (int)Enum.Parse(e.GetType(), field.Name);159 enumItem.Name = field.Name;160 enumItem.Attribute = (T[])field.GetCustomAttributes(typeof(T), false);161 return enumItem;162 }163 public static int GetEnumFileInfo(this Enum e, out string EnumName, out string FieldName)164 {165 Type type = e.GetType();166 FieldInfo field = type.GetField(e.ToString());167 EnumName = type.FullName;168 FieldName = field.Name;169 return (int)Enum.Parse(type, FieldName);170 }171 public class EnumItem172 {173 public string Name { get; set; }174 public string Description { get; set; }175 public int IntValue { get; set; }176 }177 public class EnumItem<T> : EnumExtensions.EnumItem where T : Attribute178 {179 public T[] Attribute { get; set; }180 }181 }182}...

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using System.EnumExtensions;7{8 {9 static void Main(string[] args)10 {11 Console.WriteLine("Is the Color Red a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Red"));12 Console.WriteLine("Is the Color Yellow a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Yellow"));13 Console.WriteLine("Is the Color Blue a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Blue"));14 Console.WriteLine("Is the Color Green a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Green"));15 Console.WriteLine("Is the Color Purple a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Purple"));16 Console.WriteLine("Is the Color Orange a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Orange"));17 Console.ReadLine();18 }19 }20}21using System;22using System.Collections.Generic;23using System.Linq;24using System.Text;25using System.Threading.Tasks;26using System.EnumExtensions;27{28 {29 static void Main(string[] args)30 {31 Console.WriteLine("Is the Color Red a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Red"));32 Console.WriteLine("Is the Color Yellow a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Yellow"));33 Console.WriteLine("Is the Color Blue a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Blue"));34 Console.WriteLine("Is the Color Green a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Green"));35 Console.WriteLine("Is the Color Purple a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Purple"));36 Console.WriteLine("Is the Color Orange a valid value? " + EnumExtensions.IsValidValue(typeof(Color), "Orange"));37 Console.ReadLine();38 }39 }40}41using System;42using System.Collections.Generic;43using System.Linq;44using System.Text;45using System.Threading.Tasks;46using System.EnumExtensions;47{48 {49 static void Main(string[]

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6{7 {8 static void Main(string[] args)9 {10 Console.WriteLine("Enter the value of enum");11 string input = Console.ReadLine();12 int value = Convert.ToInt32(input);13 EnumExtensions e = new EnumExtensions();14 e.GetEnumValue(value);15 Console.ReadLine();16 }17 }18}19In the above code, we have created an enum called EnumExtensions. The enum has two values, one is the name of the enum and the other is the value of the enum. The value of the enum is passed as an argument to the GetEnumValue() method. The value of the enum is then converted to the string using the ToString() method. The ToString() method is used to convert the value of the enum into the string. The value of the enum

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6{7 {8 static void Main(string[] args)9 {10 var result = EnumExtensions.GetValues<DayOfWeek>();11 foreach (var item in result)12 {13 Console.WriteLine(item);14 }15 Console.ReadLine();16 }17 }18}

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using System.Collections;7using System.Reflection;8{9 {10 static void Main(string[] args)11 {12 Console.WriteLine("Hello World!");13 Console.WriteLine("Enter a number between 1-3");14 int num = int.Parse(Console.ReadLine());15 Console.WriteLine("You entered " + num);16 Console.WriteLine("The value of the enum is " + (Day)num);17 Console.WriteLine("The value of the enum is " + EnumExtensions.GetEnumDescription((Day)num));18 Console.ReadLine();19 }20 }21}

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using System;7{8 {9 static void Main(string[] args)10 {11 Console.WriteLine("Enter the day of the week:");12 string day = Console.ReadLine();13 DayOfWeek dayOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), day);14 Console.WriteLine(dayOfWeek.IsWeekend());15 Console.ReadLine();16 }17 }18}19Recommended Posts: C# | Enum.GetValues() Method20C# | Enum.GetUnderlyingType() Method21C# | Enum.GetNames() Method22C# | Enum.GetUnderlyingType() Method23C# | Enum.IsDefined() Method24C# | Enum.Parse() Method25C# | Enum.GetName() Method26C# | Enum.Format() Method27C# | Enum.ToObject() Method28C# | Enum.HasFlag() Method29C# | Enum.GetValues() Method30C# | Enum.GetUnderlyingType() Method31C# | Enum.GetNames() Method32C# | Enum.GetUnderlyingType() Method33C# | Enum.IsDefined() Method34C# | Enum.Parse() Method35C# | Enum.GetName() Method36C# | Enum.Format() Method37C# | Enum.ToObject() Method38C# | Enum.HasFlag() Method39C# | Enum.GetValues() Method40C# | Enum.GetUnderlyingType() Method41C# | Enum.GetNames() Method42C# | Enum.GetUnderlyingType() Method43C# | Enum.IsDefined() Method44C# | Enum.Parse() Method45C# | Enum.GetName() Method46C# | Enum.Format() Method47C# | Enum.ToObject() Method48C# | Enum.HasFlag() Method49C# | Enum.GetValues() Method50C# | Enum.GetUnderlyingType() Method51C# | Enum.GetNames() Method52C# | Enum.GetUnderlyingType() Method53C# | Enum.IsDefined() Method54C# | Enum.Parse() Method55C# | Enum.GetName() Method56C# | Enum.Format() Method57C# | Enum.ToObject() Method58C# | Enum.HasFlag() Method

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.IO;3using System.Linq;4using System.Collections.Generic;5using System.Text;6{7 {8 static void Main(string[] args)9 {10 Console.WriteLine("Hello World!");11 var enumValue = EnumExtensions.GetEnumValueFromDescription<EnumTest>("Test1");12 Console.WriteLine(enumValue);13 }14 }

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5{6 {7 static void Main(string[] args)8 {9 var x = EnumExtensions.GetValues<DaysOfWeek>();10 foreach (var item in x)11 {12 Console.WriteLine(item);13 }14 Console.Read();15 }16 }17 {18 }19}20public static T[] GetValues<T>()21{22 return (T[])Enum.GetValues(typeof(T));23}

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1using System;2using System.Linq;3using System.Reflection;4{5 public static void Main()6 {7 var values = Enum.GetValues(typeof(Colors)).Cast<Colors>();8 foreach (var value in values)9 {10 Console.WriteLine(value.GetDescription());11 }12 }13}

Full Screen

Full Screen

EnumExtensions

Using AI Code Generation

copy

Full Screen

1{2 public void MyMethod()3 {4 var a = EnumExtensions.GetValues<Colors>();5 var b = EnumExtensions.GetNames<Colors>();6 var c = EnumExtensions.GetDescription<Colors>(Colors.Red);7 var d = EnumExtensions.GetDescription<Colors>(Colors.Blue);8 var e = EnumExtensions.GetDescription<Colors>(Colors.Green);9 var f = EnumExtensions.GetDescription<Colors>(Colors.Yellow);10 var g = EnumExtensions.GetDescription<Colors>(Colors.Black);11 var h = EnumExtensions.GetDescription<Colors>(Colors.White);12 var i = EnumExtensions.GetDescription<Colors>(Colors.Gray);13 }14}15{16 public void MyMethod()17 {18 var a = EnumExtensions.GetValues<Colors>();19 var b = EnumExtensions.GetNames<Colors>();20 var c = EnumExtensions.GetDescription<Colors>(Colors.Red);21 var d = EnumExtensions.GetDescription<Colors>(Colors.Blue);22 var e = EnumExtensions.GetDescription<Colors>(Colors.Green);23 var f = EnumExtensions.GetDescription<Colors>(Colors.Yellow);24 var g = EnumExtensions.GetDescription<Colors>(Colors.Black);25 var h = EnumExtensions.GetDescription<Colors>(Colors.White);26 var i = EnumExtensions.GetDescription<Colors>(Colors.Gray);27 }28}29{30 public void MyMethod()31 {32 var a = EnumExtensions.GetValues<Colors>();33 var b = EnumExtensions.GetNames<Colors>();34 var c = EnumExtensions.GetDescription<Colors>(Colors.Red);35 var d = EnumExtensions.GetDescription<Colors>(Colors.Blue);36 var e = EnumExtensions.GetDescription<Colors>(Colors.Green);37 var f = EnumExtensions.GetDescription<Colors>(Colors.Yellow);38 var g = EnumExtensions.GetDescription<Colors>(Colors.Black);39 var h = EnumExtensions.GetDescription<Colors>(Colors.White);40 var i = EnumExtensions.GetDescription<Colors>(Colors.Gray);41 }42}43{44 public void MyMethod()45 {46 var a = EnumExtensions.GetValues<Colors>();47 var b = EnumExtensions.GetNames<Colors>();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run FlaUI automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in EnumExtensions

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful