示例#1
0
        protected virtual void Init(Type recordType)
        {
            ChoRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoRecordObjectAttribute>(recordType);

            if (recObjAttr != null)
            {
                ErrorMode                  = recObjAttr.ErrorMode;
                IgnoreFieldValueMode       = recObjAttr.IgnoreFieldValueMode;
                ThrowAndStopOnMissingField = recObjAttr.ThrowAndStopOnMissingField;
                ObjectValidationMode       = recObjAttr.ObjectValidationMode;
            }
        }
示例#2
0
        protected virtual void Init(Type recordType)
        {
            if (recordType == null)
            {
                return;
            }

            _recObject = new Lazy <object>(() => ChoActivator.CreateInstance(RecordType));
            ChoRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoRecordObjectAttribute>(recordType);

            if (recObjAttr != null)
            {
                ErrorMode                  = recObjAttr.ErrorMode;
                IgnoreFieldValueMode       = recObjAttr.IgnoreFieldValueMode;
                ThrowAndStopOnMissingField = recObjAttr.ThrowAndStopOnMissingField;
                ObjectValidationMode       = recObjAttr.ObjectValidationMode;
            }
        }
示例#3
0
        protected virtual void Init(Type recordType)
        {
            if (recordType == null)
            {
                return;
            }

            var tc = recordType.GetCustomAttribute(typeof(ChoTypeConverterAttribute)) as ChoTypeConverterAttribute;

            if (tc != null)
            {
                var c = tc.CreateInstance();
                if (c is IChoValueConverter)
                {
                    ChoTypeConverter.Global.Add(recordType, c as IChoValueConverter);
                }
                else if (c is TypeConverter)
                {
                    ChoTypeConverter.Global.Add(recordType, c as TypeConverter);
                }
#if !NETSTANDARD2_0
                else if (c is IValueConverter)
                {
                    ChoTypeConverter.Global.Add(recordType, c as IValueConverter);
                }
#endif
            }

            var st = recordType.GetCustomAttribute(typeof(ChoSourceTypeAttribute)) as ChoSourceTypeAttribute;
            if (st != null)
            {
                SourceType = st.Type;
            }

            _recObject = new Lazy <object>(() => ChoActivator.CreateInstance(RecordType));
            ChoRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoRecordObjectAttribute>(recordType);
            if (recObjAttr != null)
            {
                ErrorMode                  = recObjAttr.ErrorMode;
                IgnoreFieldValueMode       = recObjAttr.IgnoreFieldValueMode;
                ThrowAndStopOnMissingField = recObjAttr.ThrowAndStopOnMissingField;
                ObjectValidationMode       = recObjAttr.ObjectValidationMode;
            }
        }