private bool IsBrowsable(string[] objectType, string propertyName) { try { // Use PropertyContext class to determine if the combination // objectType + propertyName should be shown in propertygrid // else defalut to true (show it) // objectType + propertyName --> true | false if (propertyContext != null) { foreach (string typ in objectType) { if (!propertyContext.ShowProperty(typ, propertyName)) { return(false); } if (!GeneratorController.Current.CurrentUnit.GenerationParams.ActiveObjects && (propertyName == "PublishToChannel" || propertyName == "SubscribeToChannel")) { return(false); } if (((GeneratorController.Current.CurrentUnit.GenerationParams.GenerateAuthorization == Authorization.None || GeneratorController.Current.CurrentUnit.GenerationParams.GenerateAuthorization == Authorization.PropertyLevel)) && (propertyName == "NewRoles" || propertyName == "GetRoles" || propertyName == "UpdateRoles" || propertyName == "DeleteRoles")) { return(false); } if (GeneratorController.Current.CurrentUnit.GenerationParams.TargetFramework == TargetFramework.CSLA40 && (propertyName == "AddParentReference" || propertyName == "HashcodeProperty" || propertyName == "EqualsProperty" || propertyName == "DeleteProcedureName")) { return(false); } if (GeneratorController.Current.CurrentUnit.GenerationParams.TargetFramework == TargetFramework.CSLA40 && (propertyName == "LazyLoad")) { return(false); } } if (mSelectedObject.Length > 1 && IsEnumerable(GetPropertyInfoCache(propertyName))) { return(false); } return(true); } else { return(true); } } catch //(Exception e) { Debug.WriteLine(objectType + ":" + propertyName); return(true); } }
/// <summary> /// Determines whether the specified object type is browsable. /// </summary> /// <param name="objectType">Type of the object.</param> /// <param name="propertyName">Name of the property.</param> /// <returns></returns> private bool IsBrowsable(CslaObjectInfo[] objectType, string propertyName) { try { var authorization = GeneratorController.Current.CurrentUnit.GenerationParams.GenerateAuthorization == AuthorizationLevel.None || GeneratorController.Current.CurrentUnit.GenerationParams.GenerateAuthorization == AuthorizationLevel.PropertyLevel; // Use PropertyContext class to determine if the combination // objectType + propertyName should be shown in propertygrid // else default to true (show it) // objectType + propertyName --> true | false if (_propertyContext != null) { // there is only a single element in the array. Ever. foreach (var cslaObject in objectType) { var canHaveParentProperties = cslaObject.CanHaveParentProperties(); var cslaParent = new CslaObjectInfo(); if (cslaObject.ParentType != string.Empty) cslaParent = cslaObject.Parent.CslaObjects.Find(cslaObject.ParentType); if ((authorization || ((cslaObject.AuthzProvider == AuthorizationProvider.Custom) && !GeneratorController.Current.CurrentUnit.GenerationParams.UsesCslaAuthorizationProvider)) && (propertyName == "NewRoles" || propertyName == "GetRoles" || propertyName == "UpdateRoles" || propertyName == "DeleteRoles")) return false; if ((authorization || ((cslaObject.AuthzProvider == AuthorizationProvider.IsInRole || cslaObject.AuthzProvider == AuthorizationProvider.IsNotInRole) && !GeneratorController.Current.CurrentUnit.GenerationParams.UsesCslaAuthorizationProvider) || GeneratorController.Current.CurrentUnit.GenerationParams.UsesCslaAuthorizationProvider) && (propertyName == "NewAuthzRuleType" || propertyName == "GetAuthzRuleType" || propertyName == "UpdateAuthzRuleType" || propertyName == "DeleteAuthzRuleType")) return false; if ((authorization || GeneratorController.Current.CurrentUnit.GenerationParams.UsesCslaAuthorizationProvider) && propertyName == "AuthzProvider") return false; if (GeneratorController.Current.CurrentUnit.GenerationParams.UseInlineQueries != UseInlineQueries.SpecifyByObject && propertyName == "GenerateInlineQueries") return false; if (!GeneratorController.Current.CurrentUnit.GenerationParams.DualListInheritance && propertyName == "InheritedTypeWinForms") return false; if (cslaObject.IsBaseClass() && cslaObject.CslaBaseClass.IsNotListBaseClass() && propertyName == "ItemType") return false; if (cslaObject.IsBaseClass() && cslaObject.CslaBaseClass.IsNotObjectBaseClass() && (propertyName == "ValueProperties" || propertyName == "InheritedValueProperties")) return false; if (!cslaObject.IsGenericType && propertyName == "GenericArguments") return false; if (cslaObject.ObjectType.IsReadOnlyType() && !string.IsNullOrEmpty(cslaObject.ParentType) && propertyName == "UseUnitOfWorkType") return false; if (!(cslaObject.IsDynamicEditableRoot() || cslaObject.IsReadOnlyObject()) && propertyName == "AddParentReference") return false; if (cslaObject.IsNotEditableChild() && propertyName == "DeleteProcedureName") return false; if ((cslaObject.IsNotEditableChild()) && propertyName == "DeleteUseTimestamp") return false; if ((cslaObject.IsUnitOfWork()) && propertyName == "CommandTimeout") return false; if (!(cslaObject.IsEditableChild() && (cslaParent == null || cslaParent.ObjectType.IsCollectionType())) && propertyName == "RemoveItem") return false; if (!canHaveParentProperties && (propertyName == "ParentProperties" || propertyName == "UseParentProperties")) return false; if (cslaObject.IsNotUnitOfWork() && (propertyName == "UnitOfWorkProperties" || propertyName == "UnitOfWorkType")) return false; if (string.IsNullOrEmpty(cslaObject.InheritedType.FinalName) && (propertyName == "InheritedChildCollectionProperties" || propertyName == "InheritedChildProperties" || propertyName == "InheritedValueProperties")) return false; if (!_propertyContext.ShowProperty(cslaObject.ObjectType.ToString(), propertyName)) return false; } if (_selectedObject.Length > 1 && IsEnumerable(GetPropertyInfoCache(propertyName))) return false; return true;// TO DO return true here??? } return true; } catch //(Exception e) { //Debug.WriteLine(objectType + ":" + propertyName); return true; } }