/// <summary>
        /// Processes the value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The <see cref="object" /> representing the processed value.
        /// </returns>
        internal virtual object ProcessValue(
            object value,
            DittoProcessorContext context)
        {
            if (value != null && !ValueType.IsInstanceOfType(value))
            {
                throw new ArgumentException("Expected a value argument of type " + ValueType + " but got " + value.GetType(), "value");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (!ContextType.IsInstanceOfType(context))
            {
                throw new ArgumentException("Expected a context argument of type " + ContextType + " but got " + context.GetType(), "context");
            }

            Value   = value;
            Context = context;

            var ctx = new DittoCacheContext(this, context.Content, context.TargetType, context.PropertyDescriptor, context.Culture);

            return(this.GetCacheItem(ctx, this.ProcessValue));
        }
Beispiel #2
0
        public override bool Contributes(object o, Type type)
        {
            if (type == useType)
            {
                return(true);
            }
            if (IsObjectType(ContextType))
            {
                if (o != null)
                {
                    if (ContextType.IsInstanceOfType(o))
                    {
                        lastObject = o;
                        return(true);
                    }
                    if (o is Primitive)
                    {
                        lastObject = o;
                        return(true);
                    }
                    {
                        var uuid = ToUUID(o);
                        if (uuid != UUID.Zero)
                        {
                            var lo = WorldObjects.GetSimObjectFromUUID(uuid);
                            if (lo != null)
                            {
                                lastObject = lo;
                                return(true);
                            }
                            lastObject = uuid;
                        }
                    }
                    if (type == typeof(UUID))
                    {
                        return(false);
                    }
                }
                if (IsObjectType(type))
                {
                    return(true);
                }
                return(!typeof(InventoryBase).IsInstanceOfType(o));
            }

            return(base.Contributes(o, type));
        }
        public void Fill(BucketContext bucketContext)
        {
            Debug.Assert(ContextType.IsInstanceOfType(bucketContext));

            Initialize(bucketContext);
        }