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
- XmlnsCache.cs
- CompilationUnit.cs
- PointAnimation.cs
- RuleRefElement.cs
- ADConnectionHelper.cs
- ColumnCollection.cs
- PenLineCapValidation.cs
- ControlAdapter.cs
- CodeBlockBuilder.cs
- XmlArrayItemAttributes.cs
- ReverseComparer.cs
- Positioning.cs
- XmlSerializerAssemblyAttribute.cs
- TransformerTypeCollection.cs
- InputDevice.cs
- SafeHandle.cs
- OwnerDrawPropertyBag.cs
- ListControlActionList.cs
- CodeDOMProvider.cs
- StorageSetMapping.cs
- CredentialCache.cs
- RuntimeComponentFilter.cs
- FormatPage.cs
- EraserBehavior.cs
- SystemWebExtensionsSectionGroup.cs
- RowCache.cs
- DecoratedNameAttribute.cs
- XamlGridLengthSerializer.cs
- PcmConverter.cs
- EventDescriptor.cs
- ModifierKeysConverter.cs
- FixUp.cs
- WebServiceEnumData.cs
- BaseDataBoundControl.cs
- SerializationException.cs
- ExpressionParser.cs
- BoundsDrawingContextWalker.cs
- LongAverageAggregationOperator.cs
- StringExpressionSet.cs
- CallInfo.cs
- PageAdapter.cs
- SecurityIdentifierElement.cs
- CompModSwitches.cs
- InkPresenterAutomationPeer.cs
- DeferredSelectedIndexReference.cs
- ToolStripSeparator.cs
- X509AsymmetricSecurityKey.cs
- NativeCppClassAttribute.cs
- CryptoKeySecurity.cs
- SchemaEntity.cs
- XPathItem.cs
- ReflectionServiceProvider.cs
- CharUnicodeInfo.cs
- DataMember.cs
- ToolboxItemCollection.cs
- OutputCacheSection.cs
- ProtocolsConfiguration.cs
- HttpCacheParams.cs
- QueuePathEditor.cs
- DrawingAttributesDefaultValueFactory.cs
- RequestDescription.cs
- RangeValidator.cs
- FileSecurity.cs
- CatalogZoneBase.cs
- BookmarkTable.cs
- XsdBuildProvider.cs
- LogReserveAndAppendState.cs
- IdentitySection.cs
- AuthorizationSection.cs
- RoutedEventValueSerializer.cs
- Binding.cs
- BaseProcessProtocolHandler.cs
- ConnectorMovedEventArgs.cs
- RegularExpressionValidator.cs
- SqlAliasesReferenced.cs
- ServiceControllerDesigner.cs
- KnownTypeAttribute.cs
- MimeXmlImporter.cs
- AccessedThroughPropertyAttribute.cs
- SqlTriggerAttribute.cs
- Geometry3D.cs
- Converter.cs
- AutomationPattern.cs
- TransformProviderWrapper.cs
- Closure.cs
- DataMember.cs
- TraceSwitch.cs
- TCEAdapterGenerator.cs
- SpellCheck.cs
- DefaultAsyncDataDispatcher.cs
- FlowDocumentView.cs
- ListMarkerLine.cs
- ProcessHostMapPath.cs
- Cursor.cs
- ILGenerator.cs
- GeometryModel3D.cs
- CSharpCodeProvider.cs
- mongolianshape.cs
- EntityFunctions.cs
- GeometryHitTestParameters.cs