Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / PrimitiveCodeDomSerializer.cs / 1305376 / PrimitiveCodeDomSerializer.cs
namespace System.Workflow.ComponentModel.Serialization { using System; using System.CodeDom; using System.ComponentModel; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; using System.Collections; using System.Resources; using System.Workflow.ComponentModel.Design; using System.Collections.Generic; using Microsoft.CSharp; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Compiler; using System.CodeDom.Compiler; using System.IO; using System.Reflection; using System.Diagnostics; #region Class PrimitiveCodeDomSerializer // work around : PD7's PrimitiveCodeDomSerializer does not handle well strings bigger than 200 characters, // we push our own version to fix it. internal class PrimitiveCodeDomSerializer : CodeDomSerializer { private static readonly string JSharpFileExtension = ".jsl"; private static PrimitiveCodeDomSerializer defaultSerializer; internal static PrimitiveCodeDomSerializer Default { get { if (defaultSerializer == null) { defaultSerializer = new PrimitiveCodeDomSerializer(); } return defaultSerializer; } } public override object Serialize(IDesignerSerializationManager manager, object value) { CodeExpression expression = new CodePrimitiveExpression(value); if (value == null || value is bool || value is char || value is int || value is float || value is double) { // work aroundf for J#, since they don't support auto-boxing of value types yet. CodeDomProvider codeProvider = manager.GetService(typeof(CodeDomProvider)) as CodeDomProvider; if (codeProvider != null && String.Equals(codeProvider.FileExtension, JSharpFileExtension)) { // See if we are boxing - if so, insert a cast. ExpressionContext cxt = manager.Context[typeof(ExpressionContext)] as ExpressionContext; //Debug.Assert(cxt != null, "No expression context on stack - J# boxing cast will not be inserted"); if (cxt != null) { if (cxt.ExpressionType == typeof(object)) { expression = new CodeCastExpression(value.GetType(), expression); expression.UserData.Add("CastIsBoxing", true); } } } return expression; } String stringValue = value as string; if (stringValue != null) { // WinWS: The commented code breaks us when we have long strings //if (stringValue.Length > 200) //{ // return SerializeToResourceExpression(manager, stringValue); //} //else return expression; } // generate a cast for non-int types because we won't parse them properly otherwise because we won't know to convert // them to the narrow form. // return new CodeCastExpression(new CodeTypeReference(value.GetType()), expression); } } #endregion } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EntityViewGenerationAttribute.cs
- EventBuilder.cs
- FormViewDeleteEventArgs.cs
- UnsafeNativeMethods.cs
- Geometry.cs
- ColorConverter.cs
- PKCS1MaskGenerationMethod.cs
- DataSourceConverter.cs
- XmlKeywords.cs
- InheritanceAttribute.cs
- XmlUTF8TextReader.cs
- RightsManagementEncryptedStream.cs
- OptimizedTemplateContentHelper.cs
- CryptoApi.cs
- WorkflowRequestContext.cs
- _HeaderInfo.cs
- XPathNodePointer.cs
- CompleteWizardStep.cs
- ContextMenu.cs
- StreamSecurityUpgradeInitiator.cs
- SqlDataSourceSummaryPanel.cs
- BinaryObjectInfo.cs
- XmlSchemaSimpleType.cs
- TreeViewItem.cs
- DeploymentSection.cs
- Main.cs
- Form.cs
- ErrorActivity.cs
- ExcludeFromCodeCoverageAttribute.cs
- DependencyPropertyAttribute.cs
- CompiledQueryCacheEntry.cs
- OdbcEnvironment.cs
- SmiContext.cs
- ServiceBehaviorElementCollection.cs
- CqlBlock.cs
- DataGridPageChangedEventArgs.cs
- XPathDocumentNavigator.cs
- NavigationEventArgs.cs
- MessagePropertyFilter.cs
- Pen.cs
- grammarelement.cs
- BuildResultCache.cs
- HeaderUtility.cs
- InstanceView.cs
- QilInvokeLateBound.cs
- XsltInput.cs
- FixedStringLookup.cs
- DateTimeConstantAttribute.cs
- QueryRewriter.cs
- SelectorAutomationPeer.cs
- CookielessData.cs
- EntityTypeEmitter.cs
- HttpWebRequestElement.cs
- CqlParserHelpers.cs
- StandardOleMarshalObject.cs
- _StreamFramer.cs
- SqlCommand.cs
- ContainerUtilities.cs
- ConstraintManager.cs
- XmlImplementation.cs
- ToolStripItemTextRenderEventArgs.cs
- ToolStripPanelRow.cs
- WebExceptionStatus.cs
- AddInIpcChannel.cs
- ContentWrapperAttribute.cs
- TypeUtil.cs
- NavigationEventArgs.cs
- FamilyMap.cs
- TextRunTypographyProperties.cs
- ScrollViewerAutomationPeer.cs
- DragEventArgs.cs
- BreakRecordTable.cs
- SystemDiagnosticsSection.cs
- EntityClassGenerator.cs
- HebrewCalendar.cs
- MulticastOption.cs
- WebResourceAttribute.cs
- ResourceAttributes.cs
- WebPartEventArgs.cs
- _SSPISessionCache.cs
- XPathConvert.cs
- RoutedEventArgs.cs
- InvalidAsynchronousStateException.cs
- WebPartVerbsEventArgs.cs
- XmlAnyElementAttributes.cs
- OleDbPermission.cs
- TransactionOptions.cs
- AuthorizationRule.cs
- HttpCacheVary.cs
- XmlSchemaSimpleContent.cs
- Propagator.Evaluator.cs
- cookiecollection.cs
- EventWaitHandle.cs
- ListViewItemEventArgs.cs
- HtmlElementCollection.cs
- UnsafeNativeMethodsTablet.cs
- TimelineClockCollection.cs
- ErrorStyle.cs
- QueryableDataSourceHelper.cs
- MdiWindowListItemConverter.cs