コード例 #1
0
        private void GenerateCustomLayout(IModelDetailView modelDetailView)
        {
            ITypeInfo        iTypeInfo            = modelDetailView.ModelClass.TypeInfo;
            HashSet <string> actionContainerNames = new HashSet <string>();

            foreach (IModelViewItem item in modelDetailView.Items)
            {
                IModelPropertyEditor editorInfo = (IModelPropertyEditor)item;
                if (CustomLayoutHelper.FindModelDefaultAttribute(editorInfo.ModelMember.MemberInfo, VisiblePropertiesAttribute) != null)
                {
                    editorInfo.PropertyEditorType = typeof(DetailPropertyEditor);
                }
                string visiblePropertiesAttributeValue = ((IModelMemberExtender)item).VisibleProperties;
                if (editorInfo.PropertyEditorType == typeof(DetailPropertyEditor) && !string.IsNullOrEmpty(visiblePropertiesAttributeValue))
                {
                    string nestedViewId = iTypeInfo.Name + "_" + editorInfo.PropertyName + "_DetailView";
                    editorInfo.View = modelDetailView.Application.Views[nestedViewId];
                }
                ModelDefaultAttribute actionsContainerAttribute = CustomLayoutHelper.FindModelDefaultAttribute(editorInfo.ModelMember.MemberInfo, ActionsContainerAttribute);
                if (actionsContainerAttribute != null)
                {
                    actionContainerNames.Add(actionsContainerAttribute.PropertyValue);
                }
            }
            foreach (string name in actionContainerNames)
            {
                IModelActionContainerViewItem modelActionContainerViewItem = modelDetailView.Items.AddNode <IModelActionContainerViewItem>(name);
            }
        }
        public void WithAttribute_Should_Add_Attribute()
        {
            var attribute = new ModelDefaultAttribute(String.Empty, String.Empty);

            _Builder.WithAttribute(attribute);

            A.CallTo(() => _TypeInfo.AddAttribute(A<Attribute>.That.Matches(t => t.Equals(attribute)))).MustHaveHappened();
        }
コード例 #3
0
        public void WithAttribute_Should_Add_Attribute()
        {
            var attribute = new ModelDefaultAttribute(String.Empty, String.Empty);

            _Builder.WithAttribute(attribute);

            A.CallTo(() => _TypeInfo.AddAttribute(A <Attribute> .That.Matches(t => t.Equals(attribute)))).MustHaveHappened();
        }
コード例 #4
0
 private void GenerateModelClasses(ModelNode boModel, ITypeInfo typeTnfo)
 {
     foreach (IMemberInfo memberInfo in typeTnfo.OwnMembers)
     {
         ModelDefaultAttribute attribute = CustomLayoutHelper.FindModelDefaultAttribute(memberInfo, CustomDetailViewItemsGenarator.VisiblePropertiesAttribute);
         if ((attribute != null) && (!string.IsNullOrEmpty(attribute.PropertyValue)))
         {
             IModelClass modelClass = ((IModelBOModel)boModel)[memberInfo.MemberType.FullName];
             if (modelClass == null)
             {
                 modelClass = boModel.AddNode <IModelClass>(memberInfo.MemberType.FullName);
                 ITypeInfo typeInfo = XafTypesInfo.Instance.FindTypeInfo(memberInfo.MemberType);
                 modelClass.SetValue <ITypeInfo>("TypeInfo", typeInfo);
             }
             CustomLayoutHelper.Instance.RegisterClassVisibleProperties(modelClass.Name, attribute.PropertyValue);
         }
     }
 }
コード例 #5
0
        private void AddLayoutItemNode(IModelLayoutGroup layoutGroup, IModelPropertyEditor editor)
        {
            ModelDefaultAttribute modelDefaultAttribute = FindModelDefaultAttribute(editor.ModelMember.MemberInfo, CustomDetailViewItemsGenarator.ActionsContainerAttribute);

            if (modelDefaultAttribute != null)
            {
                IModelViewItem container = editor.Parent.GetNode(modelDefaultAttribute.PropertyValue) as IModelViewItem;
                if ((container != null))
                {
                    IModelLayoutViewItem item = layoutGroup.AddNode <IModelLayoutViewItem>(container.Id);
                    item.ViewItem = container;
                    item.Index    = editor.Index;
                }
            }
            else
            {
                IModelLayoutViewItem item = layoutGroup.AddNode <IModelLayoutViewItem>(editor.PropertyName);
                item.ViewItem = editor;
                item.Index    = editor.Index;
            }
        }
コード例 #6
0
        string GetMemberDisplayFormat(IMemberInfo memberInfo)
        {
            string       result      = "";
            IModelMember modelMember = GetPropertyModel(memberInfo);

            if (modelMember != null)
            {
                result = modelMember.DisplayFormat;
            }
            else
            {
                ModelDefaultAttribute displayFormatAttribute =
                    memberInfo.FindAttributes <ModelDefaultAttribute>().FirstOrDefault(
                        attribute => attribute.PropertyName == "DisplayFormat");
                if (displayFormatAttribute != null)
                {
                    result = displayFormatAttribute.PropertyValue;
                }
            }
            return(result);
        }