dataSvcMapFileLoader.cs source code in C# .NET

Source code for the .NET framework in C#

                        

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 / Compilation / WCFModel / dataSvcMapFileLoader.cs / 1 / dataSvcMapFileLoader.cs

                            //------------------------------------------------------------------------------ 
// 
//    Copyright (C) Microsoft Corporation. All Rights Reserved.
// 
//----------------------------------------------------------------------------- 
//
// Note: Unlike most files in this directory, the code in this file is *not* 
//   shared with wizard\vsdesigner\designer\microsoft\vsdesigner\WCFModel. 
//
//  The code under ndp\fx\src\xsp\System\Web\Extensions\Compilation\XmlSerializer might have to be regerenated when 
//   the format of the svcmap file is changed, or class structure has been changed in this directory. Please follow the HowTo file
//   under Compilation directory to see how to regerenate that code.
//
 
using System;
using System.Collections.Generic; 
using System.Text; 
#if WEB_EXTENSIONS_CODE
using System.Web.Resources; 
#else
using Microsoft.VSDesigner.Resources.Microsoft.VSDesigner;
#endif
 
namespace System.Web.Compilation.WCFModel
{ 
    internal class DataSvcMapFileLoader : AbstractDataSvcMapFileLoader 
    {
        private string mapFilePath; 

        public DataSvcMapFileLoader(string mapFilePath)
        {
            this.mapFilePath = mapFilePath; 
        }
 
        ///  
        /// Given a name of a metadata file, returns the full expected path to the file.
        ///  
        /// 
        /// 
        private string GetMetadataFileFullPath(string name)
        { 
            // Should be in the same directory as the .svcmap file.
            return IO.Path.Combine(IO.Path.GetDirectoryName(mapFilePath), name); 
        } 

        ///  
        /// Get a TextReader for the .svcmap file
        /// 
        /// 
        protected override System.IO.TextReader GetMapFileReader() 
        {
            return IO.File.OpenText(mapFilePath); 
        } 

        ///  
        /// Read the contents of the given metadata file
        /// 
        /// The filename (without path) of the metadata file.
        ///  
        protected override byte[] ReadMetadataFile(string name)
        { 
            return IO.File.ReadAllBytes(GetMetadataFileFullPath(name)); 
        }
 
        /// 
        /// Get access to a byte array that contain the contents of the given extension
        /// file
        ///  
        /// 
        /// Name of the extension file. Could be a path relative to the svcmap file location 
        /// or the name of an item in a metadata storage. 
        /// 
        ///  
        protected override byte[] ReadExtensionFile(string name)
        {
            return IO.File.ReadAllBytes(GetMetadataFileFullPath(name));
        } 

        ///  
        /// Demand-create an XmlSerializer for the SvcMap file... 
        /// 
        protected override System.Xml.Serialization.XmlSerializer Serializer 
        {
            get
            {
                if (serializer == null) 
                {
                    // We have our own pre-generated XML serializer for the .datasvcmap file. 
                    serializer = new System.Web.Compilation.XmlSerializerDataSvc.DataSvcMapFileSerializer(); 
                }
                return serializer; 
            }
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------ 
// 
//    Copyright (C) Microsoft Corporation. All Rights Reserved.
// 
//----------------------------------------------------------------------------- 
//
// Note: Unlike most files in this directory, the code in this file is *not* 
//   shared with wizard\vsdesigner\designer\microsoft\vsdesigner\WCFModel. 
//
//  The code under ndp\fx\src\xsp\System\Web\Extensions\Compilation\XmlSerializer might have to be regerenated when 
//   the format of the svcmap file is changed, or class structure has been changed in this directory. Please follow the HowTo file
//   under Compilation directory to see how to regerenate that code.
//
 
using System;
using System.Collections.Generic; 
using System.Text; 
#if WEB_EXTENSIONS_CODE
using System.Web.Resources; 
#else
using Microsoft.VSDesigner.Resources.Microsoft.VSDesigner;
#endif
 
namespace System.Web.Compilation.WCFModel
{ 
    internal class DataSvcMapFileLoader : AbstractDataSvcMapFileLoader 
    {
        private string mapFilePath; 

        public DataSvcMapFileLoader(string mapFilePath)
        {
            this.mapFilePath = mapFilePath; 
        }
 
        ///  
        /// Given a name of a metadata file, returns the full expected path to the file.
        ///  
        /// 
        /// 
        private string GetMetadataFileFullPath(string name)
        { 
            // Should be in the same directory as the .svcmap file.
            return IO.Path.Combine(IO.Path.GetDirectoryName(mapFilePath), name); 
        } 

        ///  
        /// Get a TextReader for the .svcmap file
        /// 
        /// 
        protected override System.IO.TextReader GetMapFileReader() 
        {
            return IO.File.OpenText(mapFilePath); 
        } 

        ///  
        /// Read the contents of the given metadata file
        /// 
        /// The filename (without path) of the metadata file.
        ///  
        protected override byte[] ReadMetadataFile(string name)
        { 
            return IO.File.ReadAllBytes(GetMetadataFileFullPath(name)); 
        }
 
        /// 
        /// Get access to a byte array that contain the contents of the given extension
        /// file
        ///  
        /// 
        /// Name of the extension file. Could be a path relative to the svcmap file location 
        /// or the name of an item in a metadata storage. 
        /// 
        ///  
        protected override byte[] ReadExtensionFile(string name)
        {
            return IO.File.ReadAllBytes(GetMetadataFileFullPath(name));
        } 

        ///  
        /// Demand-create an XmlSerializer for the SvcMap file... 
        /// 
        protected override System.Xml.Serialization.XmlSerializer Serializer 
        {
            get
            {
                if (serializer == null) 
                {
                    // We have our own pre-generated XML serializer for the .datasvcmap file. 
                    serializer = new System.Web.Compilation.XmlSerializerDataSvc.DataSvcMapFileSerializer(); 
                }
                return serializer; 
            }
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK