예제 #1
0
        public TypeDefinition Generate()
        {
            _startIndex = _model.Properties.Count;
            foreach (var property in _composedOfType.Properties)
            {
                var name = "$" + _instanceName + "$" + property.Name;
                var dbn  = _instanceName + property.Name;
                var pd   = TypeFactory.CreateProperty(name, PropAttr, property.PropertyType, _handler);
                foreach (var attribute in property.CustomAttributes)
                {
                    pd.CustomAttributes.Add(attribute);
                }
                if (pd.GetCustomAttribute(KnownTypesHandler.DbColumnAttribute) == null)
                {
                    pd.CustomAttributes.Add(_handler.GetDbColumn(dbn));
                }
                _model.Properties.Add(pd);
                _model.Methods.Add(pd.GetMethod);
                _model.Methods.Add(pd.SetMethod);

                var pi = new PropertyInformation {
                    PropertyDefinition = pd, FieldType = FieldType.Normal
                };
                var pp = new PropertyProcessor(pi, _model, _handler);
                pp.Process();
            }
            GenerateClass();
            return(_result);
        }
예제 #2
0
        private void PopulateDbColumn()
        {
            var pd = _pi.PropertyDefinition;
            var bc = pd.GetCustomAttribute(KnownTypesHandler.DbColumnAttribute);

            if (bc != null)
            {
                pd.CustomAttributes.Remove(bc);
                _pi.FieldDefinition.CustomAttributes.Add(bc);
            }
            else if (_pi.FieldType == FieldType.LazyLoad)
            {
                var c = _handler.GetDbColumn(_pi.PropertyDefinition.Name);
                _pi.FieldDefinition.CustomAttributes.Add(c);
            }
        }