Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- ObjectHandle.cs
- DeflateStream.cs
- Input.cs
- XmlSchemaSubstitutionGroup.cs
- ProjectionAnalyzer.cs
- StreamWriter.cs
- ColumnResizeAdorner.cs
- TextFindEngine.cs
- __FastResourceComparer.cs
- TypefaceCollection.cs
- Int16Converter.cs
- ZipIOLocalFileBlock.cs
- WindowsButton.cs
- AssociativeAggregationOperator.cs
- COMException.cs
- LowerCaseStringConverter.cs
- ThrowHelper.cs
- NavigationCommands.cs
- WindowsFont.cs
- ViewStateChangedEventArgs.cs
- TextParagraphCache.cs
- SqlOuterApplyReducer.cs
- Imaging.cs
- SettingsSection.cs
- ArrayElementGridEntry.cs
- MsmqOutputSessionChannel.cs
- SimpleTextLine.cs
- FixedFlowMap.cs
- RadialGradientBrush.cs
- RegexWriter.cs
- WinHttpWebProxyFinder.cs
- BaseTemplateParser.cs
- SqlTriggerAttribute.cs
- DataContractAttribute.cs
- CallContext.cs
- ObjectStateManager.cs
- DependencyPropertyKey.cs
- XmlDataProvider.cs
- ActivityExecutorOperation.cs
- ImmutableObjectAttribute.cs
- Utils.cs
- DataGridViewCellCollection.cs
- DataViewManagerListItemTypeDescriptor.cs
- ButtonFieldBase.cs
- ApplicationServiceHelper.cs
- WebPartExportVerb.cs
- ToolBar.cs
- PropertiesTab.cs
- WebScriptEnablingBehavior.cs
- DataTemplate.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ControlsConfig.cs
- HtmlInputFile.cs
- IsolatedStorageException.cs
- View.cs
- TreePrinter.cs
- Primitive.cs
- OracleColumn.cs
- RequestTimeoutManager.cs
- OleDbDataAdapter.cs
- XmlHierarchyData.cs
- Timer.cs
- MeasurementDCInfo.cs
- ListControlConvertEventArgs.cs
- BrushConverter.cs
- StreamGeometry.cs
- SmtpDateTime.cs
- TypeSource.cs
- WindowsToolbarItemAsMenuItem.cs
- _ConnectionGroup.cs
- DockProviderWrapper.cs
- BooleanConverter.cs
- ListViewAutomationPeer.cs
- EntityDataSourceChangingEventArgs.cs
- MarshalByRefObject.cs
- WorkflowTerminatedException.cs
- StatusStrip.cs
- Config.cs
- XNameTypeConverter.cs
- ToolStripArrowRenderEventArgs.cs
- FontSourceCollection.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DataTransferEventArgs.cs
- XamlInterfaces.cs
- EntityConnectionStringBuilder.cs
- InfoCardUIAgent.cs
- PingReply.cs
- GeneralTransform2DTo3DTo2D.cs
- BatchServiceHost.cs
- CommandLibraryHelper.cs
- DataBindingCollectionEditor.cs
- DirectoryInfo.cs
- FileLogRecord.cs
- HeaderCollection.cs
- WhitespaceRuleReader.cs
- BuildProviderAppliesToAttribute.cs
- QueueProcessor.cs
- IPPacketInformation.cs
- ExchangeUtilities.cs
- DataGridViewUtilities.cs