Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / System.Activities / System / Activities / XamlIntegration / FuncTypeConverter.cs / 1305376 / FuncTypeConverter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.XamlIntegration { using System; using System.ComponentModel; using System.Globalization; using System.Reflection; using System.Runtime; using System.Windows.Markup; using System.Xaml; public class FuncDeferringLoader : XamlDeferringLoader { public override object Load(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; } object instance = Activator.CreateInstance( typeof(FuncFactory<>).MakeGenericType(propertyType.GetGenericArguments()), objectWriterFactory, xamlReader); return Delegate.CreateDelegate(propertyType, instance, instance.GetType().GetMethod("Evaluate")); } public override XamlReader Save(object value, IServiceProvider serviceProvider) { throw FxTrace.Exception.AsError(new NotSupportedException(SR.SavingActivityToXamlNotSupported)); } abstract class FuncFactory { public XamlNodeList Nodes { get; set; } } class FuncFactory: FuncFactory { IXamlObjectWriterFactory objectWriterFactory; public FuncFactory(IXamlObjectWriterFactory objectWriterFactory, XamlReader reader) { this.objectWriterFactory = objectWriterFactory; this.Nodes = new XamlNodeList(reader.SchemaContext); XamlServices.Transform(reader, this.Nodes.Writer); } public T Evaluate() { XamlObjectWriter writer = this.objectWriterFactory.GetXamlObjectWriter(new XamlObjectWriterSettings()); XamlServices.Transform(this.Nodes.GetReader(), writer); return (T)writer.Result; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NegotiateStream.cs
- QueryCacheEntry.cs
- GeometryDrawing.cs
- datacache.cs
- ConfigurationConverterBase.cs
- LambdaCompiler.Generated.cs
- InputScopeConverter.cs
- Range.cs
- WebReferenceOptions.cs
- GroupBoxRenderer.cs
- _OSSOCK.cs
- ADMembershipUser.cs
- PriorityItem.cs
- HwndAppCommandInputProvider.cs
- OutputCache.cs
- EventLogPermissionEntry.cs
- BasePattern.cs
- WebPartVerbsEventArgs.cs
- MappingMetadataHelper.cs
- SQLChars.cs
- ReflectTypeDescriptionProvider.cs
- SplitContainer.cs
- ResourceDescriptionAttribute.cs
- ObjectHandle.cs
- DynamicFilterExpression.cs
- CodeSubDirectoriesCollection.cs
- UniqueEventHelper.cs
- VisualTreeUtils.cs
- NonSerializedAttribute.cs
- Utility.cs
- WebEventTraceProvider.cs
- DetailsViewInsertedEventArgs.cs
- DoubleAnimationUsingKeyFrames.cs
- FixedSOMPageElement.cs
- GradientBrush.cs
- DataBinder.cs
- OperatingSystem.cs
- PropertyValueChangedEvent.cs
- PlatformNotSupportedException.cs
- DrawItemEvent.cs
- Lasso.cs
- SQLInt64.cs
- ModuleBuilder.cs
- input.cs
- LoginView.cs
- ServiceOperationListItemList.cs
- TextMarkerSource.cs
- IISMapPath.cs
- ScriptBehaviorDescriptor.cs
- App.cs
- AutoSizeComboBox.cs
- DetailsViewInsertEventArgs.cs
- _AuthenticationState.cs
- FactoryGenerator.cs
- DocumentPage.cs
- ForceCopyBuildProvider.cs
- HtmlInputReset.cs
- CacheDependency.cs
- XPathSelfQuery.cs
- ListViewGroupItemCollection.cs
- ValidationErrorCollection.cs
- ImageFormat.cs
- TableItemProviderWrapper.cs
- DbConnectionFactory.cs
- PolyBezierSegmentFigureLogic.cs
- SQLResource.cs
- VerticalAlignConverter.cs
- TableCell.cs
- ObjectDataSourceView.cs
- MetaDataInfo.cs
- AdapterUtil.cs
- PropertyInfoSet.cs
- ECDiffieHellman.cs
- AttributeData.cs
- RadioButton.cs
- UnsafeNativeMethodsPenimc.cs
- ListItemCollection.cs
- ListDictionaryInternal.cs
- BitStack.cs
- ChineseLunisolarCalendar.cs
- localization.cs
- BrowserInteropHelper.cs
- DataTable.cs
- HybridCollection.cs
- UrlAuthorizationModule.cs
- Rectangle.cs
- InfoCardRSACryptoProvider.cs
- RectAnimationClockResource.cs
- SymLanguageType.cs
- DocumentReferenceCollection.cs
- FreeFormPanel.cs
- CodeDomSerializerException.cs
- SingleKeyFrameCollection.cs
- ApplicationFileCodeDomTreeGenerator.cs
- StringInfo.cs
- CompilerResults.cs
- ProfileModule.cs
- nulltextnavigator.cs
- MenuStrip.cs
- GeneratedView.cs