Ejemplo n.º 1
0
        protected virtual bool TryCreateProxy(object source, SourceDescription description, out ISourceProxy proxy)
        {
            proxy = null;
            foreach (PriorityFactoryPair pair in this.factories)
            {
                try
                {
                    var factory = pair.factory;
                    if (factory == null)
                    {
                        continue;
                    }

                    proxy = factory.CreateProxy(source, description);
                    if (proxy != null)
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat("Unable to bind: \"{0}\";exception:{1}", description.ToString(), e);
                    }
                }
            }

            proxy = null;
            return(false);
        }
Ejemplo n.º 2
0
        public ISourceProxy CreateProxy(object source, SourceDescription description)
        {
            if (!description.IsStatic && source == null)
            {
                return(new EmptSourceProxy(description));
            }

            ISourceProxy proxy = null;

            if (TryCreateProxy(source, description, out proxy))
            {
                return(proxy);
            }

            throw new BindingException("Unable to bind: \"{0}\"", description.ToString());
        }
Ejemplo n.º 3
0
        public virtual object GetValue()
        {
            if (log.IsWarnEnabled)
            {
                log.WarnFormat("this is an empty source proxy,If you see this, then the DataContext/SourceObject is null.The SourceDescription is \"{0}\"", description.ToString());
            }

            return(null);
        }
        protected virtual bool TryCreateProxy(object source, SourceDescription description, out ISourceProxy proxy)
        {
            proxy = null;
            foreach (PriorityFactoryPair pair in this.factories)
            {
                var factory = pair.factory;
                if (factory == null)
                {
                    continue;
                }

                try
                {
                    proxy = factory.CreateProxy(source, description);
                    if (proxy != null)
                    {
                        return(true);
                    }
                }
                catch (MissingMemberException e)
                {
                    throw e;
                }
                catch (NullReferenceException e)
                {
                    throw e;
                }
                catch (Exception e)
                {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat("An exception occurred when using the \"{0}\" factory to create a proxy for the \"{1}\";exception:{2}", factory.GetType().Name, description.ToString(), e);
                    }
                }
            }

            proxy = null;
            return(false);
        }
        public ISourceProxy CreateProxy(object source, SourceDescription description)
        {
            try
            {
                if (!description.IsStatic && source == null)
                {
                    return(new EmptSourceProxy(description));
                }

                ISourceProxy proxy = null;
                if (TryCreateProxy(source, description, out proxy))
                {
                    return(proxy);
                }

                throw new NotSupportedException("Not found available proxy factory.");
            }
            catch (Exception e)
            {
                throw new ProxyException(e, "An exception occurred while creating a proxy for the \"{0}\".", description.ToString());
            }
        }
Ejemplo n.º 6
0
 private void DebugWarning()
 {
     if (log.IsWarnEnabled)
     {
         log.WarnFormat("this is an empty source proxy,If you see this, then the DataContext is null.The SourceDescription is \"{0}\"", description.ToString());
     }
 }