private void ProcessBoolean(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber, ref String Value) { if ((Boolean)objValue) { Value = "<span class=\"glyphicon glyphicon-ok\"></span>"; } }
public MemberPermission CreateMemberPermission(object entity, Type type, IMemberInfo member) { return(new MemberPermission { Read = Security.IsGranted(new PermissionRequest(ObjectSpace, type, SecurityOperations.Read, entity, member.Name)), Write = Security.IsGranted(new PermissionRequest(ObjectSpace, type, SecurityOperations.Write, entity, member.Name)) }); }
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)); } } }
/// <inheritdoc/> protected override CriteriaOperator CreateCriteriaOperator(IMemberInfo memberInfo, string valueToSearch) { Guard.ArgumentNotNull(memberInfo, "memberInfo"); if (string.IsNullOrEmpty(valueToSearch)) { return null; } string trimmedValueToSearch = valueToSearch.Trim(); if (!string.IsNullOrEmpty(trimmedValueToSearch)) { if (memberInfo.MemberType == typeof(string)) { return new FunctionOperator(FunctionOperatorType.Contains, new FunctionOperator(FunctionOperatorType.Upper, new OperandProperty(memberInfo.Name)), new FunctionOperator(FunctionOperatorType.Upper, new OperandValue(trimmedValueToSearch))); } else { object convertedValue = null; if (TryConvertStringTo(memberInfo.MemberType, trimmedValueToSearch, out convertedValue)) { return new BinaryOperator(memberInfo.Name, convertedValue, BinaryOperatorType.Equal); } } return null; } return null; }
void CreateProperty <TContainer, TValue>(IMemberInfo member, ReflectedPropertyBag <TContainer> propertyBag) { if (typeof(TValue).IsPointer) { return; } var arrayProperty = ReflectedPropertyBagUtils.TryCreateUnityObjectArrayProperty <TContainer, TValue>(member); if (arrayProperty != null) { propertyBag.AddProperty(arrayProperty); return; } var listProperty = ReflectedPropertyBagUtils.TryCreateUnityObjectListProperty <TContainer, TValue>(member); if (listProperty != null) { propertyBag.AddProperty(listProperty); return; } var property = ReflectedPropertyBagUtils.TryCreateUnityObjectProperty <TContainer>(member); if (property != null) { propertyBag.AddProperty(property); return; } propertyBag.AddProperty(new ReflectedMemberProperty <TContainer, TValue>(member, member.Name)); }
/// <summary> /// Initalizes a new instance of the <see cref="SuggestWeightFieldValueProvider"/> class. /// </summary> /// <param name="member">Member Info for the suggest field</param> /// <param name="fieldName">ElasticSearch field name</param> public SuggestWeightFieldValueProvider(MemberInfo member, string fieldName) { var ci = BYteWareTypeInfo.GetBYteWareTypeInfo(member.DeclaringType); _Member = ci.TypeInfo?.FindMember(member.Name); _WeightField = ci.ESSuggestFields.First(t => t.FieldName == fieldName).WeightField; }
public override string TransformType(IMemberInfo member) { var result = TransformType(member.Type); if (member.IsOptional) { result = $"TOptional<{result}>"; } if (member.CollectionType != CollectionType.None) { switch (member.CollectionType) { case CollectionType.List: result = $"TArray<{result}>"; break; case CollectionType.Dictionary: throw new NotImplementedException(); break; case CollectionType.Queue: result = $"TQueue<{result}>"; break; case CollectionType.Stack: result = $"TStack<{result}>"; break; } } return(result); }
/// <summary> /// Creates an instance of the rule. /// </summary> /// <param name="action">Action this rule will enforce.</param> /// <param name="element">Member to be authorized.</param> /// <param name="creatorProperty">Name of the property for the creator ID.</param> /// <param name="getCurrentUserDelegate">The Func delegate to get the current user ID.</param> public IsOwner(AuthorizationActions action, IMemberInfo element, string creatorProperty, Func <int> getCurrentUserDelegate) : base(action, element) { _creatorProperty = creatorProperty; _getCurrentUserDelegate = getCurrentUserDelegate; }
static TestHost CreateCustomHost(TypeInfo fixture, IMemberInfo member, TestHostAttribute attr) { bool useFixtureInstance; var hostType = GetCustomHostType(fixture, member, attr, out useFixtureInstance); return(new CustomTestHost(attr.Identifier ?? member.Name, member.Type.AsType(), hostType, attr.TestFlags, attr, useFixtureInstance)); }
static Type GetCustomHostType( TypeInfo fixtureType, IMemberInfo member, TestHostAttribute attr, out bool useFixtureInstance) { var hostType = typeof(ITestHost <>).GetTypeInfo(); var genericInstance = hostType.MakeGenericType(member.Type.AsType()).GetTypeInfo(); if (attr.HostType != null) { if (!genericInstance.IsAssignableFrom(attr.HostType.GetTypeInfo())) { throw new InternalErrorException(); } useFixtureInstance = genericInstance.IsAssignableFrom(fixtureType); return(attr.HostType); } if (genericInstance.IsAssignableFrom(fixtureType)) { useFixtureInstance = true; return(null); } throw new InternalErrorException(); }
/// <summary> /// Creates an instance of the rule. /// </summary> /// <param name="action">Action this rule will enforce.</param> /// <param name="element">Member to be authorized.</param> /// <param name="statusProperty">Name of the property for the status ID.</param> /// <param name="restrictedStatus">The statuses subject to restrictions.</param> /// <param name="roles">List of allowed roles.</param> public RestrictByStatusOrIsInRole(AuthorizationActions action, IMemberInfo element, string statusProperty, List <int> restrictedStatus, params string[] roles) : base(action, element) { _statusProperty = statusProperty; _restrictedStatus = restrictedStatus; _roles = new List <string>(roles); }
public String FormatValue(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber) { String Value = ""; if (memberInfo != null && objValue != null) { if (objValue is System.Drawing.Bitmap) { ProcessBitmap(memberInfo, objValue, columnModel, RowNumber, ref Value); } else if (objValue is Enum) { ProcessEnum(memberInfo, objValue, columnModel, RowNumber, ref Value); } else if (objValue is Boolean) { ProcessBoolean(memberInfo, objValue, columnModel, RowNumber, ref Value); } else if (objValue is Color) { ProcessColor(memberInfo, objValue, columnModel, RowNumber, ref Value); } else { ProcessDefault(memberInfo, objValue, columnModel, RowNumber, ref Value); } } return(Value); }
static bool SignatureEquals(IMemberInfo targetMember, IMemberInfo ifaceMember) { if (targetMember is not IEventInfo targetEvent || ifaceMember is not IEventInfo ifaceEvent) { return(false); } if (ifaceEvent.AddMethod is not null) { if (targetEvent.AddMethod?.SignatureEquals(ifaceEvent.AddMethod, ignoreVisibility: true) is not true) { return(false); } } if (ifaceEvent.RemoveMethod is not null) { if (targetEvent.RemoveMethod?.SignatureEquals(ifaceEvent.RemoveMethod, ignoreVisibility: true) is not true) { return(false); } } return(true); }
/// <summary>联系信息</summary> /// <returns></returns> public ActionResult Avatar() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; IMemberInfo member = MembershipManagement.Instance.MemberService[this.Account.Id]; if (member == null) { ApplicationError.Write(404); } ViewBag.member = member; IAccountInfo account = MembershipManagement.Instance.AccountService[member.Account.Id]; string avatar_180x180 = string.Empty; if (string.IsNullOrEmpty(account.CertifiedAvatar)) { avatar_180x180 = MembershipConfigurationView.Instance.AvatarVirtualFolder + "default_180x180.png"; } else { avatar_180x180 = account.CertifiedAvatar.Replace("{avatar}", MembershipConfigurationView.Instance.AvatarVirtualFolder); } ViewBag.avatar_180x180 = avatar_180x180; return(View("/views/main/account/settings/avatar.cshtml")); }
protected override string GetDefaultStringRepresentation(object value) { if (value == null) { return(NullValueString); } if (value is XPWeakReference) { if (!(value as XPWeakReference).IsAlive) { return(NullValueString); } return((value as XPWeakReference).Target.ToString()); } ITypeInfo ti = XafTypesInfo.Instance.FindTypeInfo(value.GetType()); IMemberInfo defaultMember = (ti != null) ? ti.DefaultMember : null; string result; if (defaultMember != null) { object memberValue = defaultMember.GetValue(value); result = memberValue == null ? NullValueString : memberValue.ToString(); } else { result = value.ToString(); } if (!(value is string) && result.Length > MaxLengthOfValue) { result = BlobDataString; } return(result); }
private static void ParseSimpleProperty(JObject jObject, object obj, IMemberInfo memberInfo) { JValue jValue = (JValue)jObject[memberInfo.Name]; object value = ConvertType(jValue, memberInfo); memberInfo.SetValue(obj, value); }
/// <inheritdoc /> public IEnumerable <SelectedMemberInfo> SelectMembers( IEnumerable <SelectedMemberInfo> selectedMembers, IMemberInfo context, IEquivalencyAssertionOptions config) { return(selectedMembers.Where(m => m.Name != nameof(IIntegrationEvent.Id) && m.Name != nameof(IIntegrationEvent.Created))); }
private void callback_Callback(object source, CallbackEventArgs e) { String[] p = e.Parameter.Split('|'); Object key = TypeDescriptor.GetConverter(ObjectTypeInfo.KeyMember.MemberType).ConvertFromString(p[0]); IMemberInfo member = ObjectTypeInfo.FindMember(p[1]); Object value = null; if (typeof(IXPSimpleObject).IsAssignableFrom(member.MemberType)) { Type memberKeyType = XafTypesInfo.Instance.FindTypeInfo(member.MemberType).KeyMember.MemberType; int index1 = p[2].LastIndexOf("(", StringComparison.Ordinal); int index2 = p[2].LastIndexOf(")", StringComparison.Ordinal); if (index1 > 0 && index2 > index1) { string memberKeyText = p[2].Substring(index1 + 1, index2 - index1 - 1); value = ObjectSpace.GetObjectByKey(member.MemberType, Convert.ChangeType(memberKeyText, memberKeyType)); } } else { value = TypeDescriptor.GetConverter(member.MemberType).ConvertFromString(p[2]); } object obj = ObjectSpace.GetObjectByKey(ObjectTypeInfo.Type, key); member.SetValue(obj, value); ObjectSpace.CommitChanges(); }
IClassInfoGraphNode addClassInfoGraphNode(ObjectSpace objectSpace, IMemberInfo memberInfo, NodeType nodeType) { var classInfoGraphNode =(IClassInfoGraphNode)objectSpace.CreateObject(TypesInfo.Instance.ClassInfoGraphNodeType); classInfoGraphNode.Name = memberInfo.Name; classInfoGraphNode.TypeName = getSerializedType(memberInfo).Name; classInfoGraphNode.NodeType=nodeType; return classInfoGraphNode; }
/// <summary> /// Creates an instance of <see cref="MemberMetadataBuilder"/> /// </summary> /// <param name="memberInfo">The member information to use</param> /// <param name="successorMetadataBuilder">A succesor metadata builder to use</param> /// <param name="isSkipped">A value that indicates whether a value must be skipped during binary serialization</param> public MemberMetadataBuilder(IMemberInfo memberInfo, IMetadataBuilder successorMetadataBuilder, bool isSkipped = false) { this._memberInfo = memberInfo; this._successorMetadataBuilder = successorMetadataBuilder; _isSkipped = isSkipped; }
private XPCustomMemberInfo CreateMemberInfo(ITypesInfo typesInfo, IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute) { var typeToCreateOn = getTypeToCreateOn(memberInfo, associationAttribute); if (typeToCreateOn == null) throw new NotImplementedException(); XPCustomMemberInfo xpCustomMemberInfo; if (!(memberInfo.IsList) || (memberInfo.IsList && providedAssociationAttribute.RelationType == RelationType.ManyToMany)) { xpCustomMemberInfo = typesInfo.CreateCollection( typeToCreateOn, memberInfo.Owner.Type, associationAttribute.Name, XpandModuleBase.Dictiorary, providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.Type.Name + "s", false); } else { xpCustomMemberInfo = typesInfo.CreateMember( typeToCreateOn, memberInfo.Owner.Type, associationAttribute.Name, XpandModuleBase.Dictiorary, providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.Type.Name, false); } if (!string.IsNullOrEmpty(providedAssociationAttribute.AssociationName) && memberInfo.FindAttribute<AssociationAttribute>() == null) memberInfo.AddAttribute(new AssociationAttribute(providedAssociationAttribute.AssociationName)); typesInfo.RefreshInfo(typeToCreateOn); return xpCustomMemberInfo; }
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 }); }
/// <summary> /// Creates an instance of the rule. /// </summary> /// <param name="action">Action this rule will enforce.</param> /// <param name="element">Member to be authorized.</param> /// <param name="creatorProperty">Name of the property for the creator ID.</param> /// <param name="getCurrentUserDelegate">The Func delegate to get the current user ID.</param> /// <param name="roles">List of allowed roles.</param> public IsOwnerOrIsInRole(AuthorizationActions action, IMemberInfo element, string creatorProperty, Func <int> getCurrentUserDelegate, params string[] roles) : base(action, element) { _creatorProperty = creatorProperty; _getCurrentUserDelegate = getCurrentUserDelegate; _roles = new List <string>(roles); }
internal static TestFilter CreateTestFilter(TestFilter parent, IMemberInfo member) { var categories = ReflectionHelper.GetCategories(member); var features = ReflectionHelper.GetFeatures(member); return(new TestFilter(parent, categories, features)); }
public MemberPermission CreateMemberPermission(object entity, IMemberInfo member) { return(new MemberPermission { Read = Security.CanRead(entity, member.Name), Write = Security.CanWrite(entity, member.Name) }); }
private static bool IsInvalidMember([JetBrains.Annotations.NotNull] IMemberInfo x) { if (x.SelectedMemberPath.EndsWith("ConnectionString")) { return(true); } if (x.SelectedMemberPath.Contains(".ParentCategory.")) { return(true); } if (x.SelectedMemberPath.Contains(".DeleteThis")) { return(true); } if (x.SelectedMemberPath.Contains(".ParentAffordance")) { return(true); } if (x.SelectedMemberPath.EndsWith("ID")) { return(true); } if (x.SelectedMemberPath.EndsWith(".CarpetPlotBrush")) { return(true); } return(false); }
void HandleNumericFormatAttribute(IMemberInfo memberInfo) { var numericFormatAttribute = memberInfo.FindAttribute<NumericFormatAttribute>(); if (numericFormatAttribute != null) { memberInfo.AddAttribute(new CustomAttribute("EditMaskAttribute", "f0")); memberInfo.AddAttribute(new CustomAttribute("DisplayFormatAttribute", "#")); } }
public void UpdateAssemblyTree(List <IReferenceInfo> references, IMemberInfo definition) { this.assemblyTreeView.Type = AssemblyTreeType.References; this.searchTextBox.Text = referencesText; this.assemblyTreeView.ClearNodes(); #region Add definition to tree AssemblyTreeFile file = this.assemblyTreeView.FindFile(definition.SF); if (file == null) { file = new AssemblyTreeFile(definition.SF); this.assemblyTreeView.Add(file); } file.Add(new AssemblyTreeMember(definition)); #endregion #region Add references to tree foreach (IReferenceInfo refI in references) { file = this.assemblyTreeView.FindFile(refI.SF); if (file == null) { file = new AssemblyTreeFile(refI.SF); this.assemblyTreeView.Add(file); } file.Add(new AssemblyTreeMember(refI)); } #endregion this.assemblyTreeView.CurrentNode = null; this.assemblyTreeView.RefreshNodes(); }
static Type GetParameterHostType(IMemberInfo member, TestParameterAttribute attr, out object sourceInstance) { var hostType = typeof(ITestParameterSource <>).GetTypeInfo(); var genericInstance = hostType.MakeGenericType(member.Type).GetTypeInfo(); var attrType = attr.GetType(); if (genericInstance.IsAssignableFrom(attrType.GetTypeInfo())) { sourceInstance = attr; return(attrType); } if (member.Type.Equals(typeof(bool))) { sourceInstance = null; return(typeof(BooleanTestSource)); } else if (member.TypeInfo.IsEnum) { sourceInstance = null; return(typeof(EnumTestSource <>).MakeGenericType(member.Type)); } throw new InternalErrorException(); }
internal static IEnumerable <TestFeature> GetFeatures(IMemberInfo member) { foreach (var cattr in member.GetCustomAttributes <TestFeatureAttribute> ()) { yield return(cattr.Feature); } }
public virtual string TransformType(IMemberInfo member) { var result = TransformType(member.Type); if (member.IsOptional) { result = $"std::optional<{result}>"; } if (member.CollectionType != CollectionType.None) { switch (member.CollectionType) { case CollectionType.List: result = $"std::vector<{result}>"; break; case CollectionType.Dictionary: throw new NotImplementedException(); break; case CollectionType.Queue: result = $"std::queue<{result}>"; break; case CollectionType.Stack: result = $"std::stack<{result}>"; break; } } return(result); }
public void OpenMember(AssemblyTreeMember member) { if (member.Member is IMemberInfo) { IMemberInfo memberInfo = (IMemberInfo)member.Member; FileManager.GoToDefinition(memberInfo); // TODO: remove threading! if (memberInfo.SF == this.fileManager.CurrentFile) { this.assemblyTreeView.CurrentNode = member; this.assemblyTreeView.RefreshSelectedNode(false); } } else if (member.Member is IReferenceInfo) { IReferenceInfo referenceInfo = (IReferenceInfo)member.Member; FileManager.GoToPosition(referenceInfo.SF, referenceInfo.CharIndex, referenceInfo.CharLength, referenceInfo); if (referenceInfo.SF == this.fileManager.CurrentFile) { this.assemblyTreeView.CurrentNode = member; this.assemblyTreeView.RefreshSelectedNode(false); } } }
Object FindObjectToOpen(GridColumn column, int rowHandle) { Object result = null; if (column != null && GridListEditor != null && GridListEditor.GridView() != null) { Object currObject = XtraGridUtils.GetRow(GridListEditor.GridView(), rowHandle); ITypeInfo typeInfo = currObject != null ? XafTypesInfo.Instance.FindTypeInfo(currObject.GetType()) : _listView.ObjectTypeInfo; IMemberInfo memberInfo = typeInfo.FindMember(column.FieldName); Object lastObject = null; if (GridListEditor.GridView().ActiveEditor != null) { lastObject = GridListEditor.GridView().ActiveEditor.EditValue; } else if (currObject != null && memberInfo != null) { lastObject = FindLastObject(currObject, memberInfo); } if (memberInfo != null && (IsDetailViewExists(lastObject) && DataManipulationRight.CanRead(typeInfo.Type, memberInfo.Name, currObject, LinkToListViewController.FindCollectionSource( Controller.Frame), ObjectSpace))) { result = lastObject; } } return(result); }
static string GetMemberCaption(IMemberInfo memberInfo) { string memberCaption = null; var displayNameAttr = memberInfo.FindAttribute <DisplayNameAttribute>(); if (displayNameAttr != null) { memberCaption = displayNameAttr.DisplayName; } if (string.IsNullOrEmpty(memberCaption)) { var attribute = memberInfo.FindAttribute <XafDisplayNameAttribute>(); if (attribute != null) { memberCaption = attribute.DisplayName; } } if (string.IsNullOrEmpty(memberCaption)) { memberCaption = memberInfo.DisplayName; } if (string.IsNullOrEmpty(memberCaption)) { memberCaption = CaptionHelper.ConvertCompoundName(memberInfo.Name); } return(memberCaption); }
IClassInfoGraphNode CreateComplexNode(IMemberInfo memberInfo, IObjectSpace objectSpace) { NodeType nodeType = memberInfo.MemberTypeInfo.IsPersistent ? NodeType.Object : NodeType.Collection; IClassInfoGraphNode classInfoGraphNode = CreateClassInfoGraphNode(objectSpace, memberInfo, nodeType); classInfoGraphNode.SerializationStrategy = GetSerializationStrategy(memberInfo, SerializationStrategy.SerializeAsObject); Generate(objectSpace, ReflectionHelper.GetType(classInfoGraphNode.TypeName)); return classInfoGraphNode; }
private void SetTemplate() { Settings = X.Instance<IMemberInfo>( XProto.MemberInfo ); UserInfo.DataContext = Settings; Sign.Text = Settings.Signature; Settings.PropertyChanged += PropertyChanged; }
void HandleSequencePropertyAttribute(IMemberInfo memberInfo) { var sequencePropertyAttribute = memberInfo.FindAttribute<SequencePropertyAttribute>(); if (sequencePropertyAttribute != null) { var typeInfo = ReflectionHelper.FindTypeDescendants(XafTypesInfo.Instance.FindTypeInfo(typeof(IReleasedSequencePropertyEditor))).SingleOrDefault(); if (typeInfo != null) memberInfo.AddAttribute(new CustomAttribute("PropertyEditorType", typeInfo.FullName)); } }
AssociationAttribute GetAssociationAttribute(IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute) { var associationAttribute = memberInfo.FindAttribute<AssociationAttribute>(); if (associationAttribute == null && !string.IsNullOrEmpty(providedAssociationAttribute.AssociationName)) associationAttribute = new AssociationAttribute(providedAssociationAttribute.AssociationName); else if (associationAttribute == null) throw new NullReferenceException(memberInfo + " has no association attribute"); return associationAttribute; }
public override bool IsMemberModificationDenied(object targetObject, IMemberInfo memberInfo) { if (memberInfo.GetPath().Any(currentMemberInfo =>!SecuritySystem.IsGranted(new MemberAccessPermission( currentMemberInfo.Owner.Type, currentMemberInfo.Name, MemberOperation.Write)))) { return true; } return base.IsMemberModificationDenied(targetObject, memberInfo); }
public void Init() { _MemberInfo = A.Fake<IMemberInfo>(); _Builder = new PropertyBuilder<ReferencedTargetClass, TargetClass>(_MemberInfo); A.CallTo(() => _MemberInfo.Name).Returns("OneToReferencedTarget"); _AppearanceBuilder = _Builder.UsingAppearance(); }
IModelMember GetPropertyModel(IMemberInfo memberInfo) { IModelMember result = null; if (_modelApplication != null) { IModelClass modelClass = _modelApplication.BOModel.GetClass(memberInfo.Owner.Type); if (modelClass != null) { result = modelClass.FindOwnMember(memberInfo.Name); } } return result; }
internal ApplicableFunction(IMemberInfo method, Type[] methodSignature, Type[] appliedSignature, Type[] paramsSignature, Conversion[] conversions) { this.method = method; this.methodSignature = methodSignature; this.appliedSignature = appliedSignature; this.paramsSignature = paramsSignature; this.conversions = conversions; }
public void Init() { _TypesInfo = A.Fake<ITypesInfo>(); _TypeInfo = A.Fake<ITypeInfo>(); _MemberInfo = A.Fake<IMemberInfo>(); A.CallTo(() => _TypesInfo.FindTypeInfo(A<Type>.Ignored)).Returns(_TypeInfo); _Builder = ModelBuilder.Create<TargetClass>(_TypesInfo); }
public CanSetBadgeType(Csla.Rules.AuthorizationActions action, IMemberInfo element, Common.Enums.BadgeType badgeType, string allowedRole) : base(action, element) { if (element == null || !(element is IPropertyInfo)) { throw new ArgumentException("Parameter element must be of type IPropertyInfo."); } AllowedRole = allowedRole; BadgeType = badgeType; }
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; } }; }
private void addAttributes(IMemberInfo memberInfo, AssociationAttribute associationAttribute, ProvidedAssociationAttribute providedAssociationAttribute, XPCustomMemberInfo customMemberInfo) { customMemberInfo.AddAttribute(getAssociationAttribute(customMemberInfo.IsCollection, memberInfo.Owner.Type,associationAttribute.Name)); if (providedAssociationAttribute.AttributesFactoryProperty != null){ var property = memberInfo.Owner.Type.GetProperty(providedAssociationAttribute.AttributesFactoryProperty, BindingFlags.Static|BindingFlags.Public); if (property== null) throw new NullReferenceException(string.Format("Static propeprty {0} not found at {1}", providedAssociationAttribute.GetPropertyInfo(x=>x.AttributesFactoryProperty).Name, memberInfo.Owner.Type.FullName)); var values = (IEnumerable<Attribute>) property.GetValue(null, null); foreach (Attribute attribute in values){ customMemberInfo.AddAttribute(attribute); } } }
public override bool IsMemberModificationDenied(object targetObject, IMemberInfo memberInfo) { bool firstOrDefault =memberInfo.GetPath().Select(info =>!SecuritySystemExtensions.IsGranted( new MemberAccessPermission(info.Owner.Type, info.Name, MemberOperation.Write), true)).Where(b => b).FirstOrDefault(); if (firstOrDefault) { return Fit(targetObject,MemberOperation.Write); } var securityComplex = ((SecurityBase)SecuritySystem.Instance); bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission; securityComplex.IsGrantedForNonExistentPermission = true; bool isMemberModificationDenied = base.IsMemberModificationDenied(targetObject, memberInfo); securityComplex.IsGrantedForNonExistentPermission = isGrantedForNonExistentPermission; return isMemberModificationDenied; }
public bool Fit(object currentObject, IMemberInfo memberInfo, MemberOperation memberOperation) { var memberAccessPermission = ((SecurityBase)SecuritySystem.Instance).PermissionSet.GetPermission(typeof(MemberAccessPermission)) as MemberAccessPermission; if (memberAccessPermission != null && memberAccessPermission.IsSubsetOf(memberAccessPermission)) { var objectSpace = XPObjectSpace.FindObjectSpaceByObject(currentObject); if (objectSpace != null) { var type = currentObject.GetType(); var memberAccessPermissionItem = memberAccessPermission.items.SingleOrDefault(item => item.Operation == memberOperation && item.ObjectType == type && item.MemberName == memberInfo.Name); if (memberAccessPermissionItem != null) { var criteriaOperator = CriteriaOperator.Parse(memberAccessPermissionItem.Criteria); var isObjectFitForCriteria = objectSpace.IsObjectFitForCriteria(currentObject, criteriaOperator); return isObjectFitForCriteria.GetValueOrDefault(true); } } } return true; }
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; }
private XPCustomMemberInfo GetCustomMemberInfo(IMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute) { XPCustomMemberInfo customMemberInfo; var typeToCreateOn = getTypeToCreateOn(memberInfo,associationAttribute); if (typeToCreateOn== null) throw new NotImplementedException(); var propertyName = providedAssociationAttribute.ProvidedPropertyName??typeToCreateOn.Name+"s"; if (memberInfo.IsAssociation || (memberInfo.IsList&&providedAssociationAttribute.RelationType==RelationType.ManyToMany)){ customMemberInfo = XafTypesInfo.Instance.CreateCollection(typeToCreateOn, memberInfo.Owner.Type, propertyName,XafTypesInfo.XpoTypeInfoSource.XPDictionary); } else customMemberInfo = XafTypesInfo.Instance.CreateMember(typeToCreateOn, memberInfo.Owner.Type, propertyName, XafTypesInfo.XpoTypeInfoSource.XPDictionary); return customMemberInfo; }
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)); } } }
CriteriaOperator CreateOperand(IMemberInfo memberInfo, SelectStatement selectStatement) { var referenceInfoAttribute = memberInfo.FindAttribute<ReferenceInfoAttribute>(); return new QueryOperand(GetColumnName(memberInfo, referenceInfoAttribute), GetAlias(referenceInfoAttribute, selectStatement)); }
string GetColumnName(IMemberInfo info, ReferenceInfoAttribute referenceInfoAttribute) { var defaultMember = _typeHelper.DefaultMember(referenceInfoAttribute == null ? info.MemberTypeInfo : referenceInfoAttribute.TypeInfo); string alias = null; if (referenceInfoAttribute != null) alias = " AS " + _typeHelper.GetColumnNameCore(info); return defaultMember != null ? defaultMember.Name + alias : _typeHelper.GetColumnNameCore(info); }
public string GetColumnNameCore(IMemberInfo info) { var persistentAttribute = info.FindAttribute<PersistentAttribute>(); return persistentAttribute != null ? persistentAttribute.MapTo : info.Name; }
string GetPropertyType(IMemberInfo info) { return TypeToString(info.MemberTypeInfo.IsPersistent ? _typeHelper.DefaultMember(info.MemberTypeInfo).MemberType : info.MemberTypeInfo.Type); }
string KeyAttributeCode(IMemberInfo info) { return info.IsKey ? "[" + TypeToString(typeof(KeyAttribute)) + "(true)]" + Environment.NewLine : null; }
string TableNameAttributeCode(IMemberInfo memberInfo) { return memberInfo.MemberTypeInfo.IsDomainComponent && memberInfo.MemberTypeInfo != _typeInfo ? string.Format("[{0}(\"{1}\",\"{3}\")]{2}", TypeToString(typeof(ReferenceInfoAttribute)), _typeHelper.XPDictionary.GetClassInfo(memberInfo.MemberTypeInfo.Type).TableName, Environment.NewLine, memberInfo.MemberTypeInfo.Type.FullName) : null; }
string CreateProperty(IMemberInfo info) { return CreatePropertyCore(KeyAttributeCode(info), TableNameAttributeCode(info), GetPropertyType(info), _typeHelper.GetColumnNameCore(info)); }
public override void SetupPivotGridField(IMemberInfo memberInfo) { _propertyModel = GetPropertyModel(memberInfo); base.SetupPivotGridField(memberInfo); }
protected AuthorizationRuleCore(AuthorizationActions action, IMemberInfo element) : base(action, element) { }