Beispiel #1
0
        public override bool Equals(object o)
        {
            ProjectingType other = o as ProjectingType;

            return(other != null &&
                   Projector == other.Projector &&
                   UnderlyingType.Equals(other.UnderlyingType));
        }
Beispiel #2
0
        public override bool Equals(IType other)
        {
            var o = other as TupleType;

            if (o == null)
            {
                return(false);
            }
            if (!UnderlyingType.Equals(o.UnderlyingType))
            {
                return(false);
            }
            return(UnderlyingType.Equals(o.UnderlyingType) &&
                   ElementNames.SequenceEqual(o.ElementNames));
        }
Beispiel #3
0
 public override bool Equals([NotNullWhen(true)] object?o)
 {
     return(o is ProjectingType other &&
            Projector == other.Projector &&
            UnderlyingType.Equals(other.UnderlyingType));
 }
Beispiel #4
0
 public override bool Equals(object o)
 {
     return(o is ProjectingType other &&
            Projector == other.Projector &&
            UnderlyingType.Equals(other.UnderlyingType));
 }
Beispiel #5
0
        /// <summary>
        /// Method called when FilterColumns property changes
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// Raised when a a property filter refers to a non existing candidate object type property
        /// </exception>
        private void SetFilterColumns()
        {
            var propertyFilters = Items.Cast <ValueFilter>().ToList();

            if (UnderlyingType.Equals(typeof(string)) || UnderlyingType.IsValueType)
            {
                // for native types, only one ValueFilter accepted to apply string format or IValueConverter
                if (propertyFilters.Count > 1)
                {
                    throw new InvalidOperationException(
                              "Only one property filter is authorized when underlying type is String or a value type.");
                }


// Then if there is no property filter at all, there is no conversion needed and we build a defautl property getter
                // and there is one, we build a property getter accordingly
                _valueGetters.Add(propertyFilters.Count == 0
                                      ? new PropertyFilterValueGetter(new ValueFilter())
                                      : new PropertyFilterValueGetter(propertyFilters[0]));
            }


// if the underlying type if neither a string nor value type, then it is a reference type
            else
            {
                IEnumerable <PropertyFilter> apfs;


// if there is no PropertyFilter defined, we build it by default based on every instance public properties of the underlying type
                if (propertyFilters.Count == 0)
                {
                    apfs = new List <PropertyFilter>();


// Get the type Properties
                    var pis = UnderlyingType.GetProperties(BindingFlags.Public | BindingFlags.Instance);


// iterate
                    foreach (var propertyInfo in pis)
                    {
                        var pf   = new PropertyFilter(propertyInfo.Name, DefaultMonitorPropertyChanges);
                        var pfvg = new PropertyFilterValueGetter(pf, UnderlyingType); // Generate...
                        _valueGetters.Add(pfvg);                                      // ...and add value getter for each properties
                    }
                }
                else
                {
                    // and thus every ValueFilter must be PropertyFilter
                    if (propertyFilters.Any(p => !(p is PropertyFilter)))
                    {
                        throw new InvalidOperationException("ValueFilter can't be used with reference type.");
                    }

                    apfs = propertyFilters.Cast <PropertyFilter>().ToList();
                    foreach (PropertyFilter pf in apfs)
                    {
                        // Get the PropertyInfo
                        PropertyInfo pi = UnderlyingType.GetProperty(pf.FieldName);

                        // this info is mandatory
                        if (pi == null)
                        {
                            throw new InvalidOperationException(
                                      string.Format("Cant't find the property {0} for type {1}",
                                                    pf.FieldName, UnderlyingType.Name));
                        }

                        // If pi is ok, build the value getter and add it to the list
                        var pfvg = new PropertyFilterValueGetter(pf, UnderlyingType);
                        _valueGetters.Add(pfvg);
                    }
                }

                // If there is no ValueFilter which is set to be monitored for property changes, we keep track of it to avoid to subscribe to propertychanged event later on
                _hasAnyPropertyChangesToMonitor = apfs.Any(p => p.MonitorPropertyChanged);
            }
        }