public int NumberOfVisibleFields(bool considerAlwaysShow = true) { int size = 0; MetaMetadataOneLevelNestingEnumerator fullEnumerator = FullNonRecursiveMetaMetadataIterator(); // iterate over all fields in this & then in each mixin of this while (fullEnumerator.MoveNext()) { MetaMetadataField metaMetadataField = fullEnumerator.Current; MetaMetadataField metaMetadata = fullEnumerator.CurrentObject(); // stays the same for until we // iterate over all mfd's for // it Metadata currentMetadata = fullEnumerator.CurrentMetadata; // When the iterator enters the metadata in the mixins "this" in getValueString has to be // the corresponding metadata in mixin. bool hasVisibleNonNullField = false; MetadataFieldDescriptor mfd = metaMetadataField.MetadataFieldDescriptor; if (metaMetadata.IsChildFieldDisplayed(metaMetadataField.Name)) { if (mfd.IsScalar && !mfd.IsCollection) { hasVisibleNonNullField = MetadataString.IsNotNullAndEmptyValue(mfd.GetValueString(currentMetadata)); } else if (mfd.IsComposite) { Metadata nestedMetadata = (Metadata)mfd.GetNestedMetadata(currentMetadata); hasVisibleNonNullField = (nestedMetadata != null) ? (nestedMetadata.NumberOfVisibleFields() > 0) : false; } else if (mfd.IsCollection) { ICollection collection = mfd.GetCollection(currentMetadata); hasVisibleNonNullField = (collection != null) ? (collection.Count > 0) : false; } } // "null" happens with mixins fieldAccessor b'coz getValueString() returns "null". // TODO use MetaMetadataField.numNonDisplayedFields() bool isVisibleField = !metaMetadataField.Hide && ((considerAlwaysShow && metaMetadataField.AlwaysShow) || hasVisibleNonNullField); if (isVisibleField) { size++; } } return(size); }
public void Push(MetaMetadataField mmField) { Debug.WriteLine("pushing " + mmField); mmStack.Push(mmField); // put mmd scope MultiAncestorScope<Object> scope = new MultiAncestorScope<Object>(); if (scopeStack.Count > 0) scope.AddAncestor(scopeStack.Peek()); scopeStack.Push(scope); // put generic type var scope MmdGenericTypeVarScope existingMmdGenericTypeVarScope = (MmdGenericTypeVarScope) scope.Get(GENERIC_TYPE_VAR_SCOPE); MmdGenericTypeVarScope currentMmdGenericTypeVarScope = mmField.GenericTypeVars; if (currentMmdGenericTypeVarScope != null && existingMmdGenericTypeVarScope != null) { currentMmdGenericTypeVarScope.InheritFrom(existingMmdGenericTypeVarScope, this); } scope.AddIfValueNotNull(GENERIC_TYPE_VAR_SCOPE, mmField.GenericTypeVars); }
public void Pop(MetaMetadataField mmField) { MetaMetadataField field = mmStack.Pop(); Debug.WriteLine("popping " + field); scopeStack.Pop(); if (mmField != field) throw new MetaMetadataException("mmField != field"); }
public bool IsUsingGenerics(MetaMetadataField field) { if (field.GenericTypeVars != null && field.GenericTypeVars.Count > 0) return true; MmdGenericTypeVarScope gtvScope = (MmdGenericTypeVarScope) scopeStack.Peek().Get( GENERIC_TYPE_VAR_SCOPE); if (gtvScope == null) return false; if (((field.GetMmdType() != null) && gtvScope.ContainsKey(field.GetMmdType())) || field.GetMmdType() == null && ((field.Name != null) && gtvScope.ContainsKey(field.Name)) || ((field.GetMmdExtendsAttribute() != null) && gtvScope.ContainsKey(field.GetMmdExtendsAttribute()))) return true; return false; }
public MetaMetadataOneLevelNestingEnumerator MetaMetadataIterator(MetaMetadataField metaMetadataField = null) { MetaMetadataField firstMetaMetadataField = metaMetadataField ?? this.MetaMetadata; return new MetaMetadataOneLevelNestingEnumerator(firstMetaMetadataField, this); }
public MetaMetadataOneLevelNestingEnumerator FullNonRecursiveMetaMetadataIterator(MetaMetadataField metaMetadataField = null) { MetaMetadataField firstMetaMetadataField = metaMetadataField ?? MetaMetadata; return new MetaMetadataOneLevelNestingEnumerator(firstMetaMetadataField, this); }
public MetaMetadataOneLevelNestingEnumerator FullNonRecursiveMetaMetadataIterator(MetaMetadataField metaMetadataField = null) { MetaMetadataField firstMetaMetadataField = metaMetadataField ?? MetaMetadata; return(new MetaMetadataOneLevelNestingEnumerator(firstMetaMetadataField, this)); }
public MetaMetadataOneLevelNestingEnumerator MetaMetadataIterator(MetaMetadataField metaMetadataField = null) { MetaMetadataField firstMetaMetadataField = metaMetadataField ?? this.MetaMetadata; return(new MetaMetadataOneLevelNestingEnumerator(firstMetaMetadataField, this)); }