Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / ClientServices / ConnectivityStatus.cs / 1305376 / 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
- DetailsViewUpdateEventArgs.cs
- WebPartDisplayModeCancelEventArgs.cs
- TreeViewDesigner.cs
- DecimalStorage.cs
- Window.cs
- ImageAttributes.cs
- OracleRowUpdatedEventArgs.cs
- PolicyStatement.cs
- TempEnvironment.cs
- ReadOnlyObservableCollection.cs
- EmptyCollection.cs
- IdentityManager.cs
- CustomPopupPlacement.cs
- DelegateTypeInfo.cs
- PropertyInfoSet.cs
- NativeMethods.cs
- CommandBindingCollection.cs
- Vector3DKeyFrameCollection.cs
- TypeSystemHelpers.cs
- ConfigurationManagerInternalFactory.cs
- ResourcePermissionBase.cs
- ResourcesChangeInfo.cs
- CodeDomSerializerBase.cs
- SymmetricSecurityBindingElement.cs
- HostAdapter.cs
- XmlStreamedByteStreamReader.cs
- DependencyObjectProvider.cs
- DocumentPageViewAutomationPeer.cs
- DesignTimeVisibleAttribute.cs
- ClientUtils.cs
- BamlRecordReader.cs
- CaseStatement.cs
- ScrollPatternIdentifiers.cs
- CultureInfoConverter.cs
- HtmlInputButton.cs
- PropVariant.cs
- FragmentQueryKB.cs
- SupportingTokenAuthenticatorSpecification.cs
- XhtmlBasicTextViewAdapter.cs
- PropertyReferenceSerializer.cs
- HierarchicalDataTemplate.cs
- EtwTrace.cs
- EventEntry.cs
- EpmTargetTree.cs
- ManualResetEvent.cs
- PersonalizationAdministration.cs
- CryptoHelper.cs
- WindowsListViewGroup.cs
- SuppressMergeCheckAttribute.cs
- DatagridviewDisplayedBandsData.cs
- AttachedPropertyMethodSelector.cs
- DynamicUpdateCommand.cs
- Rectangle.cs
- GridViewCommandEventArgs.cs
- GridEntry.cs
- DataView.cs
- GiveFeedbackEvent.cs
- ArraySubsetEnumerator.cs
- AdCreatedEventArgs.cs
- XmlSignatureManifest.cs
- HyperLinkDesigner.cs
- InstanceNotReadyException.cs
- Point3DConverter.cs
- XmlSchemaAnnotated.cs
- MethodImplAttribute.cs
- Deflater.cs
- NativeMethods.cs
- CollectionTraceRecord.cs
- Message.cs
- CursorInteropHelper.cs
- TypeDelegator.cs
- ProviderConnectionPoint.cs
- DataGridCellClipboardEventArgs.cs
- ReadingWritingEntityEventArgs.cs
- MetafileHeaderWmf.cs
- BamlResourceSerializer.cs
- BrowserCapabilitiesCompiler.cs
- XpsResourcePolicy.cs
- RootBuilder.cs
- _AutoWebProxyScriptHelper.cs
- HtmlTableRowCollection.cs
- Parser.cs
- QueryContinueDragEvent.cs
- ProjectionPruner.cs
- UpdatePanel.cs
- PassportIdentity.cs
- SelectionRange.cs
- ISAPIRuntime.cs
- TextTreeUndo.cs
- RectangleGeometry.cs
- Char.cs
- RuntimeEnvironment.cs
- SpellerInterop.cs
- PaintValueEventArgs.cs
- DbXmlEnabledProviderManifest.cs
- ToolStripSystemRenderer.cs
- SpeakCompletedEventArgs.cs
- HttpListenerException.cs
- TypeTypeConverter.cs
- DataRecordObjectView.cs