Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / BeginGetFileNameFromUserRequest.cs / 1 / BeginGetFileNameFromUserRequest.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.IO; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary // Processes beginning of asynchronous get file name from user request. // internal class BeginGetFileNameFromUserRequest : UIAgentAsyncBeginRequest { bool m_getContent; // Stores whether file contents are to be returned. string m_arguments; // Stores arguments passed to agent on user desktop. // // Summary // Constructs request. // // Arguments // rpcHandle - Specifies the RPC context handle. // inArgs - Specifies the stream to hold the input arguments. // outArgs - Specifies the stream to hold the output arguments. // parent - Specifies the parent UI request. // public BeginGetFileNameFromUserRequest( IntPtr rpcHandle, Stream inArgs, Stream outArgs, ClientUIRequest parent ) : base( rpcHandle, inArgs, outArgs, parent ) { } // // Summary // Reads input arguments from stream. // // Arguments // reader - Specifies a binary reader. // protected override void OnMarshalAsyncInArgs( BinaryReader reader ) { m_getContent = reader.ReadBoolean(); m_arguments = Utility.DeserializeString( reader ); } // // Summary // Gets file from user. // // Remarks // This method is called from a thread pool thread. // // Arguments // asyncParams - Specifies asynchronous parameters. // protected override object AsyncExecute( AsyncParams asyncParams ) { uint error = 0; string fileName = String.Empty; GetFileNameResult result = new GetFileNameResult(); // // Start agent on user desktop to get file from user. // using( SystemIdentity lsa = new SystemIdentity( true ) ) { error = NativeMcppMethods.CreateAndWaitForFileOpenDialogWrapper( m_arguments, RequestorIdentity, ParentRequest.CallerPid, ref fileName ); } if( 0 == error ) { try { // // Store file name. // result.FileName = fileName; // // If contents were requested and user choose a file then read and store contents. // if( m_getContent && !String.IsNullOrEmpty( fileName ) ) { FileInfo f = new FileInfo( fileName ); using( FileStream file = File.OpenRead( fileName ) ) { BinaryReader reader = new InfoCardBinaryReader( file ); result.FileContent = reader.ReadBytes( (int) f.Length ); } } } catch( Exception e ) { if( IDT.IsFatal( e ) ) { throw; } throw IDT.ThrowHelperError( new FileAccessException( SR.GetString( SR.ServiceInaccessibleFile ), e ) ); } } else { IDT.TraceDebug( "ICARDACCESS:Failed to create process with error {0}", error ); } return result; } // // Summary // The ability to cancel this request is not needed as the user desktop is active and the agent on this desktop // may be closed to end this request without choosing a file. // protected override void AsyncCancel() { ; } } } // 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
- AbandonedMutexException.cs
- InheritedPropertyDescriptor.cs
- LinqDataSourceInsertEventArgs.cs
- XmlSchemaCompilationSettings.cs
- EventSinkHelperWriter.cs
- SchemaMapping.cs
- Inflater.cs
- FillBehavior.cs
- SignedPkcs7.cs
- ProgressPage.cs
- TempEnvironment.cs
- EntityDataSourceReferenceGroup.cs
- MarkupCompilePass2.cs
- activationcontext.cs
- DataGridViewSortCompareEventArgs.cs
- SecurityTokenAuthenticator.cs
- GcSettings.cs
- PropertyChangeTracker.cs
- CompletedAsyncResult.cs
- DbTypeMap.cs
- XmlSecureResolver.cs
- AbsoluteQuery.cs
- JsonFormatWriterGenerator.cs
- StructuredType.cs
- MailSettingsSection.cs
- QuotedPrintableStream.cs
- EntityException.cs
- FixedSOMElement.cs
- ViewStateModeByIdAttribute.cs
- SourceFileBuildProvider.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- ImageDrawing.cs
- ResourceExpressionEditorSheet.cs
- SynchronizingStream.cs
- GridEntryCollection.cs
- Transform3D.cs
- PolyBezierSegment.cs
- PermissionToken.cs
- MimeParameter.cs
- ControllableStoryboardAction.cs
- XmlBinaryWriterSession.cs
- FontInfo.cs
- ThaiBuddhistCalendar.cs
- XmlAggregates.cs
- BoundingRectTracker.cs
- ResourceDescriptionAttribute.cs
- Panel.cs
- DataGridParentRows.cs
- XPathSingletonIterator.cs
- Inflater.cs
- StylusPointProperty.cs
- CodeGroup.cs
- KnownTypeAttribute.cs
- ConfigXmlWhitespace.cs
- KeyNotFoundException.cs
- TrackingStringDictionary.cs
- ProgressBarAutomationPeer.cs
- ActivityMarkupSerializationProvider.cs
- Util.cs
- ObjectParameterCollection.cs
- UnsafeNativeMethods.cs
- DataException.cs
- BamlReader.cs
- PersonalizationProviderCollection.cs
- TypeDelegator.cs
- TimerEventSubscription.cs
- AtomMaterializer.cs
- MsmqIntegrationMessageProperty.cs
- BitmapCodecInfoInternal.cs
- RIPEMD160.cs
- WebPartTransformer.cs
- BlobPersonalizationState.cs
- SamlAttribute.cs
- TextDecorationCollection.cs
- AsynchronousChannel.cs
- ValueTypePropertyReference.cs
- TextTreeText.cs
- SqlDependencyListener.cs
- SqlClientMetaDataCollectionNames.cs
- MenuItem.cs
- ObjectHelper.cs
- Trace.cs
- PersonalizationStateInfoCollection.cs
- MessageSecurityOverTcp.cs
- RootBrowserWindow.cs
- ColumnWidthChangedEvent.cs
- HtmlTextArea.cs
- ReadOnlyDictionary.cs
- Animatable.cs
- RIPEMD160.cs
- MailMessage.cs
- DataGridViewCellCollection.cs
- unitconverter.cs
- WindowsAltTab.cs
- PointUtil.cs
- CfgParser.cs
- TypeConverterHelper.cs
- HelpProvider.cs
- ExpressionQuoter.cs
- EntityDataReader.cs