本文整理汇总了C#中IEditableRoot.GetAllPropertiesForInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IEditableRoot.GetAllPropertiesForInstance方法的具体用法?C# IEditableRoot.GetAllPropertiesForInstance怎么用?C# IEditableRoot.GetAllPropertiesForInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEditableRoot
的用法示例。
在下文中一共展示了IEditableRoot.GetAllPropertiesForInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDetailsReadModel
public static DetailsReadModel CreateDetailsReadModel(IEditableRoot model, int childIndex = 0)
{
if (model == null)
{
throw new ArgumentNullException("model");
}
try
{
var result = new DetailsReadModel(model.Id, model.ProcessName, model.ProcessDisplayName)
{
ChildIndex = childIndex
};
var props = model.GetAllPropertiesForInstance();
var visibleFields = new HashSet<string>(model.Sections.SelectMany(s => s.Fields).Where(f => !f.IsHidden).Select(f => f.SystemName));
var sections = model.Sections.OrderBy(s => s.Position).Select(s => new SectionReadModel {Name = s.Name}).ToList();
foreach (var prop in props.Keys)
{
if (!visibleFields.Contains(prop.Name))
{
continue;
}
var field = new FieldReadModel(props[prop], prop);
var section = sections.FirstOrDefault(s => s.Name == field.SectionName);
if (section == null)
{
section = new SectionReadModel {Name = field.SectionName};
sections.Add(section);
}
else
{
var sect = model.Sections.First(s => s.Name == field.SectionName);
field.Position = sect.Fields.First(f => f.SystemName == field.SystemName).Position;
}
section.AddField(field);
}
foreach (var section in sections)
{
section.SortFields();
}
result.Sections = sections;
var supportStates = model as ISupportStates;
if (supportStates != null)
{
result.CurrentState = Guid.Empty == supportStates.CurrentStateGuid ? null : supportStates.CurrentStateGuid.ToString();
var nextStates = new List<IState>();
if (supportStates.CurrentState.HasValue)
{
var currentState = supportStates.StateManager.States.FirstOrDefault(s => s.Guid == supportStates.CurrentStateGuid);
if (currentState != null)
{
nextStates.Add(currentState);
}
}
nextStates.AddRange(supportStates.GetNextAvailableStates());
result.NextStates = nextStates.Select(s => new StateReadModel {Id = s.Id, Name = s.Name, Guid = s.Guid});
}
result.Title = GetTitle(model);
result.BrokenRules = GetBrokenRules(model);
//var editableRootType = TheDynamicTypeManager.Value.GetEditableRootType(processName);
//return BusinessRules.HasPermission(AuthorizationActions.CreateObject, editableRootType);
result.CanAdd = BusinessRules.HasPermission(AuthorizationActions.CreateObject, model);
return result;
}
catch (Exception)
{
//Logger.Log(LogSeverity.Error, "CreateDetailsReadModel", ex);
throw;
}
}
示例2: GetFields
private List<FieldReadModel> GetFields(IEditableRoot model)
{
var props = model.GetAllPropertiesForInstance();
var fields = new List<FieldReadModel>();
var displayFields = AnswerDisplayFields.ToDictionary(x => x.FieldName);
try
{
foreach (var prop in props.Keys)
{
if (!displayFields.ContainsKey(prop.Name))
{
continue;
}
var displayField = displayFields[prop.Name];
var field = new FieldReadModel(props[prop], prop);
field.Position = displayField.Position;
fields.Add(field);
}
}
catch (Exception ex)
{
Logger.Log(LogSeverity.Error, GetType().ToString(), ex);
}
fields = fields.Where(f => !string.IsNullOrEmpty(f.SectionName)).ToList();
return fields;
}