private bool IsBrowsable(string[] objectType, string propertyName) { try { // is it non-root? var mainCslaObject = GeneratorController.Current.CurrentUnit.CslaObjects.Find(SelectedObject[0].MainObject); if (CslaTemplateHelperCS.IsNotRootType(mainCslaObject)) { if (propertyName == "MainLoadParameters" || propertyName == "SecondaryLoadParameters") { return(false); } } if (objectType[0] == "OneToMultiple" && (propertyName == "SecondaryObject" || propertyName == "SecondaryPropertyName" || propertyName == "SecondaryCollectionTypeName" || propertyName == "SecondaryItemTypeName" || propertyName == "SecondaryLazyLoad" || propertyName == "SecondaryLoadingScheme" || propertyName == "SecondaryLoadProperties" || propertyName == "SecondaryLoadParameters")) { return(false); } if (objectType[1] == "ParentLoad" && (propertyName == "MainLoadProperties" || propertyName == "MainLazyLoad")) { return(false); } if (objectType[2] == "ParentLoad" && (propertyName == "SecondaryLoadProperties" || propertyName == "SecondaryLazyLoad")) { return(false); } if (_selectedObject.Length > 1 && IsEnumerable(GetPropertyInfoCache(propertyName))) { return(false); } return(true); } catch //(Exception e) { Debug.WriteLine(objectType + ":" + propertyName); return(true); } }
private void BuildCollectionCriteriaGet(CslaObjectInfo info, AssociativeEntity.EntityFacade entity, ChildProperty child) { const string critName = "CriteriaGet"; var selfLoad = CslaTemplateHelperCS.IsChildSelfLoaded(info); if (!selfLoad) { DeleteDefaultCollectionCriteria(info, critName); return; } StringBuilder sb; // make collection criteria if needed var collCriteria = info.CriteriaObjects; Criteria criteria = null; foreach (var crit in collCriteria) { if (CheckAndSetCollectionCriteriaGet(crit, info, critName)) { criteria = crit; break; } } if (criteria == null) { criteria = new Criteria(info); criteria.Name = critName; SetCollectionCriteriaGet(criteria, info, critName); info.CriteriaObjects.Add(criteria); // display message to the user sb = new StringBuilder(); sb.AppendFormat("Successfully added criteria {0} to {1} collection object.", critName, info.ObjectName); OutputWindow.Current.AddOutputInfo(sb.ToString()); } if (criteria.Name != critName) { return; } if (criteria.Properties.Count > 0) { // clear CriteriaGet properties criteria.Properties.Clear(); // display message to the user sb = new StringBuilder(); sb.AppendFormat("Successfully removed all criteria properties of {0} on {1} collection object.", critName, info.ObjectName); OutputWindow.Current.AddOutputInfo(sb.ToString()); } // populate collection criteria properties var addedProps = new List <string>(); if (entity.LoadProperties.Count == 0) { criteria.Properties.AddRange(CriteriaPropertyCollection.Clone(FacadeRootCriteriaProperties)); foreach (var property in FacadeRootCriteriaProperties) { addedProps.Add(property.Name); } } else { criteria.Properties.AddRange(CriteriaPropertyCollection.Clone(entity.LoadProperties)); foreach (var property in entity.LoadProperties) { addedProps.Add(property.Name); } } if (addedProps.Count > 0) { // display message to the user sb = new StringBuilder(); sb.AppendFormat("Successfully added the following properties to criteria {0}:" + Environment.NewLine, criteria.Name); foreach (var propName in addedProps) { sb.AppendFormat("\t{0}.{1}.{2}" + Environment.NewLine, critName, info.ObjectName, propName); } OutputWindow.Current.AddOutputInfo(sb.ToString()); } // is it non-root? var entityCslaObject = _cslaObjects.Find(entity.ObjectName); if (entityCslaObject != null) { if (CslaTemplateHelperCS.IsNotRootType(entityCslaObject)) { // re-fill LoadParameters with child criteria child.LoadParameters.Clear(); foreach (var property in criteria.Properties) { child.LoadParameters.Add(new Parameter(criteria, property)); } } } }