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
- SystemParameters.cs
- XPathAxisIterator.cs
- TransportReplyChannelAcceptor.cs
- dtdvalidator.cs
- BufferBuilder.cs
- DataGridTable.cs
- Int32Collection.cs
- XmlLangPropertyAttribute.cs
- WebPartRestoreVerb.cs
- SafeThemeHandle.cs
- XmlQuerySequence.cs
- HtmlElementEventArgs.cs
- ScrollChrome.cs
- VisualStyleTypesAndProperties.cs
- Pointer.cs
- SharedDp.cs
- SEHException.cs
- TableItemProviderWrapper.cs
- BaseCAMarshaler.cs
- ValidationErrorCollection.cs
- AvtEvent.cs
- ExternalException.cs
- MergablePropertyAttribute.cs
- PublisherMembershipCondition.cs
- SystemException.cs
- DeferredBinaryDeserializerExtension.cs
- CallbackBehaviorAttribute.cs
- SafeFileMapViewHandle.cs
- AtomicFile.cs
- DataPagerFieldCommandEventArgs.cs
- TransformGroup.cs
- ILGenerator.cs
- InvalidOleVariantTypeException.cs
- SectionUpdates.cs
- LineGeometry.cs
- PersistenceProvider.cs
- DesignerActionUIStateChangeEventArgs.cs
- ObjectViewQueryResultData.cs
- XmlChildNodes.cs
- DataSourceView.cs
- DragDropHelper.cs
- ListBox.cs
- ConfigXmlAttribute.cs
- DragEvent.cs
- FontConverter.cs
- ISAPIApplicationHost.cs
- ListQueryResults.cs
- DiagnosticsConfiguration.cs
- DefaultParameterValueAttribute.cs
- SettingsPropertyIsReadOnlyException.cs
- ReadOnlyHierarchicalDataSourceView.cs
- JsonCollectionDataContract.cs
- XmlTextAttribute.cs
- BrushMappingModeValidation.cs
- FolderLevelBuildProvider.cs
- XsdCachingReader.cs
- InstanceHandleReference.cs
- GridProviderWrapper.cs
- WindowsFormsSectionHandler.cs
- UnknownBitmapEncoder.cs
- DbConnectionPoolIdentity.cs
- CoreSwitches.cs
- SmtpSection.cs
- DropSource.cs
- ListenUriMode.cs
- CoTaskMemUnicodeSafeHandle.cs
- Transform3DGroup.cs
- DataGridParentRows.cs
- HttpChannelHelper.cs
- followingquery.cs
- AdvancedBindingEditor.cs
- TrackingProfileManager.cs
- KoreanLunisolarCalendar.cs
- SingleAnimationBase.cs
- PostBackOptions.cs
- WebBrowserSiteBase.cs
- MachineKeySection.cs
- LinkConverter.cs
- BitmapEffectDrawingContextWalker.cs
- ContractBase.cs
- _TLSstream.cs
- CharEnumerator.cs
- SoapCodeExporter.cs
- DataGridViewBindingCompleteEventArgs.cs
- FreezableOperations.cs
- XmlSchemaComplexContentRestriction.cs
- BaseCodeDomTreeGenerator.cs
- Token.cs
- CommonXSendMessage.cs
- CodeIdentifier.cs
- StrokeSerializer.cs
- SemaphoreSlim.cs
- PriorityQueue.cs
- XhtmlConformanceSection.cs
- XhtmlBasicLiteralTextAdapter.cs
- SourceSwitch.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- RowTypeElement.cs
- DataDocumentXPathNavigator.cs
- WindowsTitleBar.cs