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
- MemberBinding.cs
- DispatcherSynchronizationContext.cs
- BoundPropertyEntry.cs
- WorkflowControlEndpoint.cs
- Number.cs
- EncoderReplacementFallback.cs
- ComboBox.cs
- FontWeights.cs
- DataSourceXmlTextReader.cs
- OleDbException.cs
- TableParagraph.cs
- AuthenticateEventArgs.cs
- DefaultMergeHelper.cs
- XPathParser.cs
- ZipArchive.cs
- CryptoHelper.cs
- EncodingFallbackAwareXmlTextWriter.cs
- ToolBar.cs
- PropertyEmitter.cs
- InstalledFontCollection.cs
- ArgumentNullException.cs
- TouchFrameEventArgs.cs
- FixedSOMGroup.cs
- RealProxy.cs
- DictionaryBase.cs
- SystemIdentity.cs
- _CacheStreams.cs
- GenericAuthenticationEventArgs.cs
- QuaternionConverter.cs
- DoubleConverter.cs
- GroupBox.cs
- adornercollection.cs
- PerformanceCounterCategory.cs
- ReaderWriterLock.cs
- KnownAssemblyEntry.cs
- TraceEventCache.cs
- GenericPrincipal.cs
- TemplatePagerField.cs
- XamlRtfConverter.cs
- PropertyEmitterBase.cs
- CodeDomConfigurationHandler.cs
- Color.cs
- SequenceFullException.cs
- WebPartDisplayModeEventArgs.cs
- CommonDialog.cs
- CacheModeValueSerializer.cs
- SchemaMapping.cs
- ResolveDuplexAsyncResult.cs
- HttpUnhandledOperationInvoker.cs
- EventLogPermissionAttribute.cs
- SystemPens.cs
- LocalValueEnumerator.cs
- LoadWorkflowCommand.cs
- DesignerMetadata.cs
- DataViewSetting.cs
- SplitterEvent.cs
- SkipQueryOptionExpression.cs
- Compiler.cs
- WebPartDeleteVerb.cs
- ShaderRenderModeValidation.cs
- XmlStringTable.cs
- KeyBinding.cs
- WindowInteractionStateTracker.cs
- ModulesEntry.cs
- TypefaceCollection.cs
- BitVector32.cs
- XmlQueryRuntime.cs
- XmlRawWriterWrapper.cs
- TraceFilter.cs
- EntityStoreSchemaGenerator.cs
- FacetEnabledSchemaElement.cs
- ProviderSettings.cs
- XomlCompilerError.cs
- TreeViewItem.cs
- DefaultSettingsSection.cs
- ReflectionTypeLoadException.cs
- ToolStripContentPanelRenderEventArgs.cs
- UnaryNode.cs
- ToolStripDropDownClosingEventArgs.cs
- SchemaUtility.cs
- ThreadStaticAttribute.cs
- DurableTimerExtension.cs
- NTAccount.cs
- CommandField.cs
- FacetDescription.cs
- RequestCachePolicyConverter.cs
- WorkflowHostingEndpoint.cs
- StoreUtilities.cs
- TextPointer.cs
- SplayTreeNode.cs
- TranslateTransform.cs
- UnaryNode.cs
- SecurityContext.cs
- ColumnWidthChangedEvent.cs
- DesignTimeParseData.cs
- LayoutEvent.cs
- TripleDES.cs
- CorrelationQueryBehavior.cs
- XmlReflectionMember.cs
- _ScatterGatherBuffers.cs