private static bool IsMatchingFieldType(int fieldTypes, MetaFieldRec mfr) { if (fieldTypes != (int)CellarPropertyTypeFilter.All) { // Look up field type and see if it matches var flidType = mfr.m_fieldType; var fcpt = 1 << (int)flidType; if ((fieldTypes & fcpt) == 0) return false; } return true; }
private void SetDestClass(MetaFieldRec mfr, int clid) { mfr.m_dstClsid = clid; if (!mfr.Virtual) m_metaClassRecords[clid].m_incomingFields.Add(mfr); }
internal void AddField(MetaFieldRec mfr) { m_uFields.Add(mfr); }
private void ConnectMetaFieldRec(MetaFieldRec mfr) { if (mfr.m_sig == null) return; int clid; if (m_nameToClid.TryGetValue(mfr.m_sig, out clid)) { SetDestClass(mfr, clid); mfr.m_sig = null; } else if (mfr.m_sig == "IAnalyses") { foreach (int analysisClid in m_analysisClids) m_metaClassRecords[analysisClid].m_incomingFields.Add(mfr); mfr.m_sig = null; } }
/// -------------------------------------------------------------------------------- /// <summary> /// Add a field to the MetaDataCache. /// </summary> /// <param name="className">Name of the class.</param> /// <param name="flid">The flid.</param> /// <param name="fieldName">Name of the field.</param> /// <param name="fieldLabel">The field label.</param> /// <param name="fieldHelp">The field help.</param> /// <param name="fieldXml">The field XML.</param> /// <param name="fieldSignature">The field signature.</param> /// <param name="type">The type.</param> /// <param name="fsSource">The fs source.</param> /// <param name="fieldListRoot">The field list root.</param> /// <param name="fieldWs">The field ws.</param> /// -------------------------------------------------------------------------------- private void AddField(string className, int flid, string fieldName, string fieldLabel, string fieldHelp, string fieldXml, string fieldSignature, CellarPropertyType type, FieldSource fsSource, Guid fieldListRoot, int fieldWs) { // Will throw if class is not in one or the other Dictionaries. var clid = m_nameToClid[className]; var mcr = m_metaClassRecords[clid]; var mfr = new MetaFieldRec { m_flid = flid, m_fieldLabel = fieldLabel, m_fieldHelp = fieldHelp, m_fieldXml = fieldXml, m_fieldListRoot = fieldListRoot, m_fieldWs = fieldWs, m_sig = null, m_fieldSource = fsSource }; switch (type) { default: break; case CellarPropertyType.OwningAtomic: // Fall through case CellarPropertyType.OwningCollection: // Fall through case CellarPropertyType.OwningSequence: // Fall through case CellarPropertyType.ReferenceAtomic: // Fall through case CellarPropertyType.ReferenceCollection: // Fall through case CellarPropertyType.ReferenceSequence: mfr.m_sig = fieldSignature; // It may not be present yet when the whole MDC is being initialized via 'Init', // or the Constructor, as the case may be. // Only mess with setting this after intitialization of the main model. // Once all those model classes are in, a client can take his lumps // if this throws an exception. if (m_initialized) { if (string.IsNullOrEmpty(fieldSignature)) throw new KeyNotFoundException("'bstrFieldSignature' is a null or empty key."); // Note that m_fieldSource must be set before calling this. SetDestClass(mfr, m_nameToClid[fieldSignature]); } break; } mfr.m_fieldType = type; mfr.m_fieldName = fieldName; mfr.m_ownClsid = clid; mcr.AddField(mfr); m_metaFieldRecords[flid] = mfr; m_nameToFlid[MakeFlidKey(clid, fieldName)] = flid; }