code/Athena0.0.1/common/Util/wfselectoption.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Athena.common.Util
{
public class wfselectoption
{
public wfselectoption() { ;}
public object value { get; set; }
public object name { get; set; }
public wfselectoption(object value, string name)
{
this.value = value;
this.name = name;
}
public static wfselectoption Create(object instance, string valueProp = "Id", string textProp = "Name")
{
Dictionary<string, object> dic = Json.ToObject<Dictionary<string, object>>(Json.ToJson(instance));
wfselectoption option = new wfselectoption();
if (dic.Keys.Contains(valueProp) && dic.Keys.Contains(textProp))
{
option.value = dic[valueProp] == null ? null : dic[valueProp].ToString();
option.name = dic[textProp] == null ? null : dic[textProp].ToString();
}
else
{
if (option.value == null)
{
int i = 0;
foreach (var k in dic.Keys)//获取第2个
{
if (i == 0)
{
option.value = dic[k] == null ? null : dic[k].ToString();
}
if (i == 1)
{
option.name = dic[k] == null ? null : dic[k].ToString();
}
i++;
}
}
}
return option;
}
public static List<wfselectoption> CreateList<T>(IEnumerable<T> instanceList, string valueProp = "Id", string textProp = "Name")
{
List<wfselectoption> options = new List<wfselectoption>();
foreach (var instance in instanceList)
{
wfselectoption option = wfselectoption.Create(instance, valueProp, textProp);
options.Add(option);
}
后面还有 4 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
