Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / xsp / System / Web / Extensions / ClientServices / ConnectivityStatus.cs / 1 / ConnectivityStatus.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.ClientServices { using System; using System.IO; using System.Security.Principal; using System.Security; using System.Security.Permissions; using System.Security.AccessControl; public static class ConnectivityStatus { public static bool IsOffline { get { if (!_IsOfflineFetched) FetchIsOffline(); return _IsOffline; } set { if (IsOffline != value) { _IsOffline = value; StoreIsOffline(); } } } private static bool _IsOffline; private static bool _IsOfflineFetched; //[PermissionSet(SecurityAction.Assert, Unrestricted = true)] private static void FetchIsOffline() { string path = Path.Combine(System.Windows.Forms.Application.UserAppDataPath, "AppIsOffline"); _IsOffline = File.Exists(path); _IsOfflineFetched = true; } //[PermissionSet(SecurityAction.Assert, Unrestricted = true)] private static void StoreIsOffline() { string path = Path.Combine(System.Windows.Forms.Application.UserAppDataPath, "AppIsOffline"); if (!_IsOffline) { File.Delete(path); } else { using (FileStream fs = File.Create(path)) { fs.Write(new byte[0], 0, 0); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.ClientServices { using System; using System.IO; using System.Security.Principal; using System.Security; using System.Security.Permissions; using System.Security.AccessControl; public static class ConnectivityStatus { public static bool IsOffline { get { if (!_IsOfflineFetched) FetchIsOffline(); return _IsOffline; } set { if (IsOffline != value) { _IsOffline = value; StoreIsOffline(); } } } private static bool _IsOffline; private static bool _IsOfflineFetched; //[PermissionSet(SecurityAction.Assert, Unrestricted = true)] private static void FetchIsOffline() { string path = Path.Combine(System.Windows.Forms.Application.UserAppDataPath, "AppIsOffline"); _IsOffline = File.Exists(path); _IsOfflineFetched = true; } //[PermissionSet(SecurityAction.Assert, Unrestricted = true)] private static void StoreIsOffline() { string path = Path.Combine(System.Windows.Forms.Application.UserAppDataPath, "AppIsOffline"); if (!_IsOffline) { File.Delete(path); } else { using (FileStream fs = File.Create(path)) { fs.Write(new byte[0], 0, 0); } } } } } // 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
- PropagatorResult.cs
- ProxyManager.cs
- VariableQuery.cs
- ContentValidator.cs
- SessionParameter.cs
- AnnotationObservableCollection.cs
- DateTimeParse.cs
- PreviewKeyDownEventArgs.cs
- ProfileParameter.cs
- ToolStripDropDownItemDesigner.cs
- StylusPoint.cs
- MemberAssignmentAnalysis.cs
- EarlyBoundInfo.cs
- LinkArea.cs
- TreeNodeEventArgs.cs
- coordinatorfactory.cs
- AsymmetricAlgorithm.cs
- SafeHandles.cs
- IncrementalCompileAnalyzer.cs
- PresentationAppDomainManager.cs
- EntityViewContainer.cs
- util.cs
- TrustSection.cs
- StreamUpdate.cs
- LinkLabelLinkClickedEvent.cs
- WindowInteropHelper.cs
- DateTimeStorage.cs
- XPathAxisIterator.cs
- CalendarAutoFormatDialog.cs
- XsdDateTime.cs
- ContractValidationHelper.cs
- OracleRowUpdatingEventArgs.cs
- XmlSchemaAnnotation.cs
- IFlowDocumentViewer.cs
- WebPartConnectVerb.cs
- OleDbConnection.cs
- dsa.cs
- SecondaryViewProvider.cs
- NamedPermissionSet.cs
- DataTransferEventArgs.cs
- LocalizedNameDescriptionPair.cs
- ThreadExceptionDialog.cs
- DynamicResourceExtension.cs
- TemplatedWizardStep.cs
- DataGridCell.cs
- BaseDataBoundControl.cs
- EntityChangedParams.cs
- UIntPtr.cs
- TextRangeBase.cs
- DoubleCollectionConverter.cs
- InputQueueChannelAcceptor.cs
- ToolboxItem.cs
- WSDualHttpSecurityElement.cs
- XPathItem.cs
- SimpleApplicationHost.cs
- WebControl.cs
- TypeValidationEventArgs.cs
- NeutralResourcesLanguageAttribute.cs
- XmlWriter.cs
- XamlStream.cs
- SchemaName.cs
- DynamicValidatorEventArgs.cs
- WebEventTraceProvider.cs
- TabletDevice.cs
- AppSettingsSection.cs
- IdentityReference.cs
- Events.cs
- OdbcHandle.cs
- Rect.cs
- InvalidAsynchronousStateException.cs
- InvalidComObjectException.cs
- HTMLTextWriter.cs
- KeyFrames.cs
- SiteMapProvider.cs
- XamlVector3DCollectionSerializer.cs
- Int32Animation.cs
- HtmlFormWrapper.cs
- RuntimeConfigurationRecord.cs
- SelectingProviderEventArgs.cs
- MDIControlStrip.cs
- ServerIdentity.cs
- HttpModule.cs
- EmptyQuery.cs
- XmlQueryCardinality.cs
- WaitForChangedResult.cs
- CodeSubDirectoriesCollection.cs
- base64Transforms.cs
- PlatformCulture.cs
- SqlRowUpdatingEvent.cs
- SqlMetaData.cs
- Style.cs
- EndPoint.cs
- DataServiceRequestException.cs
- WindowsStatic.cs
- CategoryNameCollection.cs
- ZoneButton.cs
- WebPartsSection.cs
- SmtpReplyReaderFactory.cs
- XmlMtomReader.cs
- SoapAttributes.cs