Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / ErrorActivity.cs / 1305376 / ErrorActivity.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System; using System.Activities; using System.Activities.Presentation.View; using System.ComponentModel; using System.Runtime; using System.Xaml; using XamlDeferLoad = System.Windows.Markup.XamlDeferLoadAttribute; [Designer(typeof(ErrorActivity.ErrorActivityView))] internal class ErrorActivity : Activity { static readonly AttachableMemberIdentifier HasErrorActivitiesProperty = new AttachableMemberIdentifier(typeof(ErrorActivity), "HasErrorActivities"); internal const string ErrorNodesProperty = "ErrorNodes"; [Browsable(false)] [XamlDeferLoad(typeof(NodeListLoader), typeof(object))] public XamlNodeList ErrorNodes { get; set; } internal static bool GetHasErrorActivities(object target) { object result; if (AttachablePropertyServices.TryGetProperty(target, HasErrorActivitiesProperty, out result)) { return (bool)result; } return false; } internal static void SetHasErrorActivities(object target, bool value) { AttachablePropertyServices.SetProperty(target, HasErrorActivitiesProperty, value); } internal static void WriteNodeList(XamlWriter writer, XamlNodeList nodeList) { // We need to pass the ErrorNodes contents through as a NodeList, because XOW doesn't // currently support unknown types, even inside a DeferLoad block. // But if a NodeList is written to XOW as a Value, XOW will unpack, forcing us to re-buffer // the nodes in our deferring loader. So we wrap the NodeList value inside a dummy StartObject. writer.WriteStartObject(XamlLanguage.Object); writer.WriteStartMember(XamlLanguage.Initialization); writer.WriteValue(nodeList); writer.WriteEndMember(); writer.WriteEndObject(); } internal class NodeListLoader : XamlDeferringLoader { public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider) { // Expects a nodestream produced by WriteNodesList xamlReader.Read(); xamlReader.Read(); xamlReader.Read(); Fx.Assert(xamlReader.NodeType == XamlNodeType.Value, "Expected Value node"); return (XamlNodeList)xamlReader.Value; } public override XamlReader Save(object value, IServiceProvider serviceProvider) { return ((XamlNodeList)value).GetReader(); } } internal class ErrorActivityView : WorkflowViewElement { public ErrorActivityView() { WorkflowViewService.ShowErrorInViewElement(this, SR.ActivityLoadError, null); } } } [Designer(typeof(ErrorActivity.ErrorActivityView))] internal class ErrorActivity: Activity { [Browsable(false)] [XamlDeferLoad(typeof(ErrorActivity.NodeListLoader), typeof(object))] public XamlNodeList ErrorNodes { get; set; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System; using System.Activities; using System.Activities.Presentation.View; using System.ComponentModel; using System.Runtime; using System.Xaml; using XamlDeferLoad = System.Windows.Markup.XamlDeferLoadAttribute; [Designer(typeof(ErrorActivity.ErrorActivityView))] internal class ErrorActivity : Activity { static readonly AttachableMemberIdentifier HasErrorActivitiesProperty = new AttachableMemberIdentifier(typeof(ErrorActivity), "HasErrorActivities"); internal const string ErrorNodesProperty = "ErrorNodes"; [Browsable(false)] [XamlDeferLoad(typeof(NodeListLoader), typeof(object))] public XamlNodeList ErrorNodes { get; set; } internal static bool GetHasErrorActivities(object target) { object result; if (AttachablePropertyServices.TryGetProperty(target, HasErrorActivitiesProperty, out result)) { return (bool)result; } return false; } internal static void SetHasErrorActivities(object target, bool value) { AttachablePropertyServices.SetProperty(target, HasErrorActivitiesProperty, value); } internal static void WriteNodeList(XamlWriter writer, XamlNodeList nodeList) { // We need to pass the ErrorNodes contents through as a NodeList, because XOW doesn't // currently support unknown types, even inside a DeferLoad block. // But if a NodeList is written to XOW as a Value, XOW will unpack, forcing us to re-buffer // the nodes in our deferring loader. So we wrap the NodeList value inside a dummy StartObject. writer.WriteStartObject(XamlLanguage.Object); writer.WriteStartMember(XamlLanguage.Initialization); writer.WriteValue(nodeList); writer.WriteEndMember(); writer.WriteEndObject(); } internal class NodeListLoader : XamlDeferringLoader { public override object Load(XamlReader xamlReader, IServiceProvider serviceProvider) { // Expects a nodestream produced by WriteNodesList xamlReader.Read(); xamlReader.Read(); xamlReader.Read(); Fx.Assert(xamlReader.NodeType == XamlNodeType.Value, "Expected Value node"); return (XamlNodeList)xamlReader.Value; } public override XamlReader Save(object value, IServiceProvider serviceProvider) { return ((XamlNodeList)value).GetReader(); } } internal class ErrorActivityView : WorkflowViewElement { public ErrorActivityView() { WorkflowViewService.ShowErrorInViewElement(this, SR.ActivityLoadError, null); } } } [Designer(typeof(ErrorActivity.ErrorActivityView))] internal class ErrorActivity : Activity { [Browsable(false)] [XamlDeferLoad(typeof(ErrorActivity.NodeListLoader), typeof(object))] public XamlNodeList ErrorNodes { get; set; } } } // 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
- DtdParser.cs
- ImpersonateTokenRef.cs
- TextTreeUndo.cs
- SqlFacetAttribute.cs
- X509AsymmetricSecurityKey.cs
- MeasureItemEvent.cs
- TimerElapsedEvenArgs.cs
- TableNameAttribute.cs
- AliasedSlot.cs
- PointCollectionConverter.cs
- PointHitTestResult.cs
- TextDataBindingHandler.cs
- ExpressionConverter.cs
- ParseHttpDate.cs
- ErasingStroke.cs
- ProfileSettingsCollection.cs
- SecurityTokenContainer.cs
- CharacterHit.cs
- StyleCollection.cs
- UniqueEventHelper.cs
- UmAlQuraCalendar.cs
- GroupBoxAutomationPeer.cs
- SchemaObjectWriter.cs
- sqlnorm.cs
- XPathSelfQuery.cs
- EncoderExceptionFallback.cs
- RuntimeEnvironment.cs
- SingleResultAttribute.cs
- Html32TextWriter.cs
- LogLogRecordEnumerator.cs
- Base64Encoding.cs
- IgnoreFlushAndCloseStream.cs
- XmlRawWriterWrapper.cs
- SqlDataSourceConfigureSelectPanel.cs
- InfoCardKeyedHashAlgorithm.cs
- HtmlDocument.cs
- DigitalSignature.cs
- SizeKeyFrameCollection.cs
- MD5Cng.cs
- ApplyTemplatesAction.cs
- MetaDataInfo.cs
- MemberAccessException.cs
- ISAPIRuntime.cs
- EmptyStringExpandableObjectConverter.cs
- SocketException.cs
- EncodingInfo.cs
- MetadataItemSerializer.cs
- ReadOnlyHierarchicalDataSource.cs
- HtmlImageAdapter.cs
- BindableTemplateBuilder.cs
- AspCompat.cs
- OdbcParameter.cs
- HttpClientCertificate.cs
- OleDbPropertySetGuid.cs
- SyntaxCheck.cs
- SelectingProviderEventArgs.cs
- MergablePropertyAttribute.cs
- ReadOnlyNameValueCollection.cs
- TypeSource.cs
- CommonObjectSecurity.cs
- WindowsTokenRoleProvider.cs
- Token.cs
- TypeDescriptor.cs
- SQLGuidStorage.cs
- CachedTypeface.cs
- OracleConnectionString.cs
- LinqExpressionNormalizer.cs
- WMIInterop.cs
- DbMetaDataFactory.cs
- AttributeXamlType.cs
- WebBrowserUriTypeConverter.cs
- HwndSubclass.cs
- ProbeMatchesMessage11.cs
- EventLogSession.cs
- BasicDesignerLoader.cs
- AnnotationHighlightLayer.cs
- WebPartHelpVerb.cs
- KeyValueSerializer.cs
- GeometryModel3D.cs
- DataControlPagerLinkButton.cs
- UIElement.cs
- AttributeCollection.cs
- Utilities.cs
- ChangeTracker.cs
- baseaxisquery.cs
- RegistryKey.cs
- EmptyQuery.cs
- TextParagraphProperties.cs
- NativeActivity.cs
- PropertyInformationCollection.cs
- WorkflowMarkupSerializer.cs
- mediaeventargs.cs
- OdbcCommand.cs
- ListViewPagedDataSource.cs
- AssociatedControlConverter.cs
- PermissionToken.cs
- ArrayList.cs
- RuntimeHelpers.cs
- XNodeValidator.cs
- DataStorage.cs