Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / ImportRequest.cs / 1 / ImportRequest.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Collections; using System.Security.Principal; using System.Diagnostics; using System.Threading; //ManualResetEvent using System.ComponentModel; //Win32Exception using System.IO; //Stream using System.Text; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; using Microsoft.InfoCards.Diagnostics; // // This class is an instance of a request to import a card from a file. // It starts up the UI in the 'Import' mode. // class ImportRequest : ClientUIRequest { FileStream m_importFile; //keep a read pointer to the file string m_filename; public ImportRequest( Process callingProcess, WindowsIdentity callingIdentity, InfoCardUIAgent uiAgent, IntPtr rpcHandle, Stream inArgs, Stream outArgs ) : base( callingProcess, callingIdentity, uiAgent, rpcHandle, inArgs, outArgs, InfoCardUIAgent.CallMode.Import, ExceptionList.AllNonFatal ) { } public string ImportedFile { get{ return m_filename; } } // // No input args // protected override void OnMarshalInArgs() { BinaryReader breader = new InfoCardBinaryReader( InArgs, Encoding.Unicode ); string filename = Utility.DeserializeString( breader ); if (String.IsNullOrEmpty(filename) || filename.Length > Constants.Maxima.FileNameLength) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.InvalidImportFileName ) ) ); } if( !Path.IsPathRooted( filename ) ) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.InvalidImportFileName) ) ); } try { m_filename = filename; m_importFile = new FileStream( m_filename, FileMode.Open, FileAccess.Read, FileShare.Read ); } catch( ArgumentException e ) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.CannotOpenImportFile ), e ) ); } catch( IOException e ) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.CannotOpenImportFile ), e ) ); } catch( NotSupportedException e ) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.CannotOpenImportFile ), e ) ); } catch( UnauthorizedAccessException e ) { throw IDT.ThrowHelperError( new ImportException( SR.GetString( SR.CannotOpenImportFile ), e ) ); } } protected override void OnProcess() { // // ClientUiRequest's member function // StartAndWaitForUIAgent(); } // // No Output args. // protected override void OnMarshalOutArgs() { } protected override void OnDisposeAsUser() { base.OnDisposeAsUser(); if( null != m_importFile ) { m_importFile.Dispose(); m_importFile = null; } } // // Summary // Gets called a) if there was an exception in client processing // or b) if there was an exception in the child's request processing // protected override bool OnHandleException( Exception e, out int errorCode ) { errorCode = 0; bool handled = false; if( e is UserCancelledException ) { errorCode = (e as UserCancelledException).NativeHResult; handled = true; } return handled; } } } // 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
- Vector3DAnimation.cs
- XmlSchemaDocumentation.cs
- EventLogReader.cs
- CodePageUtils.cs
- TypefaceMap.cs
- BaseConfigurationRecord.cs
- BlockUIContainer.cs
- NavigateUrlConverter.cs
- BitmapEffectDrawingContent.cs
- DataSvcMapFileSerializer.cs
- DelegatingConfigHost.cs
- OpenTypeLayout.cs
- SchemaTypeEmitter.cs
- entityreference_tresulttype.cs
- XmlWriterSettings.cs
- DataGridRow.cs
- Parser.cs
- GlobalProxySelection.cs
- CodeDOMUtility.cs
- StringUtil.cs
- PropertyGeneratedEventArgs.cs
- DSACryptoServiceProvider.cs
- ColumnWidthChangingEvent.cs
- DisplayNameAttribute.cs
- DataGridParentRows.cs
- LinkLabelLinkClickedEvent.cs
- AccessControlList.cs
- SweepDirectionValidation.cs
- StreamInfo.cs
- SemanticBasicElement.cs
- TemporaryBitmapFile.cs
- GatewayDefinition.cs
- ProfessionalColorTable.cs
- ApplicationInfo.cs
- DecimalConverter.cs
- WebHeaderCollection.cs
- DocumentEventArgs.cs
- UrlParameterReader.cs
- ClassHandlersStore.cs
- SoapAttributeOverrides.cs
- SynchronizingStream.cs
- EventEntry.cs
- SafeBitVector32.cs
- Attributes.cs
- InvokeMethod.cs
- path.cs
- TransactionCache.cs
- IsolatedStorageFileStream.cs
- StringExpressionSet.cs
- CultureSpecificStringDictionary.cs
- AttachedPropertiesService.cs
- JsonObjectDataContract.cs
- ExpressionPrefixAttribute.cs
- XmlSchemaAttribute.cs
- Size.cs
- DataGridViewCellCancelEventArgs.cs
- WindowsToolbarItemAsMenuItem.cs
- FilteredXmlReader.cs
- Validator.cs
- FontSizeConverter.cs
- EffectiveValueEntry.cs
- CheckBoxList.cs
- MDIWindowDialog.cs
- Color.cs
- PolyBezierSegment.cs
- ConfigXmlDocument.cs
- InputLanguageCollection.cs
- HttpWebRequest.cs
- DiffuseMaterial.cs
- NotSupportedException.cs
- VisualStateManager.cs
- InProcStateClientManager.cs
- SystemInformation.cs
- SvcMapFileSerializer.cs
- UInt16Converter.cs
- ServicesSection.cs
- TabPage.cs
- Rotation3DAnimationBase.cs
- DCSafeHandle.cs
- SrgsElementList.cs
- securestring.cs
- HitTestWithGeometryDrawingContextWalker.cs
- DynamicPropertyReader.cs
- HttpPostedFile.cs
- PlaceHolder.cs
- InputReferenceExpression.cs
- MiniAssembly.cs
- PerformanceCounterPermission.cs
- MetadataSource.cs
- HtmlLiteralTextAdapter.cs
- SqlReferenceCollection.cs
- Crypto.cs
- TabItemWrapperAutomationPeer.cs
- Misc.cs
- ModifierKeysConverter.cs
- DirectoryInfo.cs
- PagesSection.cs
- RadioButton.cs
- Int32Converter.cs
- SqlCacheDependencySection.cs