Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- XmlToDatasetMap.cs
- StrokeIntersection.cs
- CommandHelper.cs
- LinqDataSourceUpdateEventArgs.cs
- VerificationAttribute.cs
- StylusSystemGestureEventArgs.cs
- WebSysDefaultValueAttribute.cs
- TraceLevelStore.cs
- DataGridViewUtilities.cs
- GridItemPattern.cs
- BuilderPropertyEntry.cs
- LocalClientSecuritySettings.cs
- NonBatchDirectoryCompiler.cs
- DataViewSettingCollection.cs
- WindowsStartMenu.cs
- MenuItemAutomationPeer.cs
- DataGridViewImageColumn.cs
- DeploymentSectionCache.cs
- PageAsyncTask.cs
- TransactionFormatter.cs
- DependentList.cs
- UnicastIPAddressInformationCollection.cs
- ObjectViewFactory.cs
- StdRegProviderWrapper.cs
- ReadOnlyDictionary.cs
- StylusPointPropertyInfoDefaults.cs
- CodeIdentifiers.cs
- TemplatePagerField.cs
- SafePointer.cs
- Int64.cs
- MasterPageParser.cs
- ToolStripLabel.cs
- TrackingWorkflowEventArgs.cs
- TransformerTypeCollection.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- SqlProviderManifest.cs
- Win32SafeHandles.cs
- TypeConverterMarkupExtension.cs
- Int32CAMarshaler.cs
- PerformanceCounterManager.cs
- DataRecordInternal.cs
- DataGridViewCellLinkedList.cs
- SocketPermission.cs
- SiteMapDataSource.cs
- ValueConversionAttribute.cs
- HwndProxyElementProvider.cs
- InstanceData.cs
- EvidenceTypeDescriptor.cs
- EntryPointNotFoundException.cs
- storepermissionattribute.cs
- UTF7Encoding.cs
- NativeRecognizer.cs
- WebBrowsableAttribute.cs
- EntityModelBuildProvider.cs
- SignedInfo.cs
- NumberSubstitution.cs
- DoubleAnimationUsingPath.cs
- WebEventTraceProvider.cs
- WindowsImpersonationContext.cs
- RangeValidator.cs
- DataGridViewButtonCell.cs
- XamlTypeMapperSchemaContext.cs
- SessionEndedEventArgs.cs
- DocumentGridContextMenu.cs
- MethodExecutor.cs
- EventWaitHandleSecurity.cs
- ArrayEditor.cs
- CustomWebEventKey.cs
- SecurityUtils.cs
- Token.cs
- SoapAttributeAttribute.cs
- InstancePersistenceCommandException.cs
- AmbientProperties.cs
- DataGridItemAutomationPeer.cs
- ConfigurationValue.cs
- StyleBamlTreeBuilder.cs
- ExeConfigurationFileMap.cs
- Canvas.cs
- ModelItemExtensions.cs
- ServicePointManagerElement.cs
- CompositeActivityTypeDescriptor.cs
- InheritedPropertyChangedEventArgs.cs
- SqlBuffer.cs
- X509Utils.cs
- XPathEmptyIterator.cs
- Context.cs
- ArgumentNullException.cs
- XPathAncestorIterator.cs
- AppDomain.cs
- DataPager.cs
- SchemaEntity.cs
- DataGridDetailsPresenter.cs
- Function.cs
- WindowsTab.cs
- GetPageNumberCompletedEventArgs.cs
- UnmanagedMemoryStreamWrapper.cs
- GenericRootAutomationPeer.cs
- Panel.cs
- coordinatorscratchpad.cs
- PropertySet.cs