Esempio n. 1
0
 protected virtual void SetGeneralizationInfo(IActivityMonitor monitor, CovariantPropertyInfo gen)
 {
     // Covariance ?
     if (PropertyType != gen.PropertyType && !gen.PropertyType.IsAssignableFrom(PropertyType))
     {
         monitor.Error($"Property '{DeclaringType.FullName}.{Name}' type is not compatible with base property '{gen.DeclaringType.FullName}.{Name}'.");
     }
     else if (_p.GetSetMethod(true) != null)
     {
         monitor.Warn($"Property '{DeclaringType.FullName}.{Name}' should not have a setter (there should only be a getter that casts the base property).");
     }
     // Propagates the top first definer level.
     _definerSpecializationDepth = gen.DefinerSpecializationDepth;
     _settablePropertyInfo       = gen._settablePropertyInfo;
 }
        protected override void SetGeneralizationInfo(IActivityMonitor monitor, CovariantPropertyInfo g)
        {
            base.SetGeneralizationInfo(monitor, g);
            AmbientPropertyOrInjectObjectInfo gen = (AmbientPropertyOrInjectObjectInfo)g;

            // A required property can not become optional.
            if (IsOptional && !gen.IsOptional)
            {
                if (_isOptionalDefined)
                {
                    monitor.Error($"{Kind}: Property '{DeclaringType.FullName}.{Name}' states that it is optional but base property '{gen.DeclaringType.FullName}.{Name}' is required.");
                }
                _isOptional = false;
            }
        }
        protected override void SetGeneralizationInfo(IActivityMonitor monitor, CovariantPropertyInfo g)
        {
            base.SetGeneralizationInfo(monitor, g);

            AmbientPropertyInfo gen = (AmbientPropertyInfo)g;

            if (!_isSourceDefined)
            {
                ResolutionSource = gen.ResolutionSource;
            }
            // Captures the Generalization.
            // We keep the fact that this property overrides one above (errors have been logged if conflict/incoherency occur).
            // We can keep the Generalization but not a reference to the specialization since we are
            // not Contextualized here, but only on a pure Type level.
            Generalization = gen;
        }