Пример #1
0
 public static Func <object> CreateFactory(XamlReader reader, Type resultType)
 {
     if (reader == null)
     {
         throw FxTrace.Exception.ArgumentNull(nameof(reader));
     }
     if (resultType == null)
     {
         throw FxTrace.Exception.ArgumentNull(nameof(resultType));
     }
     return(FuncFactory.CreateFunc(reader, resultType));
 }
        public override XamlReader Save(object value, IServiceProvider serviceProvider)
        {
            FuncFactory factory = GetFactory(value as Delegate);

            if (factory == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.SavingFuncToXamlNotSupported));
            }
            XamlReader result = factory.Nodes.GetReader();

            if (factory.ParentNamespaces != null)
            {
                result = InsertNamespaces(result, factory.ParentNamespaces);
            }
            return(result);
        }
Пример #3
0
        internal static FuncFactory CreateFactory(XamlReader xamlReader, IServiceProvider context)
        {
            IXamlObjectWriterFactory objectWriterFactory = context.GetService(typeof(IXamlObjectWriterFactory)) as IXamlObjectWriterFactory;
            IProvideValueTarget      provideValueService = context.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;

            Type propertyType = null;
            //
            // IProvideValueTarget.TargetProperty can return DP, Attached Property or MemberInfo for clr property
            // In this case it should always be a regular clr property here - we are always targeting Activity.Body.
            PropertyInfo propertyInfo = provideValueService.TargetProperty as PropertyInfo;

            if (propertyInfo != null)
            {
                propertyType = propertyInfo.PropertyType;
            }

            FuncFactory funcFactory = CreateFactory(objectWriterFactory, xamlReader, propertyType.GetGenericArguments());

            return(funcFactory);
        }
Пример #4
0
        public static Func <T> CreateFunc <T>(XamlReader reader) where T : class
        {
            FuncFactory <T> factory = new FuncFactory <T>(null, reader);

            return(factory.GetTypedFunc());
        }
Пример #5
0
        public static Func <object> CreateFunc(XamlReader reader, Type returnType)
        {
            FuncFactory factory = CreateFactory(null, reader, returnType);

            return(factory.GetFunc());
        }