Exemple #1
0
        protected virtual void CreateMemberNode(IModelClass classNode, IMemberInfo memberInfo, IModelMember propertyNode)
        {
            propertyNode.SetValue("MemberInfo", memberInfo);
            var indexAttribute = memberInfo.FindAttribute <IndexAttribute>();

            if (indexAttribute != null)
            {
                propertyNode.Index = (int)indexAttribute.Value;
            }
            const BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
            var methodInfo = typeof(ModelNode).GetMethod("SetSerializedValue", bindingFlags);

            foreach (CustomAttribute attribute in memberInfo.FindAttributes <CustomAttribute>())
            {
                methodInfo.Invoke(propertyNode, new object[] { attribute.Name, attribute.Value });
            }
            var exportedAttributeValues = new Dictionary <string, object>();

            foreach (ModelExportedValuesAttribute attribute in memberInfo.FindAttributes <ModelExportedValuesAttribute>())
            {
                attribute.FillValues(exportedAttributeValues);
            }
            methodInfo = typeof(ModelNode).GetMethod("SetSerializableValues", bindingFlags);
            methodInfo.Invoke(propertyNode, new object[] { exportedAttributeValues });
        }
        void HandleCustomAttribute(IMemberInfo memberInfo, ITypesInfo typesInfo)
        {
            var customAttributes = memberInfo.FindAttributes <Attribute>().OfType <ICustomAttribute>().ToList();

            foreach (var customAttribute in customAttributes)
            {
                for (int index = 0; index < customAttribute.Name.Split(';').Length; index++)
                {
                    string s        = customAttribute.Name.Split(';')[index];
                    var    theValue = customAttribute.Value.Split(';')[index];
                    var    typeInfo = typesInfo.FindTypeInfo(theValue);
                    if (customAttribute is PropertyEditorAttribute && typeInfo.IsInterface)
                    {
                        if (!typeInfo.Implementors.Any())
                        {
                            if (Application != null)
                            {
                                throw new InvalidOperationException(typeInfo.FullName + " has no implementors");
                            }
                        }
                        else
                        {
                            var single = typeInfo.Implementors.Single(info => !info.FindAttribute <DevExpress.ExpressApp.Editors.PropertyEditorAttribute>().IsDefaultEditor);
                            theValue = single.Type.FullName;
                        }
                    }
                    memberInfo.AddAttribute(new ModelDefaultAttribute(s, theValue));
                }
            }
        }
Exemple #3
0
        void HandleCustomAttribute(IMemberInfo memberInfo, ITypesInfo typesInfo)
        {
            var customAttributes = memberInfo.FindAttributes <Attribute>().OfType <ICustomAttribute>().ToList();

            foreach (var customAttribute in customAttributes)
            {
                for (int index = 0; index < customAttribute.Name.Split(';').Length; index++)
                {
                    string s        = customAttribute.Name.Split(';')[index];
                    var    theValue = customAttribute.Value.Split(';')[index];
                    var    typeInfo = typesInfo.FindTypeInfo(theValue);
                    if (customAttribute is PropertyEditorAttribute && typeInfo.IsInterface)
                    {
                        try {
                            theValue = typeInfo.Implementors.Single().FullName;
                        }
                        catch (InvalidOperationException) {
                            if (Application != null)
                            {
                                throw new InvalidOperationException(typeInfo.FullName + " has no implementors");
                            }
                        }
                    }
                    memberInfo.AddAttribute(new CustomAttribute(s, theValue));
                }
            }
        }
 public static IObservable <KeyValuePair <object, string> > WhenCheckedListBoxItems(this ObjectString objectString, IMemberInfo member, object o)
 => objectString.WhenCheckedListBoxItems()
 .SelectMany(t2 => member.FindAttributes <DataSourcePropertyAttribute>()
             .SelectMany(attribute => ((IEnumerable)member.Owner.FindMember(attribute.DataSourceProperty).GetValue(o)).Cast <object>())
             .ToDictionary(o1 => o1, o1 => $"{o1}").ToObservable(Scheduler.Immediate)
             .SwitchIfEmpty(Observable.Defer(() => ((IEnumerable)member.GetValue(o)).Cast <object>()
                                             .ToDictionary(o1 => (object)$"{o1}", o1 => $"{o1}").ToObservable(Scheduler.Immediate)))
             .Where(dict => !t2.e.Objects.ContainsKey(dict.Key))
             .Do(pair => t2.e.Objects.Add(pair.Key, pair.Value)));
 private static IEnumerable <T> AddMarkupPropertyEditorAttributes <T>(this IMemberInfo memberInfo, Func <T, string> valueFactory = null) where T : Attribute
 => memberInfo.FindAttributes <T>().ToArray()
 .Execute(_ => {
     memberInfo.AddAttribute(new EditorAliasAttribute(EditorAliases.MarkupContent));
     if (valueFactory != null)
     {
         var value = valueFactory.Invoke(_);
         memberInfo.AddAttribute(new ModelDefaultAttribute("DisplayFormat", value));
     }
 });
 private static ModelDefaultAttribute FindModelDefaultAttribute(IMemberInfo memberInfo, string attributeName)
 {
     foreach (ModelDefaultAttribute modelDefaultAttribute in memberInfo.FindAttributes <ModelDefaultAttribute>())
     {
         if (modelDefaultAttribute.PropertyName == attributeName)
         {
             return(modelDefaultAttribute);
         }
     }
     return(null);
 }
Exemple #7
0
        protected void OnSetupGridField(AnalysisEditorBase analysisEditor, PivotGridFieldBase pivotGridField)
        {
            IMemberInfo          memberInfo1 = analysisEditor.MemberInfo.GetPath()[0];
            IEnumerable <string> properties  =
                memberInfo1.FindAttributes <PivotedSortAttribute>().Select(attribute => attribute.PropertyName);

            if (properties.Contains(pivotGridField.FieldName))
            {
                pivotGridField.SortMode = PivotSortMode.Custom;
            }
        }
 protected override void CustomSort(IAnalysisControl analysisControl, IMemberInfo memberInfo){
     ASPxPivotGrid pivotGridControl = ((AnalysisControlWeb)analysisControl).PivotGrid;
     pivotGridControl.CustomFieldSort += (sender, args) =>{
         var pivotedSortAttribute = memberInfo.FindAttributes<PivotedSortAttribute>().SingleOrDefault(attribute => attribute.PropertyName == args.Field.FieldName);
         if (pivotedSortAttribute != null){
             var compareResult = GetCompareResult(pivotedSortAttribute.SortDirection,
                 args.GetListSourceColumnValue(args.ListSourceRowIndex1, pivotedSortAttribute.SortPropertyName),
                 args.GetListSourceColumnValue(args.ListSourceRowIndex2, pivotedSortAttribute.SortPropertyName));
             args.Result = compareResult;
             args.Handled = true;
         }
     };
 }
Exemple #9
0
        protected override void CustomSort(IAnalysisControl analysisControl, IMemberInfo memberInfo)
        {
            ASPxPivotGrid pivotGridControl = ((AnalysisControlWeb)analysisControl).PivotGrid;

            pivotGridControl.CustomFieldSort += (sender, args) => {
                var pivotedSortAttribute = memberInfo.FindAttributes <PivotedSortAttribute>().SingleOrDefault(attribute => attribute.PropertyName == args.Field.FieldName);
                if (pivotedSortAttribute != null)
                {
                    var compareResult = GetCompareResult(pivotedSortAttribute.SortDirection,
                                                         args.GetListSourceColumnValue(args.ListSourceRowIndex1, pivotedSortAttribute.SortPropertyName),
                                                         args.GetListSourceColumnValue(args.ListSourceRowIndex2, pivotedSortAttribute.SortPropertyName));
                    args.Result  = compareResult;
                    args.Handled = true;
                }
            };
        }
 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;
 }
 void HandleCustomAttribute(IMemberInfo memberInfo, ITypesInfo typesInfo) {
     var customAttributes = memberInfo.FindAttributes<Attribute>().OfType<ICustomAttribute>().ToList();
     foreach (var customAttribute in customAttributes) {
         for (int index = 0; index < customAttribute.Name.Split(';').Length; index++) {
             string s = customAttribute.Name.Split(';')[index];
             var theValue = customAttribute.Value.Split(';')[index];
             var typeInfo = typesInfo.FindTypeInfo(theValue);
             if (customAttribute is PropertyEditorAttribute && typeInfo.IsInterface) {
                 try {
                     theValue = typeInfo.Implementors.Single().FullName;
                 } catch (InvalidOperationException) {
                     if (Application != null)
                         throw new InvalidOperationException(typeInfo.FullName + " has no implementors");
                 }
             }
             memberInfo.AddAttribute(new ModelDefaultAttribute(s, theValue));
         }
     }
 }
Exemple #12
0
        private string GetMemberDisplayFormat(IMemberInfo memberInfo)
        {
            string       result      = "";
            IModelMember modelMember = GetPropertyModel(memberInfo);

            if (modelMember != null)
            {
                result = modelMember.DisplayFormat;
            }
            else
            {
                CustomAttribute displayFormatAttribute = memberInfo.FindAttributes <CustomAttribute>().FirstOrDefault(attribute => attribute.Name == "DisplayFormat");
                if (displayFormatAttribute != null)
                {
                    result = displayFormatAttribute.Value;
                }
            }
            return(result);
        }
Exemple #13
0
 .SelectMany(memberInfo => memberInfo.FindAttributes <T>().ToArray().ToObservable(Scheduler.Immediate)
             .SwitchIfEmpty(typeof(T).CreateInstance().ReturnObservable().Cast <T>())
             .Select(attribute => (memberInfo, attribute)))