internal int Compare(Graphic x, Graphic y)
            {
                var o1 = x.Attributes[Field];                 // get primitive value
                var o2 = y.Attributes[Field];                 // get primitive value

                if (isDynamicCodedValue)
                {
                    o1 = DynamicCodedValueSource.CodedValueNameLookup(TypeIDField, Field, x, dynamicCodedValueSource);
                    o2 = DynamicCodedValueSource.CodedValueNameLookup(TypeIDField, Field, y, dynamicCodedValueSource);
                }
                if (isCodedValue || isTypeIDField)
                {
                    o1 = CodedValueSources.CodedValueNameLookup(Field, x, codedValueSources);
                    o2 = CodedValueSources.CodedValueNameLookup(Field, y, codedValueSources);
                }

                return(comparer.Compare(o1, o2));                // compare primitives
            }
Ejemplo n.º 2
0
            internal int Compare(Graphic x, Graphic y)
            {
                var o1 = x.Attributes[Field];                 // get primitive value
                var o2 = y.Attributes[Field];                 // get primitive value

                if (o1 == null && o2 == null)
                {
                    return(0);
                }
                else if (o1 != null && o2 == null)
                {
                    return(1);
                }
                else if (o1 == null && o2 != null)
                {
                    return(-1);
                }

                var type = NonNullableType(DataType);

                var t1 = o1.GetType();
                var t2 = o2.GetType();

                if (type == typeof(DateTime))
                {
                    if (t1 != type && t2 != type)
                    {
                        return(0);
                    }
                    if (t1 != type && t2 == type)
                    {
                        return(-1);
                    }
                    if (t1 == type && t2 != type)
                    {
                        return(1);
                    }
                }
                else
                {
                    if (t1 != type)
                    {
                        o1 = Convert.ChangeType(o1, type);
                    }
                    if (t2 != type)
                    {
                        o2 = Convert.ChangeType(o2, type);
                    }
                }

                if (isDynamicCodedValue)
                {
                    o1 = DynamicCodedValueSource.CodedValueNameLookup(TypeIDField, Field, x, dynamicCodedValueSource);
                    o2 = DynamicCodedValueSource.CodedValueNameLookup(TypeIDField, Field, y, dynamicCodedValueSource);
                }
                else if (isCodedValue || isTypeIDField)
                {
                    o1 = CodedValueSources.CodedValueNameLookup(Field, x, codedValueSources);
                    o2 = CodedValueSources.CodedValueNameLookup(Field, y, codedValueSources);
                }

                return(comparer.Compare(o1, o2));                // compare primitives
            }