Exemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (!disposed)
     {
         if (this.childProxy != null)
         {
             this.childProxy.Dispose();
             this.childProxy = null;
         }
         disposed = true;
         base.Dispose(disposing);
     }
 }
Exemplo n.º 2
0
        public IObjectSourceProxy CreateProxy(object source, PathToken token)
        {
            IObjectSourceProxy proxy = null;

            foreach (PriorityFactoryPair pair in this.factories)
            {
                var factory = pair.factory;
                if (factory == null)
                {
                    continue;
                }

                if (factory.TryCreateProxy(source, token, this, out proxy))
                {
                    return(proxy);
                }
            }
            return(proxy);
        }
Exemplo n.º 3
0
        protected virtual void UpdateChildProxy()
        {
            if (this.childProxy != null)
            {
                this.childProxy.ValueChanged -= this.OnChildPropertyChanged;
                this.childProxy.Dispose();
                this.childProxy = null;
            }

            var currentValue = this.GetPropertyValue();

            if (currentValue == null)
            {
                return;
            }

            this.childProxy = this.factory.CreateProxy(currentValue, this.nextToken);
            if (this.childProxy != null)
            {
                this.childProxy.ValueChanged += this.OnChildPropertyChanged;
            }
        }
Exemplo n.º 4
0
        public bool TryCreateProxy(object source, PathToken token, IObjectSourceProxyFactory factory, out IObjectSourceProxy proxy)
        {
            proxy = null;
            IPathNode node = token.Current;

            if (node is TypeNode)
            {
                TypeNode typeNode = (node as TypeNode);
                Type     type     = typeNode.Type;
                if (type == null)
                {
                    type = TypeFinderUtils.FindType(typeNode.Name);
                }

                if (type == null || !token.HasNext())
                {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat("Unable to bind: not found the \"{0}\" type.", typeNode.Name);
                    }

                    return(false);
                }

                proxy = CreateStaticProxy(type, token.NextToken(), factory);
                if (proxy != null)
                {
                    return(true);
                }
            }
            else
            {
                proxy = CreateProxy(source, token, factory);
                if (proxy != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        public bool TryCreateProxy(object source, PathToken token, IObjectSourceProxyFactory factory, out IObjectSourceProxy proxy)
        {
            proxy = null;
            if (source == null || token.HasNext() || !(token.Current is MemberNode))
            {
                return(false);
            }

            MemberInfo memberInfo = token.GetMemberInfo(source);

            if (memberInfo == null)
            {
                return(false);
            }

            var fieldInfo = memberInfo as FieldInfo;

            if (fieldInfo != null && typeof(IInteractionRequest).IsAssignableFrom(fieldInfo.FieldType))
            {
                proxy = new InteractionRequestFieldObjectSourceProxy(source, fieldInfo);
                return(true);
            }

            var propertyInfo = memberInfo as PropertyInfo;

            if (propertyInfo != null && typeof(IInteractionRequest).IsAssignableFrom(propertyInfo.PropertyType))
            {
                proxy = new InteractionRequestPropertyObjectSourceProxy(source, propertyInfo);
                return(true);
            }

            return(false);
        }