当前位置: 首页>>代码示例>>C#>>正文


C# IEditableRoot.GetAllPropertiesForInstance方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:85,代码来源:ProcessController.cs

示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:34,代码来源:ChecklistFieldOptions.cs


注:本文中的IEditableRoot.GetAllPropertiesForInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。