예제 #1
0
 public static void ReceiveTypeConverter(object targetObject, XamlSetTypeConverterEventArgs eventArgs)
 {
     // The DependencyProperty refered to by Property may depend on the value of TargetName,
     // but we don't know that yet, so defer loading Property until EndInit().
     if (eventArgs.Member.Name == "Property")
     {
         Setter setter = (Setter)targetObject;
         setter.propertyName = (string)eventArgs.Value;
         setter.serviceProvider = eventArgs.ServiceProvider;
         eventArgs.Handled = true;
     }
 }
 private bool Logic_CreatePropertyValueFromValue(ObjectWriterContext ctx)
 {
     XamlMember parentProperty = ctx.ParentProperty;
     XamlType type1 = parentProperty.Type;
     object currentInstance = ctx.CurrentInstance;
     XamlReader deferredContent = currentInstance as XamlReader;
     if (deferredContent != null)
     {
         XamlValueConverter<XamlDeferringLoader> deferringLoader = parentProperty.DeferringLoader;
         if (deferringLoader != null)
         {
             ctx.CurrentInstance = this.Runtime.DeferredLoad(ctx.ServiceProviderContext, deferringLoader, deferredContent);
             return true;
         }
     }
     XamlValueConverter<TypeConverter> typeConverter = parentProperty.TypeConverter;
     object obj3 = null;
     XamlType declaringType = null;
     if (parentProperty.IsAttachable)
     {
         declaringType = parentProperty.DeclaringType;
     }
     else
     {
         declaringType = ctx.ParentType;
     }
     if (((parentProperty != null) && !parentProperty.IsUnknown) && (declaringType != null))
     {
         XamlType grandParentType = ctx.GrandParentType;
         if ((parentProperty.IsDirective && (parentProperty == XamlLanguage.Key)) && ((grandParentType != null) && grandParentType.IsDictionary))
         {
             typeConverter = grandParentType.KeyType.TypeConverter;
         }
         if (((typeConverter != null) && (typeConverter.ConverterType != null)) && (typeConverter != BuiltInValueConverter.String))
         {
             TypeConverter converterInstance = this.Runtime.GetConverterInstance<TypeConverter>(typeConverter);
             if ((converterInstance != null) && (declaringType.SetTypeConverterHandler != null))
             {
                 XamlSetTypeConverterEventArgs e = new XamlSetTypeConverterEventArgs(parentProperty, converterInstance, currentInstance, ctx.ServiceProviderContext, TypeConverterHelper.InvariantEnglishUS, ctx.ParentInstance) {
                     CurrentType = declaringType
                 };
                 declaringType.SetTypeConverterHandler(ctx.ParentInstance, e);
                 if (e.Handled)
                 {
                     return false;
                 }
             }
         }
     }
     if (typeConverter != null)
     {
         obj3 = this.Logic_CreateFromValue(ctx, typeConverter, currentInstance, parentProperty, parentProperty.Name);
     }
     else
     {
         obj3 = currentInstance;
     }
     ctx.CurrentInstance = obj3;
     return true;
 }
예제 #3
0
파일: Condition.cs 프로젝트: JianwenSun/cc
        public static void ReceiveTypeConverter(object targetObject, XamlSetTypeConverterEventArgs eventArgs)
        {
            Condition condition = targetObject as Condition;
            if (condition == null)
            {
                throw new ArgumentNullException("targetObject");
            }
            if (eventArgs == null)
            {
                throw new ArgumentNullException("eventArgs");
            }

            if (eventArgs.Member.Name == "Property")
            {
                condition._unresolvedProperty = eventArgs.Value;
                condition._serviceProvider = eventArgs.ServiceProvider;
                condition._cultureInfoForTypeConverter = eventArgs.CultureInfo;

                eventArgs.Handled = true;
            }
            else if (eventArgs.Member.Name == "Value")
            {
                condition._unresolvedValue = eventArgs.Value;
                condition._serviceProvider = eventArgs.ServiceProvider;
                condition._cultureInfoForTypeConverter = eventArgs.CultureInfo;

                eventArgs.Handled = true;
            }
        }
예제 #4
0
			// can be private.
			static void HandleTypeConverter (object o, XamlSetTypeConverterEventArgs a)
			{
			}