Exemple #1
0
        public DomainData(ICoreContext ctx, IProperty property)
        {
            this.ctx      = ctx;
            this.property = property;

            Name           = ctx.CodingStyle.GetName(property);
            Marks          = new Marks(ctx.CodingStyle.GetMarks(property));
            IsList         = property.ReturnType.CanBeCollection();
            FetchedEagerly = ctx.CodingStyle.IsFetchedEagerly(property);

            var returnType = IsList ? property.ReturnType.GetItemType() : property.ReturnType;

            if (!ctx.CodingStyle.ContainsType(returnType))
            {
                throw new TypeNotConfiguredException(returnType);
            }

            DataType = ctx.GetDomainType(returnType);
        }
Exemple #2
0
        public object Convert(object target, DomainType viewDomainType)
        {
            if (Equals(viewDomainType))
            {
                return(target);
            }
            if (Id == MODEL_ID_NULL)
            {
                return(target);
            }

            if (!viewTypes.Contains(viewDomainType))
            {
                throw new ConfigurationException("Converter", Type, new CannotConvertException(target, viewDomainType.Type));
            }

            if (!converter.ContainsKey(viewDomainType.Type))
            {
                throw new ConfigurationException("Converter", Type);
            }

            return(converter[viewDomainType.Type].Convert(target, Type, viewDomainType.Type));
        }
Exemple #3
0
 protected bool Equals(DomainType other)
 {
     return(string.Equals(Id, other.Id));
 }