/// <summary> /// Changes the field visibility to the specified <paramref name="visible" /> value for all subtypes in the specified /// <paramref name="table" /> object class /// that match the field name. /// </summary> /// <param name="source">The source.</param> /// <param name="table">The object class.</param> /// <param name="visible">if set to <c>true</c> if the field is visible.</param> /// <param name="fieldNames">The field names.</param> /// <exception cref="ArgumentNullException"> /// fieldNames /// or /// table /// </exception> public static void ChangeVisibility(this IMMConfigTopLevel source, IObjectClass table, bool visible, params string[] fieldNames) { if (source == null) { return; } if (fieldNames == null) { throw new ArgumentNullException("fieldNames"); } if (table == null) { throw new ArgumentNullException("table"); } // Change the hidden subtype of -1, which represents all subtypes. source.ChangeVisibility(table, ALL_SUBTYPES, visible, fieldNames); ISubtypes subtypes = (ISubtypes)table; IEnumerable <int> subtypeCodes = subtypes.HasSubtype ? subtypes.Subtypes.AsEnumerable().Select(o => o.Key) : new[] { subtypes.DefaultSubtypeCode }; // Change the individual subtypes. foreach (var subtypeCode in subtypeCodes) { source.ChangeVisibility(table, subtypeCode, visible, fieldNames); } }
public void IMMConfigTopLevel_ChangeVisibility_ArgumentNullException_Table() { IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); configTopLevel.ChangeVisibility(null, false, "OBJECTID"); }
public void IMMConfigTopLevel_ChangeVisibility_ArgumentNullException_FieldName() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); configTopLevel.ChangeVisibility(testClass, false, null); }
public void IMMConfigTopLevel_ChangeVisibility() { IFeatureClass testClass = base.GetTestClass(); Assert.IsNotNull(testClass); IMMConfigTopLevel configTopLevel = ConfigTopLevel.Instance; Assert.IsNotNull(configTopLevel); ISubtypes subtypes = (ISubtypes)testClass; IMMFieldManager fieldManager = testClass.GetFieldManager(subtypes.DefaultSubtypeCode); IMMFieldAdapter fieldAdapter = fieldManager.FieldByName(testClass.OIDFieldName); configTopLevel.ChangeVisibility(testClass, subtypes.DefaultSubtypeCode, false, testClass.OIDFieldName); Assert.IsFalse(fieldAdapter.Visible); }