Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Discovery / DynamicPhysicalDiscoSearcher.cs / 1305376 / DynamicPhysicalDiscoSearcher.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Discovery { using System; using System.IO; using System.Collections; using System.Web; using System.Web.Caching; using System.Diagnostics; using System.Text; using System.DirectoryServices; using System.Web.Services.Configuration; using System.ComponentModel; ////// /// Does a recursive search of virtual subdirectories to find stuff to /// make a disco file from. *.disco files (or whatever the PrimarySearchPattern is) are /// treated as end-points - recursion stops where they are found. /// internal class DynamicPhysicalDiscoSearcher : DynamicDiscoSearcher { private string startDir; internal DynamicPhysicalDiscoSearcher(string searchDir, string[] excludedUrls, string startUrl) : base(excludedUrls) { startDir = searchDir; origUrl = startUrl; } // ------------------------------------------------------------------------------- internal override void Search(string fileToSkipAtBegin) { SearchInit(fileToSkipAtBegin); ScanDirectory( startDir ); } // ------------------------------------------------------------------------------- // Look in iven directory for subdirectories, feasable for further searching. protected override void SearchSubDirectories(string localDir) { DirectoryInfo dir = new DirectoryInfo(localDir); if (!dir.Exists) return; DirectoryInfo[] subDirs = dir.GetDirectories(); foreach (DirectoryInfo subDir in subDirs) { if (subDir.Name == "." || subDir.Name == ".." ) { continue; } ScanDirectory( localDir + '\\' + subDir.Name ); } } // -------------------------------------------------------------------------------- protected override DirectoryInfo GetPhysicalDir(string dir ) { if ( !Directory.Exists(dir) ) return null; DirectoryInfo directory = new DirectoryInfo(dir); if ( !directory.Exists ) return null; if( 0 != (directory.Attributes & (FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary))) { return null; } return directory; } // ------------------------------------------------------------------------------- // Makes result URL found file path from diectory name and short file name. protected override string MakeResultPath(string dirName, string fileName) { string res = origUrl + dirName.Substring(startDir.Length, dirName.Length - startDir.Length).Replace('\\','/') + '/' + fileName; return res; } // -------------------------------------------------------------------------------- // Makes exclusion path absolute for quick comparision on search. protected override string MakeAbsExcludedPath(string pathRelativ) { return startDir + '\\' + pathRelativ.Replace('/', '\\' ); } // -------------------------------------------------------------------------------- protected override bool IsVirtualSearch { get { return false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Discovery { using System; using System.IO; using System.Collections; using System.Web; using System.Web.Caching; using System.Diagnostics; using System.Text; using System.DirectoryServices; using System.Web.Services.Configuration; using System.ComponentModel; ////// /// Does a recursive search of virtual subdirectories to find stuff to /// make a disco file from. *.disco files (or whatever the PrimarySearchPattern is) are /// treated as end-points - recursion stops where they are found. /// internal class DynamicPhysicalDiscoSearcher : DynamicDiscoSearcher { private string startDir; internal DynamicPhysicalDiscoSearcher(string searchDir, string[] excludedUrls, string startUrl) : base(excludedUrls) { startDir = searchDir; origUrl = startUrl; } // ------------------------------------------------------------------------------- internal override void Search(string fileToSkipAtBegin) { SearchInit(fileToSkipAtBegin); ScanDirectory( startDir ); } // ------------------------------------------------------------------------------- // Look in iven directory for subdirectories, feasable for further searching. protected override void SearchSubDirectories(string localDir) { DirectoryInfo dir = new DirectoryInfo(localDir); if (!dir.Exists) return; DirectoryInfo[] subDirs = dir.GetDirectories(); foreach (DirectoryInfo subDir in subDirs) { if (subDir.Name == "." || subDir.Name == ".." ) { continue; } ScanDirectory( localDir + '\\' + subDir.Name ); } } // -------------------------------------------------------------------------------- protected override DirectoryInfo GetPhysicalDir(string dir ) { if ( !Directory.Exists(dir) ) return null; DirectoryInfo directory = new DirectoryInfo(dir); if ( !directory.Exists ) return null; if( 0 != (directory.Attributes & (FileAttributes.Hidden | FileAttributes.System | FileAttributes.Temporary))) { return null; } return directory; } // ------------------------------------------------------------------------------- // Makes result URL found file path from diectory name and short file name. protected override string MakeResultPath(string dirName, string fileName) { string res = origUrl + dirName.Substring(startDir.Length, dirName.Length - startDir.Length).Replace('\\','/') + '/' + fileName; return res; } // -------------------------------------------------------------------------------- // Makes exclusion path absolute for quick comparision on search. protected override string MakeAbsExcludedPath(string pathRelativ) { return startDir + '\\' + pathRelativ.Replace('/', '\\' ); } // -------------------------------------------------------------------------------- protected override bool IsVirtualSearch { get { return false; } } } } // 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
- CannotUnloadAppDomainException.cs
- FilterEventArgs.cs
- BuildResultCache.cs
- TraceContextEventArgs.cs
- ZipIOBlockManager.cs
- XmlNodeReader.cs
- SafeNativeMethods.cs
- AssemblyBuilder.cs
- DmlSqlGenerator.cs
- DataControlButton.cs
- TraceContextRecord.cs
- OleDbDataAdapter.cs
- TrackBar.cs
- NamespaceDisplay.xaml.cs
- SectionVisual.cs
- TransactionValidationBehavior.cs
- SizeAnimationClockResource.cs
- SHA1.cs
- UserControl.cs
- ChannelBase.cs
- TextEditorSelection.cs
- SoapRpcServiceAttribute.cs
- EdmConstants.cs
- PackWebResponse.cs
- TdsParserStateObject.cs
- DispatcherTimer.cs
- X509Certificate2Collection.cs
- RoleManagerSection.cs
- SqlUserDefinedAggregateAttribute.cs
- DataGridViewComboBoxCell.cs
- DesignOnlyAttribute.cs
- ChannelServices.cs
- OleDbTransaction.cs
- ParameterCollection.cs
- DesignOnlyAttribute.cs
- XmlCodeExporter.cs
- FixedSOMPageConstructor.cs
- ListViewAutomationPeer.cs
- Array.cs
- DataAccessor.cs
- HttpRequestCacheValidator.cs
- RegistrationServices.cs
- XhtmlBasicValidationSummaryAdapter.cs
- TableLayoutRowStyleCollection.cs
- ReadOnlyPermissionSet.cs
- TreePrinter.cs
- Property.cs
- KeyPressEvent.cs
- UnsafeNativeMethods.cs
- DictionaryKeyPropertyAttribute.cs
- ModelVisual3D.cs
- MethodSet.cs
- TraversalRequest.cs
- NumericUpDownAcceleration.cs
- SystemResourceKey.cs
- ListViewDeletedEventArgs.cs
- ScopeCollection.cs
- Panel.cs
- TextServicesDisplayAttributePropertyRanges.cs
- FileNotFoundException.cs
- ResourceCategoryAttribute.cs
- ClientConfigurationSystem.cs
- PropertyChangeTracker.cs
- DetailsViewPageEventArgs.cs
- TableCell.cs
- ServiceEndpointElement.cs
- DocumentApplicationState.cs
- Selector.cs
- StateBag.cs
- ProtocolsConfigurationHandler.cs
- ArcSegment.cs
- XmlElementAttribute.cs
- CodeGenerator.cs
- DictionaryEntry.cs
- ButtonFlatAdapter.cs
- Region.cs
- RtfToXamlReader.cs
- FixedTextContainer.cs
- InputMethodStateTypeInfo.cs
- UrlMappingCollection.cs
- SafeNativeMethods.cs
- ImageCodecInfo.cs
- GcSettings.cs
- DataControlImageButton.cs
- LinqDataSourceValidationException.cs
- Mutex.cs
- HttpSessionStateWrapper.cs
- AuthenticationSection.cs
- PreservationFileWriter.cs
- Query.cs
- DynamicValidatorEventArgs.cs
- UIElement3DAutomationPeer.cs
- RawStylusInputReport.cs
- Wizard.cs
- MetadataCacheItem.cs
- AttributeCallbackBuilder.cs
- ShapingWorkspace.cs
- NotifyInputEventArgs.cs
- DeviceSpecificChoice.cs
- XmlExceptionHelper.cs