コード例 #1
0
        /// <summary>
        /// Retrieves the value for the specified object instance.
        /// </summary>
        public override object GetValue(object instance)
        {
            object dynamicValue;

            if (this.TryGetValueFromDynamic(instance, out dynamicValue))
            {
                return(dynamicValue);
            }

            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            if (string.IsNullOrEmpty(this.propertyName))
            {
                throw new ArgumentException("PropertyName not specified.");
            }

            Type instanceType = instance.GetType();

            if (this.getter == null || !object.ReferenceEquals(this.getterInstanceType, instanceType))
            {
                this.getter             = DynamicHelper.CreatePropertyValueGetter(instanceType, this.propertyName);
                this.getterInstanceType = instanceType;
            }

            return(this.getter(instance));
        }
コード例 #2
0
        private Type ResolveType(object context)
        {
            // TypePath property is with highest priority
            if (!string.IsNullOrEmpty(this.typePathCache))
            {
                if (this.typeGetter == null)
                {
                    this.typeGetter = DynamicHelper.CreatePropertyValueGetter(context.GetType(), this.typePathCache);
                }

                Type type = this.typeGetter(context) as Type;

                if (type == null)
                {
                    throw new ArgumentException("TypePath property should point to a valid Type property.");
                }

                return(type);
            }

            // Next is the Style.TargetType (if Style is specified)
            Style style = this.Style;

            if (style != null)
            {
                return(style.TargetType);
            }

            // Last is the DefaultType
            return(this.DefaultType);
        }
コード例 #3
0
        private void ResetFilterKeyGetter(object item)
        {
            this.filterKeyGetter = DynamicHelper.CreatePropertyValueGetter(item.GetType(), this.filterMemberPath);

            if (this.filterKeyGetter == null)
            {
                Debug.Assert(false, "Invalid FilterMemberPath defined.");
            }
        }
コード例 #4
0
        private string GetLegendTitle(object context)
        {
            if (string.IsNullOrEmpty(this.LegendTitlePath))
            {
                return(string.Empty);
            }

            if (this.legendTitleGetter == null)
            {
                this.legendTitleGetter = DynamicHelper.CreatePropertyValueGetter(context.GetType(), this.legendTitlePathCache);
            }

            return(this.legendTitleGetter(context) as string);
        }