示例#1
0
        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);
        }
示例#2
0
        /// <summary>
        ///     Updates the field assigned the <paramref name="modelName" /> with the <paramref name="value" /> for the specified
        ///     <paramref name="source" /> when the value is different than the original value.
        /// </summary>
        /// <param name="source">The row.</param>
        /// <param name="modelName">Name of the model.</param>
        /// <param name="value">The value.</param>
        /// <param name="throwException">
        ///     if set to <c>true</c> if an exception should be thrown when the model name is not
        ///     assigned.
        /// </param>
        /// <param name="equalityComparer">if set to <c>true</c> when the changes need to be compared prior to updating.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when the row updated; otherwise <c>false</c>
        /// </returns>
        /// <exception cref="ArgumentNullException">modelName</exception>
        /// <exception cref="IndexOutOfRangeException"></exception>
        /// <exception cref="MissingFieldModelNameException"></exception>
        public static bool Update(this IRow source, string modelName, object value, bool throwException, bool equalityComparer)
        {
            if (source == null)
            {
                return(false);
            }
            if (modelName == null)
            {
                throw new ArgumentNullException("modelName");
            }

            int index = source.Table.GetFieldIndex(modelName, throwException);

            if (index == -1)
            {
                throw new IndexOutOfRangeException();
            }

            IMMFieldManager fieldManager = source.GetFieldManager();
            IMMFieldAdapter fieldAdapter = (fieldManager != null) ? fieldManager.FieldByIndex(index) : null;

            return(source.Update(index, value, equalityComparer, fieldAdapter));
        }
示例#3
0
        /// <summary>
        ///     Updates the column index on the row with the value when the original value and the specified
        ///     <paramref name="value" /> are different.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="index">The index of the field.</param>
        /// <param name="value">The value for the field.</param>
        /// <param name="equalityComparer">
        ///     The equality comparer to use to determine whether or not values are equal.
        ///     If null, the default equality comparer for object is used.
        /// </param>
        /// <param name="fieldAdapter">The field adapter used to read the values from the ArcFM attribute editor.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when the row updated; otherwise <c>false</c>
        /// </returns>
        private static bool Update <TValue>(this IRowBuffer source, int index, TValue value, IEqualityComparer <TValue> equalityComparer, IMMFieldAdapter fieldAdapter)
        {
            bool pendingChanges = true;

            if (equalityComparer != null)
            {
                IRowChanges rowChanges    = (IRowChanges)source;
                object      originalValue = (fieldAdapter != null) ? fieldAdapter.OriginalValue : rowChanges.OriginalValue[index];

                TValue oldValue = TypeCast.Cast(originalValue, default(TValue));
                pendingChanges = !equalityComparer.Equals(oldValue, value);
            }

            if (pendingChanges)
            {
                if (Equals(value, default(TValue)) && source.Fields.Field[index].IsNullable)
                {
                    source.Value[index] = DBNull.Value;
                }
                else
                {
                    source.Value[index] = value;
                }
            }

            return(pendingChanges);
        }
示例#4
0
        /// <summary>
        ///     Updates the column index on the row with the value when the original value and the specified
        ///     <paramref name="value" /> are different.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="index">The index of the field.</param>
        /// <param name="value">The value for the field.</param>
        /// <param name="equalityCompare">if set to <c>true</c> when the changes need to be compared prior to updating.</param>
        /// <param name="fieldAdapter">The field adapter used to read the values from the ArcFM attribute editor.</param>
        /// <returns>
        ///     Returns a <see cref="bool" /> representing <c>true</c> when the row updated; otherwise <c>false</c>
        /// </returns>
        /// <exception cref="IndexOutOfRangeException"></exception>
        private static bool Update(this IRowBuffer source, int index, object value, bool equalityCompare, IMMFieldAdapter fieldAdapter)
        {
            if (index < 0 || index > source.Fields.FieldCount - 1)
            {
                throw new IndexOutOfRangeException();
            }

            if (equalityCompare)
            {
                switch (source.Fields.Field[index].Type)
                {
                case esriFieldType.esriFieldTypeOID:
                case esriFieldType.esriFieldTypeInteger:
                    return(source.Update(index, TypeCast.Cast(value, default(long)), EqualityComparer <long> .Default, fieldAdapter));

                case esriFieldType.esriFieldTypeSmallInteger:
                    return(source.Update(index, TypeCast.Cast(value, default(int)), EqualityComparer <int> .Default, fieldAdapter));

                case esriFieldType.esriFieldTypeSingle:
                    return(source.Update(index, TypeCast.Cast(value, default(float)), EqualityComparer <float> .Default, fieldAdapter));

                case esriFieldType.esriFieldTypeDouble:
                    return(source.Update(index, TypeCast.Cast(value, default(double)), EqualityComparer <double> .Default, fieldAdapter));

                case esriFieldType.esriFieldTypeString:
                case esriFieldType.esriFieldTypeDate:
                case esriFieldType.esriFieldTypeGUID:
                case esriFieldType.esriFieldTypeGlobalID:
                    return(source.Update(index, TypeCast.Cast(value, default(string)), EqualityComparer <string> .Default, fieldAdapter));

                default:
                    return(source.Update(index, value, EqualityComparer <object> .Default, fieldAdapter));
                }
            }

            return(source.Update(index, value, null, null));
        }