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
- GlyphElement.cs
- WebFormDesignerActionService.cs
- UnmanagedHandle.cs
- COM2TypeInfoProcessor.cs
- FixedSOMSemanticBox.cs
- DataGridViewColumnHeaderCell.cs
- XmlTextEncoder.cs
- HealthMonitoringSection.cs
- HttpRequest.cs
- BatchWriter.cs
- XNodeValidator.cs
- StylusSystemGestureEventArgs.cs
- CommandBinding.cs
- COM2PropertyDescriptor.cs
- RouteCollection.cs
- SafeCryptContextHandle.cs
- RoutingConfiguration.cs
- WebPartEditorCancelVerb.cs
- ShutDownListener.cs
- WebScriptClientGenerator.cs
- WebPartEditorCancelVerb.cs
- ZoneLinkButton.cs
- SafeNativeMethodsOther.cs
- StagingAreaInputItem.cs
- PropertyValidationContext.cs
- ParameterEditorUserControl.cs
- RectKeyFrameCollection.cs
- SessionStateSection.cs
- ViewValidator.cs
- ConstraintCollection.cs
- DbMetaDataFactory.cs
- SecurityRuntime.cs
- _SslState.cs
- ListViewItem.cs
- StateElementCollection.cs
- Comparer.cs
- XmlNodeList.cs
- HtmlTitle.cs
- DataStreams.cs
- BatchParser.cs
- XmlSchemaValidator.cs
- IdnElement.cs
- Point4DValueSerializer.cs
- ResourceDescriptionAttribute.cs
- Gdiplus.cs
- OleDbTransaction.cs
- DecimalStorage.cs
- BrowserDefinition.cs
- SiblingIterators.cs
- remotingproxy.cs
- ReaderWriterLock.cs
- DesignerResources.cs
- SplitterCancelEvent.cs
- TrackingMemoryStream.cs
- WebEventCodes.cs
- XamlFilter.cs
- SoapTypeAttribute.cs
- ReferenceConverter.cs
- BorderGapMaskConverter.cs
- StringComparer.cs
- ReachFixedPageSerializerAsync.cs
- Point4DValueSerializer.cs
- ExecutorLocksHeldException.cs
- RectangleGeometry.cs
- Double.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- WindowsProgressbar.cs
- PropertyPushdownHelper.cs
- SQLInt16.cs
- MD5.cs
- PersistenceTypeAttribute.cs
- BulletChrome.cs
- RowCache.cs
- Int16Animation.cs
- Translator.cs
- HttpServerVarsCollection.cs
- SearchForVirtualItemEventArgs.cs
- EntityDesignerDataSourceView.cs
- SyntaxCheck.cs
- MappedMetaModel.cs
- AppDomainFactory.cs
- FormsAuthenticationUserCollection.cs
- QueryContinueDragEvent.cs
- ThreadStartException.cs
- RoleService.cs
- GlyphRun.cs
- UndirectedGraph.cs
- FormsAuthentication.cs
- EventArgs.cs
- SecurityProtocol.cs
- CultureMapper.cs
- XmlSchemas.cs
- WmlCommandAdapter.cs
- DbConnectionPoolIdentity.cs
- EditingMode.cs
- BaseCollection.cs
- WinCategoryAttribute.cs
- PermissionListSet.cs
- BufferBuilder.cs
- UnsafeNativeMethods.cs