Example #1
0
 public ProxyProvider(IProxyConfiguration configuration,
                      IProxyCollection collection,
                      IProxyTypeGenerator typeGenerator,
                      IProxyValidator validator)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _collection    = collection ?? throw new ArgumentNullException(nameof(collection));
     _generator     = typeGenerator ?? throw new ArgumentNullException(nameof(typeGenerator));
     _validator     = validator ?? throw new ArgumentNullException(nameof(validator));
 }
Example #2
0
        public IProxyFlare Use(IProxyCollectionFactory collectionFactory)
        {
            if (collectionFactory == null)
            {
                throw new ArgumentNullException(nameof(collectionFactory));
            }

            _collection = collectionFactory.BuilderCollection();
            return(this);
        }
Example #3
0
        internal Form1(SdbConnector connector)
        {
            InitializeComponent();

            _connector = connector;

            Text = "TestApp: " + connector.Name;

            personBindingSource.DataSource = _people = connector.ObjectMapper.Get <Person>();
        }
Example #4
0
File: Form1.cs Project: SorenHK/sdb
        internal Form1(SdbConnector connector)
        {
            InitializeComponent();

            _connector = connector;

            Text = "TestApp: " + connector.Name;

            personBindingSource.DataSource = _people = connector.ObjectMapper.Get<Person>();
        }
Example #5
0
        internal static void ProxyJoins(object entity)
        {
            ClassDefineMetadata metadata = RepositoryFramework.GetDefineMetadataAndCheck(entity.GetType());

            var joins = metadata.ClassJoinDefines.Values.Cast <ClassJoinDefineMetadata>().Where(o => o.JoinType == MethodJoinType.PropertyGet);
            var ta    = TypeAccessor.GetAccessor(metadata.EntityType);

            foreach (var join in joins)
            {
                var value = ta.GetProperty(join.JoinName, entity);

                //已经为代理对象,直接忽略
                if (IsProxy(value))
                {
                    ((IProxy)value).Reset();
                    continue;
                }

                var type = join.Method.ReturnType;

                if (EntityUtil.IsGenericList(type))
                {
                    var itemType           = type.GetGenericArguments()[0];
                    var proxyType          = typeof(ProxyCollection <>).MakeGenericType(itemType);
                    IProxyCollection proxy = (IProxyCollection)FastActivator.Create(proxyType);
                    proxy.Init(entity, join);

                    ta.SetProperty(join.JoinName, entity, proxy);
                }
                else
                {
                    var ei    = new EntityProxyInterceptor(entity, join);
                    var proxy = ProxyProvider.GetCreateFunc(type)(new IInterceptor[] { ei });
                    ei.IsConstructed = true;
                    ta.SetProperty(join.JoinName, entity, proxy);
                }
            }
        }
 protected override T GetValue(DbItem item)
 {
     _children = new ProxyCollection <S>(ObjectMapper, item.Id, true);
     return((T)_children);
 }