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
- Rect3D.cs
- DesignerDataTable.cs
- Style.cs
- DataPagerFieldItem.cs
- DataObjectFieldAttribute.cs
- DbXmlEnabledProviderManifest.cs
- EntityModelBuildProvider.cs
- XsltInput.cs
- WrapperSecurityCommunicationObject.cs
- ActivityTypeResolver.xaml.cs
- ImageAnimator.cs
- TransportSecurityBindingElement.cs
- BuildProvider.cs
- PropertyExpression.cs
- QuaternionAnimation.cs
- RsaSecurityTokenAuthenticator.cs
- EntityFrameworkVersions.cs
- SessionPageStateSection.cs
- InputLanguageEventArgs.cs
- GridViewUpdatedEventArgs.cs
- RectangleHotSpot.cs
- CheckBoxList.cs
- ContextProperty.cs
- ContentType.cs
- SqlAliaser.cs
- MessageDispatch.cs
- SetIterators.cs
- ReadOnlyPropertyMetadata.cs
- TemplatedMailWebEventProvider.cs
- DataGrid.cs
- FieldAccessException.cs
- DecimalFormatter.cs
- StdValidatorsAndConverters.cs
- ResolvedKeyFrameEntry.cs
- DocComment.cs
- EventLogConfiguration.cs
- ContentType.cs
- AutomationEventArgs.cs
- ActivityStatusChangeEventArgs.cs
- QueryCursorEventArgs.cs
- CngKey.cs
- PerspectiveCamera.cs
- ProcessHostMapPath.cs
- SessionConnectionReader.cs
- BooleanSwitch.cs
- TypedOperationInfo.cs
- AccessKeyManager.cs
- WebPartVerbsEventArgs.cs
- SimpleFileLog.cs
- odbcmetadatacollectionnames.cs
- StorageEntityTypeMapping.cs
- DeclarativeConditionsCollection.cs
- URLBuilder.cs
- ChannelManager.cs
- CopyOnWriteList.cs
- BroadcastEventHelper.cs
- SafeProcessHandle.cs
- RuntimeIdentifierPropertyAttribute.cs
- Propagator.Evaluator.cs
- Rights.cs
- WebBrowserContainer.cs
- HtmlShimManager.cs
- AuthenticateEventArgs.cs
- TableCell.cs
- SqlProviderUtilities.cs
- CorrelationKeyCalculator.cs
- MetadataCollection.cs
- SendMailErrorEventArgs.cs
- CurrentChangingEventManager.cs
- SecurityRuntime.cs
- CryptoStream.cs
- GridViewEditEventArgs.cs
- Latin1Encoding.cs
- HScrollBar.cs
- PromptBuilder.cs
- MediaPlayer.cs
- ResourceReader.cs
- CssTextWriter.cs
- SiteMembershipCondition.cs
- FocusTracker.cs
- XmlSchemaRedefine.cs
- MachineKeyConverter.cs
- ObjectKeyFrameCollection.cs
- PersonalizablePropertyEntry.cs
- WebMessageEncodingElement.cs
- OdbcCommand.cs
- TraceSwitch.cs
- SerializationException.cs
- GridViewCellAutomationPeer.cs
- XmlSchemaImporter.cs
- ApplicationInfo.cs
- DeploymentExceptionMapper.cs
- CapabilitiesUse.cs
- KnownTypeAttribute.cs
- VBIdentifierNameEditor.cs
- HttpListener.cs
- CheckPair.cs
- StringValidator.cs
- MatcherBuilder.cs
- StrongNameUtility.cs