diff --git a/3177.pdf b/3177.pdf new file mode 100644 index 0000000..fe3b522 Binary files /dev/null and b/3177.pdf differ diff --git a/3178.pdf b/3178.pdf new file mode 100644 index 0000000..1d57503 Binary files /dev/null and b/3178.pdf differ diff --git a/3502.html b/3502.html new file mode 100644 index 0000000..ab53ab5 --- /dev/null +++ b/3502.html @@ -0,0 +1,146 @@ + + + + + + + + +Errata + + + + + + + +
+ +

 

+ +

Errata

+ +

Pro BizTalk 2006

+ +

1590596994

+ +

 

+ +

Note from author, George Dunphy:

+ +

 

+ +

“For requests related to the database disassembler +in chapter 5, please inform people that we had to remove the code for the +application due to an issue discovered after the book was released. I am +planning on updating the samples when the errata is +released in the coming months.”

+ +

 

+ +
+ + + + diff --git a/9781590596999.jpg b/9781590596999.jpg new file mode 100644 index 0000000..faf7c36 Binary files /dev/null and b/9781590596999.jpg differ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a44577f --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2007 George Dunphy and Ahmed Metwally + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..0376524 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Pro BizTalk 2006*](http://www.apress.com/9781590596999) by George Dunphy and Ahmed Metwally (Apress, 2007). + +![Cover image](9781590596999.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/Samples/Chapter02/AssemblyInfoManager/AssemblyManager.vb b/Samples/Chapter02/AssemblyInfoManager/AssemblyManager.vb new file mode 100644 index 0000000..05c1e84 --- /dev/null +++ b/Samples/Chapter02/AssemblyInfoManager/AssemblyManager.vb @@ -0,0 +1,12 @@ +Namespace ABC.FulFillment.Common + Public Class AssemblyInfoManager + Public Const Company As String = "ABC Company" + Public Const ProductName As String = "FulFillment Application" + Public Const Copyright As String = "Copyright (c) 2006 ABC Inc." + Public Const Trademark As String = "" + Public Const MajorVersion As String = "1" + Public Const MinorVersion As String = "01" + Public Const BuildNumber As String = "1" + Public Const RevisionNumber As String = "35" + End Class +End Namespace \ No newline at end of file diff --git a/Samples/Chapter04/Schema Instance Creater/SchemaInstanceGenerator.vb b/Samples/Chapter04/Schema Instance Creater/SchemaInstanceGenerator.vb new file mode 100644 index 0000000..3af458e --- /dev/null +++ b/Samples/Chapter04/Schema Instance Creater/SchemaInstanceGenerator.vb @@ -0,0 +1,112 @@ +Imports System +Imports System.Text +Imports System.IO +Imports System.Collections +Imports System.Xml +Imports System.Xml.Serialization +Imports System.Xml.Schema + +Imports Microsoft.BizTalk.ExplorerOM +Imports Microsoft.BizTalk.Deployment +Imports Microsoft.BizTalk.Component.Interop + + +Namespace ProBizTalk.Samples.PipelineComponents.Utilities + _ + Public Class SchemaRetriever + '/ + '/ contains a cache of all schemas in the catalog upon first use of Schemas property + '/ + Private Shared _schemas As SchemaCollection + '/ + '/ caches created DocumentSpec instances + '/ + Private Shared _docSpecCache As Hashtable + + + '/ + '/ initializes used static variables + '/ + Shared Sub New() + _docSpecCache = New Hashtable() + End Sub 'New + + + + + '/ + '/ provides access to all schemas within the catalog; initialized upon first use + '/ + + Public Shared ReadOnly Property Schemas() As SchemaCollection + Get + If _schemas Is Nothing Then + Dim cdb As New ConfigurationDatabase() + + Dim explorer As New BtsCatalogExplorer() + + ' assign the connection string, effectively connecting to the database + ' TODO: optimize this if used frequently to cache the connection + + If cdb.Database.Length = 0 Then + explorer.ConnectionString = "Integrated Security=SSPI; Persist Security Info=false; Server=(local); Database=BizTalkMgmtDb;" + Else + explorer.ConnectionString = cdb.ConnectionString + End If + _schemas = explorer.Schemas + End If + Return _schemas + End Get + End Property + + + '/ + '/ retrieves a requested and loads + '/ an example instance, which is returned. + '/ + '/ the schema to be instantiated + '/ a sample instance of the retrieved schema + Public Shared Function GetInstanceForSchema(ByVal schemaName As String) As System.IO.Stream + ' defines our return value. null is returned if we fail + Dim retVal As System.IO.Stream = Nothing + + ' retrieve the requested schema from the ExplorerOM model + Dim schema As Schema = Schemas(schemaName) ' + + ' if the local catalog contains the requested schema + If Not (schema Is Nothing) Then + Dim docSchema As DocumentSpec = Nothing + + If _docSpecCache.Contains(schema.AssemblyQualifiedName) Then + docSchema = _docSpecCache(schema.AssemblyQualifiedName) + End If + + Try + ' create a DocumentSpec from it to be able to create a correct instance + docSchema = New DocumentSpec(schemaName, schema.BtsAssembly.DisplayName) + _docSpecCache.Add(schema.AssemblyQualifiedName, docSchema) + Catch + End Try + Dim sb As New StringBuilder() + + ' if the DocumentSpec was correctly instantiated (i.e. the schema Assembly was found) + If Not (docSchema Is Nothing) Then + Dim writer As New StringWriter(sb) + Try + ' instantiate our return value + + + ' create and instance of the schema and load it into our XmlDocument instance + retVal = docSchema.CreateXmlInstance(writer) + Finally + writer.Dispose() + End Try + End If + End If + + ' return null if nothing was found or the instance otherwise + Return retVal + + End Function + End Class +End Namespace \ No newline at end of file diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.csproj b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.csproj new file mode 100644 index 0000000..6966245 --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.csproj @@ -0,0 +1,54 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + 77a3f1aa-2290-4433-a142-b7c24ac5040d + WinExe + Properties + BizTalkSuspendedMessageHandlerService + BizTalkSuspendedMessageHandlerService + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + Component + + + Service1.cs + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.suo b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.suo new file mode 100644 index 0000000..9b802f2 Binary files /dev/null and b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/BizTalkSuspendedMessageHandlerService.suo differ diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Program.cs b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Program.cs new file mode 100644 index 0000000..27640a0 --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Program.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.ServiceProcess; +using System.Text; + +namespace BizTalkSuspendedMessageHandlerService +{ + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main() + { + ServiceBase[] ServicesToRun; + + // More than one user Service may run within the same process. To add + // another service to this process, change the following line to + // create a second service object. For example, + // + // ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()}; + // + ServicesToRun = new ServiceBase[] { new Service1() }; + + ServiceBase.Run(ServicesToRun); + } + } +} \ No newline at end of file diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Properties/AssemblyInfo.cs b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..aca8ded --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BizTalkSuspendedMessageHandlerService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("TVidia")] +[assembly: AssemblyProduct("BizTalkSuspendedMessageHandlerService")] +[assembly: AssemblyCopyright("Copyright © TVidia 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("77a3f1aa-2290-4433-a142-b7c24ac5040d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Service1.Designer.cs b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Service1.Designer.cs new file mode 100644 index 0000000..2967008 --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/Service1.Designer.cs @@ -0,0 +1,37 @@ +namespace BizTalkSuspendedMessageHandlerService +{ + partial class Service1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/SuspendedMessageService.cs b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/SuspendedMessageService.cs new file mode 100644 index 0000000..255a597 --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/SuspendedMessageService.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.ServiceProcess; +using System.Text; +using System.Management; +using System.Xml; + + +namespace BizTalkSuspendedMessageHandlerService +{ + public partial class Service1: ServiceBase + { + public Service1() + { + InitializeComponent(); + } + + protected override void OnStart(string[] args) + { + // listen for messages +string scope = "root\\MicrosoftBizTalkServer"; +string wqlQuery = "Select * from MSBTS_ServiceInstanceSuspendedEvent"; +watcher = new ManagementEventWatcher(scope, wqlQuery); +watcher.EventArrived += new EventArrivedEventHandler(MyEventHandler); +watcher.Start(); + + } + +static public void MyEventHandler(object sender, EventArrivedEventArgs e) +{ +try +{ +// Read the TempDirectoryName from config file +string TempDirectoryName = ConfigurationSettings.AppSettings["SuspendedMessagesTempFileLocation"]; +// Read WaitingDirectoryName +// This folder is the location for the new XML document that this service +// creates based on context and message parts. +string WaitingDirectoryName = ConfigurationSettings.AppSettings["SuspendedMessagesFileLocation"]; +// If you want to add processing instruction for InfoPath +// this will get it +string pi = ConfigurationSettings.AppSettings["ProcessingInstruction"]; + +string waitingMessageFileName; +// xwriter for suspended message +XmlTextWriter xwriter; + +//Lookup MSBTS_ServiceInstanceSuspendedEvent in the BTS04 documentation for additional properties +string ErrorID = e.NewEvent["ErrorID"].ToString(); +string ErrorCategory = e.NewEvent["ErrorCategory"].ToString(); +string ErrorDescription = e.NewEvent["ErrorDescription"].ToString(); +string ServiceStatus = e.NewEvent["ServiceStatus"].ToString(); +string ServiceInstanceID = e.NewEvent["InstanceID"].ToString(); +EnumerationOptions enumOptions = new EnumerationOptions(); + +enumOptions.ReturnImmediately = false; + +ManagementObjectSearcher MessageInstancesInServiceInstance = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", + "Select * from MSBTS_MessageInstance where ServiceInstanceID='"+ ServiceInstanceID + "'",enumOptions); +//Enumerate through the result set +foreach(ManagementObject MessageInstance in MessageInstancesInServiceInstance.Get()) +{ + // The only way to get at the message body is to utilise the SaveToFile + // method on the BTS_MessageInstance WMI Class. + // This saves all of the message information to files. + // Each MessagePart making up a Message is saved in seperate files, typically you only + // get a Body, but we cater for Multi-Part messages to cover all scenarios + + // As well as the MessageParts a context file is created, we need to use this to + // extract the MessagePartID's and MessagePartName's out so we can then +// work out the filenames + // to open! + + // The context filename format is: + // _context.xml + + // And then the actual message information filename format is: + + // _[_].out + // MessagePartName is only required if the MessagePart has a name! + + // We need to build this filename up so we can load it up - no hacking here! + + // Save the files + MessageInstance.InvokeMethod("SaveToFile", new object[] {TempDirectoryName}); + + // Get the MessageInstanceID + string MessageInstanceID = MessageInstance["MessageInstanceID"].ToString(); + + // We now need to load the context file up to get the MessagePart information + string ContextFileName = +String.Format(@"{0}\{1}_context.xml",TempDirectoryName,MessageInstanceID); + + // Load the context file up + XmlDocument doc = new XmlDocument(); + doc.Load(ContextFileName); + + // pull out context properties that we are interested in + string ReceivedFileName = GetContextProperty(doc, "ReceivedFileName"); + string InboundTransportLocation = GetContextProperty(doc, "InboundTransportLocation"); + string InterchangeID = GetContextProperty(doc, "InterchangeID"); + string ReceivePortID = GetContextProperty(doc, "ReceivePortID"); + string ReceivePortName = GetContextProperty(doc, "ReceivePortName"); + + // Create an XmlWriter to store the data. +// This will get written to a file when complete. + waitingMessageFileName = +String.Format(@"{0}\{1}.xml",WaitingDirectoryName,MessageInstanceID); + xwriter = new XmlTextWriter(waitingMessageFileName, System.Text.Encoding.UTF8); + xwriter.Formatting = Formatting.Indented; + xwriter.WriteStartDocument(); + //Write the ProcessingInstruction node. + xwriter.WriteProcessingInstruction("mso-infoPathSolution", pi); + xwriter.WriteProcessingInstruction("mso-application", "progid=\"InfoPath.Document\""); + xwriter.WriteComment(string.Format("Created on {0}", DateTime.Now.ToString())); + //Write the context information + xwriter.WriteStartElement("ns0", "SuspendedMessage", +"http://Microsoft.BizTalk.SuspendQueue.SuspendedMessage"); + xwriter.WriteStartElement("Context"); + xwriter.WriteElementString("ReceivedFileName", ReceivedFileName); + xwriter.WriteElementString("InboundTransportLocation", InboundTransportLocation); + xwriter.WriteElementString("InterchangeID", InterchangeID); + xwriter.WriteElementString("ReceivePortID", ReceivePortID); + xwriter.WriteElementString("ReceivePortName", ReceivePortName); + xwriter.WriteEndElement(); // Context + // Start the Message Element + xwriter.WriteStartElement("Message"); + + // Use XPath to return all of the MessagePart(s) referenced in the context + // We can then load the file up to get the Message information + XmlNodeList MessageParts = doc.SelectNodes("/MessageInfo/PartInfo/MessagePart"); + foreach (XmlNode MessagePart in MessageParts) + { + // Pull the MessagePart info out that we need + string MessagePartID = MessagePart.Attributes["ID"].Value; + string MessagePartName = MessagePart.Attributes["Name"].Value; + string Contents; + string FileName; + // If we have a MessagePartName append this to the end of the filename + // It's optional so if we don't have it we don't worry about it + if (MessagePartName.Length > 0) + { + FileName = String.Format(@"{0}\{1}_{2}_{3}.out",TempDirectoryName,MessageInstanceID,MessagePartID,MessagePartName); + } + else + { + FileName = String.Format(@"{0}\{1}_{2}.out",TempDirectoryName,MessageInstanceID,MessagePartID); + } + + // Load the message, place it in canonical schema and then submit it. + // Create an instance of StreamReader to read from a file. + // The using statement also closes the StreamReader. + using (StreamReader sr = new StreamReader(FileName)) + { + // Read to end of file + Contents = sr.ReadToEnd(); + } + + // Write out Message part data + xwriter.WriteStartElement("MessagePart"); + xwriter.WriteElementString("MessagePartId", MessagePartID); + xwriter.WriteElementString("Name", MessagePartName); + xwriter.WriteStartElement("Contents"); + // Write out contets as CDATA. You may need a different strategy for this. + xwriter.WriteCData(Contents); + xwriter.WriteEndElement(); // Contents + xwriter.WriteEndElement(); // MessagePart + } + xwriter.WriteEndElement(); // Message + xwriter.WriteEndElement(); // SuspendedMessage + xwriter.Close(); +} +} +catch(Exception ex) +{ +throw ex; +} +} + +// helper function to pull out context properties given a property name +static private string GetContextProperty(XmlDocument doc, string propertyName) +{ +XmlNode MessageContext = doc.SelectSingleNode("/MessageInfo/ContextInfo/Property[@Name='" + propertyName + "']"); +if (MessageContext != null) +{ +if (MessageContext.Attributes["Value"] != null) +{ + return MessageContext.Attributes["Value"].Value; +} +else + return "Value no found"; +} +else +return "Property not found"; +} + + protected override void OnStop() + { + // TODO: Add code here to perform any tear-down necessary to stop your service. + } + } +} diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/app.config b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/app.config new file mode 100644 index 0000000..01b0c4d --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/app.config @@ -0,0 +1,15 @@ + + + + + + + diff --git a/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/bin/Debug/BizTalkSuspendedMessageHandlerService.vshost.exe b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/bin/Debug/BizTalkSuspendedMessageHandlerService.vshost.exe new file mode 100644 index 0000000..ce3f102 Binary files /dev/null and b/Samples/Chapter06/Editing Suspended Messages/BizTalkSuspendedMessageHandlerService/bin/Debug/BizTalkSuspendedMessageHandlerService.vshost.exe differ diff --git a/Samples/Chapter06/Editing Suspended Messages/Schemas/SuspendedMessage.xsd b/Samples/Chapter06/Editing Suspended Messages/Schemas/SuspendedMessage.xsd new file mode 100644 index 0000000..f2faba1 --- /dev/null +++ b/Samples/Chapter06/Editing Suspended Messages/Schemas/SuspendedMessage.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Editing Suspended Messages/SuspendedMessage.xsn b/Samples/Chapter06/Editing Suspended Messages/SuspendedMessage.xsn new file mode 100644 index 0000000..7f756dd Binary files /dev/null and b/Samples/Chapter06/Editing Suspended Messages/SuspendedMessage.xsn differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Keys/exc.snk b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Keys/exc.snk new file mode 100644 index 0000000..d48a75a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Keys/exc.snk differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj new file mode 100644 index 0000000..a001096 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj.user b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj.user new file mode 100644 index 0000000..071e719 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/BootCamp.Orchestration.Exception.FaultHandler.btproj.user @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIGenericHandler.odx b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIGenericHandler.odx new file mode 100644 index 0000000..6013d58 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIGenericHandler.odx @@ -0,0 +1,180 @@ +#if __DESIGNER_DATA +#error Do not define __DESIGNER_DATA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __DESIGNER_DATA +[Microsoft.XLANGs.BaseTypes.BPELExportable(false)] +module BootCamp.Orchestration.Exception.FaultHandler +{ + internal porttype MessagePostType + { + oneway PostTmpMsg + { + System.Xml.XmlDocument + }; + }; + [Microsoft.XLANGs.BaseTypes.BPELExportable(false)] + internal service EAIGenericHandler + { + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port implements FaultProcessType FaultProcess; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses MessagePostType MessagePost; + message FaultMessageType FaultMsg; + message System.Xml.XmlDocument TmpMsg; + Msft.Samples.BizTalk.Exception.MessageCollection msgs; + body () + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("58d0fe6f-69e9-4507-9d33-8c30573ba51d")] + activate ((Msft.Samples.BizTalk.Exception.Schemas.FaultCode == "1001"))receive (FaultProcess.SubmitFault, FaultMsg); + msgs = new Msft.Samples.BizTalk.Exception.MessageCollection(); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("d55c95ce-d175-45a6-9171-83f74277f103")] + msgs = Msft.Samples.BizTalk.Exception.ExceptionMgmt.GetMessages(FaultMsg); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("f9b93288-5b7c-4627-be7d-bf92070c52d6")] + while (msgs.MoveNext()) + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("68f218bd-4f8a-48ec-8f25-bfa15a61fdd5")] + TmpMsg = msgs.Current; + [Microsoft.XLANGs.BaseTypes.DesignerPosition("05291c45-65b3-4fdb-941b-d57065d68765")] + send (MessagePost.PostTmpMsg, TmpMsg); + } + } + } +} + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIProcessHandler.odx b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIProcessHandler.odx new file mode 100644 index 0000000..473d3d5 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/EAIProcessHandler.odx @@ -0,0 +1,396 @@ +#if __DESIGNER_DATA +#error Do not define __DESIGNER_DATA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __DESIGNER_DATA +[Microsoft.XLANGs.BaseTypes.BPELExportable(false)] +module BootCamp.Orchestration.Exception.FaultHandler +{ + internal messagetype RequestDeclined + { + body BootCamp.Orchestration.Exception.Schemas.RequestDenied Body; + }; + public messagetype RequestApproved + { + body BootCamp.Orchestration.Exception.Schemas.Request Body; + }; + public messagetype FaultMessageType + { + body Msft.Samples.BizTalk.Exception.Schemas.FaultMessage Body; + }; + internal porttype FaultProcessType + { + oneway SubmitFault + { + FaultMessageType + }; + }; + internal porttype ApprovedPublishType + { + oneway PostApprove + { + RequestApproved + }; + }; + internal porttype DeclinedPublishType + { + oneway PostDecline + { + RequestDeclined + }; + }; + internal porttype RepairPortType + { + oneway SubmitRepair + { + RequestApproved + }; + }; + [Microsoft.XLANGs.BaseTypes.BPELExportable(false)] + internal service EAIProcessHandler + { + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port implements FaultProcessType FaultProcess; + [Microsoft.XLANGs.BaseTypes.LogicalBinding()] + port uses RepairPortType RepairSubmit; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses DeclinedPublishType DeclinedPublish; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses ApprovedPublishType ApprovedPublish; + message FaultMessageType FaultMsg; + message RequestApproved RequestMsg; + message RequestDeclined DeniedMsg; + System.Exception newExc; + body () + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("5f7c7ed7-8bab-4994-8c4f-855ad63773ff")] + activate ((Msft.Samples.BizTalk.Exception.Schemas.FaultCode == "1001"))receive (FaultProcess.SubmitFault, FaultMsg); + newExc = new System.Exception(); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("f75bab47-dd38-4db8-bed9-ff80f49f3c42")] + //Retrieve the 2 messages from the Fault Message and submit them... + RequestMsg = Msft.Samples.BizTalk.Exception.ExceptionMgmt.GetMessage(FaultMsg,"ApprovedRequest"); + DeniedMsg = Msft.Samples.BizTalk.Exception.ExceptionMgmt.GetMessage(FaultMsg,"DeniedRequest"); + + //Retrieve the System.Exception from the Original Service + newExc = Msft.Samples.BizTalk.Exception.ExceptionMgmt.GetException(FaultMsg); + + // Write the error value to event log (need admin rights) + System.Diagnostics.EventLog.WriteEntry("EAIProcessHandler",newExc.Message.ToString()); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("02e11e55-c79b-4718-851e-13e9591e70c9")] + if (FaultMsg(Msft.Samples.BizTalk.Exception.Schemas.ErrorType) == "DivideByZeroException") + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("2cda7bc4-2a04-4216-8d27-d043d6582316")] + send (RepairSubmit.SubmitRepair, RequestMsg); + } + else + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("0c801fe5-d753-4e45-b5e3-e9fd38985cf7")] + send (ApprovedPublish.PostApprove, RequestMsg); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("b8607b8e-feea-4378-9368-320a9efe5f86")] + send (DeclinedPublish.PostDecline, DeniedMsg); + } + } +} + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll new file mode 100644 index 0000000..90078c5 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..5500eb6 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll new file mode 100644 index 0000000..66024d0 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll new file mode 100644 index 0000000..e1d50be Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Pipeline.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Pipeline.dll new file mode 100644 index 0000000..46fc204 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Pipeline.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Streaming.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Streaming.dll new file mode 100644 index 0000000..eadacfd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Streaming.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Tracing.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Tracing.dll new file mode 100644 index 0000000..7562873 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.Tracing.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.XPathReader.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.XPathReader.dll new file mode 100644 index 0000000..cc88d67 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.BizTalk.XPathReader.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.RuleEngine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.RuleEngine.dll new file mode 100644 index 0000000..bf91ba7 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.RuleEngine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll new file mode 100644 index 0000000..cc79316 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll new file mode 100644 index 0000000..b196f01 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll new file mode 100644 index 0000000..2e1ed54 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.Engine.dll new file mode 100644 index 0000000..ed606f0 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll new file mode 100644 index 0000000..2d590bd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..c357d4b Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..384d9db Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.BizTalk.Security.SSPI.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.BizTalk.Security.SSPI.dll new file mode 100644 index 0000000..e3f508a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.BizTalk.Security.SSPI.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll new file mode 100644 index 0000000..b196f01 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll new file mode 100644 index 0000000..2e1ed54 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..2146fbd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.dll new file mode 100644 index 0000000..3b997b2 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/bin/Development/Msft.Samples.BizTalk.Exception.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/obj/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/obj/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll new file mode 100644 index 0000000..90078c5 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.FaultHandler/obj/Deployment/BootCamp.Orchestration.Exception.FaultHandler.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj new file mode 100644 index 0000000..db50dfd --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj.user b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj.user new file mode 100644 index 0000000..071e719 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/BootCamp.Orchestration.Exception.Process.btproj.user @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/Copy of EAIProcess.odx b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/Copy of EAIProcess.odx new file mode 100644 index 0000000..45a89b7 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/Copy of EAIProcess.odx @@ -0,0 +1,364 @@ +#if __DESIGNER_DATA +#error Do not define __DESIGNER_DATA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __DESIGNER_DATA +[Microsoft.XLANGs.BaseTypes.BPELExportable(false)] +module BootCamp.Orchestration.Exception.Process +{ + public messagetype RequestApproved + { + body BootCamp.Orchestration.Exception.Schemas.Request Body; + }; + internal messagetype RequestDeclined + { + body BootCamp.Orchestration.Exception.Schemas.RequestDenied Body; + }; + public messagetype FaultMessageType + { + body Msft.Samples.BizTalk.Exception.Schemas.FaultMessage Body; + }; + public porttype ReceiveReqType + { + oneway SubmitRequest + { + RequestApproved + }; + }; + internal porttype FaultPostType + { + oneway PostFaultMsg + { + FaultMessageType + }; + }; + [Microsoft.XLANGs.BaseTypes.BPELExportable(false)] + internal service EAIProcess + { + [Microsoft.XLANGs.BaseTypes.LogicalBinding()] + port implements ReceiveReqType RequestPort; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses FaultPostType FaultPost; + message RequestApproved ApprovedRequest; + message RequestDeclined DeniedRequest; + message FaultMessageType FaultMsg; + System.Int32 x; + System.Int32 y; + System.Int32 z; + body () + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("4183e8f8-9361-4319-a4f5-09e5f41656ed")] + activate receive (RequestPort.SubmitRequest, ApprovedRequest); + x = 0; + y = 1; + z = 0; + [Microsoft.XLANGs.BaseTypes.DesignerPosition("83127ce0-b6eb-41b5-a151-0dd80f8a1eeb")] + scope + { + body + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("f69f177a-b7fe-4332-9fec-437f64562250")] + construct DeniedRequest + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("e6b25373-fd22-4fab-b6e5-d14ed112c58b")] + transform (DeniedRequest.Body) = BootCamp.Orchestration.Exception.Schemas.MapToReqDenied (ApprovedRequest.Body); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("8e2041d4-7dca-4c04-a1ae-70d8e145eaf4")] + // Generate a Divide By Zero Error + x = y/z; + } + exceptions + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("e280636b-1992-4206-ba53-04b9ec1fdf9c")] + catch (System.Exception sysExc) + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("7de7d650-8d15-4da1-a31d-a25dee88a251")] + construct FaultMsg + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("0c38cf5f-a01a-4b57-b931-fcd1c6f6fe60")] + // Create Fault Exception Message + FaultMsg.Body = Msft.Samples.BizTalk.Exception.ExceptionMgmt.CreateFaultMessage(); + + // Set Fault Message Properties + FaultMsg.Body.Application = "Some Application"; + FaultMsg.Body.FailureCategory = "Sample"; + FaultMsg.Body.FaultCode = "new fault"; + FaultMsg.Body.FaultDescription = "Some Application Description"; + FaultMsg.Body.FaultSeverity = Msft.Samples.BizTalk.Exception.FaultSeverity.Severe; + FaultMsg.Body.Scope = "Execution Scope"; + + // Add each message to the Fault Message + Msft.Samples.BizTalk.Exception.ExceptionMgmt.AddMessage(FaultMsg,ApprovedRequest); + Msft.Samples.BizTalk.Exception.ExceptionMgmt.AddMessage(FaultMsg,DeniedRequest); + Msft.Samples.BizTalk.Exception.ExceptionMgmt.SetException(FaultMsg,sysExc); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("9fd50b3f-9c63-4b11-b21c-e6d22583cec4")] + send (FaultPost.PostFaultMsg, FaultMsg); + } + } + } + } + } +} + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/EAIProcess.odx b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/EAIProcess.odx new file mode 100644 index 0000000..a4e5540 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/EAIProcess.odx @@ -0,0 +1,416 @@ +#if __DESIGNER_DATA +#error Do not define __DESIGNER_DATA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __DESIGNER_DATA +[Microsoft.XLANGs.BaseTypes.BPELExportable(false)] +module BootCamp.Orchestration.Exception.Process +{ + public messagetype RequestApproved + { + body BootCamp.Orchestration.Exception.Schemas.Request Body; + }; + internal messagetype RequestDeclined + { + body BootCamp.Orchestration.Exception.Schemas.RequestDenied Body; + }; + public messagetype FaultMessageType + { + body Msft.Samples.BizTalk.Exception.Schemas.FaultMessage Body; + }; + public porttype ReceiveReqType + { + oneway SubmitRequest + { + RequestApproved + }; + }; + internal porttype FaultPostType + { + oneway PostFaultMsg + { + FaultMessageType + }; + }; + internal porttype RequestPostType + { + oneway PostApprovalMsg + { + RequestApproved + }; + }; + [Microsoft.XLANGs.BaseTypes.BPELExportable(false)] + internal service EAIProcess + { + [Microsoft.XLANGs.BaseTypes.LogicalBinding()] + port implements ReceiveReqType RequestPort; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses RequestPostType ApprovalPost; + [Microsoft.XLANGs.BaseTypes.DirectBinding()] + port uses FaultPostType FaultPost; + message RequestApproved ApprovedRequest; + message RequestDeclined DeniedRequest; + message FaultMessageType FaultMsg; + System.Int32 x; + System.Int32 y; + body () + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("4183e8f8-9361-4319-a4f5-09e5f41656ed")] + activate receive (RequestPort.SubmitRequest, ApprovedRequest); + x = 0; + y = 1; + [Microsoft.XLANGs.BaseTypes.DesignerPosition("f69f177a-b7fe-4332-9fec-437f64562250")] + construct DeniedRequest + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("e6b25373-fd22-4fab-b6e5-d14ed112c58b")] + transform (DeniedRequest.Body) = BootCamp.Orchestration.Exception.Schemas.MapToReqDenied (ApprovedRequest.Body); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("83127ce0-b6eb-41b5-a151-0dd80f8a1eeb")] + scope + { + body + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("8e2041d4-7dca-4c04-a1ae-70d8e145eaf4")] + // Generate a Divide By Zero Error + x = y/System.Convert.ToInt32(ApprovedRequest.Body.Item.UnitPrice); + } + exceptions + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("e280636b-1992-4206-ba53-04b9ec1fdf9c")] + catch (System.Exception sysExc) + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("7de7d650-8d15-4da1-a31d-a25dee88a251")] + construct FaultMsg + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("0c38cf5f-a01a-4b57-b931-fcd1c6f6fe60")] + // Create Fault Exception Message + FaultMsg = Msft.Samples.BizTalk.Exception.ExceptionMgmt.CreateFaultMessage(); + + // Set Fault Message Properties + FaultMsg.Body.FailureCategory = "MessageBuild"; + FaultMsg.Body.FaultCode = "1001"; + FaultMsg.Body.FaultDescription = "Some error occurred"; + FaultMsg.Body.FaultSeverity = Msft.Samples.BizTalk.Exception.FaultSeverity.Severe; + FaultMsg.Body.Scope = "Execution Scope"; + + // Add each message to the Fault Message + Msft.Samples.BizTalk.Exception.ExceptionMgmt.AddMessage(FaultMsg,ApprovedRequest); + Msft.Samples.BizTalk.Exception.ExceptionMgmt.AddMessage(FaultMsg,DeniedRequest); + Msft.Samples.BizTalk.Exception.ExceptionMgmt.SetException(FaultMsg,sysExc); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("9fd50b3f-9c63-4b11-b21c-e6d22583cec4")] + send (FaultPost.PostFaultMsg, FaultMsg); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("b161d706-c656-4360-be01-4f1963aa3b20")] + terminate sysExc.Message;; + } + } + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("a128e2b4-1475-4466-86f2-e51e74335dd9")] + send (ApprovalPost.PostApprovalMsg, ApprovedRequest); + } + } +} + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Process.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Process.dll new file mode 100644 index 0000000..f3b3fbd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Process.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..5500eb6 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll new file mode 100644 index 0000000..66024d0 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll new file mode 100644 index 0000000..e1d50be Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Pipeline.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Pipeline.dll new file mode 100644 index 0000000..46fc204 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Pipeline.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Streaming.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Streaming.dll new file mode 100644 index 0000000..eadacfd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Streaming.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Tracing.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Tracing.dll new file mode 100644 index 0000000..7562873 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.Tracing.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.XPathReader.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.XPathReader.dll new file mode 100644 index 0000000..cc88d67 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.BizTalk.XPathReader.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.RuleEngine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.RuleEngine.dll new file mode 100644 index 0000000..bf91ba7 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.RuleEngine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll new file mode 100644 index 0000000..cc79316 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll new file mode 100644 index 0000000..b196f01 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll new file mode 100644 index 0000000..2e1ed54 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.BizTalk.ProcessInterface.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.Engine.dll new file mode 100644 index 0000000..ed606f0 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll new file mode 100644 index 0000000..2d590bd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..c357d4b Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..384d9db Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.BizTalk.Security.SSPI.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.BizTalk.Security.SSPI.dll new file mode 100644 index 0000000..e3f508a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.BizTalk.Security.SSPI.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll new file mode 100644 index 0000000..b196f01 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.Engine.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll new file mode 100644 index 0000000..2e1ed54 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Microsoft.XLANGs.BizTalk.ProcessInterface.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..2146fbd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.dll new file mode 100644 index 0000000..3b997b2 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/bin/Development/Msft.Samples.BizTalk.Exception.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/obj/Deployment/BootCamp.Orchestration.Exception.Process.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/obj/Deployment/BootCamp.Orchestration.Exception.Process.dll new file mode 100644 index 0000000..f3b3fbd Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Process/obj/Deployment/BootCamp.Orchestration.Exception.Process.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj new file mode 100644 index 0000000..6046bd6 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj.user b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj.user new file mode 100644 index 0000000..226ecca --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/BootCamp.Orchestration.Exception.Schemas.btproj.user @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/MapToReqDenied.btm b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/MapToReqDenied.btm new file mode 100644 index 0000000..3d6250d Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/MapToReqDenied.btm differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/Request.xsd b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/Request.xsd new file mode 100644 index 0000000..b576e41 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/Request.xsd differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/RequestDenied.xsd b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/RequestDenied.xsd new file mode 100644 index 0000000..7e39df4 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/RequestDenied.xsd differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/System-Properties.xsd b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/System-Properties.xsd new file mode 100644 index 0000000..998a762 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/System-Properties.xsd differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..5500eb6 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/bin/Deployment/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/obj/Deployment/BootCamp.Orchestration.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/obj/Deployment/BootCamp.Orchestration.Exception.Schemas.dll new file mode 100644 index 0000000..5500eb6 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/BootCamp.Orchestration.Exception.Schemas/obj/Deployment/BootCamp.Orchestration.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/FaultMessage.xsd b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/FaultMessage.xsd new file mode 100644 index 0000000..897ad6e Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/FaultMessage.xsd differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj new file mode 100644 index 0000000..1c179f9 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj.user b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj.user new file mode 100644 index 0000000..f488dee --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/Msft.Samples.BizTalk.Exception.Schemas.btproj.user @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/System-Properties.xsd b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/System-Properties.xsd new file mode 100644 index 0000000..3128691 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/System-Properties.xsd differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..c357d4b Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/bin/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/obj/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/obj/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll new file mode 100644 index 0000000..c357d4b Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception.Schemas/obj/Deployment/Msft.Samples.BizTalk.Exception.Schemas.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Microsoft.BizTalk.Security.SSPI.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Microsoft.BizTalk.Security.SSPI.dll new file mode 100644 index 0000000..e3f508a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Microsoft.BizTalk.Security.SSPI.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.dll new file mode 100644 index 0000000..aea1938 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.pdb b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.pdb new file mode 100644 index 0000000..814e718 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Debug/Msft.Samples.BizTalk.Exception.pdb differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Microsoft.BizTalk.Security.SSPI.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Microsoft.BizTalk.Security.SSPI.dll new file mode 100644 index 0000000..e3f508a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Microsoft.BizTalk.Security.SSPI.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.dll b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.dll new file mode 100644 index 0000000..c2b6d14 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.dll differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.pdb b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.pdb new file mode 100644 index 0000000..33ac08a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.Exception/bin/Release/Msft.Samples.BizTalk.Exception.pdb differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.sln b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.sln new file mode 100644 index 0000000..ca3d4e8 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.sln @@ -0,0 +1,140 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "Msft.Samples.BizTalk.Exception.Schemas", "Msft.Samples.BizTalk.Exception.Schemas\Msft.Samples.BizTalk.Exception.Schemas.btproj", "{1639B081-BAB9-473A-83DB-5639B0912D47}" +EndProject +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "BootCamp.Orchestration.Exception.Process", "BootCamp.Orchestration.Exception.Process\BootCamp.Orchestration.Exception.Process.btproj", "{B885EE28-04A1-4A9C-8B4F-676C0F09D562}" +EndProject +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "BootCamp.Orchestration.Exception.FaultHandler", "BootCamp.Orchestration.Exception.FaultHandler\BootCamp.Orchestration.Exception.FaultHandler.btproj", "{39D69167-842A-41CA-80DB-4B0F34C557BF}" +EndProject +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "BootCamp.Orchestration.Exception.Schemas", "BootCamp.Orchestration.Exception.Schemas\BootCamp.Orchestration.Exception.Schemas.btproj", "{CB4DADA9-72E4-41AD-A54D-566AB83375B4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|.NET = Debug|.NET + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Deployment|.NET = Deployment|.NET + Deployment|Any CPU = Deployment|Any CPU + Deployment|Mixed Platforms = Deployment|Mixed Platforms + Development|.NET = Development|.NET + Development|Any CPU = Development|Any CPU + Development|Mixed Platforms = Development|Mixed Platforms + Release|.NET = Release|.NET + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|.NET.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|.NET.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|.NET.Deploy.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|Any CPU.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|Mixed Platforms.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|Mixed Platforms.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Debug|Mixed Platforms.Deploy.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|.NET.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|.NET.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|.NET.Deploy.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|Any CPU.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|Mixed Platforms.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|Mixed Platforms.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Deployment|Mixed Platforms.Deploy.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|.NET.ActiveCfg = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|.NET.Build.0 = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|Any CPU.ActiveCfg = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|Mixed Platforms.ActiveCfg = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|Mixed Platforms.Build.0 = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Development|Mixed Platforms.Deploy.0 = Development|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|.NET.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|.NET.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|.NET.Deploy.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|Any CPU.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|Mixed Platforms.ActiveCfg = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|Mixed Platforms.Build.0 = Deployment|.NET + {1639B081-BAB9-473A-83DB-5639B0912D47}.Release|Mixed Platforms.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|.NET.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|.NET.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|.NET.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|Any CPU.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|Mixed Platforms.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|Mixed Platforms.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Debug|Mixed Platforms.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|.NET.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|.NET.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|.NET.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|Any CPU.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|Mixed Platforms.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|Mixed Platforms.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Deployment|Mixed Platforms.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|.NET.ActiveCfg = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|.NET.Build.0 = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|Any CPU.ActiveCfg = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|Mixed Platforms.ActiveCfg = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|Mixed Platforms.Build.0 = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Development|Mixed Platforms.Deploy.0 = Development|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|.NET.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|.NET.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|.NET.Deploy.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|Any CPU.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|Mixed Platforms.ActiveCfg = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|Mixed Platforms.Build.0 = Deployment|.NET + {B885EE28-04A1-4A9C-8B4F-676C0F09D562}.Release|Mixed Platforms.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|.NET.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|.NET.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|.NET.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|Any CPU.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|Mixed Platforms.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|Mixed Platforms.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Debug|Mixed Platforms.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|.NET.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|.NET.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|.NET.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|Any CPU.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|Mixed Platforms.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|Mixed Platforms.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Deployment|Mixed Platforms.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|.NET.ActiveCfg = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|.NET.Build.0 = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|Any CPU.ActiveCfg = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|Mixed Platforms.ActiveCfg = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|Mixed Platforms.Build.0 = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Development|Mixed Platforms.Deploy.0 = Development|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|.NET.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|.NET.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|.NET.Deploy.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|Any CPU.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|Mixed Platforms.ActiveCfg = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|Mixed Platforms.Build.0 = Deployment|.NET + {39D69167-842A-41CA-80DB-4B0F34C557BF}.Release|Mixed Platforms.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|.NET.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|.NET.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|.NET.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|Any CPU.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|Mixed Platforms.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|Mixed Platforms.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Debug|Mixed Platforms.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|.NET.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|.NET.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|.NET.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|Any CPU.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|Mixed Platforms.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|Mixed Platforms.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Deployment|Mixed Platforms.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|.NET.ActiveCfg = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|.NET.Build.0 = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|Any CPU.ActiveCfg = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|Mixed Platforms.ActiveCfg = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|Mixed Platforms.Build.0 = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Development|Mixed Platforms.Deploy.0 = Development|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|.NET.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|.NET.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|.NET.Deploy.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|Any CPU.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|Mixed Platforms.ActiveCfg = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|Mixed Platforms.Build.0 = Deployment|.NET + {CB4DADA9-72E4-41AD-A54D-566AB83375B4}.Release|Mixed Platforms.Deploy.0 = Deployment|.NET + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.suo b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.suo new file mode 100644 index 0000000..d78abc7 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Projects/Msft.Samples.BizTalk.ExceptionManagement.suo differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/FaultMessage.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/FaultMessage.xml new file mode 100644 index 0000000..b637231 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/FaultMessage.xml differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/RequestResubmitForm.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/RequestResubmitForm.xml new file mode 100644 index 0000000..ca0a7e2 --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/Instance/RequestResubmitForm.xml @@ -0,0 +1,12 @@ + +
+ 444 + 2006-09-14 +
+ + rerwe + 5 + 1 + 5 + +
\ No newline at end of file diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg.xml new file mode 100644 index 0000000..b580b1a Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg.xml differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg_GeneratesException.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg_GeneratesException.xml new file mode 100644 index 0000000..5a886b7 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Samples/RequestMsg_GeneratesException.xml differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.BindingInfo.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.BindingInfo.xml new file mode 100644 index 0000000..ce300ca --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.BindingInfo.xml @@ -0,0 +1,25 @@ + + + 2006-10-15T00:31:24.2756176-04:00 + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.msi b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.msi new file mode 100644 index 0000000..323fdaf Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BizTalk.Sample.ExceptionMgmt.msi differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.BindingInfo.xml b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.BindingInfo.xml new file mode 100644 index 0000000..62abaaf --- /dev/null +++ b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.BindingInfo.xml @@ -0,0 +1,350 @@ + + + 2006-10-15T00:31:40.9195504-04:00 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\Exception_Typed\Approve_%MessageID%.xml
+ + <CustomProps><UseTempFileOnWrite vt="11">0</UseTempFileOnWrite><CopyMode vt="19">1</CopyMode><FileName vt="8">Approve_%MessageID%.xml</FileName><AllowCacheOnWrite vt="11">0</AllowCacheOnWrite></CustomProps> + 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + true + false + 1 + + + +
+ +
+ 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + false + false + 1 + + + + 0 + <?xml version="1.0" encoding="utf-16"?> +<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Group> + <Statement Property="BTS.Operation" Operator="0" Value="PostApprove" /> + </Group> +</Filter> + + false + 5 + false + false + BootCamp.Orchestration.Exception.Test + + + + + +
E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\Exception_Typed\Denied_%MessageID%.xml
+ + <CustomProps><UseTempFileOnWrite vt="11">0</UseTempFileOnWrite><CopyMode vt="19">1</CopyMode><FileName vt="8">Denied_%MessageID%.xml</FileName><AllowCacheOnWrite vt="11">0</AllowCacheOnWrite></CustomProps> + 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + true + false + 1 + + + +
+ +
+ 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + false + false + 1 + + + + 0 + <?xml version="1.0" encoding="utf-16"?> +<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Group> + <Statement Property="BTS.Operation" Operator="0" Value="PostDecline" /> + </Group> +</Filter> + + false + 5 + false + false + BootCamp.Orchestration.Exception.Test + + + + + +
E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\Exception_TypeAgnostic\%MessageID%.xml
+ + <CustomProps><UseTempFileOnWrite vt="11">0</UseTempFileOnWrite><CopyMode vt="19">1</CopyMode><FileName vt="8">%MessageID%.xml</FileName><AllowCacheOnWrite vt="11">0</AllowCacheOnWrite></CustomProps> + 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + true + false + 1 + + + +
+ +
+ 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + false + false + 1 + + + + 0 + <?xml version="1.0" encoding="utf-16"?> +<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Group> + <Statement Property="BTS.Operation" Operator="0" Value="PostTmpMsg" /> + </Group> +</Filter> + + false + 5 + false + false + BootCamp.Orchestration.Exception.Test + + + + + +
E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\EAIProcess_Qty\QTY_%MessageID%.xml
+ + <CustomProps><UseTempFileOnWrite vt="11">0</UseTempFileOnWrite><CopyMode vt="19">1</CopyMode><FileName vt="8">QTY_%MessageID%.xml</FileName><AllowCacheOnWrite vt="11">0</AllowCacheOnWrite></CustomProps> + 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + true + false + 1 + + + +
+ +
+ 3 + 5 + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + false + false + 1 + + + + 0 + <?xml version="1.0" encoding="utf-16"?> +<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Group> + <Statement Property="BootCamp.Orchestration.Exception.Schemas.Qty" Operator="0" Value="10" /> + </Group> +</Filter> + + false + 5 + false + false + BootCamp.Orchestration.Exception.Test + + + + + <Root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Stages><Stage CategoryId="9d0e4107-4cce-4536-83fa-4a5040674ad6"><Components><Component Name="Microsoft.BizTalk.Component.XmlAsmComp"><Properties><XmlAsmProcessingInstructions vt="8">&lt;?mso-infoPathSolution solutionVersion="1.0.0.4" productVersion="11.0.6565" PIVersion="1.0.0.0" href="file:///E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\Templates\RepairReSubmitForm.xsn" name="urn:schemas-microsoft-com:office:infopath:RepairReSubmitForm:http--BootCamp-Orchestration-Exception-Schemas-Request" language="en-us" ?&gt;&lt;?mso-application progid="InfoPath.Document"?&gt;</XmlAsmProcessingInstructions></Properties></Component></Components></Stage></Stages></Root> + +
E:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\Exception_RepairForReSubmit\Repair_%MessageID%.xml
+ + <CustomProps><UseTempFileOnWrite vt="11">0</UseTempFileOnWrite><CopyMode vt="19">1</CopyMode><FileName vt="8">Repair_%MessageID%.xml</FileName><AllowCacheOnWrite vt="11">0</AllowCacheOnWrite></CustomProps> + 3 + 5 + false + 2006-09-14T04:00:00 + 2006-09-15T03:59:59 + true + false + 1 + + + +
+ +
+ 3 + 5 + false + 2006-09-14T04:00:00 + 2006-09-15T03:59:59 + false + false + 1 + + + + 0 + + + false + 5 + false + false + BootCamp.Orchestration.Exception.Test + + + + + + + + + +
e:\Projects\Demos\FaultHandler\Msft.BizTalk.ExceptionMgmt\FileDrops\in\*.xml
+ + true + false + 2000-01-01T08:00:00 + 2000-01-01T07:59:59 + false + 2006-03-04T00:00:00 + false + 2006-03-05T23:59:59 + + <CustomProps><RemoveReceivedFileRetryCount vt="19">5</RemoveReceivedFileRetryCount><RemoveReceivedFileMaxInterval vt="19">300000</RemoveReceivedFileMaxInterval><FileMask vt="8">*.xml</FileMask><BatchSizeInBytes vt="19">102400</BatchSizeInBytes><PollingInterval vt="19">1</PollingInterval><BatchSize vt="19">20</BatchSize><FileNetFailRetryInt vt="19">5</FileNetFailRetryInt><RemoveReceivedFileDelay vt="19">10</RemoveReceivedFileDelay><RenameReceivedFiles vt="11">0</RenameReceivedFiles><FileNetFailRetryCount vt="19">5</FileNetFailRetryCount></CustomProps> + + + + + true + + + +
+ + +
/HwsMessages/BTSHTTPReceive.dll?EAIProcessReSubmit
+ + false + false + 2006-09-14T04:00:00 + 2006-09-15T03:59:59 + false + 2006-09-13T20:00:00 + false + 2006-09-14T20:00:00 + + <CustomProps><ReturnCorrelationHandle vt="11">-1</ReturnCorrelationHandle><ResponseContentType vt="8">text/xml</ResponseContentType><SuspendFailedRequests vt="11">0</SuspendFailedRequests><UseSSO vt="11">0</UseSSO><LoopBack vt="11">0</LoopBack></CustomProps> + + + + + true + + + +
+
+ + 0 + 0 + + true + BootCamp.Orchestration.Exception.Test +
+
+ + \ No newline at end of file diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.msi b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.msi new file mode 100644 index 0000000..fea2d49 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Setup/BootCamp.Orchestration.Exception.Test.msi differ diff --git a/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Templates/RepairReSubmitForm.xsn b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Templates/RepairReSubmitForm.xsn new file mode 100644 index 0000000..4effa83 Binary files /dev/null and b/Samples/Chapter06/Exception Management/Msft.BizTalk.ExceptionMgmt/Templates/RepairReSubmitForm.xsn differ diff --git a/Samples/Chapter08/Custom Fact Retriever/FactRetrieverForLoansProcessing.cs b/Samples/Chapter08/Custom Fact Retriever/FactRetrieverForLoansProcessing.cs new file mode 100644 index 0000000..66bc111 --- /dev/null +++ b/Samples/Chapter08/Custom Fact Retriever/FactRetrieverForLoansProcessing.cs @@ -0,0 +1,78 @@ +//--------------------------------------------------------------------- +// File: FactRetrieverForLoansProcessing.cs +// +// Summary: Used to retrieve information from the CustInfo table +// added earlier to the Northwind sample SQL database. +// +// Sample: Loan Processing using Business Rules +// +//--------------------------------------------------------------------- +// This file is part of the Microsoft BizTalk Server 2004 SDK +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// This source code is intended only as a supplement to Microsoft BizTalk +// Server 2004 release and/or on-line documentation. See these other +// materials for detailed information regarding Microsoft code samples. +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +// PURPOSE. +//--------------------------------------------------------------------- + + +using System; +using System.Collections; +using Microsoft.RuleEngine; +using System.IO; +using System.Data; +using System.Data.SqlClient; + +namespace Microsoft.Samples.BizTalk.LoansProcessingUsingBusinessRules.myFactRetriever +{ + + /// Fact Retriever class for LoanProcessing Policy + + public class DbFactRetriever:IFactRetriever + { + + public object UpdateFacts(RuleSetInfo rulesetInfo, Microsoft.RuleEngine.RuleEngine engine, object factsHandleIn) + { + object factsHandleOut; + + // The following logic asserts the required DB rows only once and always uses the the same values (cached) during the first retrieval in subsequent execution cycles + if (factsHandleIn == null) + { + string strCmd1 = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=jinli2000"; + + SqlConnection con1 = new SqlConnection(strCmd1); + + // Using data connection binding + // DataConnection dc1 = new DataConnection("Northwind", "CustInfo", con1); + + // Using data table binding + SqlDataAdapter dAdapt1 = new SqlDataAdapter(); + dAdapt1.TableMappings.Add("Table", "CustInfo"); + con1.Open(); + SqlCommand myCommand = new SqlCommand("SELECT * FROM CustInfo", con1); + myCommand.CommandType = CommandType.Text; + dAdapt1.SelectCommand = myCommand; + DataSet ds = new DataSet("Northwind"); + dAdapt1.Fill(ds); + TypedDataTable tdt1 = new TypedDataTable(ds.Tables["CustInfo"]); + + engine.Assert(tdt1); + factsHandleOut = tdt1; + + } + + else + factsHandleOut = factsHandleIn; + + return factsHandleOut; + } + + + } +} diff --git a/Samples/Chapter08/RulesTesterAPP/App.ico b/Samples/Chapter08/RulesTesterAPP/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Samples/Chapter08/RulesTesterAPP/App.ico differ diff --git a/Samples/Chapter08/RulesTesterAPP/AssemblyInfo.cs b/Samples/Chapter08/RulesTesterAPP/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj new file mode 100644 index 0000000..4860985 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj.user b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj.user new file mode 100644 index 0000000..08f14c2 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.sln b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.sln new file mode 100644 index 0000000..89de469 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesTesterApp", "RulesTesterApp.csproj", "{0BCA7317-A600-4E99-8DB3-76B50041883E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0BCA7317-A600-4E99-8DB3-76B50041883E}.Debug.ActiveCfg = Debug|.NET + {0BCA7317-A600-4E99-8DB3-76B50041883E}.Debug.Build.0 = Debug|.NET + {0BCA7317-A600-4E99-8DB3-76B50041883E}.Release.ActiveCfg = Release|.NET + {0BCA7317-A600-4E99-8DB3-76B50041883E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.suo b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.suo new file mode 100644 index 0000000..926d679 Binary files /dev/null and b/Samples/Chapter08/RulesTesterAPP/RulesTesterApp.suo differ diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.cs b/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.cs new file mode 100644 index 0000000..49d1248 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.cs @@ -0,0 +1,348 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.IO; +using System.Xml; +using Microsoft.RuleEngine; + + +namespace RulesTesterApp +{ + /// + /// Summary description for Form1. + /// + public class RulesTesterFrm : System.Windows.Forms.Form + { + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lblProcessing; + private System.Windows.Forms.TextBox inboundTxtBx; + private System.Windows.Forms.TextBox outboundTxtBx; + private System.Windows.Forms.TextBox ProcessingTxtBx; + private System.Windows.Forms.TextBox traceTxtBx; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button processBtn; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + public RulesTesterFrm() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + // + // TODO: Add any constructor code after InitializeComponent call + // + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.processBtn = new System.Windows.Forms.Button(); + this.traceTxtBx = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.ProcessingTxtBx = new System.Windows.Forms.TextBox(); + this.outboundTxtBx = new System.Windows.Forms.TextBox(); + this.inboundTxtBx = new System.Windows.Forms.TextBox(); + this.lblProcessing = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.processBtn); + this.groupBox1.Controls.Add(this.traceTxtBx); + this.groupBox1.Controls.Add(this.label4); + this.groupBox1.Controls.Add(this.ProcessingTxtBx); + this.groupBox1.Controls.Add(this.outboundTxtBx); + this.groupBox1.Controls.Add(this.inboundTxtBx); + this.groupBox1.Controls.Add(this.lblProcessing); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(8, 8); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(536, 296); + this.groupBox1.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Start Passing Docs"; + // + // processBtn + // + this.processBtn.Location = new System.Drawing.Point(352, 96); + this.processBtn.Name = "processBtn"; + this.processBtn.Size = new System.Drawing.Size(152, 23); + this.processBtn.TabIndex = 8; + this.processBtn.Text = "Start Processing"; + this.processBtn.Click += new System.EventHandler(this.processBtn_Click); + // + // traceTxtBx + // + this.traceTxtBx.Location = new System.Drawing.Point(200, 72); + this.traceTxtBx.Name = "traceTxtBx"; + this.traceTxtBx.Size = new System.Drawing.Size(320, 20); + this.traceTxtBx.TabIndex = 7; + this.traceTxtBx.Text = "F:\\\\RulesTest\\\\TraceFiles\\\\"; + // + // label4 + // + this.label4.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label4.Location = new System.Drawing.Point(16, 75); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(168, 16); + this.label4.TabIndex = 6; + this.label4.Text = "Trace Files Folder"; + // + // ProcessingTxtBx + // + this.ProcessingTxtBx.Dock = System.Windows.Forms.DockStyle.Bottom; + this.ProcessingTxtBx.Location = new System.Drawing.Point(3, 157); + this.ProcessingTxtBx.Multiline = true; + this.ProcessingTxtBx.Name = "ProcessingTxtBx"; + this.ProcessingTxtBx.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.ProcessingTxtBx.Size = new System.Drawing.Size(530, 136); + this.ProcessingTxtBx.TabIndex = 5; + this.ProcessingTxtBx.Text = ""; + // + // outboundTxtBx + // + this.outboundTxtBx.Location = new System.Drawing.Point(200, 48); + this.outboundTxtBx.Name = "outboundTxtBx"; + this.outboundTxtBx.Size = new System.Drawing.Size(320, 20); + this.outboundTxtBx.TabIndex = 4; + this.outboundTxtBx.Text = "F:\\\\RulesTest\\\\Processed\\\\"; + // + // inboundTxtBx + // + this.inboundTxtBx.Location = new System.Drawing.Point(200, 20); + this.inboundTxtBx.Name = "inboundTxtBx"; + this.inboundTxtBx.Size = new System.Drawing.Size(320, 20); + this.inboundTxtBx.TabIndex = 3; + this.inboundTxtBx.Text = "F:\\\\RulesTest\\\\"; + // + // lblProcessing + // + this.lblProcessing.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.lblProcessing.Location = new System.Drawing.Point(8, 130); + this.lblProcessing.Name = "lblProcessing"; + this.lblProcessing.Size = new System.Drawing.Size(496, 16); + this.lblProcessing.TabIndex = 2; + this.lblProcessing.Text = "Presently Processing"; + // + // label2 + // + this.label2.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label2.Location = new System.Drawing.Point(16, 51); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(176, 16); + this.label2.TabIndex = 1; + this.label2.Text = "Outbound From Rules Folder"; + // + // label1 + // + this.label1.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(152, 16); + this.label1.TabIndex = 0; + this.label1.Text = "Inbound To Rules Folder"; + // + // RulesTesterFrm + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(552, 308); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.Name = "RulesTesterFrm"; + this.Text = "Rules Tester App"; + this.groupBox1.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new RulesTesterFrm()); + } + + private void processBtn_Click(object sender, System.EventArgs e) + { + string destDirectory = outboundTxtBx.Text.Trim(); + string root = inboundTxtBx.Text.Trim(); + string [] files = Directory.GetFiles(root); + if(files.Length == 0 ) + MessageBox.Show("No Files to Process","Did You Forget Something?",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); + for ( int i = 0 ; i < files.Length ; i++ ) + { + string fileName = files[i].Trim(); + + FileInfo fileInfo = new FileInfo(fileName); + if (fileInfo.Extension.ToUpper() == ".XML" ) + { + string dFileName = fileInfo.Name; + dFileName = dFileName.Substring(0,dFileName.Length-4); + + StreamReader sr = new StreamReader(fileName); + string s = sr.ReadToEnd(); + + XmlDocument xd = new XmlDocument(); + xd.LoadXml(s); + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing The Document: " + fileName + "\r\n"; + FireRule(xd, dFileName); + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing Completed for the document: " + fileName + "\r\n"; + sr.Close(); + string destFileName = dFileName; + destFileName = destDirectory + destFileName + fileInfo.Extension; + if (File.Exists(destFileName)) + File.Delete(destFileName); + File.Move(fileName,destFileName); + } + } + } + + private void FireRule(XmlDocument xd, string fileName) + { + + string destDirectory = outboundTxtBx.Text.Trim(); + string traceDirectory = traceTxtBx.Text.Trim(); + TypedXmlDocument doc1 = new TypedXmlDocument("TrackSource.BizTalk.Schemas.InboundToRules", xd); + + string [] policies = new string[14] { + "Data Preparation", + "Pre-Processing Group 1", + "Pre-Processing Group 2", + "Pre-Processing Group 3", + "Pre-Processing Group 4", + "Pre-Processing Group 5", + "Pre-Processing Group 6", + "Lender Specific", + "Insurance Servicing", + "Post Processing Group 1", + "Post Processing Group 2", + "Black Hole", + "Fidelity Hold", + "Procedure Set" + }; + + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing Started " + DateTime.Now + "\r\n"; + string traceFileName = fileName + "_RuleTrace"; + traceFileName = traceDirectory + traceFileName + ".txt"; + if (File.Exists(traceFileName)) + File.Delete(traceFileName); + DebugTrackingInterceptor dti = new DebugTrackingInterceptor(traceFileName); + + try + { + for( int i = 0 ; i < policies.Length; i++ ) + { + string PolicyName = policies[i].Trim(); + lblProcessing.Text = PolicyName; + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing ... " + policies[i] + " " + DateTime.Now + "\r\n"; + Application.DoEvents(); + Microsoft.RuleEngine.Policy tstPolicy = new Microsoft.RuleEngine.Policy(PolicyName); + ArrayList shortTermFacts = new ArrayList(); + shortTermFacts =GetFacts(PolicyName); + shortTermFacts.Add(doc1); + tstPolicy.Execute(shortTermFacts.ToArray(), dti ); + tstPolicy = null; + + } + } + catch(Exception ex) + { + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Exception Caught Check _Excepion Text File"; + string exceptionFileName = fileName + "_Exception"; + exceptionFileName = traceDirectory + exceptionFileName + ".txt"; + if (File.Exists(exceptionFileName)) + File.Delete(exceptionFileName); + StreamWriter sw2 = new StreamWriter(exceptionFileName); + ProcessingTxtBx.Text = ProcessingTxtBx.Text + ex.Message; + sw2.Write(ex.Message.ToString()); + sw2.Close(); + } + finally + { + ProcessingTxtBx.Text = ProcessingTxtBx.Text + "Processing Done " + DateTime.Now + "\r\n"; + lblProcessing.Text = "Writing output File" ; + string processedDoc = fileName + "_Outbound"; + processedDoc = destDirectory + processedDoc + ".xml"; + if (File.Exists(processedDoc)) + File.Delete(processedDoc); + StreamWriter sw = new StreamWriter(processedDoc); + dti.CloseTraceFile(); + sw.Write(doc1.Document.InnerXml.ToString()); + sw.Close(); + xd = null; + doc1 = null; + lblProcessing.Text = "Processing Completed for " + fileName ; + + } + //return xd; + } + + public ArrayList GetFacts(string policyName) + { + #region From rules Engine + + ArrayList shortermFacts = new ArrayList(); + Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver dd = new Microsoft.BizTalk.RuleEngineExtensions.RuleSetDeploymentDriver(); + RuleStore sqlrs; + sqlrs = dd.GetRuleStore(); + RuleSetInfoCollection rsInfoCollection = sqlrs.GetRuleSets(policyName,RuleStore.Filter.Latest); + foreach(RuleSetInfo rsInfo in rsInfoCollection) + { + RuleSet ruleset = sqlrs.GetRuleSet(rsInfo); + ArrayList bindingList =Microsoft.RuleEngine.RuleSetBindingFinder.GetBindings(ruleset); + foreach(object o in bindingList) + { + if(o is Microsoft.RuleEngine.ClassBinding) + { + Microsoft.RuleEngine.ClassBinding cb = o as Microsoft.RuleEngine.ClassBinding; + if(cb.TypeName != "TrackSource.BizTalkRules.LongTermFactsWrapper") + shortermFacts.Add(Activator.CreateInstance(cb.Type)); + + } + } + + } + return shortermFacts; + + #endregion + } + } +} diff --git a/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.resx b/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.resx new file mode 100644 index 0000000..22f63e5 --- /dev/null +++ b/Samples/Chapter08/RulesTesterAPP/RulesTesterFrm.resx @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + 8, 8 + + + True + + + False + + + True + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + RulesTesterFrm + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + + \ No newline at end of file diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.dll b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.dll new file mode 100644 index 0000000..38fd322 Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.dll differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.sln b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.sln new file mode 100644 index 0000000..564594e --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.sln @@ -0,0 +1,21 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "DeploymentSampleApplication", "DeploymentSampleApplication\DeploymentSampleApplication.btproj", "{48C3848A-19F0-4CBB-9A1D-45F914CC00D2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Deployment|.NET = Deployment|.NET + Development|.NET = Development|.NET + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {48C3848A-19F0-4CBB-9A1D-45F914CC00D2}.Deployment|.NET.ActiveCfg = Deployment|.NET + {48C3848A-19F0-4CBB-9A1D-45F914CC00D2}.Deployment|.NET.Build.0 = Deployment|.NET + {48C3848A-19F0-4CBB-9A1D-45F914CC00D2}.Deployment|.NET.Deploy.0 = Deployment|.NET + {48C3848A-19F0-4CBB-9A1D-45F914CC00D2}.Development|.NET.ActiveCfg = Development|.NET + {48C3848A-19F0-4CBB-9A1D-45F914CC00D2}.Development|.NET.Build.0 = Development|.NET + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.suo b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.suo new file mode 100644 index 0000000..698c90e Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication.suo differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/AssemblyInfo.cs b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/AssemblyInfo.cs new file mode 100644 index 0000000..23a87d0 --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/AssemblyInfo.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +[assembly: System.Reflection.AssemblyTitle("")] +[assembly: System.Reflection.AssemblyDescription("")] +[assembly: System.Reflection.AssemblyConfiguration("")] +[assembly: System.Reflection.AssemblyCompany("")] +[assembly: System.Reflection.AssemblyProduct("")] +[assembly: System.Reflection.AssemblyCopyright("")] +[assembly: System.Reflection.AssemblyTrademark("")] +[assembly: System.Reflection.AssemblyCulture("")] +[assembly: System.Reflection.AssemblyVersion("1.0.0.0")] +[assembly: System.Reflection.AssemblyDelaySign(false)] +[assembly: System.Reflection.AssemblyKeyFile("..\\..\\..\\..\\PROBIZTALK.snk")] +[assembly: System.Reflection.AssemblyKeyName("")] +[assembly: System.Reflection.AssemblyDefaultAlias("")] +[assembly: System.Reflection.AssemblyFileVersion("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersion("1.0.0.0")] +[assembly: Microsoft.XLANGs.BaseTypes.BizTalkAssemblyAttribute(typeof(Microsoft.BizTalk.XLANGs.BTXEngine.BTXService))] + diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj new file mode 100644 index 0000000..75e0608 --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj.user b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj.user new file mode 100644 index 0000000..050126d --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/DeploymentSampleApplication.btproj.user @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsResponseSchema.xsd b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsResponseSchema.xsd new file mode 100644 index 0000000..66d6559 Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsResponseSchema.xsd differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsSchema.xsd b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsSchema.xsd new file mode 100644 index 0000000..0e374f6 Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsSchema.xsd differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsToGreetingsResponseMap.btm b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsToGreetingsResponseMap.btm new file mode 100644 index 0000000..53494dd Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/GreetingsToGreetingsResponseMap.btm differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx new file mode 100644 index 0000000..7e3e8d5 --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx @@ -0,0 +1,195 @@ +#if __DESIGNER_DATA +#error Do not define __DESIGNER_DATA. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // __DESIGNER_DATA +[Microsoft.XLANGs.BaseTypes.BPELExportable(false)] +module DeploymentSampleApplication +{ + internal porttype ReceiveGreetingsPortType + { + oneway RcvGreetingsOperation + { + GreetingsSchema + }; + }; + internal porttype SendGreetingsResponsePortType + { + oneway SendGreetingsResponseOperation + { + GreetingsResponseSchema + }; + }; + [Microsoft.XLANGs.BaseTypes.BPELExportable(false)] + internal service ProcessGreetingsOrchestration + { + [Microsoft.XLANGs.BaseTypes.LogicalBinding()] + port implements ReceiveGreetingsPortType ReceiveGreetingsPort; + [Microsoft.XLANGs.BaseTypes.LogicalBinding()] + port uses SendGreetingsResponsePortType SendGreetingsResponsePort; + message GreetingsSchema GreetingsMsg; + message GreetingsResponseSchema GreetingsResponseMsg; + body () + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("6df23575-3958-455e-8c01-4887d78d3bb9")] + activate receive (ReceiveGreetingsPort.RcvGreetingsOperation, GreetingsMsg); + [Microsoft.XLANGs.BaseTypes.DesignerPosition("9481cdef-35eb-4f15-bfad-f0f322586dcb")] + construct GreetingsResponseMsg + { + [Microsoft.XLANGs.BaseTypes.DesignerPosition("d2504f0f-cb6c-489b-9792-b97220442f17")] + transform (GreetingsResponseMsg) = DeploymentSampleApplication.GreetingsToGreetingsResponseMap (GreetingsMsg); + } + [Microsoft.XLANGs.BaseTypes.DesignerPosition("1944e460-8b7c-4d30-86e7-bf6a33c435b1")] + send (SendGreetingsResponsePort.SendGreetingsResponseOperation, GreetingsResponseMsg); + } + } +} + diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx.cs b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx.cs new file mode 100644 index 0000000..5317e23 --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/ProcessGreetingsOrchestration.odx.cs @@ -0,0 +1,958 @@ + +#pragma warning disable 162 + +namespace DeploymentSampleApplication +{ + + [Microsoft.XLANGs.BaseTypes.PortTypeOperationAttribute( + "RcvGreetingsOperation", + new System.Type[]{ + typeof(DeploymentSampleApplication.__messagetype_DeploymentSampleApplication_GreetingsSchema) + }, + new string[]{ + } + )] + [Microsoft.XLANGs.BaseTypes.PortTypeAttribute(Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal, "")] + [System.SerializableAttribute] + sealed internal class ReceiveGreetingsPortType : Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase + { + public ReceiveGreetingsPortType(int portInfo, Microsoft.XLANGs.Core.IServiceProxy s) + : base(portInfo, s) + { } + public ReceiveGreetingsPortType(ReceiveGreetingsPortType p) + : base(p) + { } + + public override Microsoft.XLANGs.Core.PortBase Clone() + { + ReceiveGreetingsPortType p = new ReceiveGreetingsPortType(this); + return p; + } + + public static readonly Microsoft.XLANGs.BaseTypes.EXLangSAccess __access = Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal; + #region port reflection support + static public Microsoft.XLANGs.Core.OperationInfo RcvGreetingsOperation = new Microsoft.XLANGs.Core.OperationInfo + ( + "RcvGreetingsOperation", + System.Web.Services.Description.OperationFlow.OneWay, + typeof(ReceiveGreetingsPortType), + typeof(__messagetype_DeploymentSampleApplication_GreetingsSchema), + null, + new System.Type[]{}, + new string[]{} + ); + static public System.Collections.Hashtable OperationsInformation + { + get + { + System.Collections.Hashtable h = new System.Collections.Hashtable(); + h[ "RcvGreetingsOperation" ] = RcvGreetingsOperation; + return h; + } + } + #endregion // port reflection support + } + + [Microsoft.XLANGs.BaseTypes.PortTypeOperationAttribute( + "SendGreetingsResponseOperation", + new System.Type[]{ + typeof(DeploymentSampleApplication.__messagetype_DeploymentSampleApplication_GreetingsResponseSchema) + }, + new string[]{ + } + )] + [Microsoft.XLANGs.BaseTypes.PortTypeAttribute(Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal, "")] + [System.SerializableAttribute] + sealed internal class SendGreetingsResponsePortType : Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase + { + public SendGreetingsResponsePortType(int portInfo, Microsoft.XLANGs.Core.IServiceProxy s) + : base(portInfo, s) + { } + public SendGreetingsResponsePortType(SendGreetingsResponsePortType p) + : base(p) + { } + + public override Microsoft.XLANGs.Core.PortBase Clone() + { + SendGreetingsResponsePortType p = new SendGreetingsResponsePortType(this); + return p; + } + + public static readonly Microsoft.XLANGs.BaseTypes.EXLangSAccess __access = Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal; + #region port reflection support + static public Microsoft.XLANGs.Core.OperationInfo SendGreetingsResponseOperation = new Microsoft.XLANGs.Core.OperationInfo + ( + "SendGreetingsResponseOperation", + System.Web.Services.Description.OperationFlow.OneWay, + typeof(SendGreetingsResponsePortType), + typeof(__messagetype_DeploymentSampleApplication_GreetingsResponseSchema), + null, + new System.Type[]{}, + new string[]{} + ); + static public System.Collections.Hashtable OperationsInformation + { + get + { + System.Collections.Hashtable h = new System.Collections.Hashtable(); + h[ "SendGreetingsResponseOperation" ] = SendGreetingsResponseOperation; + return h; + } + } + #endregion // port reflection support + } + //#line 172 "C:\PROBIZTALK\Chapter10\DeploymentSampleApplication\DeploymentSampleApplication\DeploymentSampleApplication\ProcessGreetingsOrchestration.odx" + [Microsoft.XLANGs.BaseTypes.StaticSubscriptionAttribute( + 0, "ReceiveGreetingsPort", "RcvGreetingsOperation", -1, -1, true + )] + [Microsoft.XLANGs.BaseTypes.ServicePortsAttribute( + new Microsoft.XLANGs.BaseTypes.EXLangSParameter[] { + Microsoft.XLANGs.BaseTypes.EXLangSParameter.ePort|Microsoft.XLANGs.BaseTypes.EXLangSParameter.eImplements, + Microsoft.XLANGs.BaseTypes.EXLangSParameter.ePort|Microsoft.XLANGs.BaseTypes.EXLangSParameter.eUses + }, + new System.Type[] { + typeof(DeploymentSampleApplication.ReceiveGreetingsPortType), + typeof(DeploymentSampleApplication.SendGreetingsResponsePortType) + }, + new System.String[] { + "ReceiveGreetingsPort", + "SendGreetingsResponsePort" + }, + new System.Type[] { + null, + null + } + )] + [Microsoft.XLANGs.BaseTypes.ServiceCallTreeAttribute( + new System.Type[] { + }, + new System.Type[] { + }, + new System.Type[] { + } + )] + [Microsoft.XLANGs.BaseTypes.ServiceAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal, + Microsoft.XLANGs.BaseTypes.EXLangSServiceInfo.eNone + )] + [System.SerializableAttribute] + [Microsoft.XLANGs.BaseTypes.BPELExportableAttribute(false)] + sealed internal class ProcessGreetingsOrchestration : Microsoft.BizTalk.XLANGs.BTXEngine.BTXService + { + public static readonly Microsoft.XLANGs.BaseTypes.EXLangSAccess __access = Microsoft.XLANGs.BaseTypes.EXLangSAccess.eInternal; + public static readonly bool __execable = false; + [Microsoft.XLANGs.BaseTypes.CallCompensationAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSCallCompensationInfo.eNone, + new System.String[] { + }, + new System.String[] { + } + )] + public static void __bodyProxy() + { + } + private static System.Guid _serviceId = Microsoft.XLANGs.Core.HashHelper.HashServiceType(typeof(ProcessGreetingsOrchestration)); + private static volatile System.Guid[] _activationSubIds; + + private static new object _lockIdentity = new object(); + + public static System.Guid UUID { get { return _serviceId; } } + public override System.Guid ServiceId { get { return UUID; } } + + protected override System.Guid[] ActivationSubGuids + { + get { return _activationSubIds; } + set { _activationSubIds = value; } + } + + protected override object StaleStateLock + { + get { return _lockIdentity; } + } + + protected override bool HasActivation { get { return true; } } + + internal bool IsExeced = false; + + static ProcessGreetingsOrchestration() + { + Microsoft.BizTalk.XLANGs.BTXEngine.BTXService.CacheStaticState( _serviceId ); + } + + private void ConstructorHelper() + { + _segments = new Microsoft.XLANGs.Core.Segment[] { + new Microsoft.XLANGs.Core.Segment( new Microsoft.XLANGs.Core.Segment.SegmentCode(this.segment0), 0, 0, 0), + new Microsoft.XLANGs.Core.Segment( new Microsoft.XLANGs.Core.Segment.SegmentCode(this.segment1), 1, 1, 1) + }; + + _Locks = 0; + _rootContext = new __ProcessGreetingsOrchestration_root_0(this); + _stateMgrs = new Microsoft.XLANGs.Core.IStateManager[2]; + _stateMgrs[0] = _rootContext; + FinalConstruct(); + } + + public ProcessGreetingsOrchestration(System.Guid instanceId, Microsoft.BizTalk.XLANGs.BTXEngine.BTXSession session, Microsoft.BizTalk.XLANGs.BTXEngine.BTXEvents tracker) + : base(instanceId, session, "ProcessGreetingsOrchestration", tracker) + { + ConstructorHelper(); + } + + public ProcessGreetingsOrchestration(int callIndex, System.Guid instanceId, Microsoft.BizTalk.XLANGs.BTXEngine.BTXService parent) + : base(callIndex, instanceId, parent, "ProcessGreetingsOrchestration") + { + ConstructorHelper(); + } + + private const string _symInfo = @" + + RootShape 9384ecff-3922-4f09-971a-bf53a2e3fc89 + + ReceiveShape 6df23575-3958-455e-8c01-4887d78d3bb9 ServiceBody_Statement Rcv Greetings + + + + ConstructShape 9481cdef-35eb-4f15-bfad-f0f322586dcb ServiceBody_Statement ConstructMessage_GreetingsResponse + + TransformShape d2504f0f-cb6c-489b-9792-b97220442f17 ComplexStatement_Statement Transform_GreetingsToGreeetingsResponse + + MessagePartRefShape 33c2b083-4a8d-4d13-9a64-7d4a295df2c6 Transform_InputMessagePartRef MessagePartReference_1 + + + + MessagePartRefShape 0f0fab43-bbfc-47c3-bf92-e3057d07dbd8 Transform_OutputMessagePartRef MessagePartReference_2 + + + + + + MessageRefShape a688f672-8a43-4659-aba9-515e9d84361c Construct_MessageRef + + + + + + SendShape 1944e460-8b7c-4d30-86e7-bf6a33c435b1 ServiceBody_Statement Snd Greetings + + + + + + + +'ProcessGreetingsOrchestration'017214'e211a116-cb8b-44e7-a052-0de295aa0001' + + + +18322'6df23575-3958-455e-8c01-4887d78d3bb9' + + GreetingsMsgpartDeploymentSampleApplication.GreetingsSchemaOut + + + + +18513'9481cdef-35eb-4f15-bfad-f0f322586dcb' + + GreetingsResponseMsgpartDeploymentSampleApplication.GreetingsResponseSchemaOut + GreetingsMsgpartDeploymentSampleApplication.GreetingsSchemaIn + + + + +19113'1944e460-8b7c-4d30-86e7-bf6a33c435b1' + + GreetingsResponseMsgpartDeploymentSampleApplication.GreetingsResponseSchemaOut + + + +"; + + public override string odXml { get { return _symODXML; } } + + private const string _symODXML = @" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"; + + [System.SerializableAttribute] + public class __ProcessGreetingsOrchestration_root_0 : Microsoft.XLANGs.Core.ServiceContext + { + public __ProcessGreetingsOrchestration_root_0(Microsoft.XLANGs.Core.Service svc) + : base(svc, "ProcessGreetingsOrchestration") + { + } + + public override int Index { get { return 0; } } + + public override Microsoft.XLANGs.Core.Segment InitialSegment + { + get { return _service._segments[0]; } + } + public override Microsoft.XLANGs.Core.Segment FinalSegment + { + get { return _service._segments[0]; } + } + + public override int CompensationSegment { get { return -1; } } + public override bool OnError() + { + Finally(); + return false; + } + + public override void Finally() + { + ProcessGreetingsOrchestration __svc__ = (ProcessGreetingsOrchestration)_service; + __ProcessGreetingsOrchestration_root_0 __ctx0__ = (__ProcessGreetingsOrchestration_root_0)(__svc__._stateMgrs[0]); + + if (__svc__.ReceiveGreetingsPort != null) + { + __svc__.ReceiveGreetingsPort.Close(this, null); + __svc__.ReceiveGreetingsPort = null; + } + if (__svc__.SendGreetingsResponsePort != null) + { + __svc__.SendGreetingsResponsePort.Close(this, null); + __svc__.SendGreetingsResponsePort = null; + } + base.Finally(); + } + + internal Microsoft.XLANGs.Core.SubscriptionWrapper __subWrapper0; + } + + + [System.SerializableAttribute] + public class __ProcessGreetingsOrchestration_1 : Microsoft.XLANGs.Core.ExceptionHandlingContext + { + public __ProcessGreetingsOrchestration_1(Microsoft.XLANGs.Core.Service svc) + : base(svc, "ProcessGreetingsOrchestration") + { + } + + public override int Index { get { return 1; } } + + public override bool CombineParentCommit { get { return true; } } + + public override Microsoft.XLANGs.Core.Segment InitialSegment + { + get { return _service._segments[1]; } + } + public override Microsoft.XLANGs.Core.Segment FinalSegment + { + get { return _service._segments[1]; } + } + + public override int CompensationSegment { get { return -1; } } + public override bool OnError() + { + Finally(); + return false; + } + + public override void Finally() + { + ProcessGreetingsOrchestration __svc__ = (ProcessGreetingsOrchestration)_service; + __ProcessGreetingsOrchestration_1 __ctx1__ = (__ProcessGreetingsOrchestration_1)(__svc__._stateMgrs[1]); + + if (__ctx1__ != null && __ctx1__.__GreetingsMsg != null) + { + __ctx1__.UnrefMessage(__ctx1__.__GreetingsMsg); + __ctx1__.__GreetingsMsg = null; + } + if (__ctx1__ != null && __ctx1__.__GreetingsResponseMsg != null) + { + __ctx1__.UnrefMessage(__ctx1__.__GreetingsResponseMsg); + __ctx1__.__GreetingsResponseMsg = null; + } + base.Finally(); + } + + [Microsoft.XLANGs.Core.UserVariableAttribute("GreetingsMsg")] + public __messagetype_DeploymentSampleApplication_GreetingsSchema __GreetingsMsg; + [Microsoft.XLANGs.Core.UserVariableAttribute("GreetingsResponseMsg")] + public __messagetype_DeploymentSampleApplication_GreetingsResponseSchema __GreetingsResponseMsg; + } + + private static Microsoft.XLANGs.Core.CorrelationType[] _correlationTypes = null; + public override Microsoft.XLANGs.Core.CorrelationType[] CorrelationTypes { get { return _correlationTypes; } } + + private static System.Guid[] _convoySetIds; + + public override System.Guid[] ConvoySetGuids + { + get { return _convoySetIds; } + set { _convoySetIds = value; } + } + + public static object[] StaticConvoySetInformation + { + get { + return null; + } + } + + [Microsoft.XLANGs.BaseTypes.LogicalBindingAttribute()] + [Microsoft.XLANGs.BaseTypes.PortAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSParameter.eImplements + )] + [Microsoft.XLANGs.Core.UserVariableAttribute("ReceiveGreetingsPort")] + internal ReceiveGreetingsPortType ReceiveGreetingsPort; + [Microsoft.XLANGs.BaseTypes.LogicalBindingAttribute()] + [Microsoft.XLANGs.BaseTypes.PortAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSParameter.eUses + )] + [Microsoft.XLANGs.Core.UserVariableAttribute("SendGreetingsResponsePort")] + internal SendGreetingsResponsePortType SendGreetingsResponsePort; + + public static Microsoft.XLANGs.Core.PortInfo[] _portInfo = new Microsoft.XLANGs.Core.PortInfo[] { + new Microsoft.XLANGs.Core.PortInfo(new Microsoft.XLANGs.Core.OperationInfo[] {ReceiveGreetingsPortType.RcvGreetingsOperation}, + typeof(ProcessGreetingsOrchestration).GetField("ReceiveGreetingsPort", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance), + Microsoft.XLANGs.BaseTypes.Polarity.implements, + false, + Microsoft.XLANGs.Core.HashHelper.HashPort(typeof(ProcessGreetingsOrchestration), "ReceiveGreetingsPort"), + null), + new Microsoft.XLANGs.Core.PortInfo(new Microsoft.XLANGs.Core.OperationInfo[] {SendGreetingsResponsePortType.SendGreetingsResponseOperation}, + typeof(ProcessGreetingsOrchestration).GetField("SendGreetingsResponsePort", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance), + Microsoft.XLANGs.BaseTypes.Polarity.uses, + false, + Microsoft.XLANGs.Core.HashHelper.HashPort(typeof(ProcessGreetingsOrchestration), "SendGreetingsResponsePort"), + null) + }; + + public override Microsoft.XLANGs.Core.PortInfo[] PortInformation + { + get { return _portInfo; } + } + + static public System.Collections.Hashtable PortsInformation + { + get + { + System.Collections.Hashtable h = new System.Collections.Hashtable(); + h[_portInfo[0].Name] = _portInfo[0]; + h[_portInfo[1].Name] = _portInfo[1]; + return h; + } + } + + public static System.Type[] InvokedServicesTypes + { + get + { + return new System.Type[] { + // type of each service invoked by this service + }; + } + } + + public static System.Type[] CalledServicesTypes + { + get + { + return new System.Type[] { + }; + } + } + + public static System.Type[] ExecedServicesTypes + { + get + { + return new System.Type[] { + }; + } + } + + public static object[] StaticSubscriptionsInformation { + get { + return new object[1]{ + new object[5] { _portInfo[0], 0, null , -1, true } + }; + } + } + + public static Microsoft.XLANGs.RuntimeTypes.Location[] __eventLocations = new Microsoft.XLANGs.RuntimeTypes.Location[] { + new Microsoft.XLANGs.RuntimeTypes.Location(0, "00000000-0000-0000-0000-000000000000", 1, true), + new Microsoft.XLANGs.RuntimeTypes.Location(1, "6df23575-3958-455e-8c01-4887d78d3bb9", 1, true), + new Microsoft.XLANGs.RuntimeTypes.Location(2, "6df23575-3958-455e-8c01-4887d78d3bb9", 1, false), + new Microsoft.XLANGs.RuntimeTypes.Location(3, "9481cdef-35eb-4f15-bfad-f0f322586dcb", 1, true), + new Microsoft.XLANGs.RuntimeTypes.Location(4, "9481cdef-35eb-4f15-bfad-f0f322586dcb", 1, false), + new Microsoft.XLANGs.RuntimeTypes.Location(5, "1944e460-8b7c-4d30-86e7-bf6a33c435b1", 1, true), + new Microsoft.XLANGs.RuntimeTypes.Location(6, "1944e460-8b7c-4d30-86e7-bf6a33c435b1", 1, false), + new Microsoft.XLANGs.RuntimeTypes.Location(7, "00000000-0000-0000-0000-000000000000", 1, false) + }; + + public override Microsoft.XLANGs.RuntimeTypes.Location[] EventLocations + { + get { return __eventLocations; } + } + + public static Microsoft.XLANGs.RuntimeTypes.EventData[] __eventData = new Microsoft.XLANGs.RuntimeTypes.EventData[] { + new Microsoft.XLANGs.RuntimeTypes.EventData( Microsoft.XLANGs.RuntimeTypes.Operation.Start | Microsoft.XLANGs.RuntimeTypes.Operation.Body), + new Microsoft.XLANGs.RuntimeTypes.EventData( Microsoft.XLANGs.RuntimeTypes.Operation.Start | Microsoft.XLANGs.RuntimeTypes.Operation.Receive), + new Microsoft.XLANGs.RuntimeTypes.EventData( Microsoft.XLANGs.RuntimeTypes.Operation.Start | Microsoft.XLANGs.RuntimeTypes.Operation.Construct), + new Microsoft.XLANGs.RuntimeTypes.EventData( Microsoft.XLANGs.RuntimeTypes.Operation.Start | Microsoft.XLANGs.RuntimeTypes.Operation.Send), + new Microsoft.XLANGs.RuntimeTypes.EventData( Microsoft.XLANGs.RuntimeTypes.Operation.End | Microsoft.XLANGs.RuntimeTypes.Operation.Body) + }; + + public static int[] __progressLocation0 = new int[] { 0,0,0,7,7,}; + public static int[] __progressLocation1 = new int[] { 0,0,1,1,2,3,3,4,5,5,5,6,7,7,7,7,}; + + public static int[][] __progressLocations = new int[2] [] {__progressLocation0,__progressLocation1}; + public override int[][] ProgressLocations {get {return __progressLocations;} } + + public Microsoft.XLANGs.Core.StopConditions segment0(Microsoft.XLANGs.Core.StopConditions stopOn) + { + Microsoft.XLANGs.Core.Segment __seg__ = _segments[0]; + Microsoft.XLANGs.Core.Context __ctx__ = (Microsoft.XLANGs.Core.Context)_stateMgrs[0]; + __ProcessGreetingsOrchestration_root_0 __ctx0__ = (__ProcessGreetingsOrchestration_root_0)_stateMgrs[0]; + __ProcessGreetingsOrchestration_1 __ctx1__ = (__ProcessGreetingsOrchestration_1)_stateMgrs[1]; + + switch (__seg__.Progress) + { + case 0: + ReceiveGreetingsPort = new ReceiveGreetingsPortType(0, this); + SendGreetingsResponsePort = new SendGreetingsResponsePortType(1, this); + __ctx__.PrologueCompleted = true; + __ctx0__.__subWrapper0 = new Microsoft.XLANGs.Core.SubscriptionWrapper(ActivationSubGuids[0], ReceiveGreetingsPort, this); + if ( !PostProgressInc( __seg__, __ctx__, 1 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + if ((stopOn & Microsoft.XLANGs.Core.StopConditions.Initialized) != 0) + return Microsoft.XLANGs.Core.StopConditions.Initialized; + goto case 1; + case 1: + __ctx1__ = new __ProcessGreetingsOrchestration_1(this); + _stateMgrs[1] = __ctx1__; + if ( !PostProgressInc( __seg__, __ctx__, 2 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 2; + case 2: + __ctx0__.StartContext(__seg__, __ctx1__); + if ( !PostProgressInc( __seg__, __ctx__, 3 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + return Microsoft.XLANGs.Core.StopConditions.Blocked; + case 3: + if (!__ctx0__.CleanupAndPrepareToCommit(__seg__)) + return Microsoft.XLANGs.Core.StopConditions.Blocked; + if ( !PostProgressInc( __seg__, __ctx__, 4 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 4; + case 4: + __ctx1__.Finally(); + ServiceDone(__seg__, (Microsoft.XLANGs.Core.Context)_stateMgrs[0]); + __ctx0__.OnCommit(); + break; + } + return Microsoft.XLANGs.Core.StopConditions.Completed; + } + + public Microsoft.XLANGs.Core.StopConditions segment1(Microsoft.XLANGs.Core.StopConditions stopOn) + { + Microsoft.XLANGs.Core.Envelope __msgEnv__ = null; + Microsoft.XLANGs.Core.Segment __seg__ = _segments[1]; + Microsoft.XLANGs.Core.Context __ctx__ = (Microsoft.XLANGs.Core.Context)_stateMgrs[1]; + __ProcessGreetingsOrchestration_root_0 __ctx0__ = (__ProcessGreetingsOrchestration_root_0)_stateMgrs[0]; + __ProcessGreetingsOrchestration_1 __ctx1__ = (__ProcessGreetingsOrchestration_1)_stateMgrs[1]; + + switch (__seg__.Progress) + { + case 0: + __ctx__.PrologueCompleted = true; + if ( !PostProgressInc( __seg__, __ctx__, 1 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 1; + case 1: + if ( !PreProgressInc( __seg__, __ctx__, 2 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + Tracker.FireEvent(__eventLocations[0],__eventData[0],_stateMgrs[1].TrackDataStream ); + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 2; + case 2: + if ( !PreProgressInc( __seg__, __ctx__, 3 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + Tracker.FireEvent(__eventLocations[1],__eventData[1],_stateMgrs[1].TrackDataStream ); + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 3; + case 3: + if (!ReceiveGreetingsPort.GetMessageId(__ctx0__.__subWrapper0.getSubscription(this), __seg__, __ctx1__, out __msgEnv__)) + return Microsoft.XLANGs.Core.StopConditions.Blocked; + if (__ctx1__.__GreetingsMsg != null) + __ctx1__.UnrefMessage(__ctx1__.__GreetingsMsg); + __ctx1__.__GreetingsMsg = new __messagetype_DeploymentSampleApplication_GreetingsSchema("GreetingsMsg", __ctx1__); + __ctx1__.RefMessage(__ctx1__.__GreetingsMsg); + ReceiveGreetingsPort.ReceiveMessage(0, __msgEnv__, __ctx1__.__GreetingsMsg, null, (Microsoft.XLANGs.Core.Context)_stateMgrs[1], __seg__); + if (ReceiveGreetingsPort != null) + { + ReceiveGreetingsPort.Close(__ctx1__, __seg__); + ReceiveGreetingsPort = null; + } + if ( !PostProgressInc( __seg__, __ctx__, 4 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 4; + case 4: + if ( !PreProgressInc( __seg__, __ctx__, 5 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + { + Microsoft.XLANGs.RuntimeTypes.EventData __edata = new Microsoft.XLANGs.RuntimeTypes.EventData(Microsoft.XLANGs.RuntimeTypes.Operation.End | Microsoft.XLANGs.RuntimeTypes.Operation.Receive); + __edata.Messages.Add(__ctx1__.__GreetingsMsg); + __edata.PortName = @"ReceiveGreetingsPort"; + Tracker.FireEvent(__eventLocations[2],__edata,_stateMgrs[1].TrackDataStream ); + } + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 5; + case 5: + if ( !PreProgressInc( __seg__, __ctx__, 6 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + Tracker.FireEvent(__eventLocations[3],__eventData[2],_stateMgrs[1].TrackDataStream ); + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 6; + case 6: + { + __messagetype_DeploymentSampleApplication_GreetingsResponseSchema __GreetingsResponseMsg = new __messagetype_DeploymentSampleApplication_GreetingsResponseSchema("GreetingsResponseMsg", __ctx1__); + + ApplyTransform(typeof(DeploymentSampleApplication.GreetingsToGreetingsResponseMap), new object[] {__GreetingsResponseMsg.part}, new object[] {__ctx1__.__GreetingsMsg.part}); + + if (__ctx1__.__GreetingsResponseMsg != null) + __ctx1__.UnrefMessage(__ctx1__.__GreetingsResponseMsg); + __ctx1__.__GreetingsResponseMsg = __GreetingsResponseMsg; + __ctx1__.RefMessage(__ctx1__.__GreetingsResponseMsg); + } + __ctx1__.__GreetingsResponseMsg.ConstructionCompleteEvent(true); + if ( !PostProgressInc( __seg__, __ctx__, 7 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 7; + case 7: + if ( !PreProgressInc( __seg__, __ctx__, 8 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + { + Microsoft.XLANGs.RuntimeTypes.EventData __edata = new Microsoft.XLANGs.RuntimeTypes.EventData(Microsoft.XLANGs.RuntimeTypes.Operation.End | Microsoft.XLANGs.RuntimeTypes.Operation.Construct); + __edata.Messages.Add(__ctx1__.__GreetingsResponseMsg); + __edata.Messages.Add(__ctx1__.__GreetingsMsg); + Tracker.FireEvent(__eventLocations[4],__edata,_stateMgrs[1].TrackDataStream ); + } + if (__ctx1__ != null && __ctx1__.__GreetingsMsg != null) + { + __ctx1__.UnrefMessage(__ctx1__.__GreetingsMsg); + __ctx1__.__GreetingsMsg = null; + } + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 8; + case 8: + if ( !PreProgressInc( __seg__, __ctx__, 9 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + Tracker.FireEvent(__eventLocations[5],__eventData[3],_stateMgrs[1].TrackDataStream ); + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 9; + case 9: + if (!__ctx1__.PrepareToPendingCommit(__seg__)) + return Microsoft.XLANGs.Core.StopConditions.Blocked; + if ( !PostProgressInc( __seg__, __ctx__, 10 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 10; + case 10: + if ( !PreProgressInc( __seg__, __ctx__, 11 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + SendGreetingsResponsePort.SendMessage(0, __ctx1__.__GreetingsResponseMsg, null, null, __ctx1__, __seg__ , Microsoft.XLANGs.Core.ActivityFlags.NextActivityPersists ); + if (SendGreetingsResponsePort != null) + { + SendGreetingsResponsePort.Close(__ctx1__, __seg__); + SendGreetingsResponsePort = null; + } + if ((stopOn & Microsoft.XLANGs.Core.StopConditions.OutgoingRqst) != 0) + return Microsoft.XLANGs.Core.StopConditions.OutgoingRqst; + goto case 11; + case 11: + if ( !PreProgressInc( __seg__, __ctx__, 12 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + { + Microsoft.XLANGs.RuntimeTypes.EventData __edata = new Microsoft.XLANGs.RuntimeTypes.EventData(Microsoft.XLANGs.RuntimeTypes.Operation.End | Microsoft.XLANGs.RuntimeTypes.Operation.Send); + __edata.Messages.Add(__ctx1__.__GreetingsResponseMsg); + __edata.PortName = @"SendGreetingsResponsePort"; + Tracker.FireEvent(__eventLocations[6],__edata,_stateMgrs[1].TrackDataStream ); + } + if (__ctx1__ != null && __ctx1__.__GreetingsResponseMsg != null) + { + __ctx1__.UnrefMessage(__ctx1__.__GreetingsResponseMsg); + __ctx1__.__GreetingsResponseMsg = null; + } + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 12; + case 12: + if ( !PreProgressInc( __seg__, __ctx__, 13 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + Tracker.FireEvent(__eventLocations[7],__eventData[4],_stateMgrs[1].TrackDataStream ); + if (IsDebugged) + return Microsoft.XLANGs.Core.StopConditions.InBreakpoint; + goto case 13; + case 13: + if (!__ctx1__.CleanupAndPrepareToCommit(__seg__)) + return Microsoft.XLANGs.Core.StopConditions.Blocked; + if ( !PostProgressInc( __seg__, __ctx__, 14 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + goto case 14; + case 14: + if ( !PreProgressInc( __seg__, __ctx__, 15 ) ) + return Microsoft.XLANGs.Core.StopConditions.Paused; + __ctx1__.OnCommit(); + goto case 15; + case 15: + __seg__.SegmentDone(); + _segments[0].PredecessorDone(this); + break; + } + return Microsoft.XLANGs.Core.StopConditions.Completed; + } + } + + [System.SerializableAttribute] + sealed public class __DeploymentSampleApplication_GreetingsSchema__ : Microsoft.XLANGs.Core.XSDPart + { + private static DeploymentSampleApplication.GreetingsSchema _schema = new DeploymentSampleApplication.GreetingsSchema(); + + public __DeploymentSampleApplication_GreetingsSchema__(Microsoft.XLANGs.Core.XMessage msg, string name, int index) : base(msg, name, index) { } + + + #region part reflection support + public static Microsoft.XLANGs.BaseTypes.SchemaBase PartSchema { get { return (Microsoft.XLANGs.BaseTypes.SchemaBase)_schema; } } + #endregion // part reflection support + } + + [Microsoft.XLANGs.BaseTypes.MessageTypeAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSAccess.ePublic, + Microsoft.XLANGs.BaseTypes.EXLangSMessageInfo.eThirdKind, + "DeploymentSampleApplication.GreetingsSchema", + new System.Type[]{ + typeof(DeploymentSampleApplication.GreetingsSchema) + }, + new string[]{ + "part" + }, + new System.Type[]{ + typeof(__DeploymentSampleApplication_GreetingsSchema__) + }, + 0, + @"http://DeploymentSampleApplication.GreetingsSchema#Greetings" + )] + [System.SerializableAttribute] + sealed public class __messagetype_DeploymentSampleApplication_GreetingsSchema : Microsoft.BizTalk.XLANGs.BTXEngine.BTXMessage + { + public __DeploymentSampleApplication_GreetingsSchema__ part; + + private void __CreatePartWrappers() + { + part = new __DeploymentSampleApplication_GreetingsSchema__(this, "part", 0); + this.AddPart("part", 0, part); + } + + public __messagetype_DeploymentSampleApplication_GreetingsSchema(string msgName, Microsoft.XLANGs.Core.Context ctx) : base(msgName, ctx) + { + __CreatePartWrappers(); + } + } + + [System.SerializableAttribute] + sealed public class __DeploymentSampleApplication_GreetingsResponseSchema__ : Microsoft.XLANGs.Core.XSDPart + { + private static DeploymentSampleApplication.GreetingsResponseSchema _schema = new DeploymentSampleApplication.GreetingsResponseSchema(); + + public __DeploymentSampleApplication_GreetingsResponseSchema__(Microsoft.XLANGs.Core.XMessage msg, string name, int index) : base(msg, name, index) { } + + + #region part reflection support + public static Microsoft.XLANGs.BaseTypes.SchemaBase PartSchema { get { return (Microsoft.XLANGs.BaseTypes.SchemaBase)_schema; } } + #endregion // part reflection support + } + + [Microsoft.XLANGs.BaseTypes.MessageTypeAttribute( + Microsoft.XLANGs.BaseTypes.EXLangSAccess.ePublic, + Microsoft.XLANGs.BaseTypes.EXLangSMessageInfo.eThirdKind, + "DeploymentSampleApplication.GreetingsResponseSchema", + new System.Type[]{ + typeof(DeploymentSampleApplication.GreetingsResponseSchema) + }, + new string[]{ + "part" + }, + new System.Type[]{ + typeof(__DeploymentSampleApplication_GreetingsResponseSchema__) + }, + 0, + @"http://DeploymentSampleApplication.GreetingsResponseSchema#GreetingsResponse" + )] + [System.SerializableAttribute] + sealed public class __messagetype_DeploymentSampleApplication_GreetingsResponseSchema : Microsoft.BizTalk.XLANGs.BTXEngine.BTXMessage + { + public __DeploymentSampleApplication_GreetingsResponseSchema__ part; + + private void __CreatePartWrappers() + { + part = new __DeploymentSampleApplication_GreetingsResponseSchema__(this, "part", 0); + this.AddPart("part", 0, part); + } + + public __messagetype_DeploymentSampleApplication_GreetingsResponseSchema(string msgName, Microsoft.XLANGs.Core.Context ctx) : base(msgName, ctx) + { + __CreatePartWrappers(); + } + } + + [Microsoft.XLANGs.BaseTypes.BPELExportableAttribute(false)] + sealed public class _MODULE_PROXY_ { } +} diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.dll b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.dll new file mode 100644 index 0000000..27aa6be Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.dll differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.pdb b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.pdb new file mode 100644 index 0000000..28a3b9d Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/bin/Development/DeploymentSampleApplication.pdb differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.dll b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.dll new file mode 100644 index 0000000..27aa6be Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.dll differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.pdb b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.pdb new file mode 100644 index 0000000..28a3b9d Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/DeploymentSampleApplication/obj/Development/DeploymentSampleApplication.pdb differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/Documents/GreetingsSchemaInstance.xml b/Samples/Chapter10/DeploymentSampleApplication/Documents/GreetingsSchemaInstance.xml new file mode 100644 index 0000000..310ee92 Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/Documents/GreetingsSchemaInstance.xml differ diff --git a/Samples/Chapter10/DeploymentSampleApplication/Important.txt b/Samples/Chapter10/DeploymentSampleApplication/Important.txt new file mode 100644 index 0000000..a38898c --- /dev/null +++ b/Samples/Chapter10/DeploymentSampleApplication/Important.txt @@ -0,0 +1 @@ +At the time of printing a mistake was present in Exercise 10-2. To complete it successfully, please replace all occurrences of the folder "C:\PROBIZTALK\DeploymentSampleApplication\" to "C:\DeploymentSampleApplication\". diff --git a/Samples/Chapter10/DeploymentSampleApplication/PROBIZTALK.snk b/Samples/Chapter10/DeploymentSampleApplication/PROBIZTALK.snk new file mode 100644 index 0000000..653d0a1 Binary files /dev/null and b/Samples/Chapter10/DeploymentSampleApplication/PROBIZTALK.snk differ diff --git a/Samples/Chapter11/MsgBoxAnalysisQueries.sql b/Samples/Chapter11/MsgBoxAnalysisQueries.sql new file mode 100644 index 0000000..19ac076 --- /dev/null +++ b/Samples/Chapter11/MsgBoxAnalysisQueries.sql @@ -0,0 +1,90 @@ +-- --------------------------------------------------- +-- Get the number of rows in the spool table (backlog) +-- --------------------------------------------------- +SET NOCOUNT ON +SET TRANSACTION ISOLATION LEVEL READ COMMITTED +SET DEADLOCK_PRIORITY LOW +SELECT COUNT(*) as Messages, + 'Spooled Messages' as State +FROM [BizTalkMsgboxDb]..[spool] WITH (NOLOCK) +-- --------------------------------------------------- + +-- --------------------------------------------------------- +-- Get the number of orchestrations and their state per host +-- --------------------------------------------------------- +SET NOCOUNT ON +SET TRANSACTION ISOLATION LEVEL READ COMMITTED +SET DEADLOCK_PRIORITY LOW +SELECT o.nvcName AS Orchestration, COUNT(*) as Count, + CASE i.nState + WHEN 1 THEN 'Ready To Run' + WHEN 2 THEN 'Active' + WHEN 4 THEN 'Suspended Resumable' + WHEN 8 THEN 'Dehydrated' + WHEN 16 THEN 'Completed With Discarded Messages' + WHEN 32 THEN 'Suspended Non-Resumable' + END as State +FROM [BizTalkMsgboxDb]..[Instances] AS i WITH (NOLOCK) +JOIN [BizTalkMgmtDb]..[bts_Orchestration] AS o +WITH (NOLOCK) ON i.uidServiceID = o.uidGUID +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' +GROUP BY o.nvcName, i.nState +-- --------------------------------------------------------- + + +-- ---------------------------------------------------------- +-- Get the number of Messages per host Q +-- IMPORTANT! Replace each instance of Q with the name of the +-- host that you are inspecting. +-- and the number of messages in the spool that are in that Q +-- ---------------------------------------------------------- +SET NOCOUNT ON +SET TRANSACTION ISOLATION LEVEL READ COMMITTED +SET DEADLOCK_PRIORITY LOW + +SELECT COUNT(*) as Messages, 'Suspended Non-Resumable' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgBoxDb]..[BizTalkServerIsolatedHostQ_Suspended] +WITH (NOLOCK) +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' +SELECT COUNT(*) as Messages, + 'Spooled Suspended Non-Resumable' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgboxDb]..[spool] AS i WITH (NOLOCK) +JOIN [BizTalkMsgboxDb]..[BizTalkServerIsolatedHostQ_Suspended] AS o +WITH (NOLOCK) ON i.uidMessageID = o.uidMessageID +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' + +SELECT COUNT(*) as Messages, 'Scheduled' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgBoxDb]..[BizTalkServerIsolatedHostQ_Scheduled] +WITH (NOLOCK) +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' + +SELECT COUNT(*) as Count, 'Spooled Scheduled' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgboxDb]..[spool] AS i WITH (NOLOCK) +JOIN [BizTalkMsgboxDb]..[BizTalkServerIsolatedHostQ_Scheduled] +AS o WITH (NOLOCK) ON i.uidMessageID = o.uidMessageID +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' + +SELECT COUNT(*) as Messages, 'Active' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgBoxDb]..[BizTalkServerIsolatedHostQ] +WITH (NOLOCK) +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' + +SELECT COUNT(*) as Count, 'Spooled Active' as State, + 'BizTalk Server Isolated Host' as Server +FROM [BizTalkMsgboxDb]..[spool] AS i WITH (NOLOCK) +JOIN [BizTalkMsgboxDb]..[BizTalkServerIsolatedHostQ] AS o +WITH (NOLOCK) ON i.uidMessageID = o.uidMessageID +--WHERE dtCreated > '2004-08-24 00:00:00' +--AND dtCreated < '2004-08-24 13:30:00' +-- ---------------------------------------------------------- diff --git a/Samples/Chapter11/SuspendedInstancesCleanup.vbs b/Samples/Chapter11/SuspendedInstancesCleanup.vbs new file mode 100644 index 0000000..b0bf7da --- /dev/null +++ b/Samples/Chapter11/SuspendedInstancesCleanup.vbs @@ -0,0 +1,237 @@ +dim objServices, objMsg, svcinsts, inst, msg, ndx, size, nHostCount + +Dim aryClassIDs() +Dim aryTypeIDs() +Dim aryInstanceIDs() + +Dim aryClassIDsTemp() +Dim aryTypeIDsTemp() +Dim aryInstanceIDsTemp() +'----------------------------------------------- +Dim strKey2Instance +Dim strQuery2Msg +Dim objQueue + +'----------------------------------------------- +'-- Creating and opening log file to append info +'----------------------------------------------- +Dim strDirectory, strFile, objFSO, objTextFile +strDirectory = "c:" +strFile = "\TermallScriptResults.txt" +'Create the File System Object +Set objFSO = CreateObject("Scripting.FileSystemObject") + +'Check that the folder and file exists +If objFSO.FileExists(strDirectory & strFile) Then + 'OpenTextFile Method needs a Const value + 'ForAppending = 8 ForReading = 1, ForWriting = 2 + Const ForAppending = 8 + Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, + ForAppending, True) +Else + Set objTextFile = objFSO.CreateTextFile(strDirectory & strFile) +End If + +'--------------------------- +'-- Set the object reference +'--------------------------- +set objServices = GetObject("winmgmts:\\.\root\MicrosoftBizTalkServer") + +'-------------------------------------------------------------------- +'-- Create array of hostnames to loop over hosts +'-- increase the array's size, +'-- add as many hostnames as required to the array, +'-- and initialize the corresponding aryHostSuspendedMessages entries +'-------------------------------------------------------------------- +Dim aryHostNames(1) +Dim aryHostSuspsendedMessages(1) +aryHostNames(0) = "BizTalkServerApplication" +aryHostNames(1) = "BizTalkServerIsolatedHost" +aryHostSuspsendedMessages(0) = 0 +aryHostSuspsendedMessages(1) = 0 +'-------------------------------------------------------------------------- +'-- The maximum number of suspended instances to clean up in a single batch +'-------------------------------------------------------------------------- +Dim nMaxInstancesToClean +nMaxInstancesToClean = 500 + + +Dim strHost +nHostCount = 0 + +objTextFile.WriteLine("------- SCRIPT EXECUTION STARTED -------") + +'-------------------------------------------------------------------- +'-- Terminate instance in each suspended Queue for the selected hosts +'-------------------------------------------------------------------- +for each strHost in aryHostNames + + 'wscript.echo "Host: " & strHost + objTextFile.WriteLine("----------------------------------------") + objTextFile.WriteLine(Now() & " : Host: " & strHost) + +'-------------------------------- +'-- Query for Suspended instances +'-------------------------------- + wbemFlagReturnImmediately = 16 + wbemFlagForwardOnly = 32 + IFlags = wbemFlagReturnImmediately + wbemFlagForwardOnly + set svcinsts = objServices.ExecQuery( + "select * from MSBTS_serviceinstance + where (servicestatus=32 or servicestatus=4) + and HostName="""&strHost&"""",, IFlags) + + 'Using a semi-synchronous therefore the count property doesn't + 'work with wbemFlagForwardOnly + 'size = svcinsts.Count + 'wscript.echo "Suspended Message: " & size + + strKey2Instance = "MSBTS_HostQueue.HostName=""" & strHost & """" + + set objQueue = objServices.Get(strKey2Instance) + + If Err <> 0 Then + + wscript.echo Now() & " : Failed to get MSBTS_HostQueue instance" + wscript.echo Now() & " : " & Err.Description & Err.Number + objTextFile.WriteLine(Now() & " : + Failed to get MSBTS_HostQueue instance") + objTextFile.WriteLine(Now() & " : " + Err.Description & Err.Number) + + Else + + ndx = 0 + + redim aryClassIDs(nMaxInstancesToClean) + redim aryTypeIDs(nMaxInstancesToClean) + redim aryInstanceIDs(nMaxInstancesToClean) + + 'Loop through all instances and terminate nMaxInstancesToClean at a + 'time. + 'This number was choosen for optimization, so it can be changed if + 'desired. + for each inst in svcinsts + + If ndx > nMaxInstancesToClean Then + 'Currently 500 entries are ready to be terminated + + 'wscript.echo "Attempting to terminate " + '& ndx & " suspended instances in host" + objTextFile.WriteLine(Now() & + " : Attempting to terminate " + & ndx & " suspended instances in host") + + objQueue.TerminateServiceInstancesByID aryClassIDs, + aryTypeIDs, aryInstanceIDs + + If Err <> 0 Then + wscript.echo Now() & " : Terminate failed" + wscript.echo Now() & " : " & Err.Description + & Err.Number + objTextFile.WriteLine(Now() & " : Terminate failed") + objTextFile.WriteLine(Now() & " : " + Err.Description + & Err.Number) + Else + 'wscript.echo "SUCCESS> " & ndx & + '" Service instance terminated" + objTextFile.WriteLine(Now() & + " : SUCCESS> " & ndx & + " Service instance terminated") + End If + + 'Reinitialize the arrays and counter + 'to ensure we store non-terminated + 'Entries for the next round of termination + ndx = 0 + redim aryClassIDs(nMaxInstancesToClean) + redim aryTypeIDs(nMaxInstancesToClean) + redim aryInstanceIDs(nMaxInstancesToClean) + + 'Suspends script execution for 30 seconds, + 'then continues execution + 'wscript.echo "Suspending script execution for 30 seconds" + objTextFile.WriteLine(Now() & + " : Suspending script execution for 30 seconds") + Wscript.Sleep 30000 + + End If + + aryClassIDs(ndx) = inst.Properties_("ServiceClassId") + aryTypeIDs(ndx) = inst.Properties_("ServiceTypeId") + aryInstanceIDs(ndx) = inst.Properties_("InstanceId") + + ndx = ndx + 1 + + next + + 'If count <> zero then the arrays are still populated + 'and the messages need to be terminated one last time. + If ( ndx > 0 ) then + + redim aryClassIDsTemp(ndx-1) + redim aryTypeIDsTemp(ndx-1) + redim aryInstanceIDsTemp(ndx-1) + + for i=1 to ndx + aryClassIDsTemp(i-1) = aryClassIDs(i-1) + aryTypeIDsTemp(i-1) = aryTypeIDs(i-1) + aryInstanceIDsTemp(i-1) = aryInstanceIDs(i-1) + aryHostSuspsendedMessages(nHostCount) = + aryHostSuspsendedMessages(nHostCount) + 1 + next + + 'wscript.echo "Attempting to terminate " & + 'ndx & " suspended instances in host" + objTextFile.WriteLine(Now() & + " : Attempting to terminate " & ndx & + " suspended instances in host") + + objQueue.TerminateServiceInstancesByID aryClassIDsTemp, + aryTypeIDsTemp, aryInstanceIDsTemp + + If Err <> 0 Then + wscript.echo Now() & " : Terminate failed" + wscript.echo Now() & " : " & Err.Description & Err.Number + objTextFile.WriteLine(Now() & " : Terminate failed") + objTextFile.WriteLine(Now() & + " : " + Err.Description & Err.Number) + Else + 'wscript.echo "SUCCESS> " & ndx & + '" Service instance terminated" + objTextFile.WriteLine(Now() & + " : SUCCESS> " & ndx & " Service instance terminated") + End If + Else + 'wscript.echo "No suspended instances in this host" + objTextFile.WriteLine(Now() & + " : No suspended instances in this host") + End If + End If + + nHostCount = nHostCount + 1 + +Next + +objTextFile.WriteLine("") +objTextFile.WriteLine("------- SUMMARY START -------") + +nHostCount = 0 +for each strHost in aryHostNames + wscript.echo Now() & " : Total of " & + aryHostSuspsendedMessages(nHostCount) & + " suspended messages were terminated in " & + strHost & " host" + objTextFile.WriteLine(Now() & " : Total of " & + aryHostSuspsendedMessages(nHostCount) & + " suspended messages were terminated in " & + strHost & " host") + nHostCount = nHostCount + 1 +Next +objTextFile.WriteLine("------- SUMMARY END -------") +objTextFile.WriteLine("") + +wscript.echo Now() & " : Script Execution Completed" +objTextFile.WriteLine(Now() & " : Script Execution Completed") +objTextFile.WriteLine("------- SCRIPT EXECUTION ENDED -------") +objTextFile.Close +Set objTextFile = nothing diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/AssemblyInfo.vb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/AssemblyInfo.vb new file mode 100644 index 0000000..ecce02e --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.resx b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.resx new file mode 100644 index 0000000..7ec3f1f --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.resx @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Large File Decoder + + + Decodes large files + + + 1.0.0.0 + + + + + Qk02EAAAAAAAADYAAAAoAAAAIAAAACAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AIFoVgBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJ + NQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AhGtZAPTbzgDewLEA3L6uANu8rADbu6oA2bmoANi3 + pQDYtaMA17OhANaxnwDWsJwA1K2aANSrlwDSqpYA0qiTANCmkQDQpI8Az6ONAM+giwDNn4kAzZ6HAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCGblsA9NzRAPru6QD57OYA+erjAPfn + 3wD45dwA9+PaAPbg1wD139QA9N3RAPTbzgDz2MsA89bIAPLTxQDx0cIA8c+/APDNvADvy7kA78m2AO7H + tADNoIkAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AIlwXgD139MA+vDsAPnu + 6AD56+YA+eniAPjn3wD45dwA9uPaAPXh1gD13tQA9d3RAPTazQDz2MsA89XIAPLTxQDx0cEA8M++AO/N + vADvyrkA78i3AM+hiwBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8Ai3NhAPbg + 1gD78u4A+vHrAKyZiwCJcV8A0L6yAM66rgDNuKsAy7aoAMy1qADeyLoA79fLAPTazQD02MoA89XIAPLT + xADx0MEA8c6/APDMuwDvy7kA0KKNAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCNdmQA9uLYAPz08gD88+4Ahm5bALyjlgB6YE0AdVxJAHJYRABuVUAAfGNQALihkgDdxbgA9dzQAPTZ + zgDz2MoA89XIAPHTxADx0MEA8M6/APDMvADQpI8AY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AI94ZwD35NsA/Pb0APz08QCKcmAAzLivAHNaRwB/ZlUAjHNjAI11ZgB/Z1gAblVBAK+X + iAD13tMA9NzQAPTazgDz18oA89XHAPLTxADx0cEA8M6+ANGmkQBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8AkntpAPjm3gD9+fYA/PfzAI52ZQDe0coAp4+CANXGvQDEsKQAuqOVAKyQ + fgCVemcAfGNQAPXh1gD13tMA9dzQAPTazQDz18oA89XHAPLSwwDx0cEA0qmUAGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wCVfWwA+OjhAP76+QD9+PYAk3tqAPHq6ACxmIsA6eLeAOPZ + 0wDXyL8AvaaZAJV6ZwBuVUEA9+LZAPXg1QD13tMA9NzQAPTZzQD018oA8tXHAPLSxADTq5YAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AJZ/bwD56uMA/vz6AP76+ACWf24A////AI11 + ZACAaVYArJiKANfIvwDPu7IAl3xpAHJYRQD25NsA9uLYAPXg1gD13tIA9NzQAPTZzQDz18kA89TGANSs + mQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AmIJxAPns5gD//f0A/vz7AL6v + ogCum40A/PbzAM3AtgCJcF4A39PNANfIwACcgnAAdl1JAPjn3gD25NsA9uHYAPXg1QD13dMA9dzPAPTa + zADz18kA1a6bAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wCbhHMA+u7oAP/+ + /gD+/f0A/vv6AP35+AD9+PYA/fbyAI10YgB7XksAjHJiAIFmVAB7YU8A+OjgAPfm3QD349sA9uLYAPbf + 1gD13dIA9NvPAPPZzADWsZ4AY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AJ2H + dgD68esA////AP/+/gD+/fwA/vv6APn18gCijX0AqZKDAKuWiQChjYAAmYJ0AJB2ZACJcV8A+OjgAPfm + 3QD349oA9uLYAPbg1QD13dMA9NvPANezoABjSTUA////AP///wD///8A////AP///wD///8A////AP// + /wD///8An4l5APvy7gD///8A////AP/+/QD+/fwA+/j2AL+soQD9/PsA8evoAOLX0ADUxLsAxrGmAKiU + hQD56uMA+OjgAPjm3QD249oA9uHYAPbg1AD13dIA17WjAGNJNQD///8A////AP///wD///8A////AP// + /wD///8A////AP///wCijHsA+/TxAP///wD///8A////AP/+/gD+/fwA+/j2AKeThADWzcYA49nTALif + kQCHcF0A+u/pAPns5wD46uMA+OjgAPjm3QD349oA9uHYAPbf1ADZt6UAY0k1AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AKSOfgD///8A////AP///wD///8A////AP///wD+/PwAqZSHANXM + xQDk2dMAvaaYAIx0YgD78ewA+u/pAPns5gD46uMA+OjgAPjl3AD249oA9uHXANq5pwBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AppGBAP///wD///8A////AP///wD///8A////AP7+ + /QCsmYoA2M7HAOXa1QDBq58AkHpoAPvz7wD78OwA+u/pAI94ZwCTfGsA+OjgAPjm3QD349oA27qqAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCfiXkA+/LuAP///wD///8A////AP// + /wD///8A////ALCdjwDe1tAA6uLeAMu4rQCmjHwAknloAItzYQCHblwAr5WHAH1kUQD46uIA+OjgAPjl + 3ADbvKwAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AKKMewD79PEA////AP// + /wD///8A////AP///wD///8AtaSWAO3o5QDz7+0A283GALqjmACulYcAmYBvAJyDcgC6oZQAgmlWAPrs + 5gD56uMA+OffANy+rgBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8ApI5+AP// + /wD///8A////AP///wD///8A////AP///wDQxbwA5uDbAPLu7ADs5+MA1ca/AMStoAC0m4wArpWGAMey + pgCFbVsA+u7pAPrr5gD56eIA3cGxAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCmkYEA////AP///wD///8A////AP///wD///8A////APTx7wDLvbUA5d3YAO/q5wDo4d0A39XPANvQ + yQCwmIkA1MS6AIpyYQD78OsA+u7oAPnr5QDfwrMAY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AJ+JeQD78u4A////AP///wD///8A////AP///wD///8A////APPw7QDOwrkAu6qeALGe + kQCql4gApZKDAKOOfgDh1tAAjndlAPvy7gD78OsA+u7oAN/EtgBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8Aoox7APv08QD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP/+/AD+/PsA+fTxAMS3rAC4p5wA/PXxAPvz7QD68OsA4Me4AGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wC4o5QA////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A//7+AP/+/AD++/sA/vr5AP349gDJtKkAvaWXALKZiQCkingAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////ALqmmAD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A///+AP79/AD+/PsAnod2AGNJNQBjSTUAY0k1AGNJ + NQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AvKiaAP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP/9/ACgiXkA1cW9AMex + pQC5oZIAbFI+AGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wC+qpwA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A///+AKKM + fADj2tMA1cW8AHlgTABsUj4A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AMCt + nwD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8ApY5+APPv7QCIcF0AeWBMAP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8Awq+hAP///wD///8A////AP///wD//fwA/vv7AP35+AD9+PUA/PXyAPvz7wD78OsA+u3oAPnr + 5AD46eIA9+fdAPfk2wCnkYIAln9uAIhwXQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wDFsaMAw6+hAMKuoADArJ8Av6ucAL2pmwC8p5oAu6aXALiklQC3opQAtqGSALOf + kACynY8AsJuNAK6aiwCtmIgAq5aHAKmUhACWf24A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AA== + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.vb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.vb new file mode 100644 index 0000000..d8737e7 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoDecodingComponent.vb @@ -0,0 +1,314 @@ +Imports System +Imports System.IO +Imports System.Text +Imports System.Drawing +Imports System.Resources +Imports System.Reflection +Imports System.Diagnostics +Imports System.Collections +Imports System.ComponentModel +Imports Microsoft.BizTalk.Message.Interop +Imports Microsoft.BizTalk.Component.Interop +Imports Microsoft.BizTalk.Component +Imports Microsoft.BizTalk.Messaging +Imports Microsoft.BizTalk.Component.Utilities + +Namespace Microsoft.Samples.LargeFileHandler.PipelinesComponents + _ + Public Class DemoDecodingComponent + Implements IBaseComponent, IPersistPropertyBag, IComponentUI, Global.Microsoft.BizTalk.Component.Interop.IComponent, IProbeMessage + + Private _OutBoundFileDocumentSpecification As SchemaWithNone = New Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone("") + Private _InboundFileDocumentSpecification As SchemaWithNone = New Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone("") + Private _ThresholdSize As Integer = 4096 + + Private resourceManager As System.Resources.ResourceManager = New System.Resources.ResourceManager("Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoDecodingComponent", [Assembly].GetExecutingAssembly) + Private Const PROPERTY_SCHEMA_NAMESPACE = "http://Microsoft.Samples.LargeFileHandler.Schemas.LargeFilePropertySchema" + Private _FileLocation As String + + ' + 'this property will contain a single schema + ' + _ + Public Property InboundFileDocumentSpecification() As Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone + Get + + Return _InboundFileDocumentSpecification + End Get + Set(ByVal Value As Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone) + _InboundFileDocumentSpecification = Value + End Set + End Property + + ' + 'this property will contain a single schema + ' + _ + Public Property OutBoundFileDocumentSpecification() As Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone + Get + + Return _OutBoundFileDocumentSpecification + End Get + Set(ByVal Value As Global.Microsoft.BizTalk.Component.Utilities.SchemaWithNone) + _OutBoundFileDocumentSpecification = Value + End Set + End Property + + _ + Public Property ThresholdSize() As Integer + Get + Return Me._ThresholdSize + End Get + Set(ByVal value As Integer) + Me._ThresholdSize = value + End Set + End Property + + _ +Public Property LargeFileFolder() As String + Get + Return Me._FileLocation + End Get + Set(ByVal value As String) + Me._FileLocation = value + End Set + End Property + ' + 'Name of the component + ' + _ + Public ReadOnly Property Name() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Name + Get + Return resourceManager.GetString("COMPONENTNAME", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Version of the component + ' + _ + Public ReadOnly Property Version() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Version + Get + Return resourceManager.GetString("COMPONENTVERSION", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Description of the component + ' + _ + Public ReadOnly Property Description() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Description + Get + Return resourceManager.GetString("COMPONENTDESCRIPTION", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Component icon to use in BizTalk Editor + ' + _ + Public ReadOnly Property Icon() As IntPtr Implements Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Icon + Get + Return CType(Me.resourceManager.GetObject("COMPONENTICON", System.Globalization.CultureInfo.InvariantCulture), System.Drawing.Bitmap).GetHicon + End Get + End Property + + ' + 'Gets class ID of component for usage from unmanaged code. + ' + ' + 'Class ID of the component + ' + Public Sub GetClassID(ByRef classid As System.Guid) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.GetClassID + classid = New System.Guid("89dedce4-0525-472f-899c-64dc66f60727") + End Sub + + ' + 'not implemented + ' + Public Sub InitNew() Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.InitNew + End Sub + + ' + 'Loads configuration properties for the component + ' + 'Configuration property bag + 'Error status + Public Overridable Sub Load(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal errlog As Integer) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.Load + Try + Me._ThresholdSize = ReadPropertyBag(pb, "ThresholdSize") + Catch + Me._ThresholdSize = 4096 + End Try + + Try + Me._FileLocation = ReadPropertyBag(pb, "FileLocation") + Catch + Me._FileLocation = "C:\Temp" + End Try + Try + Me.InboundFileDocumentSpecification = New SchemaWithNone(ReadPropertyBag(pb, "InboundFileDocumentSpecification")) + Catch + Me.InboundFileDocumentSpecification = New SchemaWithNone("") + End Try + Try + Me.OutBoundFileDocumentSpecification = New SchemaWithNone(ReadPropertyBag(pb, "OutboundFileDocumentSpecification")) + Catch + Me.OutBoundFileDocumentSpecification = New SchemaWithNone("") + End Try + + + End Sub + + ' + 'Saves the current component configuration into the property bag + ' + 'Configuration property bag + 'not used + 'not used + Public Overridable Sub Save(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal fClearDirty As Boolean, ByVal fSaveAllProperties As Boolean) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.Save + + WritePropertyBag(pb, "ThresholdSize", Me._ThresholdSize) + WritePropertyBag(pb, "FileLocation", Me._FileLocation) + WritePropertyBag(pb, "InboundFileDocumentSpecification", _InboundFileDocumentSpecification.SchemaName) + WritePropertyBag(pb, "OutboundFileDocumentSpecification", _OutBoundFileDocumentSpecification.SchemaName) + + End Sub + + ' + 'Reads property value from property bag + ' + 'Property bag + 'Name of property + 'Value of the property + Private Function ReadPropertyBag(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal propName As String) As Object + Dim val As Object = Nothing + Try + pb.Read(propName, val, 0) + Catch e As System.ArgumentException + Return val + Catch e As System.Exception + Throw New System.ApplicationException(e.Message) + End Try + Return val + End Function + + ' + 'Writes property values into a property bag. + ' + 'Property bag. + 'Name of property. + 'Value of property. + Private Sub WritePropertyBag(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal propName As String, ByVal val As Object) + Try + pb.Write(propName, val) + Catch e As System.Exception + Throw New System.ApplicationException(e.Message) + End Try + End Sub + + ' + 'The Validate method is called by the BizTalk Editor during the build + 'of a BizTalk project. + ' + 'An Object containing the configuration properties. + 'The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + Public Function Validate(ByVal obj As Object) As System.Collections.IEnumerator Implements Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Validate + 'example implementation: + 'ArrayList errorList = new ArrayList(); + 'errorList.Add("This is a compiler error"); + 'return errorList.GetEnumerator(); + Return Nothing + End Function + ' + 'called by the messaging engine when a new message arrives + 'checks if the incoming message is in a recognizable format + 'if the message is in a recognizable format, only this component + 'within this stage will be execute (FirstMatch equals true) + ' + 'the pipeline context + 'the actual message + Public Function Probe(ByVal pc As Global.Microsoft.BizTalk.Component.Interop.IPipelineContext, ByVal inmsg As Global.Microsoft.BizTalk.Message.Interop.IBaseMessage) As Boolean Implements Global.Microsoft.BizTalk.Component.Interop.IProbeMessage.Probe + + Dim streamReader As New StreamReader(inmsg.BodyPart.Data) + Dim xmlreader As New Xml.XmlTextReader(inmsg.BodyPart.Data) + xmlreader.MoveToContent() + + If (_InboundFileDocumentSpecification.DocSpecName = xmlreader.NamespaceURI.Replace("http://", "")) Then + Return True + Else + Return False + End If + + End Function + ' + 'Implements IComponent.Execute method. + ' + 'Pipeline context + 'Input message + 'Original input message + ' + 'IComponent.Execute method is used to initiate + 'the processing of the message in this pipeline component. + ' + Public Function Execute(ByVal pContext As IPipelineContext, ByVal inmsg As IBaseMessage) As Global.Microsoft.BizTalk.Message.Interop.IBaseMessage Implements Global.Microsoft.BizTalk.Component.Interop.IComponent.Execute + 'Build the message that is to be sent out but only if it is greater than the threshold + If inmsg.BodyPart.GetOriginalDataStream.Length > Me._ThresholdSize Then + StoreMessageData(pContext, inmsg) + End If + Return inmsg + End Function + + ' + 'Method used to write the message data to a file and promote the + 'location to the MessageContext. + ' + 'Pipeline context + 'Input message to be assigned + 'Original input message by reference + ' + 'Receives the input message ByRef then assigns the file stream to the messageBody.Data property + ' + Private Sub StoreMessageData(ByVal pContext As IPipelineContext, ByRef inMsg As IBaseMessage) + Dim FullFileName As String = _FileLocation + inMsg.MessageID.ToString + ".msg" + Dim dataFile As New FileStream(FullFileName, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite, 4096) + Dim myMemoryStream As Stream = inMsg.BodyPart.GetOriginalDataStream + + Dim Buffer(4095) As Byte + Dim byteCount As Integer + + 'Not really needed, just want to initialize the data within the message part to something. + 'Proper way to do this would be to create a separate XML schema for messages which have been encoded using the + 'encoder, create a new empty document which has an element named "FilePath" and set the value of the element + 'to FullFileName. But at least this way we can see the value in the document should we need to write it out + Dim myStream As New MemoryStream(UTF8Encoding.Default.GetBytes(FullFileName)) + + If myMemoryStream.CanSeek Then + myMemoryStream.Position = 0 + Else + 'Impossible to occur, but added it anyway + Throw New Exception("The stream is not seekable") + End If + + byteCount = myMemoryStream.Read(Buffer, 0, 4096) + + While myMemoryStream.Position < myMemoryStream.Length - 1 'pos < inMsg.BodyPart.Data.Length - 1 + dataFile.Write(Buffer, 0, 4096) + dataFile.Flush() + byteCount = myMemoryStream.Read(Buffer, 0, 4096) + End While + dataFile.Write(Buffer, 0, byteCount) + dataFile.Flush() + dataFile.Close() + inMsg.BodyPart.Data = myStream + inMsg.Context.Promote("LargeFileLocation", PROPERTY_SCHEMA_NAMESPACE, FullFileName) + + 'Useful for CBR operations - i.e. route all messages that are large to a specific send port. + inMsg.Context.Promote("IsEncoded", PROPERTY_SCHEMA_NAMESPACE, True) + + End Sub + + End Class +End Namespace diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.resx b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.resx new file mode 100644 index 0000000..7d84616 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.resx @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Large File Encoder + + + Sets the data of the message to the file stream created in the orchestration + + + 1.0.0.0 + + + + + Qk02EAAAAAAAADYAAAAoAAAAIAAAACAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AIFoVgBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJ + NQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AhGtZAPTbzgDewLEA3L6uANu8rADbu6oA2bmoANi3 + pQDYtaMA17OhANaxnwDWsJwA1K2aANSrlwDSqpYA0qiTANCmkQDQpI8Az6ONAM+giwDNn4kAzZ6HAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCGblsA9NzRAPru6QD57OYA+erjAPfn + 3wD45dwA9+PaAPbg1wD139QA9N3RAPTbzgDz2MsA89bIAPLTxQDx0cIA8c+/APDNvADvy7kA78m2AO7H + tADNoIkAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AIlwXgD139MA+vDsAPnu + 6AD56+YA+eniAPjn3wD45dwA9uPaAPXh1gD13tQA9d3RAPTazQDz2MsA89XIAPLTxQDx0cEA8M++AO/N + vADvyrkA78i3AM+hiwBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8Ai3NhAPbg + 1gD78u4A+vHrAKyZiwCJcV8A0L6yAM66rgDNuKsAy7aoAMy1qADeyLoA79fLAPTazQD02MoA89XIAPLT + xADx0MEA8c6/APDMuwDvy7kA0KKNAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCNdmQA9uLYAPz08gD88+4Ahm5bALyjlgB6YE0AdVxJAHJYRABuVUAAfGNQALihkgDdxbgA9dzQAPTZ + zgDz2MoA89XIAPHTxADx0MEA8M6/APDMvADQpI8AY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AI94ZwD35NsA/Pb0APz08QCKcmAAzLivAHNaRwB/ZlUAjHNjAI11ZgB/Z1gAblVBAK+X + iAD13tMA9NzQAPTazgDz18oA89XHAPLTxADx0cEA8M6+ANGmkQBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8AkntpAPjm3gD9+fYA/PfzAI52ZQDe0coAp4+CANXGvQDEsKQAuqOVAKyQ + fgCVemcAfGNQAPXh1gD13tMA9dzQAPTazQDz18oA89XHAPLSwwDx0cEA0qmUAGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wCVfWwA+OjhAP76+QD9+PYAk3tqAPHq6ACxmIsA6eLeAOPZ + 0wDXyL8AvaaZAJV6ZwBuVUEA9+LZAPXg1QD13tMA9NzQAPTZzQD018oA8tXHAPLSxADTq5YAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AJZ/bwD56uMA/vz6AP76+ACWf24A////AI11 + ZACAaVYArJiKANfIvwDPu7IAl3xpAHJYRQD25NsA9uLYAPXg1gD13tIA9NzQAPTZzQDz18kA89TGANSs + mQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AmIJxAPns5gD//f0A/vz7AL6v + ogCum40A/PbzAM3AtgCJcF4A39PNANfIwACcgnAAdl1JAPjn3gD25NsA9uHYAPXg1QD13dMA9dzPAPTa + zADz18kA1a6bAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wCbhHMA+u7oAP/+ + /gD+/f0A/vv6AP35+AD9+PYA/fbyAI10YgB7XksAjHJiAIFmVAB7YU8A+OjgAPfm3QD349sA9uLYAPbf + 1gD13dIA9NvPAPPZzADWsZ4AY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AJ2H + dgD68esA////AP/+/gD+/fwA/vv6APn18gCijX0AqZKDAKuWiQChjYAAmYJ0AJB2ZACJcV8A+OjgAPfm + 3QD349oA9uLYAPbg1QD13dMA9NvPANezoABjSTUA////AP///wD///8A////AP///wD///8A////AP// + /wD///8An4l5APvy7gD///8A////AP/+/QD+/fwA+/j2AL+soQD9/PsA8evoAOLX0ADUxLsAxrGmAKiU + hQD56uMA+OjgAPjm3QD249oA9uHYAPbg1AD13dIA17WjAGNJNQD///8A////AP///wD///8A////AP// + /wD///8A////AP///wCijHsA+/TxAP///wD///8A////AP/+/gD+/fwA+/j2AKeThADWzcYA49nTALif + kQCHcF0A+u/pAPns5wD46uMA+OjgAPjm3QD349oA9uHYAPbf1ADZt6UAY0k1AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AKSOfgD///8A////AP///wD///8A////AP///wD+/PwAqZSHANXM + xQDk2dMAvaaYAIx0YgD78ewA+u/pAPns5gD46uMA+OjgAPjl3AD249oA9uHXANq5pwBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AppGBAP///wD///8A////AP///wD///8A////AP7+ + /QCsmYoA2M7HAOXa1QDBq58AkHpoAPvz7wD78OwA+u/pAI94ZwCTfGsA+OjgAPjm3QD349oA27qqAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCfiXkA+/LuAP///wD///8A////AP// + /wD///8A////ALCdjwDe1tAA6uLeAMu4rQCmjHwAknloAItzYQCHblwAr5WHAH1kUQD46uIA+OjgAPjl + 3ADbvKwAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AKKMewD79PEA////AP// + /wD///8A////AP///wD///8AtaSWAO3o5QDz7+0A283GALqjmACulYcAmYBvAJyDcgC6oZQAgmlWAPrs + 5gD56uMA+OffANy+rgBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8ApI5+AP// + /wD///8A////AP///wD///8A////AP///wDQxbwA5uDbAPLu7ADs5+MA1ca/AMStoAC0m4wArpWGAMey + pgCFbVsA+u7pAPrr5gD56eIA3cGxAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCmkYEA////AP///wD///8A////AP///wD///8A////APTx7wDLvbUA5d3YAO/q5wDo4d0A39XPANvQ + yQCwmIkA1MS6AIpyYQD78OsA+u7oAPnr5QDfwrMAY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AJ+JeQD78u4A////AP///wD///8A////AP///wD///8A////APPw7QDOwrkAu6qeALGe + kQCql4gApZKDAKOOfgDh1tAAjndlAPvy7gD78OsA+u7oAN/EtgBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8Aoox7APv08QD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP/+/AD+/PsA+fTxAMS3rAC4p5wA/PXxAPvz7QD68OsA4Me4AGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wC4o5QA////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A//7+AP/+/AD++/sA/vr5AP349gDJtKkAvaWXALKZiQCkingAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////ALqmmAD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A///+AP79/AD+/PsAnod2AGNJNQBjSTUAY0k1AGNJ + NQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AvKiaAP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP/9/ACgiXkA1cW9AMex + pQC5oZIAbFI+AGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wC+qpwA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A///+AKKM + fADj2tMA1cW8AHlgTABsUj4A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AMCt + nwD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8ApY5+APPv7QCIcF0AeWBMAP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8Awq+hAP///wD///8A////AP///wD//fwA/vv7AP35+AD9+PUA/PXyAPvz7wD78OsA+u3oAPnr + 5AD46eIA9+fdAPfk2wCnkYIAln9uAIhwXQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wDFsaMAw6+hAMKuoADArJ8Av6ucAL2pmwC8p5oAu6aXALiklQC3opQAtqGSALOf + kACynY8AsJuNAK6aiwCtmIgAq5aHAKmUhACWf24A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AA== + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.vb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.vb new file mode 100644 index 0000000..f5c81fe --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/DemoEncodingComponent.vb @@ -0,0 +1,194 @@ +Imports System +Imports System.IO +Imports System.Text +Imports System.Drawing +Imports System.Resources +Imports System.Reflection +Imports System.Diagnostics +Imports System.Collections +Imports System.ComponentModel +Imports Microsoft.BizTalk.Message.Interop +Imports Microsoft.BizTalk.Component.Interop +Imports Microsoft.BizTalk.Component +Imports Microsoft.BizTalk.Messaging + +Namespace Microsoft.Samples.LargeFileHandler.PipelinesComponents + + _ + Public Class DemoEncodingComponent + Implements IBaseComponent, IPersistPropertyBag, IComponentUI, Global.Microsoft.BizTalk.Component.Interop.IComponent + + Private resourceManager As System.Resources.ResourceManager = New System.Resources.ResourceManager("Microsoft.Samples.LargeFileHandler.PipelineComponents.DemoEncodingComponent", [Assembly].GetExecutingAssembly) + Private Const PROPERTY_SCHEMA_NAMESPACE = "http://Microsoft.Samples.LargeFileHandler.Schemas.LargeFilePropertySchema" + + ' + 'Name of the component + ' + _ + Public ReadOnly Property Name() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Name + Get + Return resourceManager.GetString("COMPONENTNAME", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Version of the component + ' + _ + Public ReadOnly Property Version() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Version + Get + Return resourceManager.GetString("COMPONENTVERSION", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Description of the component + ' + _ + Public ReadOnly Property Description() As String Implements Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Description + Get + Return resourceManager.GetString("COMPONENTDESCRIPTION", System.Globalization.CultureInfo.InvariantCulture) + End Get + End Property + + ' + 'Component icon to use in BizTalk Editor + ' + _ + Public ReadOnly Property Icon() As IntPtr Implements Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Icon + Get + Return CType(Me.resourceManager.GetObject("COMPONENTICON", System.Globalization.CultureInfo.InvariantCulture), System.Drawing.Bitmap).GetHicon + End Get + End Property + + ' + 'Gets class ID of component for usage from unmanaged code. + ' + ' + 'Class ID of the component + ' + Public Sub GetClassID(ByRef classid As System.Guid) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.GetClassID + classid = New System.Guid("4f1c7d50-e66f-451b-8e94-2f8d599cd013") + End Sub + + ' + 'not implemented + ' + Public Sub InitNew() Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.InitNew + End Sub + + ' + 'Loads configuration properties for the component + ' + 'Configuration property bag + 'Error status + Public Overridable Sub Load(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal errlog As Integer) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.Load + End Sub + + ' + 'Saves the current component configuration into the property bag + ' + 'Configuration property bag + 'not used + 'not used + Public Overridable Sub Save(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal fClearDirty As Boolean, ByVal fSaveAllProperties As Boolean) Implements Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.Save + End Sub + + ' + 'Reads property value from property bag + ' + 'Property bag + 'Name of property + 'Value of the property + Private Function ReadPropertyBag(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal propName As String) As Object + Dim val As Object = Nothing + Try + pb.Read(propName, val, 0) + Catch e As System.ArgumentException + Return val + Catch e As System.Exception + Throw New System.ApplicationException(e.Message) + End Try + Return val + End Function + + ' + 'Writes property values into a property bag. + ' + 'Property bag. + 'Name of property. + 'Value of property. + Private Sub WritePropertyBag(ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, ByVal propName As String, ByVal val As Object) + Try + pb.Write(propName, val) + Catch e As System.Exception + Throw New System.ApplicationException(e.Message) + End Try + End Sub + + ' + 'The Validate method is called by the BizTalk Editor during the build + 'of a BizTalk project. + ' + 'An Object containing the configuration properties. + 'The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + Public Function Validate(ByVal obj As Object) As System.Collections.IEnumerator Implements Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Validate + 'example implementation: + 'ArrayList errorList = new ArrayList(); + 'errorList.Add("This is a compiler error"); + 'return errorList.GetEnumerator(); + Return Nothing + End Function + + ' + 'Implements IComponent.Execute method. + ' + 'Pipeline context + 'Input message + 'Original input message + ' + 'IComponent.Execute method is used to initiate + 'the processing of the message in this pipeline component. + ' + Public Function Execute(ByVal pContext As IPipelineContext, ByVal inmsg As IBaseMessage) As IBaseMessage Implements Global.Microsoft.BizTalk.Component.Interop.IComponent.Execute + Dim isEncoded As Boolean = False + + Try + isEncoded = inmsg.Context.Read("IsEncoded", PROPERTY_SCHEMA_NAMESPACE) + Catch ex As Exception + isEncoded = False + End Try + + 'Build the message that is to be sent out but only if it is encoded + If isEncoded Then + BuildMessageData(pContext, inmsg) + End If + + Return inmsg + End Function + + ' + 'Method used to assign the data to a stream. Method reads path from promoted property + ' + 'Pipeline context + 'Input message to be assigned + 'Original input message by reference + ' + 'Receives the input message ByRef then assigns the file stream to the messageBody.Data property + ' + Private Sub BuildMessageData(ByVal pContext As IPipelineContext, ByRef inMsg As IBaseMessage) + + Dim messageBody As IBaseMessagePart = pContext.GetMessageFactory().CreateMessagePart() + Dim data As New FileStream(inMsg.Context.Read("LargeFileLocation", PROPERTY_SCHEMA_NAMESPACE), FileMode.Open, FileAccess.Read, FileShare.Read, 4 * 1024 * 1024) + messageBody.Data = data + If data.CanSeek Then + data.Position = 0 + End If + + inMsg.BodyPart.Data = data + End Sub + End Class + +End Namespace diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.BizTalk.Component.Utilities.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.BizTalk.Component.Utilities.dll new file mode 100644 index 0000000..83248c1 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.BizTalk.Component.Utilities.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.sln b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.sln new file mode 100644 index 0000000..9778196 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Microsoft.Samples.LargeFileHandler.PipelineComponents", "Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj", "{3FD17E7F-9CDB-451B-B0FE-99B02385123C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3FD17E7F-9CDB-451B-B0FE-99B02385123C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3FD17E7F-9CDB-451B-B0FE-99B02385123C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3FD17E7F-9CDB-451B-B0FE-99B02385123C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3FD17E7F-9CDB-451B-B0FE-99B02385123C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.suo b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.suo new file mode 100644 index 0000000..c2324f8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.suo differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj new file mode 100644 index 0000000..13d75d3 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj @@ -0,0 +1,99 @@ + + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {3FD17E7F-9CDB-451B-B0FE-99B02385123C} + Library + Microsoft.Samples.LargeFileHandler.PipelinesComponents + Microsoft.Samples.LargeFileHandler.PipelinesComponents + Windows + true + + + + + true + full + true + true + C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\ + TR3.PipelineComponents.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + TR3.PipelineComponents.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + + False + ..\Microsoft.BizTalk.Component.Utilities.dll + + + False + ..\..\..\..\..\..\..\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Deployment.dll + + + False + ..\..\..\..\..\..\..\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Microsoft.BizTalk.ExplorerOM.dll + + + False + ..\..\..\..\..\..\..\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Messaging.dll + + + False + ..\..\..\..\..\..\..\Program Files\Microsoft BizTalk Server 2006\Microsoft.BizTalk.Pipeline.dll + + + + + + + + + + + + + + + + + + + + + + Designer + + + Designer + + + + + {604022F0-ACDA-4FF9-85AA-1E769413509B} + Streams + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.user b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.user new file mode 100644 index 0000000..6a34e7d --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.user @@ -0,0 +1,5 @@ + + + ShowAllFiles + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.GenerateResource.Cache b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.GenerateResource.Cache new file mode 100644 index 0000000..9aff112 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.GenerateResource.Cache differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoDecodingComponent.resources b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoDecodingComponent.resources new file mode 100644 index 0000000..779b6a4 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoDecodingComponent.resources differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoEncodingComponent.resources b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoEncodingComponent.resources new file mode 100644 index 0000000..3c7fd0e Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoEncodingComponent.resources differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb new file mode 100644 index 0000000..f5a90fc Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/ResolveAssemblyReference.cache b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..abedaf7 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TR3.PipelineComponents.xml b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TR3.PipelineComponents.xml new file mode 100644 index 0000000..81d054c --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TR3.PipelineComponents.xml @@ -0,0 +1,11 @@ + + + + +Microsoft.Samples.LargeFileHandler.PipelinesComponents + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll new file mode 100644 index 0000000..1a29ed9 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/microsoft.samples.largefilehandler.pipelinescomponents.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/microsoft.samples.largefilehandler.pipelinescomponents.dll new file mode 100644 index 0000000..38aa380 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Debug/microsoft.samples.largefilehandler.pipelinescomponents.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.FileList.txt b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.FileList.txt new file mode 100644 index 0000000..d7c1abc --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.PipelineComponents/obj/Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.FileList.txt @@ -0,0 +1,10 @@ +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoDecodingComponent.resources +obj\Debug\Microsoft.Samples.LargeFileHandler.PipelinesComponents.DemoEncodingComponent.resources +obj\Debug\Microsoft.Samples.LargeFileHandler.PipelineComponents.vbproj.GenerateResource.Cache +C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll +C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb +C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\TR3.PipelineComponents.xml +obj\Debug\Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll +obj\Debug\TR3.PipelineComponents.xml +obj\Debug\Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.ReceivePipeline.btp b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.ReceivePipeline.btp new file mode 100644 index 0000000..aec6035 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.ReceivePipeline.btp differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.SendPipeline.btp b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.SendPipeline.btp new file mode 100644 index 0000000..00a2ea9 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.SendPipeline.btp differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj new file mode 100644 index 0000000..0bb14fc --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj.user b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj.user new file mode 100644 index 0000000..45351c7 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.btproj.user @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.suo b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.suo new file mode 100644 index 0000000..0c1f284 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.suo differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.user b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.user new file mode 100644 index 0000000..2a02b90 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/Microsoft.Samples.LargeFileHandler.Pipelines.user @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Adapter.Framework.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Adapter.Framework.dll new file mode 100644 index 0000000..abcf53a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Adapter.Framework.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Admin.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Admin.dll new file mode 100644 index 0000000..936513f Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Admin.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ApplicationDeployment.Engine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ApplicationDeployment.Engine.dll new file mode 100644 index 0000000..b8fd3c8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ApplicationDeployment.Engine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll new file mode 100644 index 0000000..058674a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.BtsDbVersion.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.BtsDbVersion.dll new file mode 100644 index 0000000..983a0e8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.BtsDbVersion.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.CachingService.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.CachingService.dll new file mode 100644 index 0000000..c911901 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.CachingService.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Component.Utilities.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Component.Utilities.dll new file mode 100644 index 0000000..6c5a14d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Component.Utilities.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.DBAccessor.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.DBAccessor.dll new file mode 100644 index 0000000..3ef7a37 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.DBAccessor.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Databases.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Databases.dll new file mode 100644 index 0000000..5c410d8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Databases.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Deployment.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Deployment.dll new file mode 100644 index 0000000..af0ad54 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Deployment.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ExplorerOM.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ExplorerOM.dll new file mode 100644 index 0000000..0706bc0 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ExplorerOM.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.IMS.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.IMS.dll new file mode 100644 index 0000000..f27c81d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.IMS.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll new file mode 100644 index 0000000..8c23af8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Interop.Agent.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MSIManager.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MSIManager.dll new file mode 100644 index 0000000..fa16d59 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MSIManager.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MUI.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MUI.dll new file mode 100644 index 0000000..6286abf Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MUI.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MessageBoxOM.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MessageBoxOM.dll new file mode 100644 index 0000000..296b05d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.MessageBoxOM.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Messaging.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Messaging.dll new file mode 100644 index 0000000..58519fc Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Messaging.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ObjectModel.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ObjectModel.dll new file mode 100644 index 0000000..419eb4a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.ObjectModel.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll new file mode 100644 index 0000000..51e7f68 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.RuleEngineExtensions.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.RuleEngineExtensions.dll new file mode 100644 index 0000000..6915fe3 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.RuleEngineExtensions.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll new file mode 100644 index 0000000..f7f9140 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Studio.Extensibility.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Studio.Extensibility.dll new file mode 100644 index 0000000..eeb7533 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Studio.Extensibility.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll new file mode 100644 index 0000000..d0bc45c Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracking.BasicTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracking.BasicTypes.dll new file mode 100644 index 0000000..e0f88f8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.Tracking.BasicTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.TypeSystem.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.TypeSystem.dll new file mode 100644 index 0000000..3d81628 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.TypeSystem.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll new file mode 100644 index 0000000..fd60673 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.RuleEngine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.RuleEngine.dll new file mode 100644 index 0000000..c0fb7ce Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.RuleEngine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll new file mode 100644 index 0000000..11241f4 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll new file mode 100644 index 0000000..6cc4e24 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll new file mode 100644 index 0000000..848d163 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.Engine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.Engine.dll new file mode 100644 index 0000000..ccf9b0e Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.Engine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll new file mode 100644 index 0000000..9fcecc2 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Streams.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Streams.dll new file mode 100644 index 0000000..52196c1 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/Streams.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/TR3.PipelineComponents.xml b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/TR3.PipelineComponents.xml new file mode 100644 index 0000000..81d054c --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Deployment/TR3.PipelineComponents.xml @@ -0,0 +1,11 @@ + + + + +Microsoft.Samples.LargeFileHandler.PipelinesComponents + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Adapter.Framework.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Adapter.Framework.dll new file mode 100644 index 0000000..abcf53a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Adapter.Framework.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Admin.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Admin.dll new file mode 100644 index 0000000..936513f Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Admin.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ApplicationDeployment.Engine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ApplicationDeployment.Engine.dll new file mode 100644 index 0000000..b8fd3c8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ApplicationDeployment.Engine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Bam.EventObservation.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Bam.EventObservation.dll new file mode 100644 index 0000000..058674a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Bam.EventObservation.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.BtsDbVersion.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.BtsDbVersion.dll new file mode 100644 index 0000000..983a0e8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.BtsDbVersion.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.CachingService.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.CachingService.dll new file mode 100644 index 0000000..c911901 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.CachingService.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Component.Utilities.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Component.Utilities.dll new file mode 100644 index 0000000..6c5a14d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Component.Utilities.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.DBAccessor.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.DBAccessor.dll new file mode 100644 index 0000000..3ef7a37 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.DBAccessor.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Databases.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Databases.dll new file mode 100644 index 0000000..5c410d8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Databases.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Deployment.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Deployment.dll new file mode 100644 index 0000000..af0ad54 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Deployment.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ExplorerOM.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ExplorerOM.dll new file mode 100644 index 0000000..0706bc0 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ExplorerOM.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.IMS.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.IMS.dll new file mode 100644 index 0000000..f27c81d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.IMS.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Interop.Agent.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Interop.Agent.dll new file mode 100644 index 0000000..8c23af8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Interop.Agent.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MSIManager.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MSIManager.dll new file mode 100644 index 0000000..fa16d59 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MSIManager.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MUI.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MUI.dll new file mode 100644 index 0000000..6286abf Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MUI.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MessageBoxOM.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MessageBoxOM.dll new file mode 100644 index 0000000..296b05d Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.MessageBoxOM.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Messaging.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Messaging.dll new file mode 100644 index 0000000..58519fc Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Messaging.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ObjectModel.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ObjectModel.dll new file mode 100644 index 0000000..419eb4a Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.ObjectModel.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Pipeline.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Pipeline.dll new file mode 100644 index 0000000..51e7f68 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Pipeline.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.RuleEngineExtensions.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.RuleEngineExtensions.dll new file mode 100644 index 0000000..6915fe3 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.RuleEngineExtensions.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Streaming.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Streaming.dll new file mode 100644 index 0000000..f7f9140 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Streaming.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Studio.Extensibility.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Studio.Extensibility.dll new file mode 100644 index 0000000..eeb7533 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Studio.Extensibility.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracing.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracing.dll new file mode 100644 index 0000000..d0bc45c Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracing.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracking.BasicTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracking.BasicTypes.dll new file mode 100644 index 0000000..e0f88f8 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.Tracking.BasicTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.TypeSystem.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.TypeSystem.dll new file mode 100644 index 0000000..3d81628 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.TypeSystem.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.XPathReader.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.XPathReader.dll new file mode 100644 index 0000000..fd60673 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.BizTalk.XPathReader.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.RuleEngine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.RuleEngine.dll new file mode 100644 index 0000000..c0fb7ce Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.RuleEngine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll new file mode 100644 index 0000000..38aa380 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb new file mode 100644 index 0000000..f5a90fc Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.Samples.LargeFileHandler.PipelinesComponents.pdb differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.BaseTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.BaseTypes.dll new file mode 100644 index 0000000..848d163 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.BaseTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.Engine.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.Engine.dll new file mode 100644 index 0000000..ccf9b0e Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.Engine.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.RuntimeTypes.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.RuntimeTypes.dll new file mode 100644 index 0000000..9fcecc2 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Microsoft.XLANGs.RuntimeTypes.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.dll new file mode 100644 index 0000000..470007c Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.pdb b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.pdb new file mode 100644 index 0000000..c086da2 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/Streams.pdb differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/TR3.PipelineComponents.xml b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/TR3.PipelineComponents.xml new file mode 100644 index 0000000..81d054c --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Pipelines/bin/Development/TR3.PipelineComponents.xml @@ -0,0 +1,11 @@ + + + + +Microsoft.Samples.LargeFileHandler.PipelinesComponents + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/LargeFilePropertySchema.xsd b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/LargeFilePropertySchema.xsd new file mode 100644 index 0000000..9e3d32b Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/LargeFilePropertySchema.xsd differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj new file mode 100644 index 0000000..444e017 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj.user b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj.user new file mode 100644 index 0000000..8e830d0 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.btproj.user @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.user b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.user new file mode 100644 index 0000000..2554d6a --- /dev/null +++ b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/Microsoft.Samples.LargeFileHandler.Schemas.user @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll new file mode 100644 index 0000000..6cc4e24 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/TR3.Schemas.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/TR3.Schemas.dll new file mode 100644 index 0000000..bff4d56 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/bin/Deployment/TR3.Schemas.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll new file mode 100644 index 0000000..6cc4e24 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/Microsoft.Samples.LargeFileHandler.Schemas.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/TR3.Schemas.dll b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/TR3.Schemas.dll new file mode 100644 index 0000000..bff4d56 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.Schemas/obj/Deployment/TR3.Schemas.dll differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.sln b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.sln new file mode 100644 index 0000000..8dea095 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.sln differ diff --git a/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.suo b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.suo new file mode 100644 index 0000000..b5ce4ee Binary files /dev/null and b/Samples/Chapter5/Large File Components/Microsoft.Samples.LargeFileHandler.suo differ diff --git a/Samples/Chapter5/Large File Components/Streams/Properties/AssemblyInfo.cs b/Samples/Chapter5/Large File Components/Streams/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a78ab9c --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Streams")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("TVidia")] +[assembly: AssemblyProduct("Streams")] +[assembly: AssemblyCopyright("Copyright © TVidia 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9764212f-15bf-4f1f-829c-2c0b98eb10b5")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Samples/Chapter5/Large File Components/Streams/SeekableReadOnlyStream.cs b/Samples/Chapter5/Large File Components/Streams/SeekableReadOnlyStream.cs new file mode 100644 index 0000000..50d1f10 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/SeekableReadOnlyStream.cs @@ -0,0 +1,365 @@ +//--------------------------------------------------------------------- +// File: SeekableReadOnlyStream.cs +// +// Summary: A sample pipeline component which demonstrates how to promote message context +// properties and write distinguished fields for XML messages using arbitrary +// XPath expressions. +// +// Sample: Arbitrary XPath Property Handler Pipeline Component SDK +// +//--------------------------------------------------------------------- +// This file is part of the Microsoft BizTalk Server 2006 SDK +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// This source code is intended only as a supplement to Microsoft BizTalk +// Server 2006 release and/or on-line documentation. See these other +// materials for detailed information regarding Microsoft code samples. +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +// PURPOSE. +//--------------------------------------------------------------------- + +using System; +using System.IO; +using System.Diagnostics; + +namespace Microsoft.Samples.BizTalk.Pipelines.CustomComponent +{ + /// + /// Implements a seekable read-only stream which uses buffering if + /// underlying stream is not seekable. Buffer in memory has size + /// threshold and overflows to disk (temporary file) if number of bytes. + /// + public class SeekableReadOnlyStream : Stream + { + /// + /// Initializes a SeekableReadOnlyStream instance with base stream and + /// buffering stream. + /// + /// Base stream + /// Buffering stream + public SeekableReadOnlyStream(Stream baseStream, Stream bufferingStream) + { + if (null == baseStream) + throw new ArgumentNullException("baseStream"); + if (null == bufferingStream) + throw new ArgumentNullException("bufferingStream"); + + // Sanity check - make sure that buffering stream is seekable + if (!bufferingStream.CanSeek) + throw new NotSupportedException("Buffering stream must be seekable"); + + this.baseStream = baseStream; + this.bufferingStream = bufferingStream; + } + + /// + /// Initializes a SeekableReadOnlyStream instance with base stream and inherently uses + /// VirtualStream instance as buffering stream. + /// + /// Base stream + public SeekableReadOnlyStream(Stream baseStream) : this(baseStream, new VirtualStream()) + { + // Empty + } + + /// + /// Initializes a SeekableReadOnlyStream instance with base stream and buffer size, and + /// inherently uses VirtualStream instance as buffering stream. + /// + /// Base stream + /// Buffer size + public SeekableReadOnlyStream(Stream baseStream, int bufferSize) : this(baseStream, new VirtualStream(bufferSize)) + { + // Empty + } + + /// + /// Gets a flag indicating whether this stream can be read. + /// + public override bool CanRead + { + get { return true; } + } + + /// + /// Gets a flag indicating whether this stream can be written to. + /// + public override bool CanWrite + { + get { return false; } + } + + public override bool CanSeek + { + get { return true; } + } + + /// + /// Gets or sets a stream position. + /// + public override long Position + { + get + { + // Check if base stream is seekable + if (baseStream.CanSeek) + return baseStream.Position; + + return bufferingStream.Position; + } + set + { + // Check if base stream is seekable + if (baseStream.CanSeek) + { + baseStream.Position = value; + return; + } + + // Check if current position is the same as being set + if (bufferingStream.Position == value) + return; + + // Check if stream position is being set to the value which is in already + // read to the buffering stream space, i.e. less than current buffering stream + // position or less than length of the buffering stream + if (value < bufferingStream.Position || value < bufferingStream.Length) + { + // Just change position in the buffering stream + bufferingStream.Position = value; + } + else + { + // + // Need to read buffer from the base stream from the current position in + // base stream to the position being set and write that buffer to the end + // of the buffering stream + // + + // Set position to the last byte in the buffering stream + bufferingStream.Seek(0, SeekOrigin.End); + + // Read buffer from the base stream and write it to the buffering stream + // in 4K chunks + byte [] buffer = new byte[ 4096 ]; + long bytesToRead = value - bufferingStream.Position; + while (bytesToRead > 0) + { + // Read to buffer 4K or byteToRead, whichever is less + int bytesRead = baseStream.Read(buffer, 0, (int) Math.Min(bytesToRead, buffer.Length)); + + // Check if any bytes were read + if (0 == bytesRead) + break; + + // Write read bytes to the buffering stream + bufferingStream.Write(buffer, 0, bytesRead); + + // Decrease bytes to read counter + bytesToRead -= bytesRead; + } + + // + // Since this stream is not writable, any attempt to point Position beyond the length + // of the base stream will not succeed, and buffering stream position will be set to the + // last byte in the buffering stream. + // + } + } + } + + /// + /// Seeks in stream. For this stream can be very expensive because entire base stream + /// can be dumped into buffering stream if SeekOrigin.End is used. + /// + /// A byte offset relative to the origin parameter + /// A value of type SeekOrigin indicating the reference point used to obtain the new position + /// The new position within the current stream + public override long Seek(long offset, SeekOrigin origin) + { + // Check if base stream is seekable + if (baseStream.CanSeek) + return baseStream.Seek(offset, origin); + + if (SeekOrigin.Begin == origin) + { + // Just set the absolute position using Position property + Position = offset; + return Position; + } + + if (SeekOrigin.Current == origin) + { + // Set the position using current Position property value plus offset + Position = Position + offset; + return Position; + } + + if (SeekOrigin.End == origin) + { + // + // Need to read all remaining not read bytes from the base stream to the + // buffering stream. We can't use offset here because stream size may not + // be available because it's not seekable. Then we'll set the position + // based on buffering stream size. + // + + // Set position to the last byte in the buffering stream + bufferingStream.Seek(0, SeekOrigin.End); + + // Read all remaining bytes from the base stream to the buffering stream + byte [] buffer = new byte[ 4096 ]; + for (;;) + { + // Read buffer from base stream + int bytesRead = baseStream.Read(buffer, 0, buffer.Length); + + // Break the reading loop if the base stream is exhausted + if (0 == bytesRead) + break; + + // Write buffer to the buffering stream + bufferingStream.Write(buffer, 0, bytesRead); + } + + // Now buffering stream size is equal to the base stream size. Set position + // using begin origin + Position = bufferingStream.Length - offset; + return Position; + } + + throw new NotSupportedException("Not supported SeekOrigin"); + } + + /// + /// Gets the length in bytes of the stream. For this stream can be very expensive + /// because entire base stream will be dumped into buffering stream. + /// + public override long Length + { + get + { + // Check if base stream is seekable + if (baseStream.CanSeek) + return baseStream.Length; + + // Preserve the current stream position + long position = Position; + + // Seek to the end of stream + Seek(0, SeekOrigin.End); + + // Length will be equal to the current position + long length = Position; + + // Restore the current stream position + Position = position; + + return length; + } + } + + /// + /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. + /// + /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count- 1) replaced by the bytes read from the current source + /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream + /// The maximum number of bytes to be read from the current stream + /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached + public override int Read(byte[] buffer, int offset, int count) + { + // Check if base stream is seekable + if (baseStream.CanSeek) + return baseStream.Read(buffer, offset, count); + + int bytesReadTotal = 0; + + // Check if buffering stream has some bytes to read, starting from the + // current position + if (bufferingStream.Length > bufferingStream.Position) + { + // Read available bytes in buffering stream or count bytes to the buffer, whichever is less + bytesReadTotal = bufferingStream.Read(buffer, offset, (int) Math.Min(bufferingStream.Length - bufferingStream.Position, count)); + + // Account for bytes read from the buffering stream + count -= bytesReadTotal; + offset += bytesReadTotal; + } + + // Check if we have any more bytes to read + if (count > 0) + { + Debug.Assert(bufferingStream.Position == bufferingStream.Length); + + // + // At this point, buffering stream has position set to its end. We need to read buffer from + // the base stream and write it to the buffering stream + // + + // Read count bytes from the base stream starting from offset + int bytesRead = baseStream.Read(buffer, offset, count); + + // Check if bytes were really read + if (bytesRead > 0) + { + // Write number of read bytes to the buffering stream starting from offset in buffer + bufferingStream.Write(buffer, offset, bytesRead); + } + + // Add number of bytes read at this step to the number of totally read bytes + bytesReadTotal += bytesRead; + } + + return bytesReadTotal; + } + + /// + /// Writes to stream. + /// + /// Buffer to write to stream + /// Stream offset to start write from + /// Number of bytes from buffer to write + /// Is thrown always + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } + + /// + /// Set stream length. + /// + /// Stream length + /// Is thrown always + public override void SetLength(long value) + { + throw new NotSupportedException(); + } + + /// + /// Closes base and buffering streams. + /// + public override void Close() + { + // Close underlying streams + baseStream.Close(); + bufferingStream.Close(); + } + + /// + /// Flushes the stream. + /// + public override void Flush() + { + // Flush the buffering stream + bufferingStream.Flush(); + } + + + private Stream baseStream; + private Stream bufferingStream; + } +} diff --git a/Samples/Chapter5/Large File Components/Streams/Streams.csproj b/Samples/Chapter5/Large File Components/Streams/Streams.csproj new file mode 100644 index 0000000..0e153b8 --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/Streams.csproj @@ -0,0 +1,48 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {604022F0-ACDA-4FF9-85AA-1E769413509B} + Library + Properties + Streams + Streams + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Large File Components/Streams/Streams.sln b/Samples/Chapter5/Large File Components/Streams/Streams.sln new file mode 100644 index 0000000..c288c6a --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/Streams.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Streams", "Streams.csproj", "{604022F0-ACDA-4FF9-85AA-1E769413509B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {604022F0-ACDA-4FF9-85AA-1E769413509B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {604022F0-ACDA-4FF9-85AA-1E769413509B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {604022F0-ACDA-4FF9-85AA-1E769413509B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {604022F0-ACDA-4FF9-85AA-1E769413509B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter5/Large File Components/Streams/Streams.suo b/Samples/Chapter5/Large File Components/Streams/Streams.suo new file mode 100644 index 0000000..5a4e9bf Binary files /dev/null and b/Samples/Chapter5/Large File Components/Streams/Streams.suo differ diff --git a/Samples/Chapter5/Large File Components/Streams/VirtualStream.cs b/Samples/Chapter5/Large File Components/Streams/VirtualStream.cs new file mode 100644 index 0000000..531f4ee --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/VirtualStream.cs @@ -0,0 +1,414 @@ +//--------------------------------------------------------------------- +// File: VirtualStream.cs +// +// Summary: A sample pipeline component which demonstrates how to promote message context +// properties and write distinguished fields for XML messages using arbitrary +// XPath expressions. +// +// Sample: Arbitrary XPath Property Handler Pipeline Component SDK +// +//--------------------------------------------------------------------- +// This file is part of the Microsoft BizTalk Server 2006 SDK +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// This source code is intended only as a supplement to Microsoft BizTalk +// Server 2006 release and/or on-line documentation. See these other +// materials for detailed information regarding Microsoft code samples. +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR +// PURPOSE. +//--------------------------------------------------------------------- + +using System; +using System.IO; +using System.Text; +using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; + +namespace Microsoft.Samples.BizTalk.Pipelines.CustomComponent +{ + /// + /// Implements a virtual stream, i.e. the always seekable stream which + /// uses configurable amount of memory to reduce a memory footprint and + /// temporarily stores remaining data in a temporary file on disk. + /// + public sealed class VirtualStream : Stream, IDisposable + { + /// + /// Memory handling. + /// + public enum MemoryFlag + { + AutoOverFlowToDisk = 0, + OnlyInMemory = 1, + OnlyToDisk = 2 + } + + // Constants + private const int MemoryThreshold = 4*1024*1024; // The maximum possible memory consumption (4Mb) + private const int DefaultMemorySize = 4*1024; // Default memory consumption (4Kb) + + private Stream wrappedStream; + private bool isDisposed; + private bool isInMemory; + private int thresholdSize; + private MemoryFlag memoryStatus; + + /// + /// Initializes a VirtualStream instance with default parameters (10K memory buffer, + /// allow overflow to disk). + /// + public VirtualStream() + : this(DefaultMemorySize, MemoryFlag.AutoOverFlowToDisk, new MemoryStream()) + { + } + + /// + /// Initializes a VirtualStream instance with memory buffer size. + /// + /// Memory buffer size + public VirtualStream(int bufferSize) + : this(bufferSize, MemoryFlag.AutoOverFlowToDisk, new MemoryStream(bufferSize)) + { + } + + /// + /// Initializes a VirtualStream instance with a default memory size and memory flag specified. + /// + /// Memory flag + public VirtualStream(MemoryFlag flag) + : this(DefaultMemorySize, flag, + (flag == MemoryFlag.OnlyToDisk) ? CreatePersistentStream() : new MemoryStream()) + { + } + + /// + /// Initializes a VirtualStream instance with a memory buffer size and memory flag specified. + /// + /// Memory buffer size + /// Memory flag + public VirtualStream(int bufferSize, MemoryFlag flag) + : this(bufferSize, flag, + (flag == MemoryFlag.OnlyToDisk) ? CreatePersistentStream() : new MemoryStream(bufferSize)) + { + } + + /// + /// Initializes a VirtualStream instance with a memory buffer size, memory flag and underlying stream + /// specified. + /// + /// Memory buffer size + /// Memory flag + /// Underlying stream + private VirtualStream(int bufferSize, MemoryFlag flag, Stream dataStream) + { + if (null == dataStream) + throw new ArgumentNullException("dataStream"); + + isInMemory = (flag != MemoryFlag.OnlyToDisk); + memoryStatus = flag; + bufferSize = Math.Min(bufferSize, MemoryThreshold); + thresholdSize = bufferSize; + + if (isInMemory) + wrappedStream = dataStream; // Don't want to double wrap memory stream + else + wrappedStream = new BufferedStream(dataStream, bufferSize); + isDisposed = false; + } + + #region Stream Methods and Properties + + /// + /// Gets a flag indicating whether a stream can be read. + /// + override public bool CanRead + { + get {return wrappedStream.CanRead;} + } + /// + /// Gets a flag indicating whether a stream can be written. + /// + override public bool CanWrite + { + get {return wrappedStream.CanWrite;} + } + /// + /// Gets a flag indicating whether a stream can seek. + /// + override public bool CanSeek + { + get {return true;} + } + /// + /// Returns the length of the source stream. + /// + /// + override public long Length + { + get {return wrappedStream.Length;} + } + + /// + /// Gets or sets a position in the stream. + /// + override public long Position + { + get {return wrappedStream.Position;} + set {wrappedStream.Seek(value, SeekOrigin.Begin);} + } + + /// + /// + /// + /// + /// Calling other methods after calling Close() may result in a ObjectDisposedException beeing throwed. + /// + override public void Close() + { + if(!isDisposed) + { + GC.SuppressFinalize(this); + Cleanup(); + } + } + + /// + /// + /// + /// + /// + override public void Flush() + { + ThrowIfDisposed(); + wrappedStream.Flush(); + } + + /// + /// + /// + /// + /// + /// + /// + /// The number of bytes read + /// + /// + /// May throw . + /// It will read from cached persistence stream + /// + override public int Read(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + return wrappedStream.Read(buffer, offset, count); + } + + /// + /// + /// + /// + /// + /// + /// The current position + /// + /// + /// May throw . + /// It will cache any new data into the persistence stream + /// + override public long Seek(long offset, SeekOrigin origin) + { + ThrowIfDisposed(); + return wrappedStream.Seek(offset, origin); + } + + /// + /// + /// + /// + /// + /// May throw . + /// + override public void SetLength(long length) + { + ThrowIfDisposed(); + + // Check if new position is greater than allowed by threshold + if (memoryStatus == MemoryFlag.AutoOverFlowToDisk && + isInMemory && + length > thresholdSize) + { + // Currently in memory, and the new write will push it over the limit + // Switching to Persist Stream + BufferedStream persistStream = new BufferedStream(CreatePersistentStream(), thresholdSize); + + // Copy current wrapped memory stream to the persist stream + CopyStreamContent((MemoryStream)wrappedStream, persistStream); + + // Close old wrapped stream + if (wrappedStream != null) + wrappedStream.Close(); + + wrappedStream = persistStream; + isInMemory = false; + } + + // Set new length for the wrapped stream + wrappedStream.SetLength(length); + } + + /// + /// + /// + /// + /// + /// + /// + /// Write to the underlying stream. + /// + override public void Write(byte[] buffer, int offset, int count) + { + ThrowIfDisposed(); + + // Check if new position after write is greater than allowed by threshold + if (memoryStatus == MemoryFlag.AutoOverFlowToDisk && + isInMemory && + (count + wrappedStream.Position) > thresholdSize) + { + // Currently in memory, and the new write will push it over the limit + // Switching to Persist Stream + BufferedStream persistStream = new BufferedStream(CreatePersistentStream(), thresholdSize); + + // Copy current wrapped memory stream to the persist stream + CopyStreamContent((MemoryStream) wrappedStream, persistStream); + + // Close old wrapped stream + if (wrappedStream != null) + wrappedStream.Close(); + + wrappedStream = persistStream; + isInMemory = false; + } + + wrappedStream.Write(buffer, offset, count); + } + + #endregion + + #region IDisposable Interface + + /// + /// + /// + /// + /// It will call + /// + public void Dispose() + { + Close(); + } + + #endregion + + #region Private Utility Functions + + /// + /// Utility method called by the Finalize(), Close() or Dispose() to close and release + /// both the source and the persistence stream. + /// + private void Cleanup() + { + if(!isDisposed) + { + isDisposed = true; + if(null != wrappedStream) + { + wrappedStream.Close(); + wrappedStream = null; + } + } + } + + /// + /// Copies source memory stream to the target stream. + /// + /// Source memory stream + /// Target stream + private void CopyStreamContent(MemoryStream source, Stream target) + { + // Remember position for the source stream + long currentPosition = source.Position; + + // Read and write in chunks each thresholdSize + byte[] tempBuffer = new Byte[thresholdSize]; + int read = 0; + + source.Position = 0; + while ((read = source.Read(tempBuffer, 0, tempBuffer.Length)) != 0) + target.Write(tempBuffer, 0, read); + + // Set target's stream position to be the same as was in source stream. This is required because + // target stream is going substitute source stream. + target.Position = currentPosition; + + // Restore source stream's position (just in case to preserve the source stream's state) + source.Position = currentPosition; + } + + /// + /// Called by other methods to check the stream state. + /// It will thorw if the stream was closed or disposed. + /// + private void ThrowIfDisposed() + { + if(isDisposed || null == wrappedStream) + throw new ObjectDisposedException("VirtualStream"); + } + + /// + /// Utility method. + /// Creates a FileStream with a unique name and the temporary and delete-on-close attributes. + /// + /// + /// The temporary persistence stream + /// + public static Stream CreatePersistentStream() + { + StringBuilder name = new StringBuilder(256); + + IntPtr handle; + if(0 == GetTempFileName(Path.GetTempPath(), "BTS", 0, name)) + throw new IOException("GetTempFileName Failed.", Marshal.GetHRForLastWin32Error()); + + handle = CreateFile(name.ToString(), (UInt32) FileAccess.ReadWrite, 0, IntPtr.Zero, (UInt32) FileMode.Create, 0x04000100, IntPtr.Zero); + + // FileStream constructor will throw exception if handle is zero or -1. + return new FileStream(new SafeFileHandle(handle, true), FileAccess.ReadWrite); + } + + [DllImport("kernel32.dll")] + private static extern UInt32 GetTempFileName + ( + string path, + string prefix, + UInt32 unique, + StringBuilder name + ); + + [DllImport("kernel32.dll")] + private static extern IntPtr CreateFile + ( + string name, + UInt32 accessMode, + UInt32 shareMode, + IntPtr security, + UInt32 createMode, + UInt32 flags, + IntPtr template + ); + + #endregion + } +} diff --git a/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.dll b/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.dll new file mode 100644 index 0000000..470007c Binary files /dev/null and b/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.dll differ diff --git a/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.pdb b/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.pdb new file mode 100644 index 0000000..c086da2 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Streams/bin/Debug/Streams.pdb differ diff --git a/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.dll b/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.dll new file mode 100644 index 0000000..470007c Binary files /dev/null and b/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.dll differ diff --git a/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.pdb b/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.pdb new file mode 100644 index 0000000..c086da2 Binary files /dev/null and b/Samples/Chapter5/Large File Components/Streams/obj/Debug/Streams.pdb differ diff --git a/Samples/Chapter5/Large File Components/Streams/obj/Streams.csproj.FileList.txt b/Samples/Chapter5/Large File Components/Streams/obj/Streams.csproj.FileList.txt new file mode 100644 index 0000000..f2868bc --- /dev/null +++ b/Samples/Chapter5/Large File Components/Streams/obj/Streams.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\Streams.dll +bin\Debug\Streams.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Streams.dll +obj\Debug\Streams.pdb diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Pipelines.Samples.GnuPG/Microsoft.Pipelines.Samples.GnuPG.btproj b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Pipelines.Samples.GnuPG/Microsoft.Pipelines.Samples.GnuPG.btproj new file mode 100644 index 0000000..e8f28d0 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Pipelines.Samples.GnuPG/Microsoft.Pipelines.Samples.GnuPG.btproj @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.sln b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.sln new file mode 100644 index 0000000..eca4159 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.sln differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.suo b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.suo new file mode 100644 index 0000000..f95d19f Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Pipelines.GnuPG.suo differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/AssemblyInfo.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/AssemblyInfo.cs new file mode 100644 index 0000000..2a20445 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/FileStreamReadWrite.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/FileStreamReadWrite.cs new file mode 100644 index 0000000..5ec36a2 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/FileStreamReadWrite.cs @@ -0,0 +1,62 @@ +namespace Microsoft.Samples.PipelineUtilities +{ + using System; + using System.IO; + + /// + /// Summary description for FileStreamReadWrite. + /// + public abstract class FileStreamReadWrite + { + public static void DumpStreamToFile (Stream fromStream, string toFilename) + { + FileStream file = null; + try + { + file = new FileStream(toFilename, System.IO.FileMode.Create); + byte[] tmpBuff = new byte[4096]; + int bytesRead = 0; + + while ((bytesRead = fromStream.Read(tmpBuff, 0, tmpBuff.Length)) != 0) + { + file.Write(tmpBuff, 0, bytesRead); + } + + file.Close(); + file = null; + } + finally + { + if (file != null) file.Close(); + } + } + + public static MemoryStream ReadFileToMemoryStream (string fromFilename) + { + FileStream file = null; + try + { + file = new FileStream(fromFilename, System.IO.FileMode.Open); + MemoryStream memStream = new MemoryStream(); + byte[] tmpBuff = new byte[4096]; + int bytesRead = 0; + + while ((bytesRead = file.Read(tmpBuff, 0, tmpBuff.Length)) != 0) + { + memStream.Write(tmpBuff, 0, bytesRead); + } + + file.Close(); + file = null; + + memStream.Position = 0; + return memStream; + } + finally + { + if (file != null) file.Close(); + } + } + + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj new file mode 100644 index 0000000..488f189 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj @@ -0,0 +1,109 @@ + + + Local + 8.0.50727 + 2.0 + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3} + Debug + AnyCPU + + + + + Microsoft.Samples.PipelineUtilities + + + JScript + Grid + IE50 + false + Library + Microsoft.Samples.PipelineUtilities + OnBuildSuccess + + + + + + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + Microsoft.BizTalk.Pipeline + ..\..\..\Program Files\Microsoft BizTalk Server 2004\Microsoft.BizTalk.Pipeline.dll + + + System + + + System.Data + + + System.XML + + + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user new file mode 100644 index 0000000..7e53e79 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user @@ -0,0 +1,57 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Program Files\Microsoft BizTalk Server 2004\ + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs new file mode 100644 index 0000000..0a43cea --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs @@ -0,0 +1,55 @@ +using System; + +namespace Microsoft.Samples.PipelineUtilities +{ + /// + /// Summary description for PropertyBagReadWrite. + /// + public abstract class PropertyBagReadWrite + { + /// + /// Reads property value from property bag. + /// + /// Property bag. + /// Name of property. + /// Value of the property. + public static object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName) + { + object val = null; + + try + { + pb.Read(propName, out val, 0); + } + catch(ArgumentException) + { + return val; + } + catch(Exception ex) + { + throw new ApplicationException(ex.Message); + } + + return val; + } + + /// + /// Writes property values into a property bag. + /// + /// Property bag. + /// Name of property. + /// Value of property. + public static void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val) + { + try + { + pb.Write(propName, ref val); + } + catch(Exception ex) + { + throw new ApplicationException(ex.Message); + } + } + + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll new file mode 100644 index 0000000..08d46b1 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb new file mode 100644 index 0000000..39d3bca Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll new file mode 100644 index 0000000..7cc9402 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb new file mode 100644 index 0000000..4478349 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll new file mode 100644 index 0000000..08d46b1 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb new file mode 100644 index 0000000..39d3bca Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll new file mode 100644 index 0000000..7cc9402 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb new file mode 100644 index 0000000..4478349 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata new file mode 100644 index 0000000..dbcaa24 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt new file mode 100644 index 0000000..358d4c7 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\Microsoft.Samples.PipelineUtilities.dll +bin\Debug\Microsoft.Samples.PipelineUtilities.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Samples.PipelineUtilities.dll +obj\Debug\Microsoft.Samples.PipelineUtilities.pdb diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt new file mode 100644 index 0000000..77536ff --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\Microsoft.Utility.PipelinePropertyAttribute.dll +bin\Debug\Microsoft.Utility.PipelinePropertyAttribute.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Utility.PipelinePropertyAttribute.dll +obj\Debug\Microsoft.Utility.PipelinePropertyAttribute.pdb diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/AssemblyInfo.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/AssemblyInfo.cs new file mode 100644 index 0000000..cc9c4f2 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGCommand.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGCommand.cs new file mode 100644 index 0000000..81a620c --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGCommand.cs @@ -0,0 +1,259 @@ +using System; +using System.Text; +using System.Diagnostics; +using System.IO; + +namespace Microsoft.Utilities.Cryptography.GnuPG +{ + public enum Commands + { + Encrypt, + Decrypt + }; + + public enum VerboseLevel + { + NoVerbose, + Verbose, + VeryVerbose, + ExtremelyVerbose + }; + + /// + /// Summary description for GnuPGCommand. + /// + public class GnuPGCommand + { + private Commands command = Commands.Decrypt; + private bool armor = true; + private bool yes = true; + private string recipient = ""; + private string homeDir = ""; + private string passphrase = ""; + private VerboseLevel verbose = VerboseLevel.NoVerbose; + private bool batch = true; + private string originator = ""; + private string inputFile = ""; + private string outputFile = ""; + + private bool recipientRequired = false; + private bool passphraseRequired = false; + + #region Properties + + public Commands Command + { + set + { + this.command = value; + + switch (value) + { + case Commands.Decrypt: + this.recipientRequired = false; + this.passphraseRequired = false; + this.armor = false; + break; + + case Commands.Encrypt: + this.recipientRequired = true; + break; + + default: + break; + } + } + + get { return(this.command); } + } + + public bool Armor + { + set { this.armor = value; } + get { return(this.armor); } + } + + public string Recipient + { + set { this.recipient = value; } + get { return(this.recipient); } + } + + public string Originator + { + set { this.originator = value; } + get { return(this.originator); } + } + + public bool Yes + { + set { this.yes = value; } + get { return(this.yes); } + } + + public bool Batch + { + set { this.batch = value; } + get { return(this.batch); } + } + + public string Passphrase + { + set { this.passphrase = value; } + get { return(this.passphrase); } + } + + public string HomeDirectory + { + set { this.homeDir = value; } + get { return(this.homeDir); } + } + + public VerboseLevel Verbose + { + set { this.verbose = value; } + get { return(this.verbose); } + } + + public string InputFile + { + set { this.inputFile = value; } + get { return(this.inputFile); } + } + + public string OutputFile + { + set { this.outputFile = value; } + get { return(this.outputFile); } + } + + #endregion + + public GnuPGCommand() + { + } + + public override string ToString() + { + return ConstructCommandLine(); + } + + #region Helpers + + private string ConstructCommandLine() + { + StringBuilder commandLine = new StringBuilder("", 255); + + if ((this.homeDir != null) && (this.homeDir != "")) + { + commandLine.Append("--homedir \""); + commandLine.Append(this.homeDir); + commandLine.Append("\" "); + } + + if (this.yes) + { + commandLine.Append("--yes "); + } + + if (this.batch) + { + commandLine.Append("--batch "); + commandLine.Append("--passphrase-fd 0 "); // get passphrase from stdin (not console device, which is default) + } + + switch (this.command) + { + case Commands.Encrypt: + commandLine.Append("-e "); + break; + + case Commands.Decrypt: + commandLine.Append("-d "); + break; + } + + if (this.armor) + { + commandLine.Append("-a "); + } + + if (this.recipient != "") + { + string[] recipients = recipient.Split(new Char[] {';'}); + + foreach (string s in recipients) + { + System.Diagnostics.Debug.WriteLine(s); + if (s.Trim() != "") + { + commandLine.Append("-r \""); + commandLine.Append(s); + commandLine.Append("\" "); + } + } + } + else + { + // If you encrypt, you NEED a recipient! + if (this.recipientRequired) + { + throw new GnuPGException("GPGNET: Missing 'recipient' parameter: cannot encrypt without a recipient"); + } + } + + if (this.originator != "") + { + commandLine.Append("--default-key \""); + commandLine.Append(this.originator); + commandLine.Append("\" "); + } + + if (this.passphrase == "") + { + if (this.passphraseRequired) + { + throw new GnuPGException("GPGNET: Missing 'passphrase' parameter: cannot sign without a passphrase"); + } + } + + switch (this.verbose) + { + case VerboseLevel.NoVerbose: + commandLine.Append("--no-verbose "); + break; + + case VerboseLevel.Verbose: + commandLine.Append("-v "); + break; + + case VerboseLevel.VeryVerbose: + commandLine.Append("-v -v "); + break; + + case VerboseLevel.ExtremelyVerbose: + commandLine.Append("-v -v -v "); + break; + } + + if (this.outputFile != "") + { + commandLine.Append("-o \""); + commandLine.Append(this.outputFile); + commandLine.Append("\" "); + } + + // must always be the last argument + if (this.inputFile != "") + { + commandLine.Append("\""); + commandLine.Append(this.inputFile); + commandLine.Append("\""); + } + + return(commandLine.ToString()); + } + + #endregion + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGException.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGException.cs new file mode 100644 index 0000000..35b593b --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGException.cs @@ -0,0 +1,14 @@ +using System; + +namespace Microsoft.Utilities.Cryptography.GnuPG +{ + /// + /// Summary description for GnuPGException. + /// + public class GnuPGException: Exception + { + public GnuPGException(string message): base(message) + { + } + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGWrapper.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGWrapper.cs new file mode 100644 index 0000000..fdad908 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/GnuPGWrapper.cs @@ -0,0 +1,190 @@ +using System; +using System.Text; +using System.Diagnostics; +using System.IO; +using System.Threading; + +namespace Microsoft.Utilities.Cryptography.GnuPG +{ + public class GnuPGWrapper + { + private Process GnuPGProcess = null; + private GnuPGCommand GPGCommand = null; + private int processTimeOutMilliseconds = 30000; + private int exitCode = 0; + private string outString = ""; + private string errString = ""; + private const string executableName = @"gpg.exe"; + private const string default_binDir = @"C:\gnupg"; + + private string binDir = ""; + + #region Properties + + public int ExitCode + { + get{ return(exitCode); } + } + + public string ErrorMessage + { + get{ return(errString); } + } + + public GnuPGCommand Command + { + get { return(this.GPGCommand); } + } + + public int ProcessTimeOut + { + get { return(processTimeOutMilliseconds); } + set { processTimeOutMilliseconds = value; } + } + + #endregion + + public GnuPGWrapper() + { + this.binDir = default_binDir; + GPGCommand = new GnuPGCommand(); + GPGCommand.HomeDirectory = default_binDir; + } + + public GnuPGWrapper(string binDir) + { + this.binDir = (binDir == null ? default_binDir : binDir); + GPGCommand = new GnuPGCommand(); + GPGCommand.HomeDirectory = this.binDir; + } + + public void Initialize(string binDir) + { + this.binDir = (binDir == null ? default_binDir : binDir); + GPGCommand.HomeDirectory = this.binDir; + } + + public string Execute(string inText) + { + string fileName = this.binDir + @"\" + executableName; + string arguments = GPGCommand.ToString(); + ProcessStartInfo procInfo = new ProcessStartInfo( fileName, arguments ); + procInfo.WorkingDirectory = binDir; + procInfo.CreateNoWindow = true; + procInfo.UseShellExecute = false; + procInfo.RedirectStandardInput = true; + procInfo.RedirectStandardOutput = true; + procInfo.RedirectStandardError = true; + + GnuPGProcess = Process.Start(procInfo); + + string passphrase = GPGCommand.Passphrase; + if ((passphrase != null) && (passphrase != "")) + { + if (procInfo.RedirectStandardInput) + { + GnuPGProcess.StandardInput.WriteLine( passphrase ); + GnuPGProcess.StandardInput.Flush(); + } + } + + if (inText != null) + { + if (procInfo.RedirectStandardInput) + { + GnuPGProcess.StandardInput.WriteLine(inText); + GnuPGProcess.StandardInput.Flush(); + } + } + + if (procInfo.RedirectStandardInput) + GnuPGProcess.StandardInput.Close(); + outString = ""; + errString = ""; + + ThreadStart stdOutDelegate = new ThreadStart(StandardOutHandler); + Thread stdOutThread = new Thread(stdOutDelegate); + stdOutThread.Start(); + ThreadStart stdErrDelegate = new ThreadStart(StanderErrHandler); + Thread stdErrThread = new Thread(stdErrDelegate); + stdErrThread.Start(); + + if (GnuPGProcess.WaitForExit(processTimeOutMilliseconds)) + { + if (!stdOutThread.Join(processTimeOutMilliseconds/2)) + { + stdOutThread.Abort(); + } + if (!stdErrThread.Join(processTimeOutMilliseconds/2)) + { + stdErrThread.Abort(); + } + } + else + { + outString = ""; + errString = "Timed out after " + processTimeOutMilliseconds.ToString() + " milliseconds"; + GnuPGProcess.Kill(); + GnuPGProcess.WaitForExit(); + + if (stdOutThread.IsAlive) + { + stdOutThread.Abort(); + } + + if (stdErrThread.IsAlive) + { + stdErrThread.Abort(); + } + } + + this.exitCode = GnuPGProcess.ExitCode; + + // don't allow warnings to throw errors, so if the call to GnuPG writes something to + // stdout then we return it, and whatever is on stderr, we only throw an error if + // there is nothing returned on stdout and the exitcode is not 0. + if ((exitCode != 0) && (outString == "")) + { + if (errString == "") + { + errString = "GPGNET: [" + GnuPGProcess.ExitCode.ToString() + "]: Unknown error"; + } + + throw new GnuPGException(errString); + } + + System.Diagnostics.Debug.WriteLine( string.Format(" Exit Code = {0}", exitCode ) ); + System.Diagnostics.Debug.WriteLine( string.Format(" Output = {0}", outString ) ); + System.Diagnostics.Debug.WriteLine( string.Format(" Error = {0}", errString ) ); + return outString; + } + + #region Thread Handlers + + public void StandardOutHandler() + { + string output = ""; + if (this.GnuPGProcess.StartInfo.RedirectStandardOutput) + output = this.GnuPGProcess.StandardOutput.ReadToEnd(); + + lock(this) + { + this.outString = output; + } + } + + public void StanderErrHandler() + { + string error = ""; + if (this.GnuPGProcess.StartInfo.RedirectStandardError) + this.GnuPGProcess.StandardError.ReadToEnd(); + + lock(this) + { + this.errString = error; + } + } + + #endregion + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj new file mode 100644 index 0000000..e466b6b --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj @@ -0,0 +1,108 @@ + + + Local + 8.0.50727 + 2.0 + {C15E56BF-9BFA-467A-909E-6B47C3BFC484} + Debug + AnyCPU + + + + + Microsoft.Utilities.Cryptography.GnuPG + + + JScript + Grid + IE50 + false + Library + Microsoft.Utilities.Cryptography.GnuPG + OnBuildSuccess + + + + + + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj.user b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj.user new file mode 100644 index 0000000..f9f192e --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.csproj.user @@ -0,0 +1,58 @@ + + + 7.10.3077 + Debug + AnyCPU + + + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.suo b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.suo new file mode 100644 index 0000000..3b3e0e0 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/Microsoft.Utilities.Cryptography.GnuPG.suo differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/obj/Debug/Neudesic.Utilities.Cryptography.GnuPG.projdata b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/obj/Debug/Neudesic.Utilities.Cryptography.GnuPG.projdata new file mode 100644 index 0000000..aaad4c1 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.GnuPG/obj/Debug/Neudesic.Utilities.Cryptography.GnuPG.projdata differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/AssemblyInfo.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/AssemblyInfo.cs new file mode 100644 index 0000000..917d3a8 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("Microsoft.Utility.PipelineGnuPG")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.cs new file mode 100644 index 0000000..bbb0d65 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.cs @@ -0,0 +1,175 @@ +namespace Microsoft.Utility.PipelineGnuPG +{ + using System; + using System.ComponentModel; + using System.Collections; + using System.Diagnostics; + using System.Drawing; + using System.IO; + using System.Reflection; + using Microsoft.BizTalk.Component.Interop; + using Microsoft.Samples.PipelineUtilities; + using Microsoft.Utilities.Cryptography.GnuPG; + + [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] + [ComponentCategory(CategoryTypes.CATID_Decoder)] + [System.Runtime.InteropServices.Guid("AEE2E180-8E4F-426d-9E39-C314E09F977E")] + public class GnuPGDecodeComponent : + IBaseComponent, + Microsoft.BizTalk.Component.Interop.IComponent, + Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, + IComponentUI + { + + // Component information + #region IBaseComponent + [Browsable(false)] public string Name { get { return "Gnu PGP decoder"; } } + [Browsable(false)] public string Version { get { return "1.0"; } } + [Browsable(false)] public string Description { get { return "GnuPG Decode Pipeline Component"; } } + [Browsable(false)] public System.IntPtr Icon { get { return ((Bitmap)resourceManager.GetObject("IconBitmap")).GetHicon(); } } + #endregion + + private System.Resources.ResourceManager resourceManager = + new System.Resources.ResourceManager("Microsoft.Utility.PipelineGnuPG.GnuPGDecodeComponent", Assembly.GetExecutingAssembly()); + + // Property: Passphrase + private string _passphrase; + [ + DisplayName("Passphrase"), + Description("Passphrase used to retreive private key.") + ] + public string Passphrase + { + get { return _passphrase; } + set { _passphrase = value; } + } + + // Property: GnuPGBinDir + private string _gnupgbindir; + [ + DisplayName("GnuPGBinDir"), + Description(@"Installation directory of GnuPG, that contains gpg.exe file. Default, if not specified, is ""C:\gnupg"". Do not include trailing slash.") + ] + public string GnuPGBinDir + { + get { return _gnupgbindir; } + set { _gnupgbindir = value; } + } + + private Stream Decode (System.IO.Stream inStream) + { + Stream outStream = inStream; + string inFile = Path.GetTempFileName(); + string outFile = Path.ChangeExtension(inFile, "txt"); + + try + { + FileStreamReadWrite.DumpStreamToFile( inStream, inFile ); + + GnuPGWrapper GPG = new GnuPGWrapper(_gnupgbindir); + GnuPGCommand GPGCommand = GPG.Command; + GPGCommand.Command = Commands.Decrypt; + GPGCommand.InputFile = inFile; + GPGCommand.OutputFile = outFile; + GPGCommand.Passphrase = _passphrase; + // TODO: support encrypted passphrase, no passphrase is a security risk + + GPG.Execute(null); + + outStream = FileStreamReadWrite.ReadFileToMemoryStream( outFile ); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + } + finally + { + if (File.Exists(inFile)) + { + File.Delete(inFile); + } + + if (File.Exists(outFile)) + { + File.Delete(outFile); + } + } + + return outStream; + } + + #region IPersistPropertyBag Members + + public void InitNew() + { + } + + public void GetClassID(out Guid classID) + { + classID = new Guid ("4FC12033-D0BD-4298-BB31-FBDBA72F5961"); + } + + public void Load(IPropertyBag propertyBag, int errorLog) + { + string text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "Passphrase" ); + if (text != null) _passphrase = text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "GnuPGBinDir" ); + if (text != null) _gnupgbindir = text; + } + + public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) + { + object val; + val = (object)_passphrase; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "Passphrase", val ); + val = (object)_gnupgbindir; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "GnuPGBinDir", val ); + } + + #endregion + + + #region IComponent Members + + public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) + { + try + { + if (pInMsg != null) + { + Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream(); + pInMsg.BodyPart.Data = Decode( originalStream ); + pContext.ResourceTracker.AddResource( pInMsg.BodyPart.Data ); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine( "Exception caught in GnuPGDecodeComponent::Execute: " + ex.Message ); + } + return pInMsg; + } + + #endregion + + #region IComponentUI Members + + /// + /// The Validate method is called by the BizTalk Editor during the build + /// of a BizTalk project. + /// + /// An Object containing the configuration properties. + /// The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + public IEnumerator Validate(object projectSystem) + { + // example implementation: + // ArrayList errorList = new ArrayList(); + // errorList.Add("This is a compiler error"); + // return errorList.GetEnumerator(); + return null; + } + + + #endregion + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.resx b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGDecodeComponent.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.cs b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.cs new file mode 100644 index 0000000..85886fa --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.cs @@ -0,0 +1,175 @@ +namespace Microsoft.Utility.PipelineGnuPG +{ + using System; + using System.ComponentModel; + using System.Collections; + using System.Diagnostics; + using System.Drawing; + using System.IO; + using System.Reflection; + using Microsoft.BizTalk.Component.Interop; + using Microsoft.Samples.PipelineUtilities; + using Microsoft.Utilities.Cryptography.GnuPG; + + [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] + [ComponentCategory(CategoryTypes.CATID_Encoder)] + [System.Runtime.InteropServices.Guid("C1917FE1-841B-4583-A59E-B57F76871899")] + public class GnuPGEncodeComponent : + IBaseComponent, + Microsoft.BizTalk.Component.Interop.IComponent, + Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, + IComponentUI + { + + // Component information + #region IBaseComponent + [Browsable(false)] public string Name { get { return "Gnu PGP encoder"; } } + [Browsable(false)] public string Version { get { return "1.0"; } } + [Browsable(false)] public string Description { get { return "GnuPG Encode Pipeline Component"; } } + [Browsable(false)] public System.IntPtr Icon { get { return ((Bitmap)resourceManager.GetObject("IconBitmap")).GetHicon(); } } + #endregion + + private System.Resources.ResourceManager resourceManager = + new System.Resources.ResourceManager("Microsoft.Utility.PipelineGnuPG.GnuPGEncodeComponent", Assembly.GetExecutingAssembly()); + + // Property: Recipient + private string _recipient; + [ + DisplayName("Recipient"), + Description("Recipient identifier used to retreive public key from encryption.") + ] + public string Recipient + { + get { return _recipient; } + set { _recipient = value; } + } + + // Property: GnuPGBinDir + private string _gnupgbindir; + [ + DisplayName("GnuPGBinDir"), + Description(@"Installation directory of GnuPG, that contains gpg.exe file. Default, if not specified, is ""C:\gnupg"". Do not include trailing slash.") + ] + public string GnuPGBinDir + { + get { return _gnupgbindir; } + set { _gnupgbindir = value; } + } + + private Stream Encode (Stream inStream) + { + Stream outStream = inStream; + string inFile = Path.GetTempFileName(); + string outFile = Path.ChangeExtension(inFile, "gpg"); + + try + { + FileStreamReadWrite.DumpStreamToFile( inStream, inFile ); + + GnuPGWrapper GPG = new GnuPGWrapper(_gnupgbindir); + GnuPGCommand GPGCommand = GPG.Command; + GPGCommand.Command = Commands.Encrypt; + GPGCommand.Recipient = _recipient; + GPGCommand.Armor = true; + GPGCommand.InputFile = inFile; + GPGCommand.OutputFile = outFile; + + GPG.Execute(null); + + outStream = FileStreamReadWrite.ReadFileToMemoryStream( outFile ); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + } + finally + { + if (File.Exists(inFile)) + { + File.Delete(inFile); + } + + if (File.Exists(outFile)) + { + File.Delete(outFile); + } + } + + return outStream; + } + + #region IPersistPropertyBag Members + + public void InitNew() + { + } + + public void GetClassID(out Guid classID) + { + classID = new Guid ("A398E8D1-4213-4438-9010-66F366D4BDF4"); + } + + public void Load(IPropertyBag propertyBag, int errorLog) + { + string text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "Recipient" ); + if (text != null) _recipient = text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "GnuPGBinDir" ); + if (text != null) _gnupgbindir = text; + } + + public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) + { + object val; + val = (object)_recipient; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "Recipient", val ); + val = (object)_gnupgbindir; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "GnuPGBinDir", val ); + } + + #endregion + + + #region IComponent Members + + public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) + { + try + { + if (pInMsg != null) + { + Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream(); + pInMsg.BodyPart.Data = Encode( originalStream ); + pContext.ResourceTracker.AddResource( pInMsg.BodyPart.Data ); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine( "Exception caught in GnuPGDecodeComponent::Execute: " + ex.Message ); + } + return pInMsg; + } + + #endregion + + #region IComponentUI Members + + /// + /// The Validate method is called by the BizTalk Editor during the build + /// of a BizTalk project. + /// + /// An Object containing the configuration properties. + /// The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + public IEnumerator Validate(object projectSystem) + { + // example implementation: + // ArrayList errorList = new ArrayList(); + // errorList.Add("This is a compiler error"); + // return errorList.GetEnumerator(); + return null; + } + + + #endregion + } +} diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.resx b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/GnuPGEncodeComponent.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj new file mode 100644 index 0000000..bb7f6ba --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj @@ -0,0 +1,128 @@ + + + Local + 8.0.50727 + 2.0 + {24AA9137-8809-4BDE-AF30-C8685F9578D6} + Debug + AnyCPU + + + + + Microsoft.Utility.PipelineGnuPG + + + JScript + Grid + IE50 + false + Library + Microsoft.Utility.PipelineGnuPG + OnBuildSuccess + + + + + + + + + ..\..\..\Program Files\Microsoft BizTalk Server 2004\Pipeline Components\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + Microsoft.BizTalk.Pipeline + ..\..\..\Program Files\Microsoft BizTalk Server 2004\Microsoft.BizTalk.Pipeline.dll + + + System + + + System.Data + + + System.Drawing + + + System.XML + + + Microsoft.Samples.PipelineUtilities + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + Microsoft.Utilities.Cryptography.GnuPG + {C15E56BF-9BFA-467A-909E-6B47C3BFC484} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + Code + + + Code + + + GnuPGDecodeComponent.cs + + + GnuPGEncodeComponent.cs + + + + + + + + "$(SolutionDir)PostBuild.bat" + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj.user b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj.user new file mode 100644 index 0000000..92d1a61 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/Microsoft.Utility.PipelineGnuPG.csproj.user @@ -0,0 +1,55 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Program Files\Microsoft BizTalk Server 2004\ + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Program + "C:\test\PipelineComponents\BtpTest\GnuPGDecode.btp" -d "C:\test\PipelineComponents\BtpTest\test.gpg" -c + + + C:\Program Files\Microsoft BizTalk Server 2004\SDK\Utilities\PipelineTools\Pipeline.exe + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/PipelineGnuPg.resx b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/PipelineGnuPg.resx new file mode 100644 index 0000000..17bc7a8 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/PipelineGnuPg.resx @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Qk02EAAAAAAAADYAAAAoAAAAIAAAACAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AIFoVgBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJ + NQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AhGtZAPTbzgDewLEA3L6uANu8rADbu6oA2bmoANi3 + pQDYtaMA17OhANaxnwDWsJwA1K2aANSrlwDSqpYA0qiTANCmkQDQpI8Az6ONAM+giwDNn4kAzZ6HAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCGblsA9NzRAPru6QD57OYA+erjAPfn + 3wD45dwA9+PaAPbg1wD139QA9N3RAPTbzgDz2MsA89bIAPLTxQDx0cIA8c+/APDNvADvy7kA78m2AO7H + tADNoIkAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AIlwXgD139MA+vDsAPnu + 6AD56+YA+eniAPjn3wD45dwA9uPaAPXh1gD13tQA9d3RAPTazQDz2MsA89XIAPLTxQDx0cEA8M++AO/N + vADvyrkA78i3AM+hiwBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8Ai3NhAPbg + 1gD78u4A+vHrAKyZiwCJcV8A0L6yAM66rgDNuKsAy7aoAMy1qADeyLoA79fLAPTazQD02MoA89XIAPLT + xADx0MEA8c6/APDMuwDvy7kA0KKNAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCNdmQA9uLYAPz08gD88+4Ahm5bALyjlgB6YE0AdVxJAHJYRABuVUAAfGNQALihkgDdxbgA9dzQAPTZ + zgDz2MoA89XIAPHTxADx0MEA8M6/APDMvADQpI8AY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AI94ZwD35NsA/Pb0APz08QCKcmAAzLivAHNaRwB/ZlUAjHNjAI11ZgB/Z1gAblVBAK+X + iAD13tMA9NzQAPTazgDz18oA89XHAPLTxADx0cEA8M6+ANGmkQBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8AkntpAPjm3gD9+fYA/PfzAI52ZQDe0coAp4+CANXGvQDEsKQAuqOVAKyQ + fgCVemcAfGNQAPXh1gD13tMA9dzQAPTazQDz18oA89XHAPLSwwDx0cEA0qmUAGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wCVfWwA+OjhAP76+QD9+PYAk3tqAPHq6ACxmIsA6eLeAOPZ + 0wDXyL8AvaaZAJV6ZwBuVUEA9+LZAPXg1QD13tMA9NzQAPTZzQD018oA8tXHAPLSxADTq5YAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AJZ/bwD56uMA/vz6AP76+ACWf24A////AI11 + ZACAaVYArJiKANfIvwDPu7IAl3xpAHJYRQD25NsA9uLYAPXg1gD13tIA9NzQAPTZzQDz18kA89TGANSs + mQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AmIJxAPns5gD//f0A/vz7AL6v + ogCum40A/PbzAM3AtgCJcF4A39PNANfIwACcgnAAdl1JAPjn3gD25NsA9uHYAPXg1QD13dMA9dzPAPTa + zADz18kA1a6bAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wCbhHMA+u7oAP/+ + /gD+/f0A/vv6AP35+AD9+PYA/fbyAI10YgB7XksAjHJiAIFmVAB7YU8A+OjgAPfm3QD349sA9uLYAPbf + 1gD13dIA9NvPAPPZzADWsZ4AY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AJ2H + dgD68esA////AP/+/gD+/fwA/vv6APn18gCijX0AqZKDAKuWiQChjYAAmYJ0AJB2ZACJcV8A+OjgAPfm + 3QD349oA9uLYAPbg1QD13dMA9NvPANezoABjSTUA////AP///wD///8A////AP///wD///8A////AP// + /wD///8An4l5APvy7gD///8A////AP/+/QD+/fwA+/j2AL+soQD9/PsA8evoAOLX0ADUxLsAxrGmAKiU + hQD56uMA+OjgAPjm3QD249oA9uHYAPbg1AD13dIA17WjAGNJNQD///8A////AP///wD///8A////AP// + /wD///8A////AP///wCijHsA+/TxAP///wD///8A////AP/+/gD+/fwA+/j2AKeThADWzcYA49nTALif + kQCHcF0A+u/pAPns5wD46uMA+OjgAPjm3QD349oA9uHYAPbf1ADZt6UAY0k1AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AKSOfgD///8A////AP///wD///8A////AP///wD+/PwAqZSHANXM + xQDk2dMAvaaYAIx0YgD78ewA+u/pAPns5gD46uMA+OjgAPjl3AD249oA9uHXANq5pwBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AppGBAP///wD///8A////AP///wD///8A////AP7+ + /QCsmYoA2M7HAOXa1QDBq58AkHpoAPvz7wD78OwA+u/pAI94ZwCTfGsA+OjgAPjm3QD349oA27qqAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCfiXkA+/LuAP///wD///8A////AP// + /wD///8A////ALCdjwDe1tAA6uLeAMu4rQCmjHwAknloAItzYQCHblwAr5WHAH1kUQD46uIA+OjgAPjl + 3ADbvKwAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AKKMewD79PEA////AP// + /wD///8A////AP///wD///8AtaSWAO3o5QDz7+0A283GALqjmACulYcAmYBvAJyDcgC6oZQAgmlWAPrs + 5gD56uMA+OffANy+rgBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8ApI5+AP// + /wD///8A////AP///wD///8A////AP///wDQxbwA5uDbAPLu7ADs5+MA1ca/AMStoAC0m4wArpWGAMey + pgCFbVsA+u7pAPrr5gD56eIA3cGxAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCmkYEA////AP///wD///8A////AP///wD///8A////APTx7wDLvbUA5d3YAO/q5wDo4d0A39XPANvQ + yQCwmIkA1MS6AIpyYQD78OsA+u7oAPnr5QDfwrMAY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AJ+JeQD78u4A////AP///wD///8A////AP///wD///8A////APPw7QDOwrkAu6qeALGe + kQCql4gApZKDAKOOfgDh1tAAjndlAPvy7gD78OsA+u7oAN/EtgBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8Aoox7APv08QD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP/+/AD+/PsA+fTxAMS3rAC4p5wA/PXxAPvz7QD68OsA4Me4AGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wC4o5QA////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A//7+AP/+/AD++/sA/vr5AP349gDJtKkAvaWXALKZiQCkingAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////ALqmmAD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A///+AP79/AD+/PsAnod2AGNJNQBjSTUAY0k1AGNJ + NQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AvKiaAP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP/9/ACgiXkA1cW9AMex + pQC5oZIAbFI+AGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wC+qpwA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A///+AKKM + fADj2tMA1cW8AHlgTABsUj4A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AMCt + nwD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8ApY5+APPv7QCIcF0AeWBMAP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8Awq+hAP///wD///8A////AP///wD//fwA/vv7AP35+AD9+PUA/PXyAPvz7wD78OsA+u3oAPnr + 5AD46eIA9+fdAPfk2wCnkYIAln9uAIhwXQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wDFsaMAw6+hAMKuoADArJ8Av6ucAL2pmwC8p5oAu6aXALiklQC3opQAtqGSALOf + kACynY8AsJuNAK6aiwCtmIgAq5aHAKmUhACWf24A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AA== + + + \ No newline at end of file diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.dll new file mode 100644 index 0000000..9e1a445 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.pdb new file mode 100644 index 0000000..161b2a8 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Microsoft.Utility.PipelineGnuPG.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.dll new file mode 100644 index 0000000..0f8292d Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.pdb new file mode 100644 index 0000000..b3b61b2 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/bin/Debug/Neudesic.Utilities.Cryptography.GnuPG.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGDecodeComponent.resources b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGDecodeComponent.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGDecodeComponent.resources differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGEncodeComponent.resources b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGEncodeComponent.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.GnuPGEncodeComponent.resources differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.PipelineGnuPg.resources b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.PipelineGnuPg.resources new file mode 100644 index 0000000..b354bcb Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.PipelineGnuPg.resources differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.csproj.GenerateResource.Cache b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.csproj.GenerateResource.Cache new file mode 100644 index 0000000..c65dd7b Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.csproj.GenerateResource.Cache differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.dll b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.dll new file mode 100644 index 0000000..2f2aaa4 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.dll differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.pdb b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.pdb new file mode 100644 index 0000000..e22441e Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.pdb differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.projdata b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.projdata new file mode 100644 index 0000000..d270fb8 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/Microsoft.Utility.PipelineGnuPG.projdata differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/ResolveAssemblyReference.cache b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..f73a387 Binary files /dev/null and b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/build.force b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Debug/build.force new file mode 100644 index 0000000..e69de29 diff --git a/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Microsoft.Utility.PipelineGnuPG.csproj.FileList.txt b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Microsoft.Utility.PipelineGnuPG.csproj.FileList.txt new file mode 100644 index 0000000..fa797e8 --- /dev/null +++ b/Samples/Chapter5/PGP Pipeline Components/Microsoft.Utilities.Cryptography.PipelineGnuPG/obj/Microsoft.Utility.PipelineGnuPG.csproj.FileList.txt @@ -0,0 +1,9 @@ +..\..\..\Program Files\Microsoft BizTalk Server 2004\Pipeline Components\Microsoft.Utility.PipelineGnuPG.dll +..\..\..\Program Files\Microsoft BizTalk Server 2004\Pipeline Components\Microsoft.Utility.PipelineGnuPG.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Utility.PipelineGnuPG.GnuPGDecodeComponent.resources +obj\Debug\Microsoft.Utility.PipelineGnuPG.GnuPGEncodeComponent.resources +obj\Debug\Microsoft.Utility.PipelineGnuPG.PipelineGnuPg.resources +obj\Debug\Microsoft.Utility.PipelineGnuPG.csproj.GenerateResource.Cache +obj\Debug\Microsoft.Utility.PipelineGnuPG.dll +obj\Debug\Microsoft.Utility.PipelineGnuPG.pdb diff --git a/Samples/Chapter5/SigningKey.snk b/Samples/Chapter5/SigningKey.snk new file mode 100644 index 0000000..11c139f Binary files /dev/null and b/Samples/Chapter5/SigningKey.snk differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj new file mode 100644 index 0000000..3336c01 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj.user b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj.user new file mode 100644 index 0000000..45351c7 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipPipelines.btproj.user @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipReceivePipeline.btp b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipReceivePipeline.btp new file mode 100644 index 0000000..e5d47ea Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipReceivePipeline.btp differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipSendPipeline.btp b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipSendPipeline.btp new file mode 100644 index 0000000..f60959d Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/ZipSendPipeline.btp differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/ICSharpCode.SharpZipLib.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..8eaf000 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/ICSharpCode.SharpZipLib.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll new file mode 100644 index 0000000..058674a Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Bam.EventObservation.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll new file mode 100644 index 0000000..51e7f68 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Pipeline.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll new file mode 100644 index 0000000..f7f9140 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Streaming.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll new file mode 100644 index 0000000..d0bc45c Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.Tracing.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll new file mode 100644 index 0000000..fd60673 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.BizTalk.XPathReader.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Samples.PipelineUtilities.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Samples.PipelineUtilities.dll new file mode 100644 index 0000000..ce86d67 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Samples.PipelineUtilities.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Utility.PipelineZip.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Utility.PipelineZip.dll new file mode 100644 index 0000000..ec7d0e2 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.Utility.PipelineZip.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll new file mode 100644 index 0000000..848d163 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.BaseTypes.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll new file mode 100644 index 0000000..9fcecc2 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ABC.BizTalk.Pipelines.ZipPipelines/bin/Deployment/Microsoft.XLANGs.RuntimeTypes.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.sln b/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.sln new file mode 100644 index 0000000..160e188 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Samples.PipelineUtilities", "Microsoft.Samples.Utilities\Microsoft.Samples.PipelineUtilities.csproj", "{74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Utility.PipelineZip", "Microsoft.Utility.PipelineZip\Microsoft.Utility.PipelineZip.csproj", "{548FA7AD-797A-4437-A5D5-2EBF4F718281}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpZipLib", "ICSharpCode.SharpZipLib\ICSharpCode.SharpZipLib.csproj", "{7F1C5F40-A2C9-4B92-8A23-78E95A74C194}" +EndProject +Project("{EF7E3281-CD33-11D4-8326-00C04FA0CE8D}") = "ZipPipelines", "ABC.BizTalk.Pipelines.ZipPipelines\ZipPipelines.btproj", "{FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|.NET = Debug|.NET + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Deployment|.NET = Deployment|.NET + Deployment|Any CPU = Deployment|Any CPU + Deployment|Mixed Platforms = Deployment|Mixed Platforms + Development|.NET = Development|.NET + Development|Any CPU = Development|Any CPU + Development|Mixed Platforms = Development|Mixed Platforms + Release|.NET = Release|.NET + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Debug|.NET.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Deployment|.NET.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Deployment|Any CPU.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Deployment|Any CPU.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Deployment|Mixed Platforms.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Deployment|Mixed Platforms.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Development|.NET.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Development|Any CPU.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Development|Any CPU.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Development|Mixed Platforms.ActiveCfg = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Development|Mixed Platforms.Build.0 = Debug|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Release|.NET.ActiveCfg = Release|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Release|Any CPU.Build.0 = Release|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Debug|.NET.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Debug|Any CPU.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Deployment|.NET.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Deployment|Any CPU.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Deployment|Any CPU.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Deployment|Mixed Platforms.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Deployment|Mixed Platforms.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Development|.NET.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Development|Any CPU.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Development|Any CPU.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Development|Mixed Platforms.ActiveCfg = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Development|Mixed Platforms.Build.0 = Debug|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Release|.NET.ActiveCfg = Release|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Release|Any CPU.ActiveCfg = Release|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Release|Any CPU.Build.0 = Release|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {548FA7AD-797A-4437-A5D5-2EBF4F718281}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Debug|.NET.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Deployment|.NET.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Deployment|Any CPU.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Deployment|Any CPU.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Deployment|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Deployment|Mixed Platforms.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Development|.NET.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Development|Any CPU.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Development|Any CPU.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Development|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Development|Mixed Platforms.Build.0 = Debug|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Release|.NET.ActiveCfg = Release|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Release|Any CPU.Build.0 = Release|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|.NET.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|.NET.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|.NET.Deploy.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|Any CPU.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|Mixed Platforms.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|Mixed Platforms.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Debug|Mixed Platforms.Deploy.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|.NET.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|.NET.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|.NET.Deploy.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|Any CPU.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|Mixed Platforms.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|Mixed Platforms.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Deployment|Mixed Platforms.Deploy.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|.NET.ActiveCfg = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|.NET.Build.0 = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|Any CPU.ActiveCfg = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|Mixed Platforms.ActiveCfg = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|Mixed Platforms.Build.0 = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Development|Mixed Platforms.Deploy.0 = Development|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|.NET.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|.NET.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|.NET.Deploy.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|Any CPU.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|Mixed Platforms.ActiveCfg = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|Mixed Platforms.Build.0 = Deployment|.NET + {FE2F7D0F-D784-4AB2-A62D-91C6B59AA81D}.Release|Mixed Platforms.Deploy.0 = Deployment|.NET + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.suo b/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.suo new file mode 100644 index 0000000..ec241a4 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Chapter 5 - Zip pipeline sample.suo differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/AssemblyInfo.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/AssemblyInfo.cs new file mode 100644 index 0000000..cc9c4f2 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj new file mode 100644 index 0000000..a71ffe4 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj @@ -0,0 +1,168 @@ + + + Local + 8.0.50727 + 2.0 + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194} + Debug + AnyCPU + + + + + ICSharpCode.SharpZipLib + + + JScript + Grid + IE50 + false + Library + ICSharpCode.SharpZipLib + OnBuildSuccess + + + + + + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj.user b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj.user new file mode 100644 index 0000000..f9f192e --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj.user @@ -0,0 +1,58 @@ + + + 7.10.3077 + Debug + AnyCPU + + + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ZipException.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ZipException.cs new file mode 100644 index 0000000..961a99c --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/ZipException.cs @@ -0,0 +1,63 @@ +// ZipException.cs +// +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib +{ + + /// + /// Represents errors specific to Zip file handling + /// + public class ZipException : ApplicationException + { + /// + /// Initializes a new instance of the ZipException class. + /// + public ZipException() + { + } + + /// + /// Initializes a new instance of the ZipException class with a specified error message. + /// + public ZipException(string msg) : base(msg) + { + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.dll b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..8eaf000 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.pdb b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.pdb new file mode 100644 index 0000000..369a59b Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/bin/Debug/ICSharpCode.SharpZipLib.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/Adler32.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/Adler32.cs new file mode 100644 index 0000000..882d01b --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/Adler32.cs @@ -0,0 +1,200 @@ +// Adler32.cs - Computes Adler32 data checksum of a data stream +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Checksums +{ + + /// + /// Computes Adler32 checksum for a stream of data. An Adler32 + /// checksum is not as reliable as a CRC32 checksum, but a lot faster to + /// compute. + /// + /// The specification for Adler32 may be found in RFC 1950. + /// ZLIB Compressed Data Format Specification version 3.3) + /// + /// + /// From that document: + /// + /// "ADLER32 (Adler-32 checksum) + /// This contains a checksum value of the uncompressed data + /// (excluding any dictionary data) computed according to Adler-32 + /// algorithm. This algorithm is a 32-bit extension and improvement + /// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 + /// standard. + /// + /// Adler-32 is composed of two sums accumulated per byte: s1 is + /// the sum of all bytes, s2 is the sum of all s1 values. Both sums + /// are done modulo 65521. s1 is initialized to 1, s2 to zero. The + /// Adler-32 checksum is stored as s2*65536 + s1 in most- + /// significant-byte first (network) order." + /// + /// "8.2. The Adler-32 algorithm + /// + /// The Adler-32 algorithm is much faster than the CRC32 algorithm yet + /// still provides an extremely low probability of undetected errors. + /// + /// The modulo on unsigned long accumulators can be delayed for 5552 + /// bytes, so the modulo operation time is negligible. If the bytes + /// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position + /// and order sensitive, unlike the first sum, which is just a + /// checksum. That 65521 is prime is important to avoid a possible + /// large class of two-byte errors that leave the check unchanged. + /// (The Fletcher checksum uses 255, which is not prime and which also + /// makes the Fletcher check insensitive to single byte changes 0 - + /// 255.) + /// + /// The sum s1 is initialized to 1 instead of zero to make the length + /// of the sequence part of s2, so that the length does not have to be + /// checked separately. (Any sequence of zeroes has a Fletcher + /// checksum of zero.)" + /// + /// + /// + public sealed class Adler32 : IChecksum + { + /// + /// largest prime smaller than 65536 + /// + readonly static uint BASE = 65521; + + uint checksum; + + /// + /// Returns the Adler32 data checksum computed so far. + /// + public long Value { + get { + return checksum; + } + } + + /// + /// Creates a new instance of the Adler32 class. + /// The checksum starts off with a value of 1. + /// + public Adler32() + { + Reset(); + } + + /// + /// Resets the Adler32 checksum to the initial value. + /// + public void Reset() + { + checksum = 1; //Initialize to 1 + } + + /// + /// Updates the checksum with the byte b. + /// + /// + /// the data value to add. The high byte of the int is ignored. + /// + public void Update(int bval) + { + //We could make a length 1 byte array and call update again, but I + //would rather not have that overhead + uint s1 = checksum & 0xFFFF; + uint s2 = checksum >> 16; + + s1 = (s1 + ((uint)bval & 0xFF)) % BASE; + s2 = (s1 + s2) % BASE; + + checksum = (s2 << 16) + s1; + } + + /// + /// Updates the checksum with the bytes taken from the array. + /// + /// + /// buffer an array of bytes + /// + public void Update(byte[] buffer) + { + Update(buffer, 0, buffer.Length); + } + + /// + /// Updates the checksum with the bytes taken from the array. + /// + /// + /// an array of bytes + /// + /// + /// the start of the data used for this update + /// + /// + /// the number of bytes to use for this update + /// + public void Update(byte[] buf, int off, int len) + { + if (buf == null) { + throw new ArgumentNullException("buf"); + } + + if (off < 0 || len < 0 || off + len > buf.Length) { + throw new ArgumentOutOfRangeException(); + } + + //(By Per Bothner) + uint s1 = checksum & 0xFFFF; + uint s2 = checksum >> 16; + + while (len > 0) { + // We can defer the modulo operation: + // s1 maximally grows from 65521 to 65521 + 255 * 3800 + // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 + int n = 3800; + if (n > len) { + n = len; + } + len -= n; + while (--n >= 0) { + s1 = s1 + (uint)(buf[off++] & 0xFF); + s2 = s2 + s1; + } + s1 %= BASE; + s2 %= BASE; + } + + checksum = (s2 << 16) | s1; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/CRC32.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/CRC32.cs new file mode 100644 index 0000000..be5a9f2 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/CRC32.cs @@ -0,0 +1,211 @@ +// CRC32.cs - Computes CRC32 data checksum of a data stream +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Checksums +{ + + /// + /// Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + /// x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + /// + /// Polynomials over GF(2) are represented in binary, one bit per coefficient, + /// with the lowest powers in the most significant bit. Then adding polynomials + /// is just exclusive-or, and multiplying a polynomial by x is a right shift by + /// one. If we call the above polynomial p, and represent a byte as the + /// polynomial q, also with the lowest power in the most significant bit (so the + /// byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + /// where a mod b means the remainder after dividing a by b. + /// + /// This calculation is done using the shift-register method of multiplying and + /// taking the remainder. The register is initialized to zero, and for each + /// incoming bit, x^32 is added mod p to the register if the bit is a one (where + /// x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + /// x (which is shifting right by one and adding x^32 mod p if the bit shifted + /// out is a one). We start with the highest power (least significant bit) of + /// q and repeat for all eight bits of q. + /// + /// The table is simply the CRC of all possible eight bit values. This is all + /// the information needed to generate CRC's on data a byte at a time for all + /// combinations of CRC register values and incoming bytes. + /// + public sealed class Crc32 : IChecksum + { + readonly static uint CrcSeed = 0xFFFFFFFF; + + readonly static uint[] CrcTable = new uint[] { + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, + 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, + 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, + 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, + 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, + 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, + 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, + 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, + 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, + 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, + 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, + 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, + 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, + 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, + 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, + 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, + 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, + 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, + 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, + 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, + 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, + 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, + 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, + 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, + 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, + 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, + 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, + 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, + 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, + 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, + 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, + 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, + 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, + 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, + 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, + 0x2D02EF8D + }; + + internal static uint ComputeCrc32(uint oldCrc, byte bval) + { + return (uint)(Crc32.CrcTable[(oldCrc ^ bval) & 0xFF] ^ (oldCrc >> 8)); + } + + /// + /// The crc data checksum so far. + /// + uint crc = 0; + + /// + /// Returns the CRC32 data checksum computed so far. + /// + public long Value { + get { + return (long)crc; + } + set { + crc = (uint)value; + } + } + + /// + /// Resets the CRC32 data checksum as if no update was ever called. + /// + public void Reset() + { + crc = 0; + } + + /// + /// Updates the checksum with the int bval. + /// + /// + /// the byte is taken as the lower 8 bits of bval + /// + public void Update(int bval) + { + crc ^= CrcSeed; + crc = CrcTable[(crc ^ bval) & 0xFF] ^ (crc >> 8); + crc ^= CrcSeed; + } + + /// + /// Updates the checksum with the bytes taken from the array. + /// + /// + /// buffer an array of bytes + /// + public void Update(byte[] buffer) + { + Update(buffer, 0, buffer.Length); + } + + /// + /// Adds the byte array to the data checksum. + /// + /// + /// the buffer which contains the data + /// + /// + /// the offset in the buffer where the data starts + /// + /// + /// the length of the data + /// + public void Update(byte[] buf, int off, int len) + { + if (buf == null) { + throw new ArgumentNullException("buf"); + } + + if (off < 0 || len < 0 || off + len > buf.Length) { + throw new ArgumentOutOfRangeException(); + } + + crc ^= CrcSeed; + + while (--len >= 0) { + crc = CrcTable[(crc ^ buf[off++]) & 0xFF] ^ (crc >> 8); + } + + crc ^= CrcSeed; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/IChecksum.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/IChecksum.cs new file mode 100644 index 0000000..48d04cb --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/IChecksum.cs @@ -0,0 +1,93 @@ +// IChecksum.cs - Interface to compute a data checksum +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +namespace ICSharpCode.SharpZipLib.Checksums +{ + + /// + /// Interface to compute a data checksum used by checked input/output streams. + /// A data checksum can be updated by one byte or with a byte array. After each + /// update the value of the current checksum can be returned by calling + /// getValue. The complete checksum object can also be reset + /// so it can be used again with new data. + /// + public interface IChecksum + { + /// + /// Returns the data checksum computed so far. + /// + long Value + { + get; + } + + /// + /// Resets the data checksum as if no update was ever called. + /// + void Reset(); + + /// + /// Adds one byte to the data checksum. + /// + /// + /// the data value to add. The high byte of the int is ignored. + /// + void Update(int bval); + + /// + /// Updates the data checksum with the bytes taken from the array. + /// + /// + /// buffer an array of bytes + /// + void Update(byte[] buffer); + + /// + /// Adds the byte array to the data checksum. + /// + /// + /// the buffer which contains the data + /// + /// + /// the offset in the buffer where the data starts + /// + /// + /// the length of the data + /// + void Update(byte[] buf, int off, int len); + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/StrangeCRC.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/StrangeCRC.cs new file mode 100644 index 0000000..c9b9ff8 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/checksums/StrangeCRC.cs @@ -0,0 +1,184 @@ +// StrangeCRC.cs - computes a crc used in the bziplib ... I don't think that +// this is the 'standard' crc, please correct me, if I'm wrong +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Checksums +{ + /// + /// Bzip2 checksum algorithm + /// + public class StrangeCRC : IChecksum + { + readonly static uint[] crc32Table = { + 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, + 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, + 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, + 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, + 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, + 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, + 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, + 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, + 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, + 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, + 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, + 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, + 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, + 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, + 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, + 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, + 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, + 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, + 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, + 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, + 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, + 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, + 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, + 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, + 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, + 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, + 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, + 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, + 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, + 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, + 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, + 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, + 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, + 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, + 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, + 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, + 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, + 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, + 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, + 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, + 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, + 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, + 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, + 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, + 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, + 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, + 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, + 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, + 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, + 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, + 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, + 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, + 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, + 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, + 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, + 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, + 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, + 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, + 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, + 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, + 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, + 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 + }; + + int globalCrc; + + /// + /// construct Crc + /// + public StrangeCRC() + { + Reset(); + } + + /// + /// reset state of Crc + /// + public void Reset() + { + globalCrc = -1; + } + + /// + /// current Crc value + /// + public long Value { + get { + return ~globalCrc; + } + } + + /// + /// update Crc value + /// + /// data update is based on + public void Update(int inCh) + { + int temp = (globalCrc >> 24) ^ inCh; + if (temp < 0) { + temp = 256 + temp; + } + globalCrc = (int)((globalCrc << 8) ^ crc32Table[temp]); + } + + /// + /// Update Crc based on a block of data + /// + public void Update(byte[] buf) + { + Update(buf, 0, buf.Length); + } + + /// + /// update Crc based on a portion of a block of data + /// + /// block of data + /// index of first byte to use + /// number of bytes to use + public void Update(byte[] buf, int off, int len) + { + if (buf == null) { + throw new ArgumentNullException("buf"); + } + + if (off < 0 || len < 0 || off + len > buf.Length) { + throw new ArgumentOutOfRangeException(); + } + + for (int i = 0; i < len; ++i) { + Update(buf[off++]); + } + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.dll b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..8eaf000 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.pdb b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.pdb new file mode 100644 index 0000000..369a59b Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.projdata b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.projdata new file mode 100644 index 0000000..8bc7d24 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/Debug/ICSharpCode.SharpZipLib.projdata differ diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/ICSharpCode.SharpZipLib.csproj.FileList.txt b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/ICSharpCode.SharpZipLib.csproj.FileList.txt new file mode 100644 index 0000000..2ff3276 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/obj/ICSharpCode.SharpZipLib.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\ICSharpCode.SharpZipLib.dll +bin\Debug\ICSharpCode.SharpZipLib.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\ICSharpCode.SharpZipLib.dll +obj\Debug\ICSharpCode.SharpZipLib.pdb diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Deflater.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Deflater.cs new file mode 100644 index 0000000..accaab0 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Deflater.cs @@ -0,0 +1,552 @@ +// Deflater.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// This is the Deflater class. The deflater class compresses input + /// with the deflate algorithm described in RFC 1951. It has several + /// compression levels and three different strategies described below. + /// + /// This class is not thread safe. This is inherent in the API, due + /// to the split of deflate and setInput. + /// + /// author of the original java version : Jochen Hoenicke + /// + public class Deflater + { + /// + /// The best and slowest compression level. This tries to find very + /// long and distant string repetitions. + /// + public static int BEST_COMPRESSION = 9; + + /// + /// The worst but fastest compression level. + /// + public static int BEST_SPEED = 1; + + /// + /// The default compression level. + /// + public static int DEFAULT_COMPRESSION = -1; + + /// + /// This level won't compress at all but output uncompressed blocks. + /// + public static int NO_COMPRESSION = 0; + + /// + /// The compression method. This is the only method supported so far. + /// There is no need to use this constant at all. + /// + public static int DEFLATED = 8; + + /* + * The Deflater can do the following state transitions: + * + * (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---. + * / | (2) (5) | + * / v (5) | + * (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3) + * \ | (3) | ,-------' + * | | | (3) / + * v v (5) v v + * (1) -> BUSY_STATE ----> FINISHING_STATE + * | (6) + * v + * FINISHED_STATE + * \_____________________________________/ + * | (7) + * v + * CLOSED_STATE + * + * (1) If we should produce a header we start in INIT_STATE, otherwise + * we start in BUSY_STATE. + * (2) A dictionary may be set only when we are in INIT_STATE, then + * we change the state as indicated. + * (3) Whether a dictionary is set or not, on the first call of deflate + * we change to BUSY_STATE. + * (4) -- intentionally left blank -- :) + * (5) FINISHING_STATE is entered, when flush() is called to indicate that + * there is no more INPUT. There are also states indicating, that + * the header wasn't written yet. + * (6) FINISHED_STATE is entered, when everything has been flushed to the + * internal pending output buffer. + * (7) At any time (7) + * + */ + + private static int IS_SETDICT = 0x01; + private static int IS_FLUSHING = 0x04; + private static int IS_FINISHING = 0x08; + + private static int INIT_STATE = 0x00; + private static int SETDICT_STATE = 0x01; + // private static int INIT_FINISHING_STATE = 0x08; + // private static int SETDICT_FINISHING_STATE = 0x09; + private static int BUSY_STATE = 0x10; + private static int FLUSHING_STATE = 0x14; + private static int FINISHING_STATE = 0x1c; + private static int FINISHED_STATE = 0x1e; + private static int CLOSED_STATE = 0x7f; + + /// + /// Compression level. + /// + private int level; + + /// + /// If true no Zlib/RFC1950 headers or footers are generated + /// + private bool noHeaderOrFooter; + + /// + /// The current state. + /// + private int state; + + /// + /// The total bytes of output written. + /// + private int totalOut; + + /// + /// The pending output. + /// + private DeflaterPending pending; + + /// + /// The deflater engine. + /// + private DeflaterEngine engine; + + /// + /// Creates a new deflater with default compression level. + /// + public Deflater() : this(DEFAULT_COMPRESSION, false) + { + + } + + /// + /// Creates a new deflater with given compression level. + /// + /// + /// the compression level, a value between NO_COMPRESSION + /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. + /// + /// if lvl is out of range. + public Deflater(int lvl) : this(lvl, false) + { + + } + + /// + /// Creates a new deflater with given compression level. + /// + /// + /// the compression level, a value between NO_COMPRESSION + /// and BEST_COMPRESSION. + /// + /// + /// true, if we should suppress the Zlib/RFC1950 header at the + /// beginning and the adler checksum at the end of the output. This is + /// useful for the GZIP/PKZIP formats. + /// + /// if lvl is out of range. + public Deflater(int level, bool noHeaderOrFooter) + { + if (level == DEFAULT_COMPRESSION) { + level = 6; + } else if (level < NO_COMPRESSION || level > BEST_COMPRESSION) { + throw new ArgumentOutOfRangeException("level"); + } + + pending = new DeflaterPending(); + engine = new DeflaterEngine(pending); + this.noHeaderOrFooter = noHeaderOrFooter; + SetStrategy(DeflateStrategy.Default); + SetLevel(level); + Reset(); + } + + + /// + /// Resets the deflater. The deflater acts afterwards as if it was + /// just created with the same compression level and strategy as it + /// had before. + /// + public void Reset() + { + state = (noHeaderOrFooter ? BUSY_STATE : INIT_STATE); + totalOut = 0; + pending.Reset(); + engine.Reset(); + } + + /// + /// Gets the current adler checksum of the data that was processed so far. + /// + public int Adler { + get { + return engine.Adler; + } + } + + /// + /// Gets the number of input bytes processed so far. + /// + public int TotalIn { + get { + return engine.TotalIn; + } + } + + /// + /// Gets the number of output bytes so far. + /// + public int TotalOut { + get { + return totalOut; + } + } + + /// + /// Flushes the current input block. Further calls to deflate() will + /// produce enough output to inflate everything in the current input + /// block. This is not part of Sun's JDK so I have made it package + /// private. It is used by DeflaterOutputStream to implement + /// flush(). + /// + public void Flush() + { + state |= IS_FLUSHING; + } + + /// + /// Finishes the deflater with the current input block. It is an error + /// to give more input after this method was called. This method must + /// be called to force all bytes to be flushed. + /// + public void Finish() + { + state |= IS_FLUSHING | IS_FINISHING; + } + + /// + /// Returns true if the stream was finished and no more output bytes + /// are available. + /// + public bool IsFinished { + get { + return state == FINISHED_STATE && pending.IsFlushed; + } + } + + /// + /// Returns true, if the input buffer is empty. + /// You should then call setInput(). + /// NOTE: This method can also return true when the stream + /// was finished. + /// + public bool IsNeedingInput { + get { + return engine.NeedsInput(); + } + } + + /// + /// Sets the data which should be compressed next. This should be only + /// called when needsInput indicates that more input is needed. + /// If you call setInput when needsInput() returns false, the + /// previous input that is still pending will be thrown away. + /// The given byte array should not be changed, before needsInput() returns + /// true again. + /// This call is equivalent to setInput(input, 0, input.length). + /// + /// + /// the buffer containing the input data. + /// + /// + /// if the buffer was finished() or ended(). + /// + public void SetInput(byte[] input) + { + SetInput(input, 0, input.Length); + } + + /// + /// Sets the data which should be compressed next. This should be + /// only called when needsInput indicates that more input is needed. + /// The given byte array should not be changed, before needsInput() returns + /// true again. + /// + /// + /// the buffer containing the input data. + /// + /// + /// the start of the data. + /// + /// + /// the length of the data. + /// + /// + /// if the buffer was finished() or ended() or if previous input is still pending. + /// + public void SetInput(byte[] input, int off, int len) + { + if ((state & IS_FINISHING) != 0) { + throw new InvalidOperationException("finish()/end() already called"); + } + engine.SetInput(input, off, len); + } + + /// + /// Sets the compression level. There is no guarantee of the exact + /// position of the change, but if you call this when needsInput is + /// true the change of compression level will occur somewhere near + /// before the end of the so far given input. + /// + /// + /// the new compression level. + /// + public void SetLevel(int lvl) + { + if (lvl == DEFAULT_COMPRESSION) { + lvl = 6; + } else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) { + throw new ArgumentOutOfRangeException("lvl"); + } + + if (level != lvl) { + level = lvl; + engine.SetLevel(lvl); + } + } + + /// + /// Get current compression level + /// + /// compression level + public int GetLevel() { + return level; + } + + /// + /// Sets the compression strategy. Strategy is one of + /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact + /// position where the strategy is changed, the same as for + /// setLevel() applies. + /// + /// + /// The new compression strategy. + /// + public void SetStrategy(DeflateStrategy strategy) + { + engine.Strategy = strategy; + } + + /// + /// Deflates the current input block with to the given array. + /// + /// + /// The buffer where compressed data is stored + /// + /// + /// The number of compressed bytes added to the output, or 0 if either + /// needsInput() or finished() returns true or length is zero. + /// + public int Deflate(byte[] output) + { + return Deflate(output, 0, output.Length); + } + + /// + /// Deflates the current input block to the given array. + /// + /// + /// Buffer to store the compressed data. + /// + /// + /// Offset into the output array. + /// + /// + /// The maximum number of bytes that may be stored. + /// + /// + /// The number of compressed bytes added to the output, or 0 if either + /// needsInput() or finished() returns true or length is zero. + /// + /// + /// If end() was previously called. + /// + /// + /// If offset and/or length don't match the array length. + /// + public int Deflate(byte[] output, int offset, int length) + { + int origLength = length; + + if (state == CLOSED_STATE) { + throw new InvalidOperationException("Deflater closed"); + } + + if (state < BUSY_STATE) { + /* output header */ + int header = (DEFLATED + + ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8; + int level_flags = (level - 1) >> 1; + if (level_flags < 0 || level_flags > 3) { + level_flags = 3; + } + header |= level_flags << 6; + if ((state & IS_SETDICT) != 0) { + /* Dictionary was set */ + header |= DeflaterConstants.PRESET_DICT; + } + header += 31 - (header % 31); + + + pending.WriteShortMSB(header); + if ((state & IS_SETDICT) != 0) { + int chksum = engine.Adler; + engine.ResetAdler(); + pending.WriteShortMSB(chksum >> 16); + pending.WriteShortMSB(chksum & 0xffff); + } + + state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING)); + } + + for (;;) { + int count = pending.Flush(output, offset, length); + offset += count; + totalOut += count; + length -= count; + + if (length == 0 || state == FINISHED_STATE) { + break; + } + + if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) { + if (state == BUSY_STATE) { + /* We need more input now */ + return origLength - length; + } else if (state == FLUSHING_STATE) { + if (level != NO_COMPRESSION) { + /* We have to supply some lookahead. 8 bit lookahead + * is needed by the zlib inflater, and we must fill + * the next byte, so that all bits are flushed. + */ + int neededbits = 8 + ((-pending.BitCount) & 7); + while (neededbits > 0) { + /* write a static tree block consisting solely of + * an EOF: + */ + pending.WriteBits(2, 10); + neededbits -= 10; + } + } + state = BUSY_STATE; + } else if (state == FINISHING_STATE) { + pending.AlignToByte(); + + // Compressed data is complete. Write footer information if required. + if (!noHeaderOrFooter) { + int adler = engine.Adler; + pending.WriteShortMSB(adler >> 16); + pending.WriteShortMSB(adler & 0xffff); + } + state = FINISHED_STATE; + } + } + } + return origLength - length; + } + + /// + /// Sets the dictionary which should be used in the deflate process. + /// This call is equivalent to setDictionary(dict, 0, dict.Length). + /// + /// + /// the dictionary. + /// + /// + /// if setInput () or deflate () were already called or another dictionary was already set. + /// + public void SetDictionary(byte[] dict) + { + SetDictionary(dict, 0, dict.Length); + } + + /// + /// Sets the dictionary which should be used in the deflate process. + /// The dictionary is a byte array containing strings that are + /// likely to occur in the data which should be compressed. The + /// dictionary is not stored in the compressed output, only a + /// checksum. To decompress the output you need to supply the same + /// dictionary again. + /// + /// + /// The dictionary data + /// + /// + /// An offset into the dictionary. + /// + /// + /// The length of the dictionary data to use + /// + /// + /// If setInput () or deflate () were already called or another dictionary was already set. + /// + public void SetDictionary(byte[] dict, int offset, int length) + { + if (state != INIT_STATE) { + throw new InvalidOperationException(); + } + + state = SETDICT_STATE; + engine.SetDictionary(dict, offset, length); + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterConstants.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterConstants.cs new file mode 100644 index 0000000..a973db2 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterConstants.cs @@ -0,0 +1,186 @@ +// DeflaterConstants.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// This class contains constants used for deflation. + /// + public class DeflaterConstants + { + /// + /// Set to true to enable debugging + /// + public const bool DEBUGGING = false; + + /// + /// Written to Zip file to identify a stored block + /// + public const int STORED_BLOCK = 0; + + /// + /// Identifies static tree in Zip file + /// + public const int STATIC_TREES = 1; + + /// + /// Identifies dynamic tree in Zip file + /// + public const int DYN_TREES = 2; + + /// + /// Header flag indicating a preset dictionary for deflation + /// + public const int PRESET_DICT = 0x20; + + /// + /// Sets internal buffer sizes for Huffman encoding + /// + public const int DEFAULT_MEM_LEVEL = 8; + + /// + /// Internal compression engine constant + /// + public const int MAX_MATCH = 258; + + /// + /// Internal compression engine constant + /// + public const int MIN_MATCH = 3; + + /// + /// Internal compression engine constant + /// + public const int MAX_WBITS = 15; + + /// + /// Internal compression engine constant + /// + public const int WSIZE = 1 << MAX_WBITS; + + /// + /// Internal compression engine constant + /// + public const int WMASK = WSIZE - 1; + + /// + /// Internal compression engine constant + /// + public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7; + + /// + /// Internal compression engine constant + /// + public const int HASH_SIZE = 1 << HASH_BITS; + + /// + /// Internal compression engine constant + /// + public const int HASH_MASK = HASH_SIZE - 1; + + /// + /// Internal compression engine constant + /// + public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH; + + /// + /// Internal compression engine constant + /// + public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; + + /// + /// Internal compression engine constant + /// + public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD; + + /// + /// Internal compression engine constant + /// + public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8); + + /// + /// Internal compression engine constant + /// + public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5); + + /// + /// Internal compression engine constant + /// + public const int DEFLATE_STORED = 0; + + /// + /// Internal compression engine constant + /// + public const int DEFLATE_FAST = 1; + + /// + /// Internal compression engine constant + /// + public const int DEFLATE_SLOW = 2; + + /// + /// Internal compression engine constant + /// + public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; + + /// + /// Internal compression engine constant + /// + public static int[] MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 }; + + /// + /// Internal compression engine constant + /// + public static int[] NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 }; + + /// + /// Internal compression engine constant + /// + public static int[] MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 }; + + /// + /// Internal compression engine constant + /// + public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; + + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterEngine.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterEngine.cs new file mode 100644 index 0000000..821e571 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterEngine.cs @@ -0,0 +1,706 @@ +// DeflaterEngine.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +using ICSharpCode.SharpZipLib.Checksums; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// Strategies for deflater + /// + public enum DeflateStrategy + { + /// + /// The default strategy + /// + Default = 0, + + /// + /// This strategy will only allow longer string repetitions. It is + /// useful for random data with a small character set. + /// + Filtered = 1, + + + /// + /// This strategy will not look for string repetitions at all. It + /// only encodes with Huffman trees (which means, that more common + /// characters get a smaller encoding. + /// + HuffmanOnly = 2 + } + + /// + /// Low level compression engine for deflate algorithm which uses a 32K sliding window + /// with secondary compression from Huffman/Shannon-Fano codes. + /// + public class DeflaterEngine : DeflaterConstants + { + static int TOO_FAR = 4096; + + int ins_h; + short[] head; + short[] prev; + + int matchStart, matchLen; + bool prevAvailable; + int blockStart; + int strstart, lookahead; + byte[] window; + + DeflateStrategy strategy; + int max_chain, max_lazy, niceLength, goodLength; + + /// + /// The current compression function. + /// + int comprFunc; + + /// + /// The input data for compression. + /// + byte[] inputBuf; + + /// + /// The total bytes of input read. + /// + int totalIn; + + /// + /// The offset into inputBuf, where input data starts. + /// + int inputOff; + + /// + /// The end offset of the input data. + /// + int inputEnd; + + DeflaterPending pending; + DeflaterHuffman huffman; + + /// + /// The adler checksum + /// + Adler32 adler; + + /// + /// Construct instance with pending buffer + /// + /// + /// Pending buffer to use + /// > + public DeflaterEngine(DeflaterPending pending) + { + this.pending = pending; + huffman = new DeflaterHuffman(pending); + adler = new Adler32(); + + window = new byte[2 * WSIZE]; + head = new short[HASH_SIZE]; + prev = new short[WSIZE]; + + /* We start at index 1, to avoid an implementation deficiency, that + * we cannot build a repeat pattern at index 0. + */ + blockStart = strstart = 1; + } + + /// + /// Reset internal state + /// + public void Reset() + { + huffman.Reset(); + adler.Reset(); + blockStart = strstart = 1; + lookahead = 0; + totalIn = 0; + prevAvailable = false; + matchLen = MIN_MATCH - 1; + + for (int i = 0; i < HASH_SIZE; i++) { + head[i] = 0; + } + + for (int i = 0; i < WSIZE; i++) { + prev[i] = 0; + } + } + + /// + /// Reset Adler checksum + /// + public void ResetAdler() + { + adler.Reset(); + } + + /// + /// Get current value of Adler checksum + /// + public int Adler { + get { + return (int)adler.Value; + } + } + + /// + /// Total data processed + /// + public int TotalIn { + get { + return totalIn; + } + } + + /// + /// Get/set the deflate strategy + /// + public DeflateStrategy Strategy { + get { + return strategy; + } + set { + strategy = value; + } + } + + /// + /// Set the deflate level (0-9) + /// + public void SetLevel(int lvl) + { + goodLength = DeflaterConstants.GOOD_LENGTH[lvl]; + max_lazy = DeflaterConstants.MAX_LAZY[lvl]; + niceLength = DeflaterConstants.NICE_LENGTH[lvl]; + max_chain = DeflaterConstants.MAX_CHAIN[lvl]; + + if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) { + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("Change from " + comprFunc + " to " + // + DeflaterConstants.COMPR_FUNC[lvl]); + // } + switch (comprFunc) { + case DEFLATE_STORED: + if (strstart > blockStart) { + huffman.FlushStoredBlock(window, blockStart, + strstart - blockStart, false); + blockStart = strstart; + } + UpdateHash(); + break; + case DEFLATE_FAST: + if (strstart > blockStart) { + huffman.FlushBlock(window, blockStart, strstart - blockStart, + false); + blockStart = strstart; + } + break; + case DEFLATE_SLOW: + if (prevAvailable) { + huffman.TallyLit(window[strstart-1] & 0xff); + } + if (strstart > blockStart) { + huffman.FlushBlock(window, blockStart, strstart - blockStart, false); + blockStart = strstart; + } + prevAvailable = false; + matchLen = MIN_MATCH - 1; + break; + } + comprFunc = COMPR_FUNC[lvl]; + } + } + + void UpdateHash() + { + // if (DEBUGGING) { + // //Console.WriteLine("updateHash: "+strstart); + // } + ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1]; + } + + int InsertString() + { + short match; + int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK; + + // if (DEBUGGING) { + // if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^ + // (window[strstart + 1] << HASH_SHIFT) ^ + // (window[strstart + 2])) & HASH_MASK)) { + // throw new Exception("hash inconsistent: " + hash + "/" + // +window[strstart] + "," + // +window[strstart+1] + "," + // +window[strstart+2] + "," + HASH_SHIFT); + // } + // } + + prev[strstart & WMASK] = match = head[hash]; + head[hash] = (short)strstart; + ins_h = hash; + return match & 0xffff; + } + + void SlideWindow() + { + Array.Copy(window, WSIZE, window, 0, WSIZE); + matchStart -= WSIZE; + strstart -= WSIZE; + blockStart -= WSIZE; + + /* Slide the hash table (could be avoided with 32 bit values + * at the expense of memory usage). + */ + for (int i = 0; i < HASH_SIZE; ++i) { + int m = head[i] & 0xffff; + head[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); + } + + /* Slide the prev table. */ + for (int i = 0; i < WSIZE; i++) { + int m = prev[i] & 0xffff; + prev[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); + } + } + + /// + /// Fill the window + /// + public void FillWindow() + { + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (strstart >= WSIZE + MAX_DIST) { + SlideWindow(); + } + + /* If there is not enough lookahead, but still some input left, + * read in the input + */ + while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) { + int more = 2 * WSIZE - lookahead - strstart; + + if (more > inputEnd - inputOff) { + more = inputEnd - inputOff; + } + + System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more); + adler.Update(inputBuf, inputOff, more); + + inputOff += more; + totalIn += more; + lookahead += more; + } + + if (lookahead >= MIN_MATCH) { + UpdateHash(); + } + } + + bool FindLongestMatch(int curMatch) + { + int chainLength = this.max_chain; + int niceLength = this.niceLength; + short[] prev = this.prev; + int scan = this.strstart; + int match; + int best_end = this.strstart + matchLen; + int best_len = Math.Max(matchLen, MIN_MATCH - 1); + + int limit = Math.Max(strstart - MAX_DIST, 0); + + int strend = strstart + MAX_MATCH - 1; + byte scan_end1 = window[best_end - 1]; + byte scan_end = window[best_end]; + + /* Do not waste too much time if we already have a good match: */ + if (best_len >= this.goodLength) { + chainLength >>= 2; + } + + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if (niceLength > lookahead) { + niceLength = lookahead; + } + + if (DeflaterConstants.DEBUGGING && strstart > 2 * WSIZE - MIN_LOOKAHEAD) { + throw new InvalidOperationException("need lookahead"); + } + + do { + if (DeflaterConstants.DEBUGGING && curMatch >= strstart) { + throw new InvalidOperationException("future match"); + } + if (window[curMatch + best_len] != scan_end || + window[curMatch + best_len - 1] != scan_end1 || + window[curMatch] != window[scan] || + window[curMatch + 1] != window[scan + 1]) { + continue; + } + + match = curMatch + 2; + scan += 2; + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart + 258. + */ + while (window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && + window[++scan] == window[++match] && scan < strend) ; + + if (scan > best_end) { + // if (DeflaterConstants.DEBUGGING && ins_h == 0) + // System.err.println("Found match: "+curMatch+"-"+(scan-strstart)); + matchStart = curMatch; + best_end = scan; + best_len = scan - strstart; + + if (best_len >= niceLength) { + break; + } + + scan_end1 = window[best_end - 1]; + scan_end = window[best_end]; + } + scan = strstart; + } while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit && --chainLength != 0); + + matchLen = Math.Min(best_len, lookahead); + return matchLen >= MIN_MATCH; + } + + /// + /// Set compression dictionary + /// + public void SetDictionary(byte[] buffer, int offset, int length) + { + if (DeflaterConstants.DEBUGGING && strstart != 1) { + throw new InvalidOperationException("strstart not 1"); + } + adler.Update(buffer, offset, length); + if (length < MIN_MATCH) { + return; + } + if (length > MAX_DIST) { + offset += length - MAX_DIST; + length = MAX_DIST; + } + + System.Array.Copy(buffer, offset, window, strstart, length); + + UpdateHash(); + --length; + while (--length > 0) { + InsertString(); + strstart++; + } + strstart += 2; + blockStart = strstart; + } + + bool DeflateStored(bool flush, bool finish) + { + if (!flush && lookahead == 0) { + return false; + } + + strstart += lookahead; + lookahead = 0; + + int storedLen = strstart - blockStart; + + if ((storedLen >= DeflaterConstants.MAX_BLOCK_SIZE) || /* Block is full */ + (blockStart < WSIZE && storedLen >= MAX_DIST) || /* Block may move out of window */ + flush) { + bool lastBlock = finish; + if (storedLen > DeflaterConstants.MAX_BLOCK_SIZE) { + storedLen = DeflaterConstants.MAX_BLOCK_SIZE; + lastBlock = false; + } + + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]"); + // } + + huffman.FlushStoredBlock(window, blockStart, storedLen, lastBlock); + blockStart += storedLen; + return !lastBlock; + } + return true; + } + + private bool DeflateFast(bool flush, bool finish) + { + if (lookahead < MIN_LOOKAHEAD && !flush) { + return false; + } + + while (lookahead >= MIN_LOOKAHEAD || flush) { + if (lookahead == 0) { + /* We are flushing everything */ + huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); + blockStart = strstart; + return false; + } + + if (strstart > 2 * WSIZE - MIN_LOOKAHEAD) { + /* slide window, as findLongestMatch needs this. + * This should only happen when flushing and the window + * is almost full. + */ + SlideWindow(); + } + + int hashHead; + if (lookahead >= MIN_MATCH && + (hashHead = InsertString()) != 0 && + strategy != DeflateStrategy.HuffmanOnly && + strstart - hashHead <= MAX_DIST && + FindLongestMatch(hashHead)) { + /* longestMatch sets matchStart and matchLen */ + // if (DeflaterConstants.DEBUGGING) { + // for (int i = 0 ; i < matchLen; i++) { + // if (window[strstart+i] != window[matchStart + i]) { + // throw new Exception(); + // } + // } + // } + + // -jr- Hak hak hak this stops problems with fast/low compression and index out of range + if (huffman.TallyDist(strstart - matchStart, matchLen)) { + bool lastBlock = finish && lookahead == 0; + huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); + blockStart = strstart; + } + + lookahead -= matchLen; + if (matchLen <= max_lazy && lookahead >= MIN_MATCH) { + while (--matchLen > 0) { + ++strstart; + InsertString(); + } + ++strstart; + } else { + strstart += matchLen; + if (lookahead >= MIN_MATCH - 1) { + UpdateHash(); + } + } + matchLen = MIN_MATCH - 1; + continue; + } else { + /* No match found */ + huffman.TallyLit(window[strstart] & 0xff); + ++strstart; + --lookahead; + } + + if (huffman.IsFull()) { + bool lastBlock = finish && lookahead == 0; + huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); + blockStart = strstart; + return !lastBlock; + } + } + return true; + } + + bool DeflateSlow(bool flush, bool finish) + { + if (lookahead < MIN_LOOKAHEAD && !flush) { + return false; + } + + while (lookahead >= MIN_LOOKAHEAD || flush) { + if (lookahead == 0) { + if (prevAvailable) { + huffman.TallyLit(window[strstart-1] & 0xff); + } + prevAvailable = false; + + /* We are flushing everything */ + if (DeflaterConstants.DEBUGGING && !flush) { + throw new Exception("Not flushing, but no lookahead"); + } + huffman.FlushBlock(window, blockStart, strstart - blockStart, + finish); + blockStart = strstart; + return false; + } + + if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD) { + /* slide window, as findLongestMatch need this. + * This should only happen when flushing and the window + * is almost full. + */ + SlideWindow(); + } + + int prevMatch = matchStart; + int prevLen = matchLen; + if (lookahead >= MIN_MATCH) { + int hashHead = InsertString(); + if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) { + /* longestMatch sets matchStart and matchLen */ + + /* Discard match if too small and too far away */ + if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) { + matchLen = MIN_MATCH - 1; + } + } + } + + /* previous match was better */ + if (prevLen >= MIN_MATCH && matchLen <= prevLen) { + // if (DeflaterConstants.DEBUGGING) { + // for (int i = 0 ; i < matchLen; i++) { + // if (window[strstart-1+i] != window[prevMatch + i]) + // throw new Exception(); + // } + // } + huffman.TallyDist(strstart - 1 - prevMatch, prevLen); + prevLen -= 2; + do { + strstart++; + lookahead--; + if (lookahead >= MIN_MATCH) { + InsertString(); + } + } while (--prevLen > 0); + strstart ++; + lookahead--; + prevAvailable = false; + matchLen = MIN_MATCH - 1; + } else { + if (prevAvailable) { + huffman.TallyLit(window[strstart-1] & 0xff); + } + prevAvailable = true; + strstart++; + lookahead--; + } + + if (huffman.IsFull()) { + int len = strstart - blockStart; + if (prevAvailable) { + len--; + } + bool lastBlock = (finish && lookahead == 0 && !prevAvailable); + huffman.FlushBlock(window, blockStart, len, lastBlock); + blockStart += len; + return !lastBlock; + } + } + return true; + } + + /// + /// Deflate drives actual compression of data + /// + public bool Deflate(bool flush, bool finish) + { + bool progress; + do { + FillWindow(); + bool canFlush = flush && inputOff == inputEnd; + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("window: ["+blockStart+","+strstart+"," + // +lookahead+"], "+comprFunc+","+canFlush); + // } + switch (comprFunc) { + case DEFLATE_STORED: + progress = DeflateStored(canFlush, finish); + break; + case DEFLATE_FAST: + progress = DeflateFast(canFlush, finish); + break; + case DEFLATE_SLOW: + progress = DeflateSlow(canFlush, finish); + break; + default: + throw new InvalidOperationException("unknown comprFunc"); + } + } while (pending.IsFlushed && progress); /* repeat while we have no pending output and progress was made */ + return progress; + } + + /// Sets input data to be deflated. Should only be called when NeedsInput() + /// returns true + public void SetInput(byte[] buf, int off, int len) + { + if (inputOff < inputEnd) { + throw new InvalidOperationException("Old input was not completely processed"); + } + + int end = off + len; + + /* We want to throw an ArrayIndexOutOfBoundsException early. The + * check is very tricky: it also handles integer wrap around. + */ + if (0 > off || off > end || end > buf.Length) { + throw new ArgumentOutOfRangeException(); + } + + inputBuf = buf; + inputOff = off; + inputEnd = end; + } + + /// + /// Return true if input is needed via SetInput + /// + public bool NeedsInput() + { + return inputEnd == inputOff; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterHuffman.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterHuffman.cs new file mode 100644 index 0000000..084e3f0 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterHuffman.cs @@ -0,0 +1,887 @@ +// DeflaterHuffman.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// This is the DeflaterHuffman class. + /// + /// This class is not thread safe. This is inherent in the API, due + /// to the split of deflate and setInput. + /// + /// author of the original java version : Jochen Hoenicke + /// + public class DeflaterHuffman + { + static int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6); + static int LITERAL_NUM = 286; + static int DIST_NUM = 30; + static int BITLEN_NUM = 19; + static int REP_3_6 = 16; + static int REP_3_10 = 17; + static int REP_11_138 = 18; + static int EOF_SYMBOL = 256; + static int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; + + static byte[] bit4Reverse = { + 0, + 8, + 4, + 12, + 2, + 10, + 6, + 14, + 1, + 9, + 5, + 13, + 3, + 11, + 7, + 15 + }; + + /// + /// Not documented + /// + public class Tree + { + /// + /// Not documented + /// + public short[] freqs; + + /// + /// Not documented + /// + public byte[] length; + + /// + /// Not documented + /// + public int minNumCodes; + + /// + /// Not documented + /// + public int numCodes; + + short[] codes; + int[] bl_counts; + int maxLength; + DeflaterHuffman dh; + + /// + /// Not documented + /// + public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) + { + this.dh = dh; + this.minNumCodes = minCodes; + this.maxLength = maxLength; + freqs = new short[elems]; + bl_counts = new int[maxLength]; + } + + /// + /// Resets the internal state of the tree + /// + public void Reset() + { + for (int i = 0; i < freqs.Length; i++) { + freqs[i] = 0; + } + codes = null; + length = null; + } + + /// + /// Not documented + /// + public void WriteSymbol(int code) + { + // if (DeflaterConstants.DEBUGGING) { + // freqs[code]--; + // // Console.Write("writeSymbol("+freqs.length+","+code+"): "); + // } + dh.pending.WriteBits(codes[code] & 0xffff, length[code]); + } + + /// + /// Check that at least one frequency is non-zero + /// + /// + /// No frequencies are non-zero + /// + public void CheckEmpty() + { + bool empty = true; + for (int i = 0; i < freqs.Length; i++) { + if (freqs[i] != 0) { + //Console.WriteLine("freqs[" + i + "] == " + freqs[i]); + empty = false; + } + } + + if (!empty) { + throw new ApplicationException("!Empty"); + } + //Console.WriteLine("checkEmpty suceeded!"); + } + + /// + /// Set static codes and length + /// + /// new codes + /// length for new codes + public void SetStaticCodes(short[] stCodes, byte[] stLength) + { + codes = stCodes; + length = stLength; + } + + /// + /// Build dynamic codes and lengths + /// + public void BuildCodes() + { + int numSymbols = freqs.Length; + int[] nextCode = new int[maxLength]; + int code = 0; + codes = new short[freqs.Length]; + + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("buildCodes: "+freqs.Length); + // } + + for (int bits = 0; bits < maxLength; bits++) { + nextCode[bits] = code; + code += bl_counts[bits] << (15 - bits); + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("bits: " + ( bits + 1) + " count: " + bl_counts[bits] + // +" nextCode: "+code); + // } + } + if (DeflaterConstants.DEBUGGING && code != 65536) { + throw new ApplicationException("Inconsistent bl_counts!"); + } + + for (int i=0; i < numCodes; i++) { + int bits = length[i]; + if (bits > 0) { + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+"), + // +bits); + // } + codes[i] = BitReverse(nextCode[bits-1]); + nextCode[bits-1] += 1 << (16 - bits); + } + } + } + + void BuildLength(int[] childs) + { + this.length = new byte [freqs.Length]; + int numNodes = childs.Length / 2; + int numLeafs = (numNodes + 1) / 2; + int overflow = 0; + + for (int i = 0; i < maxLength; i++) { + bl_counts[i] = 0; + } + + /* First calculate optimal bit lengths */ + int[] lengths = new int[numNodes]; + lengths[numNodes-1] = 0; + + for (int i = numNodes - 1; i >= 0; i--) { + if (childs[2*i+1] != -1) { + int bitLength = lengths[i] + 1; + if (bitLength > maxLength) { + bitLength = maxLength; + overflow++; + } + lengths[childs[2*i]] = lengths[childs[2*i+1]] = bitLength; + } else { + /* A leaf node */ + int bitLength = lengths[i]; + bl_counts[bitLength - 1]++; + this.length[childs[2*i]] = (byte) lengths[i]; + } + } + + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("Tree "+freqs.Length+" lengths:"); + // for (int i=0; i < numLeafs; i++) { + // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] + // + " len: "+length[childs[2*i]]); + // } + // } + + if (overflow == 0) { + return; + } + + int incrBitLen = maxLength - 1; + do { + /* Find the first bit length which could increase: */ + while (bl_counts[--incrBitLen] == 0) + ; + + /* Move this node one down and remove a corresponding + * amount of overflow nodes. + */ + do { + bl_counts[incrBitLen]--; + bl_counts[++incrBitLen]++; + overflow -= 1 << (maxLength - 1 - incrBitLen); + } while (overflow > 0 && incrBitLen < maxLength - 1); + } while (overflow > 0); + + /* We may have overshot above. Move some nodes from maxLength to + * maxLength-1 in that case. + */ + bl_counts[maxLength-1] += overflow; + bl_counts[maxLength-2] -= overflow; + + /* Now recompute all bit lengths, scanning in increasing + * frequency. It is simpler to reconstruct all lengths instead of + * fixing only the wrong ones. This idea is taken from 'ar' + * written by Haruhiko Okumura. + * + * The nodes were inserted with decreasing frequency into the childs + * array. + */ + int nodePtr = 2 * numLeafs; + for (int bits = maxLength; bits != 0; bits--) { + int n = bl_counts[bits-1]; + while (n > 0) { + int childPtr = 2*childs[nodePtr++]; + if (childs[childPtr + 1] == -1) { + /* We found another leaf */ + length[childs[childPtr]] = (byte) bits; + n--; + } + } + } + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("*** After overflow elimination. ***"); + // for (int i=0; i < numLeafs; i++) { + // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] + // + " len: "+length[childs[2*i]]); + // } + // } + } + + /// + /// Not documented + /// + public void BuildTree() + { + int numSymbols = freqs.Length; + + /* heap is a priority queue, sorted by frequency, least frequent + * nodes first. The heap is a binary tree, with the property, that + * the parent node is smaller than both child nodes. This assures + * that the smallest node is the first parent. + * + * The binary tree is encoded in an array: 0 is root node and + * the nodes 2*n+1, 2*n+2 are the child nodes of node n. + */ + int[] heap = new int[numSymbols]; + int heapLen = 0; + int maxCode = 0; + for (int n = 0; n < numSymbols; n++) { + int freq = freqs[n]; + if (freq != 0) { + /* Insert n into heap */ + int pos = heapLen++; + int ppos; + while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) { + heap[pos] = heap[ppos]; + pos = ppos; + } + heap[pos] = n; + + maxCode = n; + } + } + + /* We could encode a single literal with 0 bits but then we + * don't see the literals. Therefore we force at least two + * literals to avoid this case. We don't care about order in + * this case, both literals get a 1 bit code. + */ + while (heapLen < 2) { + int node = maxCode < 2 ? ++maxCode : 0; + heap[heapLen++] = node; + } + + numCodes = Math.Max(maxCode + 1, minNumCodes); + + int numLeafs = heapLen; + int[] childs = new int[4*heapLen - 2]; + int[] values = new int[2*heapLen - 1]; + int numNodes = numLeafs; + for (int i = 0; i < heapLen; i++) { + int node = heap[i]; + childs[2*i] = node; + childs[2*i+1] = -1; + values[i] = freqs[node] << 8; + heap[i] = i; + } + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + do { + int first = heap[0]; + int last = heap[--heapLen]; + + /* Propagate the hole to the leafs of the heap */ + int ppos = 0; + int path = 1; + + while (path < heapLen) { + if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { + path++; + } + + heap[ppos] = heap[path]; + ppos = path; + path = path * 2 + 1; + } + + /* Now propagate the last element down along path. Normally + * it shouldn't go too deep. + */ + int lastVal = values[last]; + while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { + heap[path] = heap[ppos]; + } + heap[path] = last; + + + int second = heap[0]; + + /* Create a new node father of first and second */ + last = numNodes++; + childs[2*last] = first; + childs[2*last+1] = second; + int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff); + values[last] = lastVal = values[first] + values[second] - mindepth + 1; + + /* Again, propagate the hole to the leafs */ + ppos = 0; + path = 1; + + while (path < heapLen) { + if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { + path++; + } + + heap[ppos] = heap[path]; + ppos = path; + path = ppos * 2 + 1; + } + + /* Now propagate the new element down along path */ + while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { + heap[path] = heap[ppos]; + } + heap[path] = last; + } while (heapLen > 1); + + if (heap[0] != childs.Length / 2 - 1) { + throw new ApplicationException("Heap invariant violated"); + } + + BuildLength(childs); + } + + /// + /// Get encoded length + /// + /// Encoded length, the sum of frequencies * lengths + public int GetEncodedLength() + { + int len = 0; + for (int i = 0; i < freqs.Length; i++) { + len += freqs[i] * length[i]; + } + return len; + } + + /// + /// Not documented + /// + public void CalcBLFreq(Tree blTree) + { + int max_count; /* max repeat count */ + int min_count; /* min repeat count */ + int count; /* repeat count of the current code */ + int curlen = -1; /* length of current code */ + + int i = 0; + while (i < numCodes) { + count = 1; + int nextlen = length[i]; + if (nextlen == 0) { + max_count = 138; + min_count = 3; + } else { + max_count = 6; + min_count = 3; + if (curlen != nextlen) { + blTree.freqs[nextlen]++; + count = 0; + } + } + curlen = nextlen; + i++; + + while (i < numCodes && curlen == length[i]) { + i++; + if (++count >= max_count) { + break; + } + } + + if (count < min_count) { + blTree.freqs[curlen] += (short)count; + } else if (curlen != 0) { + blTree.freqs[REP_3_6]++; + } else if (count <= 10) { + blTree.freqs[REP_3_10]++; + } else { + blTree.freqs[REP_11_138]++; + } + } + } + + /// + /// Write tree values + /// + /// Tree to write + public void WriteTree(Tree blTree) + { + int max_count; /* max repeat count */ + int min_count; /* min repeat count */ + int count; /* repeat count of the current code */ + int curlen = -1; /* length of current code */ + + int i = 0; + while (i < numCodes) { + count = 1; + int nextlen = length[i]; + if (nextlen == 0) { + max_count = 138; + min_count = 3; + } else { + max_count = 6; + min_count = 3; + if (curlen != nextlen) { + blTree.WriteSymbol(nextlen); + count = 0; + } + } + curlen = nextlen; + i++; + + while (i < numCodes && curlen == length[i]) { + i++; + if (++count >= max_count) { + break; + } + } + + if (count < min_count) { + while (count-- > 0) { + blTree.WriteSymbol(curlen); + } + } else if (curlen != 0) { + blTree.WriteSymbol(REP_3_6); + dh.pending.WriteBits(count - 3, 2); + } else if (count <= 10) { + blTree.WriteSymbol(REP_3_10); + dh.pending.WriteBits(count - 3, 3); + } else { + blTree.WriteSymbol(REP_11_138); + dh.pending.WriteBits(count - 11, 7); + } + } + } + } + + /// + /// Pending buffer to use + /// + public DeflaterPending pending; + + Tree literalTree, distTree, blTree; + + short[] d_buf; + byte[] l_buf; + int last_lit; + int extra_bits; + + static short[] staticLCodes; + static byte[] staticLLength; + static short[] staticDCodes; + static byte[] staticDLength; + + /// + /// Reverse the bits of a 16 bit value. + /// + /// Value to reverse bits + /// Value with bits reversed + public static short BitReverse(int toReverse) + { + return (short) (bit4Reverse[toReverse & 0xF] << 12 | + bit4Reverse[(toReverse >> 4) & 0xF] << 8 | + bit4Reverse[(toReverse >> 8) & 0xF] << 4 | + bit4Reverse[toReverse >> 12]); + } + + + static DeflaterHuffman() + { + /* See RFC 1951 3.2.6 */ + /* Literal codes */ + staticLCodes = new short[LITERAL_NUM]; + staticLLength = new byte[LITERAL_NUM]; + int i = 0; + while (i < 144) { + staticLCodes[i] = BitReverse((0x030 + i) << 8); + staticLLength[i++] = 8; + } + while (i < 256) { + staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7); + staticLLength[i++] = 9; + } + while (i < 280) { + staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9); + staticLLength[i++] = 7; + } + while (i < LITERAL_NUM) { + staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8); + staticLLength[i++] = 8; + } + + /* Distant codes */ + staticDCodes = new short[DIST_NUM]; + staticDLength = new byte[DIST_NUM]; + for (i = 0; i < DIST_NUM; i++) { + staticDCodes[i] = BitReverse(i << 11); + staticDLength[i] = 5; + } + } + + /// + /// Construct instance with pending buffer + /// + /// Pending buffer to use + public DeflaterHuffman(DeflaterPending pending) + { + this.pending = pending; + + literalTree = new Tree(this, LITERAL_NUM, 257, 15); + distTree = new Tree(this, DIST_NUM, 1, 15); + blTree = new Tree(this, BITLEN_NUM, 4, 7); + + d_buf = new short[BUFSIZE]; + l_buf = new byte [BUFSIZE]; + } + + /// + /// Reset internal state + /// + public void Reset() + { + last_lit = 0; + extra_bits = 0; + literalTree.Reset(); + distTree.Reset(); + blTree.Reset(); + } + + int Lcode(int len) + { + if (len == 255) { + return 285; + } + + int code = 257; + while (len >= 8) { + code += 4; + len >>= 1; + } + return code + len; + } + + int Dcode(int distance) + { + int code = 0; + while (distance >= 4) { + code += 2; + distance >>= 1; + } + return code + distance; + } + + /// + /// Write all trees to pending buffer + /// + public void SendAllTrees(int blTreeCodes) + { + blTree.BuildCodes(); + literalTree.BuildCodes(); + distTree.BuildCodes(); + pending.WriteBits(literalTree.numCodes - 257, 5); + pending.WriteBits(distTree.numCodes - 1, 5); + pending.WriteBits(blTreeCodes - 4, 4); + for (int rank = 0; rank < blTreeCodes; rank++) { + pending.WriteBits(blTree.length[BL_ORDER[rank]], 3); + } + literalTree.WriteTree(blTree); + distTree.WriteTree(blTree); + // if (DeflaterConstants.DEBUGGING) { + // blTree.CheckEmpty(); + // } + } + + /// + /// Compress current buffer writing data to pending buffer + /// + public void CompressBlock() + { + for (int i = 0; i < last_lit; i++) { + int litlen = l_buf[i] & 0xff; + int dist = d_buf[i]; + if (dist-- != 0) { + // if (DeflaterConstants.DEBUGGING) { + // Console.Write("["+(dist+1)+","+(litlen+3)+"]: "); + // } + + int lc = Lcode(litlen); + literalTree.WriteSymbol(lc); + + int bits = (lc - 261) / 4; + if (bits > 0 && bits <= 5) { + pending.WriteBits(litlen & ((1 << bits) - 1), bits); + } + + int dc = Dcode(dist); + distTree.WriteSymbol(dc); + + bits = dc / 2 - 1; + if (bits > 0) { + pending.WriteBits(dist & ((1 << bits) - 1), bits); + } + } else { + // if (DeflaterConstants.DEBUGGING) { + // if (litlen > 32 && litlen < 127) { + // Console.Write("("+(char)litlen+"): "); + // } else { + // Console.Write("{"+litlen+"}: "); + // } + // } + literalTree.WriteSymbol(litlen); + } + } + // if (DeflaterConstants.DEBUGGING) { + // Console.Write("EOF: "); + // } + literalTree.WriteSymbol(EOF_SYMBOL); + // if (DeflaterConstants.DEBUGGING) { + // literalTree.CheckEmpty(); + // distTree.CheckEmpty(); + // } + } + + /// + /// Flush block to output with no compression + /// + /// Data to write + /// Index of first byte to write + /// Count of bytes to write + /// True if this is the last block + public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) + { + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("Flushing stored block "+ storedLength); + // } + pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3); + pending.AlignToByte(); + pending.WriteShort(storedLength); + pending.WriteShort(~storedLength); + pending.WriteBlock(stored, storedOffset, storedLength); + Reset(); + } + + /// + /// Flush block to output with compression + /// + /// Data to flush + /// Index of first byte to flush + /// Count of bytes to flush + /// True if this is the last block + public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) + { + literalTree.freqs[EOF_SYMBOL]++; + + /* Build trees */ + literalTree.BuildTree(); + distTree.BuildTree(); + + /* Calculate bitlen frequency */ + literalTree.CalcBLFreq(blTree); + distTree.CalcBLFreq(blTree); + + /* Build bitlen tree */ + blTree.BuildTree(); + + int blTreeCodes = 4; + for (int i = 18; i > blTreeCodes; i--) { + if (blTree.length[BL_ORDER[i]] > 0) { + blTreeCodes = i+1; + } + } + int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() + + literalTree.GetEncodedLength() + distTree.GetEncodedLength() + + extra_bits; + + int static_len = extra_bits; + for (int i = 0; i < LITERAL_NUM; i++) { + static_len += literalTree.freqs[i] * staticLLength[i]; + } + for (int i = 0; i < DIST_NUM; i++) { + static_len += distTree.freqs[i] * staticDLength[i]; + } + if (opt_len >= static_len) { + /* Force static trees */ + opt_len = static_len; + } + + if (storedOffset >= 0 && storedLength + 4 < opt_len >> 3) { + /* Store Block */ + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len + // + " <= " + static_len); + // } + FlushStoredBlock(stored, storedOffset, storedLength, lastBlock); + } else if (opt_len == static_len) { + /* Encode with static tree */ + pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3); + literalTree.SetStaticCodes(staticLCodes, staticLLength); + distTree.SetStaticCodes(staticDCodes, staticDLength); + CompressBlock(); + Reset(); + } else { + /* Encode with dynamic tree */ + pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3); + SendAllTrees(blTreeCodes); + CompressBlock(); + Reset(); + } + } + + /// + /// Get value indicating if internal buffer is full + /// + /// true if buffer is full + public bool IsFull() + { + return last_lit >= BUFSIZE; + } + + /// + /// Add literal to buffer + /// + /// + /// Value indicating internal buffer is full + public bool TallyLit(int lit) + { + // if (DeflaterConstants.DEBUGGING) { + // if (lit > 32 && lit < 127) { + // //Console.WriteLine("("+(char)lit+")"); + // } else { + // //Console.WriteLine("{"+lit+"}"); + // } + // } + d_buf[last_lit] = 0; + l_buf[last_lit++] = (byte)lit; + literalTree.freqs[lit]++; + return IsFull(); + } + + /// + /// Add distance code and length to literal and distance trees + /// + /// Distance code + /// Length + /// Value indicating if internal buffer is full + public bool TallyDist(int dist, int len) + { + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("["+dist+","+len+"]"); + // } + + d_buf[last_lit] = (short)dist; + l_buf[last_lit++] = (byte)(len - 3); + + int lc = Lcode(len - 3); + literalTree.freqs[lc]++; + if (lc >= 265 && lc < 285) { + extra_bits += (lc - 261) / 4; + } + + int dc = Dcode(dist - 1); + distTree.freqs[dc]++; + if (dc >= 4) { + extra_bits += dc / 2 - 1; + } + return IsFull(); + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterPending.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterPending.cs new file mode 100644 index 0000000..4cecc2e --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/DeflaterPending.cs @@ -0,0 +1,57 @@ +// DeflaterPending.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// This class stores the pending output of the Deflater. + /// + /// author of the original java version : Jochen Hoenicke + /// + public class DeflaterPending : PendingBuffer + { + /// + /// Construct instance with default buffer size + /// + public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) + { + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Inflater.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Inflater.cs new file mode 100644 index 0000000..d9f397e --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Inflater.cs @@ -0,0 +1,826 @@ +// Inflater.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// Inflater is used to decompress data that has been compressed according + /// to the "deflate" standard described in rfc1951. + /// + /// By default Zlib (rfc1950) headers and footers are expected in the input. + /// You can use constructor public Inflater(bool noHeader) passing true + /// if there is no Zlib header information + /// + /// The usage is as following. First you have to set some input with + /// setInput(), then inflate() it. If inflate doesn't + /// inflate any bytes there may be three reasons: + ///
    + ///
  • needsInput() returns true because the input buffer is empty. + /// You have to provide more input with setInput(). + /// NOTE: needsInput() also returns true when, the stream is finished. + ///
  • + ///
  • needsDictionary() returns true, you have to provide a preset + /// dictionary with setDictionary().
  • + ///
  • finished() returns true, the inflater has finished.
  • + ///
+ /// Once the first output byte is produced, a dictionary will not be + /// needed at a later stage. + /// + /// author of the original java version : John Leuner, Jochen Hoenicke + ///
+ public class Inflater + { + /// + /// Copy lengths for literal codes 257..285 + /// + static int[] CPLENS = { + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 + }; + + /// + /// Extra bits for literal codes 257..285 + /// + static int[] CPLEXT = { + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 + }; + + /// + /// Copy offsets for distance codes 0..29 + /// + static int[] CPDIST = { + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577 + }; + + /// + /// Extra bits for distance codes + /// + static int[] CPDEXT = { + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13 + }; + + /// + /// These are the possible states for an inflater + /// + const int DECODE_HEADER = 0; + const int DECODE_DICT = 1; + const int DECODE_BLOCKS = 2; + const int DECODE_STORED_LEN1 = 3; + const int DECODE_STORED_LEN2 = 4; + const int DECODE_STORED = 5; + const int DECODE_DYN_HEADER = 6; + const int DECODE_HUFFMAN = 7; + const int DECODE_HUFFMAN_LENBITS = 8; + const int DECODE_HUFFMAN_DIST = 9; + const int DECODE_HUFFMAN_DISTBITS = 10; + const int DECODE_CHKSUM = 11; + const int FINISHED = 12; + + /// + /// This variable contains the current state. + /// + int mode; + + /// + /// The adler checksum of the dictionary or of the decompressed + /// stream, as it is written in the header resp. footer of the + /// compressed stream. + /// Only valid if mode is DECODE_DICT or DECODE_CHKSUM. + /// + int readAdler; + + /// + /// The number of bits needed to complete the current state. This + /// is valid, if mode is DECODE_DICT, DECODE_CHKSUM, + /// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS. + /// + int neededBits; + int repLength; + int repDist; + int uncomprLen; + + /// + /// True, if the last block flag was set in the last block of the + /// inflated stream. This means that the stream ends after the + /// current block. + /// + bool isLastBlock; + + /// + /// The total number of inflated bytes. + /// + int totalOut; + + /// + /// The total number of bytes set with setInput(). This is not the + /// value returned by the TotalIn property, since this also includes the + /// unprocessed input. + /// + int totalIn; + + /// + /// This variable stores the noHeader flag that was given to the constructor. + /// True means, that the inflated stream doesn't contain a Zlib header or + /// footer. + /// + bool noHeader; + + StreamManipulator input; + OutputWindow outputWindow; + InflaterDynHeader dynHeader; + InflaterHuffmanTree litlenTree, distTree; + Adler32 adler; + + /// + /// Creates a new inflater or RFC1951 decompressor + /// RFC1950/Zlib headers and footers will be expected in the input data + /// + public Inflater() : this(false) + { + } + + /// + /// Creates a new inflater. + /// + /// + /// True if no RFC1950/Zlib header and footer fields are expected in the input data + /// + /// This is used for GZIPed/Zipped input. + /// + /// For compatibility with + /// Sun JDK you should provide one byte of input more than needed in + /// this case. + /// + public Inflater(bool noHeader) + { + this.noHeader = noHeader; + this.adler = new Adler32(); + input = new StreamManipulator(); + outputWindow = new OutputWindow(); + mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; + } + + /// + /// Resets the inflater so that a new stream can be decompressed. All + /// pending input and output will be discarded. + /// + public void Reset() + { + mode = noHeader ? DECODE_BLOCKS : DECODE_HEADER; + totalIn = totalOut = 0; + input.Reset(); + outputWindow.Reset(); + dynHeader = null; + litlenTree = null; + distTree = null; + isLastBlock = false; + adler.Reset(); + } + + /// + /// Decodes a zlib/RFC1950 header. + /// + /// + /// False if more input is needed. + /// + /// + /// The header is invalid. + /// + private bool DecodeHeader() + { + int header = input.PeekBits(16); + if (header < 0) { + return false; + } + input.DropBits(16); + + /* The header is written in "wrong" byte order */ + header = ((header << 8) | (header >> 8)) & 0xffff; + if (header % 31 != 0) { + throw new ApplicationException("Header checksum illegal"); + } + + if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) { + throw new ApplicationException("Compression Method unknown"); + } + + /* Maximum size of the backwards window in bits. + * We currently ignore this, but we could use it to make the + * inflater window more space efficient. On the other hand the + * full window (15 bits) is needed most times, anyway. + int max_wbits = ((header & 0x7000) >> 12) + 8; + */ + + if ((header & 0x0020) == 0) { // Dictionary flag? + mode = DECODE_BLOCKS; + } else { + mode = DECODE_DICT; + neededBits = 32; + } + return true; + } + + /// + /// Decodes the dictionary checksum after the deflate header. + /// + /// + /// False if more input is needed. + /// + private bool DecodeDict() + { + while (neededBits > 0) { + int dictByte = input.PeekBits(8); + if (dictByte < 0) { + return false; + } + input.DropBits(8); + readAdler = (readAdler << 8) | dictByte; + neededBits -= 8; + } + return false; + } + + /// + /// Decodes the huffman encoded symbols in the input stream. + /// + /// + /// false if more input is needed, true if output window is + /// full or the current block ends. + /// + /// + /// if deflated stream is invalid. + /// + private bool DecodeHuffman() + { + int free = outputWindow.GetFreeSpace(); + while (free >= 258) { + int symbol; + switch (mode) { + case DECODE_HUFFMAN: + /* This is the inner loop so it is optimized a bit */ + while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { + outputWindow.Write(symbol); + if (--free < 258) { + return true; + } + } + + if (symbol < 257) { + if (symbol < 0) { + return false; + } else { + /* symbol == 256: end of block */ + distTree = null; + litlenTree = null; + mode = DECODE_BLOCKS; + return true; + } + } + + try { + repLength = CPLENS[symbol - 257]; + neededBits = CPLEXT[symbol - 257]; + } catch (Exception) { + throw new ApplicationException("Illegal rep length code"); + } + goto case DECODE_HUFFMAN_LENBITS; /* fall through */ + + case DECODE_HUFFMAN_LENBITS: + if (neededBits > 0) { + mode = DECODE_HUFFMAN_LENBITS; + int i = input.PeekBits(neededBits); + if (i < 0) { + return false; + } + input.DropBits(neededBits); + repLength += i; + } + mode = DECODE_HUFFMAN_DIST; + goto case DECODE_HUFFMAN_DIST;/* fall through */ + + case DECODE_HUFFMAN_DIST: + symbol = distTree.GetSymbol(input); + if (symbol < 0) { + return false; + } + + try { + repDist = CPDIST[symbol]; + neededBits = CPDEXT[symbol]; + } catch (Exception) { + throw new ApplicationException("Illegal rep dist code"); + } + + goto case DECODE_HUFFMAN_DISTBITS;/* fall through */ + + case DECODE_HUFFMAN_DISTBITS: + if (neededBits > 0) { + mode = DECODE_HUFFMAN_DISTBITS; + int i = input.PeekBits(neededBits); + if (i < 0) { + return false; + } + input.DropBits(neededBits); + repDist += i; + } + + outputWindow.Repeat(repLength, repDist); + free -= repLength; + mode = DECODE_HUFFMAN; + break; + + default: + throw new ApplicationException("Inflater unknown mode"); + } + } + return true; + } + + /// + /// Decodes the adler checksum after the deflate stream. + /// + /// + /// false if more input is needed. + /// + /// + /// If checksum doesn't match. + /// + private bool DecodeChksum() + { + while (neededBits > 0) { + int chkByte = input.PeekBits(8); + if (chkByte < 0) { + return false; + } + input.DropBits(8); + readAdler = (readAdler << 8) | chkByte; + neededBits -= 8; + } + if ((int) adler.Value != readAdler) { + throw new ApplicationException("Adler chksum doesn't match: " + (int)adler.Value + " vs. " + readAdler); + } + mode = FINISHED; + return false; + } + + /// + /// Decodes the deflated stream. + /// + /// + /// false if more input is needed, or if finished. + /// + /// + /// ApplicationException, if deflated stream is invalid. + /// + private bool Decode() + { + switch (mode) { + case DECODE_HEADER: + return DecodeHeader(); + case DECODE_DICT: + return DecodeDict(); + case DECODE_CHKSUM: + return DecodeChksum(); + + case DECODE_BLOCKS: + if (isLastBlock) { + if (noHeader) { + mode = FINISHED; + return false; + } else { + input.SkipToByteBoundary(); + neededBits = 32; + mode = DECODE_CHKSUM; + return true; + } + } + + int type = input.PeekBits(3); + if (type < 0) { + return false; + } + input.DropBits(3); + + if ((type & 1) != 0) { + isLastBlock = true; + } + switch (type >> 1){ + case DeflaterConstants.STORED_BLOCK: + input.SkipToByteBoundary(); + mode = DECODE_STORED_LEN1; + break; + case DeflaterConstants.STATIC_TREES: + litlenTree = InflaterHuffmanTree.defLitLenTree; + distTree = InflaterHuffmanTree.defDistTree; + mode = DECODE_HUFFMAN; + break; + case DeflaterConstants.DYN_TREES: + dynHeader = new InflaterDynHeader(); + mode = DECODE_DYN_HEADER; + break; + default: + throw new ApplicationException("Unknown block type " + type); + } + return true; + + case DECODE_STORED_LEN1: + { + if ((uncomprLen = input.PeekBits(16)) < 0) { + return false; + } + input.DropBits(16); + mode = DECODE_STORED_LEN2; + } + goto case DECODE_STORED_LEN2; /* fall through */ + + case DECODE_STORED_LEN2: + { + int nlen = input.PeekBits(16); + if (nlen < 0) { + return false; + } + input.DropBits(16); + if (nlen != (uncomprLen ^ 0xffff)) { + throw new ApplicationException("broken uncompressed block"); + } + mode = DECODE_STORED; + } + goto case DECODE_STORED;/* fall through */ + + case DECODE_STORED: + { + int more = outputWindow.CopyStored(input, uncomprLen); + uncomprLen -= more; + if (uncomprLen == 0) { + mode = DECODE_BLOCKS; + return true; + } + return !input.IsNeedingInput; + } + + case DECODE_DYN_HEADER: + if (!dynHeader.Decode(input)) { + return false; + } + + litlenTree = dynHeader.BuildLitLenTree(); + distTree = dynHeader.BuildDistTree(); + mode = DECODE_HUFFMAN; + goto case DECODE_HUFFMAN; /* fall through */ + + case DECODE_HUFFMAN: + case DECODE_HUFFMAN_LENBITS: + case DECODE_HUFFMAN_DIST: + case DECODE_HUFFMAN_DISTBITS: + return DecodeHuffman(); + + case FINISHED: + return false; + + default: + throw new ApplicationException("Inflater.Decode unknown mode"); + } + } + + /// + /// Sets the preset dictionary. This should only be called, if + /// needsDictionary() returns true and it should set the same + /// dictionary, that was used for deflating. The getAdler() + /// function returns the checksum of the dictionary needed. + /// + /// + /// The dictionary. + /// + /// + /// No dictionary is needed. + /// + /// + /// if the dictionary checksum is wrong. + /// + public void SetDictionary(byte[] buffer) + { + SetDictionary(buffer, 0, buffer.Length); + } + + /// + /// Sets the preset dictionary. This should only be called, if + /// needsDictionary() returns true and it should set the same + /// dictionary, that was used for deflating. The getAdler() + /// function returns the checksum of the dictionary needed. + /// + /// + /// The dictionary. + /// + /// + /// The offset into buffer where the dictionary starts. + /// + /// + /// The length of the dictionary. + /// + /// + /// No dictionary is needed. + /// + /// + /// The adler checksum for the buffer is invalid + /// + public void SetDictionary(byte[] buffer, int offset, int len) + { + if (!IsNeedingDictionary) { + throw new InvalidOperationException(); + } + + adler.Update(buffer, offset, len); + if ((int)adler.Value != readAdler) { + throw new ApplicationException("Wrong adler checksum"); + } + adler.Reset(); + outputWindow.CopyDict(buffer, offset, len); + mode = DECODE_BLOCKS; + } + + /// + /// Sets the input. This should only be called, if needsInput() + /// returns true. + /// + /// + /// the input. + /// + /// + /// if no input is needed. + /// + public void SetInput(byte[] buf) + { + SetInput(buf, 0, buf.Length); + } + + /// + /// Sets the input. This should only be called, if needsInput() + /// returns true. + /// + /// + /// The source of input data + /// + /// + /// The offset into buffer where the input starts. + /// + /// + /// The number of bytes of input to use. + /// + /// + /// No input is needed. + /// + /// + /// The off and/or len are wrong. + /// + public void SetInput(byte[] buffer, int offset, int length) + { + input.SetInput(buffer, offset, length); + totalIn += length; + } + + /// + /// Inflates the compressed stream to the output buffer. If this + /// returns 0, you should check, whether needsDictionary(), + /// needsInput() or finished() returns true, to determine why no + /// further output is produced. + /// + /// + /// the output buffer. + /// + /// + /// the number of bytes written to the buffer, 0 if no further + /// output can be produced. + /// + /// + /// if buf has length 0. + /// + /// + /// if deflated stream is invalid. + /// + public int Inflate(byte[] buf) + { + return Inflate(buf, 0, buf.Length); + } + + /// + /// Inflates the compressed stream to the output buffer. If this + /// returns 0, you should check, whether needsDictionary(), + /// needsInput() or finished() returns true, to determine why no + /// further output is produced. + /// + /// + /// the output buffer. + /// + /// + /// the offset into buffer where the output should start. + /// + /// + /// the maximum length of the output. + /// + /// + /// the number of bytes written to the buffer, 0 if no further output can be produced. + /// + /// + /// if len is <= 0. + /// + /// + /// if the offset and/or len are wrong. + /// + /// + /// if deflated stream is invalid. + /// + public int Inflate(byte[] buf, int offset, int len) + { + if (len < 0) { + throw new ArgumentOutOfRangeException("len < 0"); + } + + // Special case: len may be zero + if (len == 0) { + if (IsFinished == false) {// -jr- 08-Nov-2003 INFLATE_BUG fix.. + Decode(); + } + return 0; + } +/* + // Check for correct buff, off, len triple + if (off < 0 || off + len >= buf.Length) { + throw new ArgumentException("off/len outside buf bounds"); + } +*/ + int count = 0; + int more; + do { + if (mode != DECODE_CHKSUM) { + /* Don't give away any output, if we are waiting for the + * checksum in the input stream. + * + * With this trick we have always: + * needsInput() and not finished() + * implies more output can be produced. + */ + more = outputWindow.CopyOutput(buf, offset, len); + adler.Update(buf, offset, more); + offset += more; + count += more; + totalOut += more; + len -= more; + if (len == 0) { + return count; + } + } + } while (Decode() || (outputWindow.GetAvailable() > 0 && mode != DECODE_CHKSUM)); + return count; + } + + /// + /// Returns true, if the input buffer is empty. + /// You should then call setInput(). + /// NOTE: This method also returns true when the stream is finished. + /// + public bool IsNeedingInput { + get { + return input.IsNeedingInput; + } + } + + /// + /// Returns true, if a preset dictionary is needed to inflate the input. + /// + public bool IsNeedingDictionary { + get { + return mode == DECODE_DICT && neededBits == 0; + } + } + + /// + /// Returns true, if the inflater has finished. This means, that no + /// input is needed and no output can be produced. + /// + public bool IsFinished { + get { + return mode == FINISHED && outputWindow.GetAvailable() == 0; + } + } + + /// + /// Gets the adler checksum. This is either the checksum of all + /// uncompressed bytes returned by inflate(), or if needsDictionary() + /// returns true (and thus no output was yet produced) this is the + /// adler checksum of the expected dictionary. + /// + /// + /// the adler checksum. + /// + public int Adler { + get { + return IsNeedingDictionary ? readAdler : (int) adler.Value; + } + } + + /// + /// Gets the total number of output bytes returned by inflate(). + /// + /// + /// the total number of output bytes. + /// + public int TotalOut { + get { + return totalOut; + } + } + + /// + /// Gets the total number of processed compressed input bytes. + /// + /// + /// The total number of bytes of processed input bytes. + /// + public int TotalIn { + get { + return totalIn - RemainingInput; + } + } + +#if TEST_HAK + /// + /// -jr test hak trying to figure out a bug + /// + public int UnseenInput { + get { + return totalIn - ((input.AvailableBits + 7) >> 3); + } + } + + /// + /// -jr test hak trying to figure out a bug + /// + public int PlainTotalIn { + get { + return totalIn; + } + } +#endif + + /// + /// Gets the number of unprocessed input bytes. Useful, if the end of the + /// stream is reached and you want to further process the bytes after + /// the deflate stream. + /// + /// + /// The number of bytes of the input which have not been processed. + /// + public int RemainingInput { + get { + return input.AvailableBytes; + } + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterDynHeader.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterDynHeader.cs new file mode 100644 index 0000000..ad90558 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterDynHeader.cs @@ -0,0 +1,207 @@ +// InflaterDynHeader.cs +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + class InflaterDynHeader + { + const int LNUM = 0; + const int DNUM = 1; + const int BLNUM = 2; + const int BLLENS = 3; + const int LENS = 4; + const int REPS = 5; + + static readonly int[] repMin = { 3, 3, 11 }; + static readonly int[] repBits = { 2, 3, 7 }; + + byte[] blLens; + byte[] litdistLens; + + InflaterHuffmanTree blTree; + + int mode; + int lnum, dnum, blnum, num; + int repSymbol; + byte lastLen; + int ptr; + + static readonly int[] BL_ORDER = + { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; + + public InflaterDynHeader() + { + } + + public bool Decode(StreamManipulator input) + { + decode_loop: + for (;;) { + switch (mode) { + case LNUM: + lnum = input.PeekBits(5); + if (lnum < 0) { + return false; + } + lnum += 257; + input.DropBits(5); + // System.err.println("LNUM: "+lnum); + mode = DNUM; + goto case DNUM; // fall through + case DNUM: + dnum = input.PeekBits(5); + if (dnum < 0) { + return false; + } + dnum++; + input.DropBits(5); + // System.err.println("DNUM: "+dnum); + num = lnum+dnum; + litdistLens = new byte[num]; + mode = BLNUM; + goto case BLNUM; // fall through + case BLNUM: + blnum = input.PeekBits(4); + if (blnum < 0) { + return false; + } + blnum += 4; + input.DropBits(4); + blLens = new byte[19]; + ptr = 0; + // System.err.println("BLNUM: "+blnum); + mode = BLLENS; + goto case BLLENS; // fall through + case BLLENS: + while (ptr < blnum) { + int len = input.PeekBits(3); + if (len < 0) { + return false; + } + input.DropBits(3); + // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); + blLens[BL_ORDER[ptr]] = (byte) len; + ptr++; + } + blTree = new InflaterHuffmanTree(blLens); + blLens = null; + ptr = 0; + mode = LENS; + goto case LENS; // fall through + case LENS: + { + int symbol; + while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { + /* Normal case: symbol in [0..15] */ + + // System.err.println("litdistLens["+ptr+"]: "+symbol); + litdistLens[ptr++] = lastLen = (byte)symbol; + + if (ptr == num) { + /* Finished */ + return true; + } + } + + /* need more input ? */ + if (symbol < 0) { + return false; + } + + /* otherwise repeat code */ + if (symbol >= 17) { + /* repeat zero */ + // System.err.println("repeating zero"); + lastLen = 0; + } else { + if (ptr == 0) { + throw new Exception(); + } + } + repSymbol = symbol-16; + } + mode = REPS; + goto case REPS; // fall through + case REPS: + { + int bits = repBits[repSymbol]; + int count = input.PeekBits(bits); + if (count < 0) { + return false; + } + input.DropBits(bits); + count += repMin[repSymbol]; + // System.err.println("litdistLens repeated: "+count); + + if (ptr + count > num) { + throw new Exception(); + } + while (count-- > 0) { + litdistLens[ptr++] = lastLen; + } + + if (ptr == num) { + /* Finished */ + return true; + } + } + mode = LENS; + goto decode_loop; + } + } + } + + public InflaterHuffmanTree BuildLitLenTree() + { + byte[] litlenLens = new byte[lnum]; + Array.Copy(litdistLens, 0, litlenLens, 0, lnum); + return new InflaterHuffmanTree(litlenLens); + } + + public InflaterHuffmanTree BuildDistTree() + { + byte[] distLens = new byte[dnum]; + Array.Copy(litdistLens, lnum, distLens, 0, dnum); + return new InflaterHuffmanTree(distLens); + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterHuffmanTree.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterHuffmanTree.cs new file mode 100644 index 0000000..1984932 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/InflaterHuffmanTree.cs @@ -0,0 +1,225 @@ +// InflaterHuffmanTree.cs +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// Huffman tree used for inflation + /// + public class InflaterHuffmanTree + { + static int MAX_BITLEN = 15; + short[] tree; + + /// + /// Literal length tree + /// + public static InflaterHuffmanTree defLitLenTree; + + /// + /// Distance tree + /// + public static InflaterHuffmanTree defDistTree; + + static InflaterHuffmanTree() + { + try { + byte[] codeLengths = new byte[288]; + int i = 0; + while (i < 144) { + codeLengths[i++] = 8; + } + while (i < 256) { + codeLengths[i++] = 9; + } + while (i < 280) { + codeLengths[i++] = 7; + } + while (i < 288) { + codeLengths[i++] = 8; + } + defLitLenTree = new InflaterHuffmanTree(codeLengths); + + codeLengths = new byte[32]; + i = 0; + while (i < 32) { + codeLengths[i++] = 5; + } + defDistTree = new InflaterHuffmanTree(codeLengths); + } catch (Exception) { + throw new ApplicationException("InflaterHuffmanTree: static tree length illegal"); + } + } + + /// + /// Constructs a Huffman tree from the array of code lengths. + /// + /// + /// the array of code lengths + /// + public InflaterHuffmanTree(byte[] codeLengths) + { + BuildTree(codeLengths); + } + + void BuildTree(byte[] codeLengths) + { + int[] blCount = new int[MAX_BITLEN + 1]; + int[] nextCode = new int[MAX_BITLEN + 1]; + + for (int i = 0; i < codeLengths.Length; i++) { + int bits = codeLengths[i]; + if (bits > 0) { + blCount[bits]++; + } + } + + int code = 0; + int treeSize = 512; + for (int bits = 1; bits <= MAX_BITLEN; bits++) { + nextCode[bits] = code; + code += blCount[bits] << (16 - bits); + if (bits >= 10) { + /* We need an extra table for bit lengths >= 10. */ + int start = nextCode[bits] & 0x1ff80; + int end = code & 0x1ff80; + treeSize += (end - start) >> (16 - bits); + } + } + +/* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g + if (code != 65536) + { + throw new Exception("Code lengths don't add up properly."); + } +*/ + /* Now create and fill the extra tables from longest to shortest + * bit len. This way the sub trees will be aligned. + */ + tree = new short[treeSize]; + int treePtr = 512; + for (int bits = MAX_BITLEN; bits >= 10; bits--) { + int end = code & 0x1ff80; + code -= blCount[bits] << (16 - bits); + int start = code & 0x1ff80; + for (int i = start; i < end; i += 1 << 7) { + tree[DeflaterHuffman.BitReverse(i)] = (short) ((-treePtr << 4) | bits); + treePtr += 1 << (bits-9); + } + } + + for (int i = 0; i < codeLengths.Length; i++) { + int bits = codeLengths[i]; + if (bits == 0) { + continue; + } + code = nextCode[bits]; + int revcode = DeflaterHuffman.BitReverse(code); + if (bits <= 9) { + do { + tree[revcode] = (short) ((i << 4) | bits); + revcode += 1 << bits; + } while (revcode < 512); + } else { + int subTree = tree[revcode & 511]; + int treeLen = 1 << (subTree & 15); + subTree = -(subTree >> 4); + do { + tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits); + revcode += 1 << bits; + } while (revcode < treeLen); + } + nextCode[bits] = code + (1 << (16 - bits)); + } + + } + + /// + /// Reads the next symbol from input. The symbol is encoded using the + /// huffman tree. + /// + /// + /// input the input source. + /// + /// + /// the next symbol, or -1 if not enough input is available. + /// + public int GetSymbol(StreamManipulator input) + { + int lookahead, symbol; + if ((lookahead = input.PeekBits(9)) >= 0) { + if ((symbol = tree[lookahead]) >= 0) { + input.DropBits(symbol & 15); + return symbol >> 4; + } + int subtree = -(symbol >> 4); + int bitlen = symbol & 15; + if ((lookahead = input.PeekBits(bitlen)) >= 0) { + symbol = tree[subtree | (lookahead >> 9)]; + input.DropBits(symbol & 15); + return symbol >> 4; + } else { + int bits = input.AvailableBits; + lookahead = input.PeekBits(bits); + symbol = tree[subtree | (lookahead >> 9)]; + if ((symbol & 15) <= bits) { + input.DropBits(symbol & 15); + return symbol >> 4; + } else { + return -1; + } + } + } else { + int bits = input.AvailableBits; + lookahead = input.PeekBits(bits); + symbol = tree[lookahead]; + if (symbol >= 0 && (symbol & 15) <= bits) { + input.DropBits(symbol & 15); + return symbol >> 4; + } else { + return -1; + } + } + } + } +} + diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/PendingBuffer.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/PendingBuffer.cs new file mode 100644 index 0000000..4fc0240 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/PendingBuffer.cs @@ -0,0 +1,274 @@ +// PendingBuffer.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression +{ + + /// + /// This class is general purpose class for writing data to a buffer. + /// + /// It allows you to write bits as well as bytes + /// Based on DeflaterPending.java + /// + /// author of the original java version : Jochen Hoenicke + /// + public class PendingBuffer + { + /// Internal work buffer + /// + protected byte[] buf; + + int start; + int end; + + uint bits; + int bitCount; + + /// + /// construct instance using default buffer size of 4096 + /// + public PendingBuffer() : this( 4096 ) + { + + } + + /// + /// construct instance using specified buffer size + /// + /// + /// size to use for internal buffer + /// + public PendingBuffer(int bufsize) + { + buf = new byte[bufsize]; + } + + /// + /// Clear internal state/buffers + /// + public void Reset() + { + start = end = bitCount = 0; + } + + /// + /// write a byte to buffer + /// + /// + /// value to write + /// + public void WriteByte(int b) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + buf[end++] = (byte) b; + } + + /// + /// Write a short value to buffer LSB first + /// + /// + /// value to write + /// + public void WriteShort(int s) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + buf[end++] = (byte) s; + buf[end++] = (byte) (s >> 8); + } + + /// + /// write an integer LSB first + /// + /// value to write + public void WriteInt(int s) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + buf[end++] = (byte) s; + buf[end++] = (byte) (s >> 8); + buf[end++] = (byte) (s >> 16); + buf[end++] = (byte) (s >> 24); + } + + /// + /// Write a block of data to buffer + /// + /// data to write + /// offset of first byte to write + /// number of bytes to write + public void WriteBlock(byte[] block, int offset, int len) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + System.Array.Copy(block, offset, buf, end, len); + end += len; + } + + /// + /// The number of bits written to the buffer + /// + public int BitCount { + get { + return bitCount; + } + } + + /// + /// Align internal buffer on a byte boundary + /// + public void AlignToByte() + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + if (bitCount > 0) { + buf[end++] = (byte) bits; + if (bitCount > 8) { + buf[end++] = (byte) (bits >> 8); + } + } + bits = 0; + bitCount = 0; + } + + /// + /// Write bits to internal buffer + /// + /// source of bits + /// number of bits to write + public void WriteBits(int b, int count) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + // if (DeflaterConstants.DEBUGGING) { + // //Console.WriteLine("writeBits("+b+","+count+")"); + // } + bits |= (uint)(b << bitCount); + bitCount += count; + if (bitCount >= 16) { + buf[end++] = (byte) bits; + buf[end++] = (byte) (bits >> 8); + bits >>= 16; + bitCount -= 16; + } + } + + /// + /// Write a short value to internal buffer most significant byte first + /// + /// value to write + public void WriteShortMSB(int s) + { + if (DeflaterConstants.DEBUGGING && start != 0) { + throw new Exception(); + } + buf[end++] = (byte) (s >> 8); + buf[end++] = (byte) s; + } + + /// + /// Indicates if buffer has been flushed + /// + public bool IsFlushed { + get { + return end == 0; + } + } + + /// + /// Flushes the pending buffer into the given output array. If the + /// output array is to small, only a partial flush is done. + /// + /// + /// the output array; + /// + /// + /// the offset into output array; + /// + /// + /// length the maximum number of bytes to store; + /// + /// + /// IndexOutOfBoundsException if offset or length are invalid. + /// + public int Flush(byte[] output, int offset, int length) + { + if (bitCount >= 8) { + buf[end++] = (byte) bits; + bits >>= 8; + bitCount -= 8; + } + if (length > end - start) { + length = end - start; + System.Array.Copy(buf, start, output, offset, length); + start = 0; + end = 0; + } else { + System.Array.Copy(buf, start, output, offset, length); + start += length; + } + return length; + } + + /// + /// Convert internal buffer to byte array. + /// Buffer is empty on completion + /// + /// + /// converted buffer contents contents + /// + public byte[] ToByteArray() + { + byte[] ret = new byte[end - start]; + System.Array.Copy(buf, start, ret, 0, ret.Length); + start = 0; + end = 0; + return ret; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/DeflaterOutputStream.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/DeflaterOutputStream.cs new file mode 100644 index 0000000..a289f59 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/DeflaterOutputStream.cs @@ -0,0 +1,449 @@ +// DeflaterOutputStream.cs +// +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.IO; +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Zip.Compression; + +namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams +{ + + /// + /// A special stream deflating or compressing the bytes that are + /// written to it. It uses a Deflater to perform actual deflating. + /// + /// authors of the original java version : Tom Tromey, Jochen Hoenicke + /// + public class DeflaterOutputStream : Stream + { + /// + /// This buffer is used temporarily to retrieve the bytes from the + /// deflater and write them to the underlying output stream. + /// + protected byte[] buf; + + /// + /// The deflater which is used to deflate the stream. + /// + protected Deflater def; + + /// + /// Base stream the deflater depends on. + /// + protected Stream baseOutputStream; + + /// + /// Allows client to determine if an entry can be patched after its added + /// + public bool CanPatchEntries { + get { + return baseOutputStream.CanSeek; + } + } + + /// + /// Gets value indicating stream can be read from + /// + public override bool CanRead { + get { + return baseOutputStream.CanRead; + } + } + + /// + /// Gets a value indicating if seeking is supported for this stream + /// This property always returns false + /// + public override bool CanSeek { + get { + return false; + } + } + + /// + /// Get value indicating if this stream supports writing + /// + public override bool CanWrite { + get { + return baseOutputStream.CanWrite; + } + } + + /// + /// Get current length of stream + /// + public override long Length { + get { + return baseOutputStream.Length; + } + } + + /// + /// The current position within the stream. + /// Always throws a NotSupportedExceptionNotSupportedException + /// + /// Any attempt to set position + public override long Position { + get { + return baseOutputStream.Position; + } + set { +// baseOutputStream.Position = value; + throw new NotSupportedException("DefalterOutputStream Position not supported"); + } + } + + /// + /// Sets the current position of this stream to the given value. Not supported by this class! + /// + /// Any access + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException("DeflaterOutputStream Seek not supported"); +// return baseOutputStream.Seek(offset, origin); + } + + /// + /// Sets the length of this stream to the given value. Not supported by this class! + /// + /// Any access + public override void SetLength(long val) + { +// baseOutputStream.SetLength(val); + throw new NotSupportedException("DeflaterOutputStream SetLength not supported"); + } + + /// + /// Read a byte from stream advancing position by one + /// + /// Any access + public override int ReadByte() + { +// return baseOutputStream.ReadByte(); + throw new NotSupportedException("DeflaterOutputStream ReadByte not supported"); + } + + /// + /// Read a block of bytes from stream + /// + /// Any access + public override int Read(byte[] b, int off, int len) + { +// return baseOutputStream.Read(b, off, len); + throw new NotSupportedException("DeflaterOutputStream Read not supported"); + } + + /// + /// Asynchronous reads are not supported a NotSupportedException is always thrown + /// + /// + /// + /// + /// + /// + /// + /// Any access + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw new NotSupportedException("DeflaterOutputStream BeginRead not currently supported"); + } + + /// + /// Asynchronous writes arent supported, a NotSupportedException is always thrown + /// + /// + /// + /// + /// + /// + /// + /// Any access + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw new NotSupportedException("DeflaterOutputStream BeginWrite not currently supported"); + } + + /// + /// Deflates everything in the def's input buffers. This will call + /// def.deflate() until all bytes from the input buffers + /// are processed. + /// + protected void Deflate() + { + while (!def.IsNeedingInput) { + int len = def.Deflate(buf, 0, buf.Length); + + if (len <= 0) { + break; + } + + if (this.Password != null) { + this.EncryptBlock(buf, 0, len); + } + + baseOutputStream.Write(buf, 0, len); + } + + if (!def.IsNeedingInput) { + throw new ApplicationException("DeflaterOutputStream can't deflate all input?"); + } + } + + /// + /// Creates a new DeflaterOutputStream with a default Deflater and default buffer size. + /// + /// + /// the output stream where deflated output should be written. + /// + public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512) + { + } + + /// + /// Creates a new DeflaterOutputStream with the given Deflater and + /// default buffer size. + /// + /// + /// the output stream where deflated output should be written. + /// + /// + /// the underlying deflater. + /// + public DeflaterOutputStream(Stream baseOutputStream, Deflater defl) : this(baseOutputStream, defl, 512) + { + } + + /// + /// Creates a new DeflaterOutputStream with the given Deflater and + /// buffer size. + /// + /// + /// The output stream where deflated output is written. + /// + /// + /// The underlying deflater to use + /// + /// + /// The buffer size to use when deflating + /// + /// + /// bufsize is less than or equal to zero. + /// + /// + /// baseOutputStream does not support writing + /// + /// + /// deflater instance is null + /// + public DeflaterOutputStream(Stream baseOutputStream, Deflater deflater, int bufsize) + { + if (baseOutputStream.CanWrite == false) { + throw new ArgumentException("baseOutputStream", "must support writing"); + } + + if (deflater == null) { + throw new ArgumentNullException("deflater"); + } + + if (bufsize <= 0) { + throw new ArgumentOutOfRangeException("bufsize", "Non-negative number required"); + } + + this.baseOutputStream = baseOutputStream; + buf = new byte[bufsize]; + def = deflater; + } + + /// + /// Flushes the stream by calling flush() on the deflater and then + /// on the underlying stream. This ensures that all bytes are + /// flushed. + /// + public override void Flush() + { + def.Flush(); + Deflate(); + baseOutputStream.Flush(); + } + + /// + /// Finishes the stream by calling finish() on the deflater. + /// + public virtual void Finish() + { + def.Finish(); + while (!def.IsFinished) { + int len = def.Deflate(buf, 0, buf.Length); + if (len <= 0) { + break; + } + + if (this.Password != null) { + this.EncryptBlock(buf, 0, len); + } + + baseOutputStream.Write(buf, 0, len); + } + if (!def.IsFinished) { + throw new ApplicationException("Can't deflate all input?"); + } + baseOutputStream.Flush(); + } + + /// + /// Calls finish() and closes the stream. + /// + public override void Close() + { + Finish(); + baseOutputStream.Close(); + } + + /// + /// Writes a single byte to the compressed output stream. + /// + /// + /// The byte value. + /// + public override void WriteByte(byte bval) + { + byte[] b = new byte[1]; + b[0] = bval; + Write(b, 0, 1); + } + + /// + /// Writes bytes from an array to the compressed stream. + /// + /// + /// The byte array + /// + /// + /// The offset into the byte array where to start. + /// + /// + /// The number of bytes to write. + /// + public override void Write(byte[] buf, int off, int len) + { + def.SetInput(buf, off, len); + Deflate(); + } + + #region Encryption + + // TODO Refactor this code. The presence of Zip specific code in this low level class is wrong + string password = null; + uint[] keys = null; + + /// + /// Get/set the password used for encryption. When null no encryption is performed + /// + public string Password { + get { + return password; + } + set { + password = value; + } + } + + + /// + /// Encrypt a single byte + /// + /// + /// The encrypted value + /// + protected byte EncryptByte() + { + uint temp = ((keys[2] & 0xFFFF) | 2); + return (byte)((temp * (temp ^ 1)) >> 8); + } + + + /// + /// Encrypt a block of data + /// + /// + /// Data to encrypt. NOTE the original contents of the buffer are lost + /// + /// + /// Offset of first byte in buffer to encrypt + /// + /// + /// Number of bytes in buffer to encrypt + /// + protected void EncryptBlock(byte[] buffer, int offset, int length) + { + for (int i = offset; i < offset + length; ++i) { + byte oldbyte = buffer[i]; + buffer[i] ^= EncryptByte(); + UpdateKeys(oldbyte); + } + } + + /// + /// Initializes encryption keys based on given password + /// + protected void InitializePassword(string password) { + keys = new uint[] { + 0x12345678, + 0x23456789, + 0x34567890 + }; + + for (int i = 0; i < password.Length; ++i) { + UpdateKeys((byte)password[i]); + } + } + + /// + /// Update encryption keys + /// + protected void UpdateKeys(byte ch) + { + keys[0] = Crc32.ComputeCrc32(keys[0], ch); + keys[1] = keys[1] + (byte)keys[0]; + keys[1] = keys[1] * 134775813 + 1; + keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); + } + #endregion + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/InflaterInputStream.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/InflaterInputStream.cs new file mode 100644 index 0000000..a272b59 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/InflaterInputStream.cs @@ -0,0 +1,540 @@ +// InflaterInputStream.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.IO; + +using ICSharpCode.SharpZipLib.Zip.Compression; +using ICSharpCode.SharpZipLib.Checksums; + +namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams +{ + + /// + /// This filter stream is used to decompress data compressed using the "deflate" + /// format. The "deflate" format is described in RFC 1951. + /// + /// This stream may form the basis for other decompression filters, such + /// as the GZipInputStream. + /// + /// Author of the original java version : John Leuner. + /// + public class InflaterInputStream : Stream + { + /// + /// Decompressor for this stream + /// + protected Inflater inf; + + /// + /// Byte array used for buffering input. + /// + protected byte[] buf; + + /// + /// Size of buffer + /// + protected int len; + + // Used for reading single bytes the ReadByte() call + private byte[] onebytebuffer = new byte[1]; + + /// + /// Base stream the inflater reads from. + /// + protected Stream baseInputStream; + + /// + /// The compressed size + /// + protected long csize; + + /// + /// Gets a value indicating whether the current stream supports reading + /// + public override bool CanRead { + get { + return baseInputStream.CanRead; + } + } + + /// + /// Value of false indicating seeking is not supported for this stream + /// This property always returns false + /// + public override bool CanSeek { + get { + return false; + } + } + + /// + /// Get true if stream is writeable + /// This property always returns false + /// + public override bool CanWrite { + get { + return false; + } + } + + /// + /// A value representing the length of the stream in bytes. + /// + public override long Length { + get { + return len; + } + } + + /// + /// The current position within the stream + /// Throws a NotSupportedException when attempting to set the position + /// + /// Attempting to set the position + public override long Position { + get { + return baseInputStream.Position; + } + set { + throw new NotSupportedException("InflaterInputStream Position not supported"); + } + } + + /// + /// Flushes the baseInputStream + /// + public override void Flush() + { + baseInputStream.Flush(); + } + + /// + /// Sets the position within the current stream + /// Always throws a NotSupportedException + /// + /// Any access + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException("Seek not supported"); + } + + /// + /// Set the length of the current stream + /// Always throws a NotSupportedException + /// + /// Any access + public override void SetLength(long val) + { + throw new NotSupportedException("InflaterInputStream SetLength not supported"); + } + + /// + /// Writes a sequence of bytes to stream and advances the current position + /// This method always throws a NotSupportedException + /// + /// Any access + public override void Write(byte[] array, int offset, int count) + { + throw new NotSupportedException("InflaterInputStream Write not supported"); + } + + /// + /// Writes one byte to the current stream and advances the current position + /// Always throws a NotSupportedException + /// + /// Any access + public override void WriteByte(byte val) + { + throw new NotSupportedException("InflaterInputStream WriteByte not supported"); + } + + /// + /// Entry point to begin an asynchronous write. Always throws a NotSupportedException. + /// + /// The buffer to write data from + /// Offset of first byte to write + /// The maximum number of bytes to write + /// The method to be called when the asynchronous write operation is completed + /// A user-provided object that distinguishes this particular asynchronous write request from other requests + /// An IAsyncResult that references the asynchronous write + /// Any access + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) + { + throw new NotSupportedException("InflaterInputStream BeginWrite not supported"); + } + + /// + /// Create an InflaterInputStream with the default decompressor + /// and a default buffer size of 4KB. + /// + /// + /// The InputStream to read bytes from + /// + public InflaterInputStream(Stream baseInputStream) : this(baseInputStream, new Inflater(), 4096) + { + } + + /// + /// Create an InflaterInputStream with the specified decompressor + /// and a default buffer size of 4KB. + /// + /// + /// The source of input data + /// + /// + /// The decompressor used to decompress data read from baseInputStream + /// + public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096) + { + } + + /// + /// Create an InflaterInputStream with the specified decompressor + /// and the specified buffer size. + /// + /// + /// The InputStream to read bytes from + /// + /// + /// The decompressor to use + /// + /// + /// Size of the buffer to use + /// + public InflaterInputStream(Stream baseInputStream, Inflater inflater, int bufferSize) + { + if (baseInputStream == null) { + throw new ArgumentNullException("InflaterInputStream baseInputStream is null"); + } + + if (inflater == null) { + throw new ArgumentNullException("InflaterInputStream Inflater is null"); + } + + if (bufferSize <= 0) { + throw new ArgumentOutOfRangeException("bufferSize"); + } + + this.baseInputStream = baseInputStream; + this.inf = inflater; + buf = new byte[bufferSize]; + + // TODO rework this!! The original code will mask real exceptions. +/* Is this valid in all cases? + if (baseInputStream.CanSeek) { + this.len = baseInputStream.Length; + } else { + this.len = 0; + } +*/ + try { + this.len = (int)baseInputStream.Length; + } catch (Exception) { + // the stream may not support Length property + this.len = 0; + } + + } + + /// + /// Returns 0 once the end of the stream (EOF) has been reached. + /// Otherwise returns 1. + /// + /// TODO make this a bool property? + public virtual int Available { + get { + return inf.IsFinished ? 0 : 1; + } + } + + /// + /// Closes the input stream + /// + public override void Close() + { + baseInputStream.Close(); + } + + int readChunkSize = 0; + + // TODO this is an ineficient way of handling this situation + // revamp this to operate better... + + /// + /// Sets the size of chunks to read from the input stream + /// 0 means as larger as possible. + /// + /// + /// Used to handle decryption where the length of stream is unknown. + /// + protected int BufferReadSize { + get { + return readChunkSize; + } + + set { + readChunkSize = value; + } + } + + /// + /// Fill input buffer with a chunk of data. + /// + /// + /// Stream ends early + /// + protected void FillInputBuffer() + { + if (readChunkSize <= 0) { + len = baseInputStream.Read(buf, 0, buf.Length); + } else { + len = baseInputStream.Read(buf, 0, readChunkSize); + } + + } + /// + /// Fills the buffer with more data to decompress. + /// + /// + /// Stream ends early + /// + protected void Fill() + { + FillInputBuffer(); + + if (keys != null) { + DecryptBlock(buf, 0, len); + } + +#if READ_SINGLE_WHEN_DECRYPTING + // This solves some decryption problems but there are still some lurking. + // At issue is exactly where the stream and decryption should finish. + if (keys == null) { + len = baseInputStream.Read(buf, 0, buf.Length); + } else { + len = baseInputStream.Read(buf, 0, 1); + } + + if (keys != null) { + DecryptBlock(buf, 0, len); + } +#endif + +#if STANDARD + len = baseInputStream.Read(buf, 0, buf.Length); + + if (keys != null) { + DecryptBlock(buf, 0, System.Math.Min((int)(csize - inf.TotalIn), len)); + } +#endif + + if (len <= 0) { + throw new ZipException("Deflated stream ends early."); + } + + inf.SetInput(buf, 0, len); + } + + /// + /// Reads one byte of decompressed data. + /// + /// The byte is baseInputStream the lower 8 bits of the int. + /// + /// + /// The byte read cast to an int, or -1 on end of stream. + /// + public override int ReadByte() + { + int nread = Read(onebytebuffer, 0, 1); // read one byte + if (nread > 0) { + return onebytebuffer[0] & 0xff; + } + return -1; // ok + } + + /// + /// Decompresses data into the byte array + /// + /// + /// The array to read and decompress data into + /// + /// + /// The offset indicating where the data should be placed + /// + /// + /// The number of bytes to decompress + /// + /// The number of bytes read. Zero signals the end of stream + /// + /// Inflater needs a dictionary + /// + public override int Read(byte[] b, int off, int len) + { + for (;;) { + int count; + try { + count = inf.Inflate(b, off, len); + } catch (Exception e) { + throw new ZipException(e.ToString()); + } + + if (count > 0) { + return count; + } + + if (inf.IsNeedingDictionary) { + throw new ZipException("Need a dictionary"); + } else if (inf.IsFinished) { + return 0; + } else if (inf.IsNeedingInput) { + Fill(); + } else { + throw new InvalidOperationException("Don't know what to do"); + } + } + } + + /// + /// Skip specified number of bytes of uncompressed data + /// + /// + /// Number of bytes to skip + /// + /// + /// The number of bytes skipped, zero if the end of + /// stream has been reached + /// + /// + /// Number of bytes to skip is zero or less + /// + public long Skip(long n) + { + if (n <= 0) { + throw new ArgumentOutOfRangeException("n"); + } + + // v0.80 Skip by seeking if underlying stream supports it... + if (baseInputStream.CanSeek) { + baseInputStream.Seek(n, SeekOrigin.Current); + return n; + } else { + int len = 2048; + if (n < len) { + len = (int) n; + } + byte[] tmp = new byte[len]; + return (long)baseInputStream.Read(tmp, 0, tmp.Length); + } + } + + #region Encryption stuff + + // TODO Refactor this code. The presence of Zip specific code in this low level class is wrong + + /// + /// A buffer used for decrypting data. Used to hold Zip crypto header. + /// + protected byte[] cryptbuffer = null; + + uint[] keys = null; + + /// + /// Decrypt a single byte + /// + /// plain text byte value + protected byte DecryptByte() + { + uint temp = ((keys[2] & 0xFFFF) | 2); + return (byte)((temp * (temp ^ 1)) >> 8); + } + + /// + /// Decrypt cipher text block, updating keys + /// + /// Data to decrypt + /// Offset of first byte to process + /// Number of bytes to process + protected void DecryptBlock(byte[] buf, int off, int len) + { + for (int i = off; i < off + len; ++i) { + buf[i] ^= DecryptByte(); + UpdateKeys(buf[i]); + } + } + + /// + /// Initialise the decryption keys + /// + /// The password used to initialise the keys + protected void InitializePassword(string password) + { + keys = new uint[] { + 0x12345678, + 0x23456789, + 0x34567890 + }; + for (int i = 0; i < password.Length; ++i) { + UpdateKeys((byte)password[i]); + } + } + + /// + /// Update the decryption keys + /// + /// Character to update the keys with + protected void UpdateKeys(byte ch) + { + keys[0] = Crc32.ComputeCrc32(keys[0], ch); + keys[1] = keys[1] + (byte)keys[0]; + keys[1] = keys[1] * 134775813 + 1; + keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); + } + + /// + /// Clear any cryptographic state. + /// + protected void StopDecrypting() + { + keys = null; + cryptbuffer = null; + } + #endregion + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/OutputWindow.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/OutputWindow.cs new file mode 100644 index 0000000..058f51f --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/OutputWindow.cs @@ -0,0 +1,227 @@ +// OutputWindow.cs +// +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams +{ + + /// + /// Contains the output from the Inflation process. + /// We need to have a window so that we can refer backwards into the output stream + /// to repeat stuff. + /// + /// author of the original java version : John Leuner + /// + public class OutputWindow + { + private static int WINDOW_SIZE = 1 << 15; + private static int WINDOW_MASK = WINDOW_SIZE - 1; + + private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes + private int windowEnd = 0; + private int windowFilled = 0; + + /// + /// write a byte to this output window + /// + /// value to write + /// + /// if window is full + /// + public void Write(int abyte) + { + if (windowFilled++ == WINDOW_SIZE) { + throw new InvalidOperationException("Window full"); + } + window[windowEnd++] = (byte) abyte; + windowEnd &= WINDOW_MASK; + } + + + private void SlowRepeat(int repStart, int len, int dist) + { + while (len-- > 0) { + window[windowEnd++] = window[repStart++]; + windowEnd &= WINDOW_MASK; + repStart &= WINDOW_MASK; + } + } + + /// + /// Append a byte pattern already in the window itself + /// + /// length of pattern to copy + /// distance from end of window pattern occurs + /// + /// If the repeated data overflows the window + /// + public void Repeat(int len, int dist) + { + if ((windowFilled += len) > WINDOW_SIZE) { + throw new InvalidOperationException("Window full"); + } + + int rep_start = (windowEnd - dist) & WINDOW_MASK; + int border = WINDOW_SIZE - len; + if (rep_start <= border && windowEnd < border) { + if (len <= dist) { + System.Array.Copy(window, rep_start, window, windowEnd, len); + windowEnd += len; + } else { + /* We have to copy manually, since the repeat pattern overlaps. */ + while (len-- > 0) { + window[windowEnd++] = window[rep_start++]; + } + } + } else { + SlowRepeat(rep_start, len, dist); + } + } + + /// + /// Copy from input manipulator to internal window + /// + /// source of data + /// length of data to copy + /// the number of bytes copied + public int CopyStored(StreamManipulator input, int len) + { + len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes); + int copied; + + int tailLen = WINDOW_SIZE - windowEnd; + if (len > tailLen) { + copied = input.CopyBytes(window, windowEnd, tailLen); + if (copied == tailLen) { + copied += input.CopyBytes(window, 0, len - tailLen); + } + } else { + copied = input.CopyBytes(window, windowEnd, len); + } + + windowEnd = (windowEnd + copied) & WINDOW_MASK; + windowFilled += copied; + return copied; + } + + /// + /// Copy dictionary to window + /// + /// source dictionary + /// offset of start in source dictionary + /// length of dictionary + /// + /// If window isnt empty + /// + public void CopyDict(byte[] dict, int offset, int len) + { + if (windowFilled > 0) { + throw new InvalidOperationException(); + } + + if (len > WINDOW_SIZE) { + offset += len - WINDOW_SIZE; + len = WINDOW_SIZE; + } + System.Array.Copy(dict, offset, window, 0, len); + windowEnd = len & WINDOW_MASK; + } + + /// + /// Get remaining unfilled space in window + /// + /// Number of bytes left in window + public int GetFreeSpace() + { + return WINDOW_SIZE - windowFilled; + } + + /// + /// Get bytes available for output in window + /// + /// Number of bytes filled + public int GetAvailable() + { + return windowFilled; + } + + /// + /// Copy contents of window to output + /// + /// buffer to copy to + /// offset to start at + /// number of bytes to count + /// The number of bytes copied + /// + /// If a window underflow occurs + /// + public int CopyOutput(byte[] output, int offset, int len) + { + int copy_end = windowEnd; + if (len > windowFilled) { + len = windowFilled; + } else { + copy_end = (windowEnd - windowFilled + len) & WINDOW_MASK; + } + + int copied = len; + int tailLen = len - copy_end; + + if (tailLen > 0) { + System.Array.Copy(window, WINDOW_SIZE - tailLen, output, offset, tailLen); + offset += tailLen; + len = copy_end; + } + System.Array.Copy(window, copy_end - len, output, offset, len); + windowFilled -= copied; + if (windowFilled < 0) { + throw new InvalidOperationException(); + } + return copied; + } + + /// + /// Reset by clearing window so GetAvailable returns 0 + /// + public void Reset() + { + windowFilled = windowEnd = 0; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/StreamManipulator.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/StreamManipulator.cs new file mode 100644 index 0000000..cf4fb1a --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/Compression/Streams/StreamManipulator.cs @@ -0,0 +1,270 @@ +// StreamManipulator.cs +// +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; + +namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams +{ + + /// + /// This class allows us to retrieve a specified number of bits from + /// the input buffer, as well as copy big byte blocks. + /// + /// It uses an int buffer to store up to 31 bits for direct + /// manipulation. This guarantees that we can get at least 16 bits, + /// but we only need at most 15, so this is all safe. + /// + /// There are some optimizations in this class, for example, you must + /// never peek more than 8 bits more than needed, and you must first + /// peek bits before you may drop them. This is not a general purpose + /// class but optimized for the behaviour of the Inflater. + /// + /// authors of the original java version : John Leuner, Jochen Hoenicke + /// + public class StreamManipulator + { + private byte[] window; + private int window_start = 0; + private int window_end = 0; + + private uint buffer = 0; + private int bits_in_buffer = 0; + + /// + /// Get the next n bits but don't increase input pointer. n must be + /// less or equal 16 and if this call succeeds, you must drop + /// at least n - 8 bits in the next call. + /// + /// + /// the value of the bits, or -1 if not enough bits available. */ + /// + public int PeekBits(int n) + { + if (bits_in_buffer < n) { + if (window_start == window_end) { + return -1; // ok + } + buffer |= (uint)((window[window_start++] & 0xff | + (window[window_start++] & 0xff) << 8) << bits_in_buffer); + bits_in_buffer += 16; + } + return (int)(buffer & ((1 << n) - 1)); + } + + /// + /// Drops the next n bits from the input. You should have called PeekBits + /// with a bigger or equal n before, to make sure that enough bits are in + /// the bit buffer. + /// + public void DropBits(int n) + { + buffer >>= n; + bits_in_buffer -= n; + } + + /// + /// Gets the next n bits and increases input pointer. This is equivalent + /// to PeekBits followed by dropBits, except for correct error handling. + /// + /// + /// the value of the bits, or -1 if not enough bits available. + /// + public int GetBits(int n) + { + int bits = PeekBits(n); + if (bits >= 0) { + DropBits(n); + } + return bits; + } + + /// + /// Gets the number of bits available in the bit buffer. This must be + /// only called when a previous PeekBits() returned -1. + /// + /// + /// the number of bits available. + /// + public int AvailableBits { + get { + return bits_in_buffer; + } + } + + /// + /// Gets the number of bytes available. + /// + /// + /// The number of bytes available. + /// + public int AvailableBytes { + get { + return window_end - window_start + (bits_in_buffer >> 3); + } + } + + /// + /// Skips to the next byte boundary. + /// + public void SkipToByteBoundary() + { + buffer >>= (bits_in_buffer & 7); + bits_in_buffer &= ~7; + } + + /// + /// Returns true when SetInput can be called + /// + public bool IsNeedingInput { + get { + return window_start == window_end; + } + } + + /// + /// Copies length bytes from input buffer to output buffer starting + /// at output[offset]. You have to make sure, that the buffer is + /// byte aligned. If not enough bytes are available, copies fewer + /// bytes. + /// + /// + /// The buffer to copy bytes to. + /// + /// + /// The offset in the buffer at which copying starts + /// + /// + /// The length to copy, 0 is allowed. + /// + /// + /// The number of bytes copied, 0 if no bytes were available. + /// + /// + /// Length is less than zero + /// + /// + /// Bit buffer isnt byte aligned + /// + public int CopyBytes(byte[] output, int offset, int length) + { + if (length < 0) { + throw new ArgumentOutOfRangeException("length", "negative"); + } + if ((bits_in_buffer & 7) != 0) { + /* bits_in_buffer may only be 0 or a multiple of 8 */ + throw new InvalidOperationException("Bit buffer is not byte aligned!"); + } + + int count = 0; + while (bits_in_buffer > 0 && length > 0) { + output[offset++] = (byte) buffer; + buffer >>= 8; + bits_in_buffer -= 8; + length--; + count++; + } + + if (length == 0) { + return count; + } + + int avail = window_end - window_start; + if (length > avail) { + length = avail; + } + System.Array.Copy(window, window_start, output, offset, length); + window_start += length; + + if (((window_start - window_end) & 1) != 0) { + /* We always want an even number of bytes in input, see peekBits */ + buffer = (uint)(window[window_start++] & 0xff); + bits_in_buffer = 8; + } + return count + length; + } + + /// + /// Constructs a default StreamManipulator with all buffers empty + /// + public StreamManipulator() + { + } + + + /// + /// resets state and empties internal buffers + /// + public void Reset() + { + buffer = (uint)(window_start = window_end = bits_in_buffer = 0); + } + + /// + /// Add more input for consumption. + /// Only call when IsNeedingInput returns true + /// + /// data to be input + /// offset of first byte of input + /// length of input + public void SetInput(byte[] buf, int off, int len) + { + if (window_start < window_end) { + throw new InvalidOperationException("Old input was not completely processed"); + } + + int end = off + len; + + /* We want to throw an ArrayIndexOutOfBoundsException early. The + * check is very tricky: it also handles integer wrap around. + */ + if (0 > off || off > end || end > buf.Length) { + throw new ArgumentOutOfRangeException(); + } + + if ((len & 1) != 0) { + /* We always want an even number of bytes in input, see peekBits */ + buffer |= (uint)((buf[off++] & 0xff) << bits_in_buffer); + bits_in_buffer += 8; + } + + window = buf; + window_start = off; + window_end = end; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipConstants.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipConstants.cs new file mode 100644 index 0000000..b075771 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipConstants.cs @@ -0,0 +1,418 @@ +// ZipConstants.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System.Text; + +namespace ICSharpCode.SharpZipLib.Zip +{ + + /// + /// The kind of compression used for an entry in an archive + /// + public enum CompressionMethod + { + /// + /// A direct copy of the file contents is held in the archive + /// + Stored = 0, + + /// + /// Common Zip compression method using a sliding dictionary + /// of up to 32KB and secondary compression from Huffman/Shannon-Fano trees + /// + Deflated = 8, + + /// + /// An extension to deflate with a 64KB window. Not supported + /// + Deflate64 = 9, + + /// + /// Not supported + /// + BZip2 = 11, + + /// + /// WinZip special for AES encryption, Not supported + /// + WinZipAES = 99, + + } + + /// + /// This class contains constants used for Zip format files + /// + public sealed class ZipConstants + { + /// + /// The version made by field for entries in the central header when created by this library + /// + /// + /// This is also the Zip version for the library when comparing against the version required to extract + /// for an entry. See ZipInputStream.CanDecompressEntry. + /// + public const int VERSION_MADE_BY = 20; + + // The local entry header + + /// + /// Size of local entry header (excluding variable length fields at end) + /// + public const int LOCHDR = 30; + + /// + /// Signature for local entry header + /// + public const int LOCSIG = 'P' | ('K' << 8) | (3 << 16) | (4 << 24); + + /// + /// Offset of version to extract in local entry header + /// + public const int LOCVER = 4; + + /// + /// Offset of general purpose flags in local entry header + /// + public const int LOCFLG = 6; + + /// + /// Offset of compression method in local entry header + /// + public const int LOCHOW = 8; + + /// + /// Offset of last mod file time + date in local entry header + /// + public const int LOCTIM = 10; + + /// + /// Offset of crc-32 in local entry header + /// + public const int LOCCRC = 14; + + /// + /// Offset of compressed size in local entry header + /// + public const int LOCSIZ = 18; + + /// + /// Offset of uncompressed size in local entry header + /// + public const int LOCLEN = 22; + + /// + /// Offset of file name length in local entry header + /// + public const int LOCNAM = 26; + + /// + /// Offset of extra field length in local entry header + /// + public const int LOCEXT = 28; + + + /// + /// Signature for spanning entry + /// + public const int SPANNINGSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); + + /// + /// Signature for temporary spanning entry + /// + public const int SPANTEMPSIG = 'P' | ('K' << 8) | ('0' << 16) | ('0' << 24); + + /// + /// Signature for data descriptor + /// + /// + /// This is only used where the length, Crc, or compressed size isnt known when the + /// entry is created and the output stream doesnt support seeking. + /// The local entry cannot be 'patched' with the correct values in this case + /// so the values are recorded after the data prefixed by this header, as well as in the central directory.
+ ///
+ public const int EXTSIG = 'P' | ('K' << 8) | (7 << 16) | (8 << 24); + + /// + /// Size of data descriptor + /// + public const int EXTHDR = 16; + + /// + /// Offset of crc-32 in data descriptor + /// + public const int EXTCRC = 4; + + /// + /// Offset of compressed size in data descriptor + /// + public const int EXTSIZ = 8; + + /// + /// Offset of uncompressed length in data descriptor + /// + public const int EXTLEN = 12; + + + /// + /// Signature for central header + /// + public const int CENSIG = 'P' | ('K' << 8) | (1 << 16) | (2 << 24); + + /// + /// Size of central header entry + /// + public const int CENHDR = 46; + + /// + /// Offset of version made by in central file header + /// + public const int CENVEM = 4; + + /// + /// Offset of version needed to extract in central file header + /// + public const int CENVER = 6; + + /// + /// Offset of general purpose bit flag in central file header + /// + public const int CENFLG = 8; + + /// + /// Offset of compression method in central file header + /// + public const int CENHOW = 10; + + /// + /// Offset of time/date in central file header + /// + public const int CENTIM = 12; + + /// + /// Offset of crc-32 in central file header + /// + public const int CENCRC = 16; + + /// + /// Offset of compressed size in central file header + /// + public const int CENSIZ = 20; + + /// + /// Offset of uncompressed size in central file header + /// + public const int CENLEN = 24; + + /// + /// Offset of file name length in central file header + /// + public const int CENNAM = 28; + + /// + /// Offset of extra field length in central file header + /// + public const int CENEXT = 30; + + /// + /// Offset of file comment length in central file header + /// + public const int CENCOM = 32; + + /// + /// Offset of disk start number in central file header + /// + public const int CENDSK = 34; + + /// + /// Offset of internal file attributes in central file header + /// + public const int CENATT = 36; + + /// + /// Offset of external file attributes in central file header + /// + public const int CENATX = 38; + + /// + /// Offset of relative offset of local header in central file header + /// + public const int CENOFF = 42; + + + /// + /// Signature for Zip64 central file header + /// + public const int CENSIG64 = 'P' | ('K' << 8) | (6 << 16) | (6 << 24); + + + + /// + /// Central header digitial signature + /// + public const int CENDIGITALSIG = 'P' | ('K' << 8) | (5 << 16) | (5 << 24); + + + // The entries at the end of central directory + + /// + /// End of central directory record signature + /// + public const int ENDSIG = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); + + /// + /// Size of end of central record (excluding variable fields) + /// + public const int ENDHDR = 22; + + // The following two fields are missing in SUN JDK + + /// + /// Offset of number of this disk + /// + public const int ENDNRD = 4; + + /// + /// Offset of number of disk with start of central directory + /// + public const int ENDDCD = 6; + + /// + /// Offset of number of entries in the central directory of this disk + /// + public const int ENDSUB = 8; + + /// + /// Offset of total number of entries in the central directory + /// + public const int ENDTOT = 10; + + /// + /// Offset of size of central directory + /// + public const int ENDSIZ = 12; + + /// + /// Offset of offset of start of central directory with respect to starting disk number + /// + public const int ENDOFF = 16; + + /// + /// Offset of ZIP file comment length + /// + public const int ENDCOM = 20; + + /// + /// Size of cryptographic header stored before entry data + /// + public const int CRYPTO_HEADER_SIZE = 12; + + +#if !COMPACT_FRAMEWORK + + static int defaultCodePage = 0; + + /// + /// Default encoding used for string conversion. 0 gives default system ansi code page. + /// Dont use unicode encodings if you want to be Zip compatible! + /// Using the default code page isnt the full solution neccessarily + /// there are many variable factors, codepage 850 is often a good choice for + /// European users, however be careful about compatability. + /// + public static int DefaultCodePage { + get { + return defaultCodePage; + } + set { + defaultCodePage = value; + } + } +#endif + + /// + /// Convert a portion of a byte array to a string. + /// + /// + /// Data to convert to string + /// + /// + /// Number of bytes to convert starting from index 0 + /// + /// + /// data[0]..data[length - 1] converted to a string + /// + public static string ConvertToString(byte[] data, int length) + { +#if COMPACT_FRAMEWORK + return Encoding.ASCII.GetString(data, 0, length); +#else + return Encoding.GetEncoding(DefaultCodePage).GetString(data, 0, length); +#endif + } + + /// + /// Convert byte array to string + /// + /// + /// Byte array to convert + /// + /// + /// dataconverted to a string + /// + public static string ConvertToString(byte[] data) + { + return ConvertToString(data, data.Length); + } + + /// + /// Convert a string to a byte array + /// + /// + /// String to convert to an array + /// + /// Converted array + public static byte[] ConvertToArray(string str) + { +#if COMPACT_FRAMEWORK + return Encoding.ASCII.GetBytes(str); +#else + return Encoding.GetEncoding(DefaultCodePage).GetBytes(str); +#endif + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipEntry.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipEntry.cs new file mode 100644 index 0000000..8847a0b --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipEntry.cs @@ -0,0 +1,693 @@ +// ZipEntry.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.IO; + +namespace ICSharpCode.SharpZipLib.Zip +{ + + /// + /// This class represents an entry in a zip archive. This can be a file + /// or a directory + /// ZipFile and ZipInputStream will give you instances of this class as + /// information about the members in an archive. ZipOutputStream + /// uses an instance of this class when creating an entry in a Zip file. + ///
+ ///
Author of the original java version : Jochen Hoenicke + ///
+ public class ZipEntry : ICloneable + { + static int KNOWN_SIZE = 1; + static int KNOWN_CSIZE = 2; + static int KNOWN_CRC = 4; + static int KNOWN_TIME = 8; + static int KNOWN_EXTERN_ATTRIBUTES = 16; + + ushort known = 0; // Bit flags made up of above bits + int externalFileAttributes = -1; // contains external attributes (os dependant) + + ushort versionMadeBy; // Contains host system and version information + // only relevant for central header entries + + string name; + ulong size; + ulong compressedSize; + ushort versionToExtract; // Version required to extract (library handles <= 2.0) + uint crc; + uint dosTime; + + CompressionMethod method = CompressionMethod.Deflated; + byte[] extra = null; + string comment = null; + + int flags; // general purpose bit flags + + int zipFileIndex = -1; // used by ZipFile + int offset; // used by ZipFile and ZipOutputStream + + /// + /// Get/Set flag indicating if entry is encrypted. + /// A simple helper routine to aid interpretation of flags + /// + public bool IsCrypted { + get { + return (flags & 1) != 0; + } + set { + if (value) { + flags |= 1; + } else { + flags &= ~1; + } + } + } + + /// + /// Get/Set general purpose bit flag for entry + /// + /// + /// General purpose bit flag
+ /// Bit 0: If set, indicates the file is encrypted
+ /// Bit 1-2 Only used for compression type 6 Imploding, and 8, 9 deflating
+ /// Imploding:
+ /// Bit 1 if set indicates an 8K sliding dictionary was used. If clear a 4k dictionary was used
+ /// Bit 2 if set indicates 3 Shannon-Fanno trees were used to encode the sliding dictionary, 2 otherwise
+ ///
+ /// Deflating:
+ /// Bit 2 Bit 1
+ /// 0 0 Normal compression was used
+ /// 0 1 Maximum compression was used
+ /// 1 0 Fast compression was used
+ /// 1 1 Super fast compression was used
+ ///
+ /// Bit 3: If set, the fields crc-32, compressed size + /// and uncompressed size are were not able to be written during zip file creation + /// The correct values are held in a data descriptor immediately following the compressed data.
+ /// Bit 4: Reserved for use by PKZIP for enhanced deflating
+ /// Bit 5: If set indicates the file contains compressed patch data
+ /// Bit 6: If set indicates strong encryption was used.
+ /// Bit 7-15: Unused or reserved
+ ///
+ public int Flags { + get { + return flags; + } + set { + flags = value; + } + } + + + /// + /// Get/Set index of this entry in Zip file + /// + public int ZipFileIndex { + get { + return zipFileIndex; + } + set { + zipFileIndex = value; + } + } + + /// + /// Get/set offset for use in central header + /// + public int Offset { + get { + return offset; + } + set { + if (((ulong)value & 0xFFFFFFFF00000000L) != 0) { + throw new ArgumentOutOfRangeException("Offset"); + } + offset = value; + } + } + + + /// + /// Get/Set external file attributes as an integer. + /// The values of this are operating system dependant see + /// HostSystem for details + /// + public int ExternalFileAttributes { + get { + if ((known & KNOWN_EXTERN_ATTRIBUTES) == 0) { + return -1; + } else { + return externalFileAttributes; + } + } + + set { + externalFileAttributes = value; + known |= (ushort)KNOWN_EXTERN_ATTRIBUTES; + } + } + + /// + /// Get the version made by for this entry or zero if unknown. + /// The value / 10 indicates the major version number, and + /// the value mod 10 is the minor version number + /// + public int VersionMadeBy { + get { + return versionMadeBy & 0xff; + } + } + + /// + /// Gets the compatability information for the external file attribute + /// If the external file attributes are compatible with MS-DOS and can be read + /// by PKZIP for DOS version 2.04g then this value will be zero. Otherwise the value + /// will be non-zero and identify the host system on which the attributes are compatible. + /// + /// + /// + /// The values for this as defined in the Zip File format and by others are shown below. The values are somewhat + /// misleading in some cases as they are not all used as shown. You should consult the relevant documentation + /// to obtain up to date and correct information. The modified appnote by the infozip group is + /// particularly helpful as it documents a lot of peculiarities. The document is however a little dated. + /// + /// 0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) + /// 1 - Amiga + /// 2 - OpenVMS + /// 3 - Unix + /// 4 - VM/CMS + /// 5 - Atari ST + /// 6 - OS/2 HPFS + /// 7 - Macintosh + /// 8 - Z-System + /// 9 - CP/M + /// 10 - Windows NTFS + /// 11 - MVS (OS/390 - Z/OS) + /// 12 - VSE + /// 13 - Acorn Risc + /// 14 - VFAT + /// 15 - Alternate MVS + /// 16 - BeOS + /// 17 - Tandem + /// 18 - OS/400 + /// 19 - OS/X (Darwin) + /// 99 - WinZip AES + /// remainder - unused + /// + /// + + public int HostSystem { + get { return (versionMadeBy >> 8) & 0xff; } + } + + /// + /// Creates a zip entry with the given name. + /// + /// + /// The name for this entry. Can include directory components. + /// The convention for names is 'unix' style paths with no device names and + /// path elements separated by '/' characters. This is not enforced see CleanName + /// on how to ensure names are valid if this is desired. + /// + /// + /// The name passed is null + /// + public ZipEntry(string name) : this(name, 0, ZipConstants.VERSION_MADE_BY) + { + } + + /// + /// Creates a zip entry with the given name and version required to extract + /// + /// + /// The name for this entry. Can include directory components. + /// The convention for names is 'unix' style paths with no device names and + /// path elements separated by '/' characters. This is not enforced see CleanName + /// on how to ensure names are valid if this is desired. + /// + /// + /// The minimum 'feature version' required this entry + /// + /// + /// The name passed is null + /// + public ZipEntry(string name, int versionRequiredToExtract) : this(name, versionRequiredToExtract, ZipConstants.VERSION_MADE_BY) + { + } + + /// + /// Initializes an entry with the given name and made by information + /// + /// Name for this entry + /// Version and HostSystem Information + /// Minimum required zip feature version required to extract this entry + /// + /// The name passed is null + /// + /// + /// versionRequiredToExtract should be 0 (auto-calculate) or > 10 + /// + /// + /// This constructor is used by the ZipFile class when reading from the central header + /// It is not generally useful, use the constructor specifying the name only. + /// + public ZipEntry(string name, int versionRequiredToExtract, int madeByInfo) + { + if (name == null) { + throw new System.ArgumentNullException("ZipEntry name"); + } + + if (versionRequiredToExtract != 0 && versionRequiredToExtract < 10) { + throw new ArgumentOutOfRangeException("versionRequiredToExtract"); + } + + this.DateTime = System.DateTime.Now; + this.name = name; + this.versionMadeBy = (ushort)madeByInfo; + this.versionToExtract = (ushort)versionRequiredToExtract; + } + + /// + /// Creates a copy of the given zip entry. + /// + /// + /// The entry to copy. + /// + public ZipEntry(ZipEntry e) + { + known = e.known; + name = e.name; + size = e.size; + compressedSize = e.compressedSize; + crc = e.crc; + dosTime = e.dosTime; + method = e.method; + ExtraData = e.ExtraData; // Note use of property ensuring data is unique + comment = e.comment; + versionToExtract = e.versionToExtract; + versionMadeBy = e.versionMadeBy; + externalFileAttributes = e.externalFileAttributes; + flags = e.flags; + + zipFileIndex = -1; + offset = 0; + } + + /// + /// Get minimum Zip feature version required to extract this entry + /// + /// + /// Minimum features are defined as:
+ /// 1.0 - Default value
+ /// 1.1 - File is a volume label
+ /// 2.0 - File is a folder/directory
+ /// 2.0 - File is compressed using Deflate compression
+ /// 2.0 - File is encrypted using traditional encryption
+ /// 2.1 - File is compressed using Deflate64
+ /// 2.5 - FIle is compressed using PKWARE DCL Implode
+ /// 2.7 - File is a patch data set
+ /// 4.5 - File uses Zip64 format extensions
+ /// 4.6 - File is compressed using BZIP2 compression
+ /// 5.0 - File is encrypted using DES
+ /// 5.0 - File is encrypted using 3DES
+ /// 5.0 - File is encrypted using original RC2 encryption
+ /// 5.0 - File is encrypted using RC4 encryption
+ /// 5.1 - File is encrypted using AES encryption
+ /// 5.1 - File is encrypted using corrected RC2 encryption
+ /// 5.1 - File is encrypted using corrected RC2-64 encryption
+ /// 6.1 - File is encrypted using non-OAEP key wrapping
+ /// 6.2 - Central directory encryption (not confirmed yet)
+ ///
+ public int Version { + get { + if (versionToExtract != 0) { + return versionToExtract; + } else { + int result = 10; + if (CompressionMethod.Deflated == method) { + result = 20; + } else if (IsDirectory == true) { + result = 20; + } else if (IsCrypted == true) { + result = 20; + } else if ((known & KNOWN_EXTERN_ATTRIBUTES) != 0 && (externalFileAttributes & 0x08) != 0) { + result = 11; + } + return result; + } + } + } + + /// + /// Get/Set DosTime + /// + public long DosTime { + get { + if ((known & KNOWN_TIME) == 0) { + return 0; + } else { + return dosTime; + } + } + set { + this.dosTime = (uint)value; + known |= (ushort)KNOWN_TIME; + } + } + + + /// + /// Gets/Sets the time of last modification of the entry. + /// + public DateTime DateTime { + get { + uint sec = 2 * (dosTime & 0x1f); + uint min = (dosTime >> 5) & 0x3f; + uint hrs = (dosTime >> 11) & 0x1f; + uint day = (dosTime >> 16) & 0x1f; + uint mon = ((dosTime >> 21) & 0xf); + uint year = ((dosTime >> 25) & 0x7f) + 1980; + return new System.DateTime((int)year, (int)mon, (int)day, (int)hrs, (int)min, (int)sec); + } + set { + DosTime = ((uint)value.Year - 1980 & 0x7f) << 25 | + ((uint)value.Month) << 21 | + ((uint)value.Day) << 16 | + ((uint)value.Hour) << 11 | + ((uint)value.Minute) << 5 | + ((uint)value.Second) >> 1; + } + } + + /// + /// Returns the entry name. The path components in the entry should + /// always separated by slashes ('/'). Dos device names like C: should also + /// be removed. See CleanName. + /// + public string Name { + get { + return name; + } + } + + /// + /// Cleans a name making it conform to Zip file conventions. + /// Devices names ('c:\') and UNC share names ('\\server\share') are removed + /// and forward slashes ('\') are converted to back slashes ('/'). + /// + /// Name to clean + /// Make names relative if true or absolute if false + static public string CleanName(string name, bool relativePath) + { + if (name == null) { + return ""; + } + + if (Path.IsPathRooted(name) == true) { + // NOTE: + // for UNC names... \\machine\share\zoom\beet.txt gives \zoom\beet.txt + name = name.Substring(Path.GetPathRoot(name).Length); + } + + name = name.Replace(@"\", "/"); + + if (relativePath == true) { + if (name.Length > 0 && (name[0] == Path.AltDirectorySeparatorChar || name[0] == Path.DirectorySeparatorChar)) { + name = name.Remove(0, 1); + } + } else { + if (name.Length > 0 && name[0] != Path.AltDirectorySeparatorChar && name[0] != Path.DirectorySeparatorChar) { + name = name.Insert(0, "/"); + } + } + return name; + } + + /// + /// Cleans a name making it conform to Zip file conventions. + /// Devices names ('c:\') and UNC share names ('\\server\share') are removed + /// and forward slashes ('\') are converted to back slashes ('/'). + /// Names are made relative by trimming leading slashes which is compatible + /// with Windows-XPs built in Zip file handling. + /// + /// Name to clean + static public string CleanName(string name) + { + return CleanName(name, true); + } + + /// + /// Gets/Sets the size of the uncompressed data. + /// + /// + /// If the size is not in the range 0..0xffffffffL + /// + /// + /// The size or -1 if unknown. + /// + public long Size { + get { + return (known & KNOWN_SIZE) != 0 ? (long)size : -1L; + } + set { + if (((ulong)value & 0xFFFFFFFF00000000L) != 0) { + throw new ArgumentOutOfRangeException("size"); + } + this.size = (ulong)value; + this.known |= (ushort)KNOWN_SIZE; + } + } + + /// + /// Gets/Sets the size of the compressed data. + /// + /// + /// Size is not in the range 0..0xffffffff + /// + /// + /// The size or -1 if unknown. + /// + public long CompressedSize { + get { + return (known & KNOWN_CSIZE) != 0 ? (long)compressedSize : -1L; + } + set { + if (((ulong)value & 0xffffffff00000000L) != 0) { + throw new ArgumentOutOfRangeException(); + } + this.compressedSize = (ulong)value; + this.known |= (ushort)KNOWN_CSIZE; + } + } + + /// + /// Gets/Sets the crc of the uncompressed data. + /// + /// + /// Crc is not in the range 0..0xffffffffL + /// + /// + /// The crc value or -1 if unknown. + /// + public long Crc { + get { + return (known & KNOWN_CRC) != 0 ? crc & 0xffffffffL : -1L; + } + set { + if (((ulong)crc & 0xffffffff00000000L) != 0) { + throw new ArgumentOutOfRangeException(); + } + this.crc = (uint)value; + this.known |= (ushort)KNOWN_CRC; + } + } + + /// + /// Gets/Sets the compression method. Only Deflated and Stored are supported. + /// + /// + /// The compression method for this entry + /// + /// + /// + public CompressionMethod CompressionMethod { + get { + return method; + } + set { + this.method = value; + } + } + + /// + /// Gets/Sets the extra data. + /// + /// + /// Extra data is longer than 0xffff bytes. + /// + /// + /// Extra data or null if not set. + /// + public byte[] ExtraData { + get { + return extra; + } + set { + if (value == null) { + this.extra = null; + return; + } + + if (value.Length > 0xffff) { + throw new System.ArgumentOutOfRangeException(); + } + + this.extra = new byte[value.Length]; + Array.Copy(value, this.extra, value.Length); + + try { + int pos = 0; + while (pos < extra.Length) { + int sig = (extra[pos++] & 0xff) | (extra[pos++] & 0xff) << 8; + int len = (extra[pos++] & 0xff) | (extra[pos++] & 0xff) << 8; + + if (len < 0 || pos + len > extra.Length) { + // This is still lenient but the extra data is corrupt + // TODO drop the extra data? or somehow indicate to user + // there is a problem... + break; + } + + if (sig == 0x5455) { + // extended time stamp, unix format by Rainer Prem + int flags = extra[pos]; + // Can include other times but these are ignored. Length of data should + // actually be 1 + 4 * no of bits in flags. + if ((flags & 1) != 0 && len >= 5) { + int iTime = ((extra[pos+1] & 0xff) | + (extra[pos + 2] & 0xff) << 8 | + (extra[pos + 3] & 0xff) << 16 | + (extra[pos + 4] & 0xff) << 24); + + DateTime = (new DateTime ( 1970, 1, 1, 0, 0, 0 ) + new TimeSpan ( 0, 0, 0, iTime, 0 )).ToLocalTime (); + known |= (ushort)KNOWN_TIME; + } + } else if (sig == 0x0001) { + // ZIP64 extended information extra field + // Of variable size depending on which fields in header are too small + // fields appear here if the corresponding local or central directory record field + // is set to 0xFFFF or 0xFFFFFFFF + // + // Original Size 8 bytes + // Compressed size 8 bytes + // Relative header offset 8 bytes + // Disk start number 4 bytes + } + pos += len; + } + } catch (Exception) { + /* be lenient */ + return; + } + } + } + + + /// + /// Gets/Sets the entry comment. + /// + /// + /// If comment is longer than 0xffff. + /// + /// + /// The comment or null if not set. + /// + public string Comment { + get { + return comment; + } + set { + // TODO this test is strictly incorrect as the length is in characters + // While the test is correct in that a comment of this length or greater + // is definitely invalid, shorter comments may also have an invalid length. + if (value != null && value.Length > 0xffff) { + throw new ArgumentOutOfRangeException(); + } + this.comment = value; + } + } + + /// + /// Gets a value indicating of the if the entry is a directory. A directory is determined by + /// an entry name with a trailing slash '/'. The external file attributes + /// can also mark a file as a directory. The trailing slash convention should always be followed + /// however. + /// + public bool IsDirectory { + get { + bool result = false; + int nlen = name.Length; + result = nlen > 0 && name[nlen - 1] == '/'; + + if (result == false && (known & KNOWN_EXTERN_ATTRIBUTES) != 0) { + if (HostSystem == 0 && (ExternalFileAttributes & 16) != 0) { + result = true; + } + } + return result; + } + } + + /// + /// Creates a copy of this zip entry. + /// + public object Clone() + { + return this.MemberwiseClone(); + } + + /// + /// Gets the string representation of this ZipEntry. + /// + public override string ToString() + { + return name; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipFile.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipFile.cs new file mode 100644 index 0000000..565b201 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipFile.cs @@ -0,0 +1,620 @@ +// ZipFile.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.Collections; +using System.IO; +using System.Text; + +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; +using ICSharpCode.SharpZipLib.Zip.Compression; + +namespace ICSharpCode.SharpZipLib.Zip +{ + + /// + /// This class represents a Zip archive. You can ask for the contained + /// entries, or get an input stream for a file entry. The entry is + /// automatically decompressed. + /// + /// This class is thread safe: You can open input streams for arbitrary + /// entries in different threads. + ///
+ ///
Author of the original java version : Jochen Hoenicke + ///
+ /// + /// + /// using System; + /// using System.Text; + /// using System.Collections; + /// using System.IO; + /// + /// using ICSharpCode.SharpZipLib.Zip; + /// + /// class MainClass + /// { + /// static public void Main(string[] args) + /// { + /// ZipFile zFile = new ZipFile(args[0]); + /// Console.WriteLine("Listing of : " + zFile.Name); + /// Console.WriteLine(""); + /// Console.WriteLine("Raw Size Size Date Time Name"); + /// Console.WriteLine("-------- -------- -------- ------ ---------"); + /// foreach (ZipEntry e in zFile) { + /// DateTime d = e.DateTime; + /// Console.WriteLine("{0, -10}{1, -10}{2} {3} {4}", e.Size, e.CompressedSize, + /// d.ToString("dd-MM-yy"), d.ToString("t"), + /// e.Name); + /// } + /// } + /// } + /// + /// + public class ZipFile : IEnumerable + { + string name; + string comment; + Stream baseStream; + ZipEntry[] entries; + + /// + /// Opens a Zip file with the given name for reading. + /// + /// + /// An i/o error occurs + /// + /// + /// The file doesn't contain a valid zip archive. + /// + public ZipFile(string name) : this(File.OpenRead(name)) + { + } + + /// + /// Opens a Zip file reading the given FileStream + /// + /// + /// An i/o error occurs. + /// + /// + /// The file doesn't contain a valid zip archive. + /// + public ZipFile(FileStream file) + { + this.baseStream = file; + this.name = file.Name; + ReadEntries(); + } + + /// + /// Opens a Zip file reading the given Stream + /// + /// + /// An i/o error occurs + /// + /// + /// The file doesn't contain a valid zip archive.
+ /// The stream provided cannot seek + ///
+ public ZipFile(Stream baseStream) + { + if (baseStream.CanSeek == false) { + throw new ZipException("ZipFile stream must be seekable"); + } + this.baseStream = baseStream; + this.name = null; + ReadEntries(); + } + + + /// + /// Read an unsigned short in little endian byte order. + /// + /// + /// An i/o error occurs. + /// + /// + /// The file ends prematurely + /// + int ReadLeShort() + { + return baseStream.ReadByte() | baseStream.ReadByte() << 8; + } + + /// + /// Read an int in little endian byte order. + /// + /// + /// An i/o error occurs. + /// + /// + /// The file ends prematurely + /// + int ReadLeInt() + { + return ReadLeShort() | ReadLeShort() << 16; + } + + /// + /// Read the central directory of a zip file and fill the entries + /// array. This is called exactly once by the constructors. + /// + /// + /// An i/o error occurs. + /// + /// + /// The central directory is malformed or cannot be found + /// + void ReadEntries() + { + /* Search for the End Of Central Directory. When a zip comment is + * present the directory may start earlier. + * + * TODO: The search is limited to 64K which is the maximum size of a trailing comment field to aid speed. + * This should be compatible with both SFX and ZIP files but has only been tested for Zip files + * Need to confirm this is valid in all cases. + */ + + long pos = baseStream.Length - ZipConstants.ENDHDR; + long giveUpMarker = Math.Max(pos - 0x10000, 0); + + do { + if (pos < giveUpMarker) { + throw new ZipException("central directory not found, probably not a zip file"); + } + baseStream.Seek(pos--, SeekOrigin.Begin); + } while (ReadLeInt() != ZipConstants.ENDSIG); + + long oldPos = baseStream.Position; + baseStream.Position += ZipConstants.ENDTOT - ZipConstants.ENDNRD; + + if (baseStream.Position - oldPos != ZipConstants.ENDTOT - ZipConstants.ENDNRD) { + throw new EndOfStreamException(); + } + int count = ReadLeShort(); + + oldPos = baseStream.Position; + baseStream.Position += ZipConstants.ENDOFF - ZipConstants.ENDSIZ; + + if (baseStream.Position - oldPos != ZipConstants.ENDOFF - ZipConstants.ENDSIZ) { + throw new EndOfStreamException(); + } + + int centralOffset = ReadLeInt(); + + int commentSize = ReadLeShort(); + byte[] zipComment = new byte[commentSize]; + baseStream.Read(zipComment, 0, zipComment.Length); + comment = ZipConstants.ConvertToString(zipComment); + + entries = new ZipEntry[count]; + baseStream.Seek(centralOffset, SeekOrigin.Begin); + + for (int i = 0; i < count; i++) { + if (ReadLeInt() != ZipConstants.CENSIG) { + throw new ZipException("Wrong Central Directory signature"); + } + + int versionMadeBy = ReadLeShort(); + int versionToExtract = ReadLeShort(); + int bitFlags = ReadLeShort(); + int method = ReadLeShort(); + int dostime = ReadLeInt(); + int crc = ReadLeInt(); + int csize = ReadLeInt(); + int size = ReadLeInt(); + int nameLen = ReadLeShort(); + int extraLen = ReadLeShort(); + int commentLen = ReadLeShort(); + + int diskStartNo = ReadLeShort(); // Not currently used + int internalAttributes = ReadLeShort(); // Not currently used + int externalAttributes = ReadLeInt(); + int offset = ReadLeInt(); + + byte[] buffer = new byte[Math.Max(nameLen, commentLen)]; + + baseStream.Read(buffer, 0, nameLen); + string name = ZipConstants.ConvertToString(buffer, nameLen); + + ZipEntry entry = new ZipEntry(name, versionToExtract, versionMadeBy); + entry.CompressionMethod = (CompressionMethod)method; + entry.Crc = crc & 0xffffffffL; + entry.Size = size & 0xffffffffL; + entry.CompressedSize = csize & 0xffffffffL; + entry.DosTime = (uint)dostime; + + if (extraLen > 0) { + byte[] extra = new byte[extraLen]; + baseStream.Read(extra, 0, extraLen); + entry.ExtraData = extra; + } + + if (commentLen > 0) { + baseStream.Read(buffer, 0, commentLen); + entry.Comment = ZipConstants.ConvertToString(buffer, commentLen); + } + + entry.ZipFileIndex = i; + entry.Offset = offset; + entry.ExternalFileAttributes = externalAttributes; + + entries[i] = entry; + } + } + + /// + /// Closes the ZipFile. This also closes all input streams managed by + /// this class. Once closed, no further instance methods should be + /// called. + /// + /// + /// An i/o error occurs. + /// + public void Close() + { + entries = null; + lock(baseStream) { + baseStream.Close(); + } + } + + /// + /// Returns an enumerator for the Zip entries in this Zip file. + /// + /// + /// The Zip file has been closed. + /// + public IEnumerator GetEnumerator() + { + if (entries == null) { + throw new InvalidOperationException("ZipFile has closed"); + } + + return new ZipEntryEnumeration(entries); + } + + /// + /// Return the index of the entry with a matching name + /// + /// Entry name to find + /// If true the comparison is case insensitive + /// The index position of the matching entry or -1 if not found + /// + /// The Zip file has been closed. + /// + public int FindEntry(string name, bool ignoreCase) + { + if (entries == null) { + throw new InvalidOperationException("ZipFile has been closed"); + } + + for (int i = 0; i < entries.Length; i++) { + if (string.Compare(name, entries[i].Name, ignoreCase) == 0) { + return i; + } + } + return -1; // ok + } + + /// + /// Indexer property for ZipEntries + /// + [System.Runtime.CompilerServices.IndexerNameAttribute("EntryByIndex")] + public ZipEntry this[int index] { + get { + return (ZipEntry) entries[index].Clone(); + } + } + + /// + /// Searches for a zip entry in this archive with the given name. + /// String comparisons are case insensitive + /// + /// + /// The name to find. May contain directory components separated by slashes ('/'). + /// + /// + /// The zip entry, or null if no entry with that name exists. + /// + /// + /// The Zip file has been closed. + /// + public ZipEntry GetEntry(string name) + { + if (entries == null) { + throw new InvalidOperationException("ZipFile has been closed"); + } + + int index = FindEntry(name, true); + return index >= 0 ? (ZipEntry) entries[index].Clone() : null; + } + + /// + /// Checks, if the local header of the entry at index i matches the + /// central directory, and returns the offset to the data. + /// + /// + /// The start offset of the (compressed) data. + /// + /// + /// The stream ends prematurely + /// + /// + /// The local header signature is invalid, the entry and central header file name lengths are different + /// or the local and entry compression methods dont match + /// + long CheckLocalHeader(ZipEntry entry) + { + lock(baseStream) { + baseStream.Seek(entry.Offset, SeekOrigin.Begin); + if (ReadLeInt() != ZipConstants.LOCSIG) { + throw new ZipException("Wrong Local header signature"); + } + + short shortValue = (short)ReadLeShort(); // version required to extract + if (shortValue > ZipConstants.VERSION_MADE_BY) { + throw new ZipException(string.Format("Version required to extract this entry not supported ({0})", shortValue)); + } + + shortValue = (short)ReadLeShort(); // general purpose bit flags. + if ((shortValue & 0x30) != 0) { + throw new ZipException("The library doesnt support the zip version required to extract this entry"); + } + + if (entry.CompressionMethod != (CompressionMethod)ReadLeShort()) { + throw new ZipException("Compression method mismatch"); + } + + // Skip time, crc, size and csize + long oldPos = baseStream.Position; + baseStream.Position += ZipConstants.LOCNAM - ZipConstants.LOCTIM; + + if (baseStream.Position - oldPos != ZipConstants.LOCNAM - ZipConstants.LOCTIM) { + throw new EndOfStreamException(); + } + + if (entry.Name.Length != ReadLeShort()) { + throw new ZipException("file name length mismatch"); + } + + int extraLen = entry.Name.Length + ReadLeShort(); + return entry.Offset + ZipConstants.LOCHDR + extraLen; + } + } + + /// + /// Creates an input stream reading the given zip entry as + /// uncompressed data. Normally zip entry should be an entry + /// returned by GetEntry(). + /// + /// + /// the input stream. + /// + /// + /// The ZipFile has already been closed + /// + /// + /// The compression method for the entry is unknown + /// + /// + /// The entry is not found in the ZipFile + /// + public Stream GetInputStream(ZipEntry entry) + { + if (entries == null) { + throw new InvalidOperationException("ZipFile has closed"); + } + + int index = entry.ZipFileIndex; + if (index < 0 || index >= entries.Length || entries[index].Name != entry.Name) { + index = FindEntry(entry.Name, true); + if (index < 0) { + throw new IndexOutOfRangeException(); + } + } + return GetInputStream(index); + } + + + /// + /// Creates an input stream reading the zip entry based on the index passed + /// + /// + /// An input stream. + /// + /// + /// The ZipFile has already been closed + /// + /// + /// The compression method for the entry is unknown + /// + /// + /// The entry is not found in the ZipFile + /// + public Stream GetInputStream(int entryIndex) + { + if (entries == null) + { + throw new InvalidOperationException("ZipFile has closed"); + } + + long start = CheckLocalHeader(entries[entryIndex]); + CompressionMethod method = entries[entryIndex].CompressionMethod; + Stream istr = new PartialInputStream(baseStream, start, entries[entryIndex].CompressedSize); + + switch (method) { + case CompressionMethod.Stored: + return istr; + case CompressionMethod.Deflated: + return new InflaterInputStream(istr, new Inflater(true)); + default: + throw new ZipException("Unknown compression method " + method); + } + } + + /// + /// Gets the comment for the zip file. + /// + public string ZipFileComment { + get { + return comment; + } + } + + /// + /// Gets the name of this zip file. + /// + public string Name { + get { + return name; + } + } + + /// + /// Gets the number of entries in this zip file. + /// + /// + /// The Zip file has been closed. + /// + public int Size { + get { + if (entries != null) { + return entries.Length; + } else { + throw new InvalidOperationException("ZipFile is closed"); + } + } + } + + class ZipEntryEnumeration : IEnumerator + { + ZipEntry[] array; + int ptr = -1; + + public ZipEntryEnumeration(ZipEntry[] arr) + { + array = arr; + } + + public object Current { + get { + return array[ptr]; + } + } + + public void Reset() + { + ptr = -1; + } + + public bool MoveNext() + { + return (++ptr < array.Length); + } + } + + class PartialInputStream : InflaterInputStream + { + Stream baseStream; + long filepos, end; + + public PartialInputStream(Stream baseStream, long start, long len) : base(baseStream) + { + this.baseStream = baseStream; + filepos = start; + end = start + len; + } + + public override int Available + { + get { + long amount = end - filepos; + if (amount > Int32.MaxValue) { + return Int32.MaxValue; + } + + return (int) amount; + } + } + + public override int ReadByte() + { + if (filepos == end) { + return -1; //ok + } + + lock(baseStream) { + baseStream.Seek(filepos++, SeekOrigin.Begin); + return baseStream.ReadByte(); + } + } + + public override int Read(byte[] b, int off, int len) + { + if (len > end - filepos) { + len = (int) (end - filepos); + if (len == 0) { + return 0; + } + } + lock(baseStream) { + baseStream.Seek(filepos, SeekOrigin.Begin); + int count = baseStream.Read(b, off, len); + if (count > 0) { + filepos += len; + } + return count; + } + } + + public long SkipBytes(long amount) + { + if (amount < 0) { + throw new ArgumentOutOfRangeException(); + } + if (amount > end - filepos) { + amount = end - filepos; + } + filepos += amount; + return amount; + } + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipInputStream.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipInputStream.cs new file mode 100644 index 0000000..ecf596a --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipInputStream.cs @@ -0,0 +1,595 @@ +// ZipInputStream.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.Text; +using System.IO; + +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Zip.Compression; +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.Zip +{ + /// + /// This is an InflaterInputStream that reads the files baseInputStream an zip archive + /// one after another. It has a special method to get the zip entry of + /// the next file. The zip entry contains information about the file name + /// size, compressed size, Crc, etc. + /// It includes support for Stored and Deflated entries. + ///
+ ///
Author of the original java version : Jochen Hoenicke + ///
+ /// + /// This sample shows how to read a zip file + /// + /// using System; + /// using System.Text; + /// using System.IO; + /// + /// using ICSharpCode.SharpZipLib.Zip; + /// + /// class MainClass + /// { + /// public static void Main(string[] args) + /// { + /// ZipInputStream s = new ZipInputStream(File.OpenRead(args[0])); + /// + /// ZipEntry theEntry; + /// while ((theEntry = s.GetNextEntry()) != null) { + /// int size = 2048; + /// byte[] data = new byte[2048]; + /// + /// Console.Write("Show contents (y/n) ?"); + /// if (Console.ReadLine() == "y") { + /// while (true) { + /// size = s.Read(data, 0, data.Length); + /// if (size > 0) { + /// Console.Write(new ASCIIEncoding().GetString(data, 0, size)); + /// } else { + /// break; + /// } + /// } + /// } + /// } + /// s.Close(); + /// } + /// } + /// + /// + public class ZipInputStream : InflaterInputStream + { + Crc32 crc = new Crc32(); + ZipEntry entry = null; + + long size; + int method; + int flags; + long avail; + string password = null; + + /// + /// Optional password used for encryption when non-null + /// + public string Password { + get { + return password; + } + set { + password = value; + } + } + + + /// + /// Gets a value indicating if the entry can be decompressed + /// + /// + /// The entry can only be decompressed if the library supports the zip features required to extract it. + /// See the ZipEntry Version property for more details. + /// + public bool CanDecompressEntry { + get { + return entry != null && entry.Version <= ZipConstants.VERSION_MADE_BY; + } + } + + /// + /// Creates a new Zip input stream, for reading a zip archive. + /// + public ZipInputStream(Stream baseInputStream) : base(baseInputStream, new Inflater(true)) + { + } + + void FillBuf(int size) + { + avail = len = baseInputStream.Read(buf, 0, Math.Min(buf.Length, size)); + } + + int ReadBuf(byte[] outBuf, int offset, int length) + { + if (avail <= 0) { + FillBuf(length); + if (avail <= 0) { + return 0; + } + } + + if (length > avail) { + length = (int)avail; + } + + System.Array.Copy(buf, len - (int)avail, outBuf, offset, length); + avail -= length; + return length; + } + + void ReadFully(byte[] outBuf) + { + int off = 0; + int len = outBuf.Length; + while (len > 0) { + int count = ReadBuf(outBuf, off, len); + if (count <= 0) { + throw new ZipException("Unexpected EOF"); + } + off += count; + len -= count; + } + } + + int ReadLeByte() + { + if (avail <= 0) { + FillBuf(1); + if (avail <= 0) { + throw new ZipException("EOF in header"); + } + } + return buf[len - avail--] & 0xff; + } + + /// + /// Read an unsigned short baseInputStream little endian byte order. + /// + int ReadLeShort() + { + return ReadLeByte() | (ReadLeByte() << 8); + } + + /// + /// Read an int baseInputStream little endian byte order. + /// + int ReadLeInt() + { + return ReadLeShort() | (ReadLeShort() << 16); + } + + /// + /// Read an int baseInputStream little endian byte order. + /// + long ReadLeLong() + { + return ReadLeInt() | (ReadLeInt() << 32); + } + + /// + /// Advances to the next entry in the archive + /// + /// + /// The next entry in the archive or null if there are no more entries. + /// + /// + /// If the previous entry is still open CloseEntry is called. + /// + /// + /// Input stream is closed + /// + /// + /// Password is not set, password is invalid, compression method is invalid, + /// version required to extract is not supported + /// + public ZipEntry GetNextEntry() + { + if (crc == null) { + throw new InvalidOperationException("Closed."); + } + + if (entry != null) { + CloseEntry(); + } + + if (this.cryptbuffer != null) { + + if (inf.IsFinished == false && (entry.Flags & 8) != 0) { + throw new ZipException("NextEntry location not known"); + } + + if (avail == 0 && inf.RemainingInput != 0) { + avail = inf.RemainingInput - 16; + inf.Reset(); + } + baseInputStream.Position -= this.len; + baseInputStream.Read(this.buf, 0, this.len); + + } + + if (avail <= 0) { + FillBuf(ZipConstants.LOCHDR); + } + + int header = ReadLeInt(); + + if (header == ZipConstants.CENSIG || + header == ZipConstants.ENDSIG || + header == ZipConstants.CENDIGITALSIG || + header == ZipConstants.CENSIG64) { + // No more individual entries exist + Close(); + return null; + } + + // -jr- 07-Dec-2003 Ignore spanning temporary signatures if found + // SPANNINGSIG is same as descriptor signature and is untested as yet. + if (header == ZipConstants.SPANTEMPSIG || header == ZipConstants.SPANNINGSIG) { + header = ReadLeInt(); + } + + if (header != ZipConstants.LOCSIG) { + throw new ZipException("Wrong Local header signature: 0x" + String.Format("{0:X}", header)); + } + + short versionRequiredToExtract = (short)ReadLeShort(); + + flags = ReadLeShort(); + method = ReadLeShort(); + uint dostime = (uint)ReadLeInt(); + int crc2 = ReadLeInt(); + csize = ReadLeInt(); + size = ReadLeInt(); + int nameLen = ReadLeShort(); + int extraLen = ReadLeShort(); + + bool isCrypted = (flags & 1) == 1; + + byte[] buffer = new byte[nameLen]; + ReadFully(buffer); + + string name = ZipConstants.ConvertToString(buffer); + + entry = new ZipEntry(name, versionRequiredToExtract); + entry.Flags = flags; + + if (method == (int)CompressionMethod.Stored && (!isCrypted && csize != size || (isCrypted && csize - ZipConstants.CRYPTO_HEADER_SIZE != size))) { + throw new ZipException("Stored, but compressed != uncompressed"); + } + + if (method != (int)CompressionMethod.Stored && method != (int)CompressionMethod.Deflated) { + throw new ZipException("unknown compression method " + method); + } + + entry.CompressionMethod = (CompressionMethod)method; + + if ((flags & 8) == 0) { + entry.Crc = crc2 & 0xFFFFFFFFL; + entry.Size = size & 0xFFFFFFFFL; + entry.CompressedSize = csize & 0xFFFFFFFFL; + BufferReadSize = 0; + } else { + + if (isCrypted) { + BufferReadSize = 1; + } else { + BufferReadSize = 0; + } + + // This allows for GNU, WinZip and possibly other archives, the PKZIP spec says these are zero + // under these circumstances. + if (crc2 != 0) { + entry.Crc = crc2 & 0xFFFFFFFFL; + } + + if (size != 0) { + entry.Size = size & 0xFFFFFFFFL; + } + if (csize != 0) { + entry.CompressedSize = csize & 0xFFFFFFFFL; + } + } + + + entry.DosTime = dostime; + + if (extraLen > 0) { + byte[] extra = new byte[extraLen]; + ReadFully(extra); + entry.ExtraData = extra; + } + + // TODO How to handle this? + // This library cannot handle versions greater than 20 + // Throwing an exception precludes getting at later possibly useable entries. + // Could also skip this entry entirely + // Letting it slip past here isnt so great as it wont work + if (versionRequiredToExtract > 20) { + throw new ZipException("Libray cannot extract this entry version required (" + versionRequiredToExtract.ToString() + ")"); + } + + // test for encryption + if (isCrypted) { + if (password == null) { + throw new ZipException("No password set."); + } + InitializePassword(password); + cryptbuffer = new byte[ZipConstants.CRYPTO_HEADER_SIZE]; + ReadFully(cryptbuffer); + DecryptBlock(cryptbuffer, 0, cryptbuffer.Length); + + if ((flags & 8) == 0) { + if (cryptbuffer[ZipConstants.CRYPTO_HEADER_SIZE - 1] != (byte)(crc2 >> 24)) { + throw new ZipException("Invalid password"); + } + } + else { + if (cryptbuffer[ZipConstants.CRYPTO_HEADER_SIZE - 1] != (byte)((dostime >> 8) & 0xff)) { + throw new ZipException("Invalid password"); + } + } + + if (csize >= ZipConstants.CRYPTO_HEADER_SIZE) { + csize -= ZipConstants.CRYPTO_HEADER_SIZE; + } + } else { + cryptbuffer = null; + } + + if (method == (int)CompressionMethod.Deflated && avail > 0) { + System.Array.Copy(buf, len - (int)avail, buf, 0, (int)avail); + len = (int)avail; + avail = 0; + if (isCrypted) { + DecryptBlock(buf, 0, Math.Min((int)csize, len)); + } + inf.SetInput(buf, 0, len); + } + + return entry; + } + + void ReadDataDescriptor() + { + if (ReadLeInt() != ZipConstants.EXTSIG) { + throw new ZipException("Data descriptor signature not found"); + } + + entry.Crc = ReadLeInt() & 0xFFFFFFFFL; + csize = ReadLeInt(); + size = ReadLeInt(); + + entry.Size = size & 0xFFFFFFFFL; + entry.CompressedSize = csize & 0xFFFFFFFFL; + } + + /// + /// Closes the current zip entry and moves to the next one. + /// + /// + /// The stream is closed + /// + /// + /// The Zip stream ends early + /// + public void CloseEntry() + { + if (crc == null) { + throw new InvalidOperationException("Closed."); + } + + if (entry == null) { + return; + } + + if (method == (int)CompressionMethod.Deflated) { + if ((flags & 8) != 0) { + // We don't know how much we must skip, read until end. + byte[] tmp = new byte[2048]; + while (Read(tmp, 0, tmp.Length) > 0) + ; + // read will close this entry + return; + } + csize -= inf.TotalIn; + avail = inf.RemainingInput; + } + + if (avail > csize && csize >= 0) { + avail -= csize; + } else { + csize -= avail; + avail = 0; + while (csize != 0) { + int skipped = (int)base.Skip(csize & 0xFFFFFFFFL); + + if (skipped <= 0) { + throw new ZipException("Zip archive ends early."); + } + + csize -= skipped; + } + } + + size = 0; + crc.Reset(); + if (method == (int)CompressionMethod.Deflated) { + inf.Reset(); + } + entry = null; + } + + /// + /// Returns 1 if there is an entry available + /// Otherwise returns 0. + /// + public override int Available { + get { + return entry != null ? 1 : 0; + } + } + + /// + /// Reads a byte from the current zip entry. + /// + /// + /// The byte or -1 if end of stream is reached. + /// + /// + /// An i/o error occured. + /// + /// + /// The deflated stream is corrupted. + /// + public override int ReadByte() + { + byte[] b = new byte[1]; + if (Read(b, 0, 1) <= 0) { + return -1; // ok + } + return b[0] & 0xff; + } + + /// + /// Reads a block of bytes from the current zip entry. + /// + /// + /// The number of bytes read (this may be less than the length requested, even before the end of stream), or 0 on end of stream. + /// + /// + /// An i/o error occured. + /// + /// + /// The deflated stream is corrupted. + /// + /// + /// The stream is not open. + /// + public override int Read(byte[] b, int off, int len) + { + if (crc == null) { + throw new InvalidOperationException("Closed."); + } + + if (entry == null) { + return 0; + } + + bool finished = false; + + switch (method) { + case (int)CompressionMethod.Deflated: + len = base.Read(b, off, len); + if (len <= 0) { + if (!inf.IsFinished) { + throw new ZipException("Inflater not finished!?"); + } + avail = inf.RemainingInput; + + if ((flags & 8) == 0 && (inf.TotalIn != csize || inf.TotalOut != size)) { + throw new ZipException("size mismatch: " + csize + ";" + size + " <-> " + inf.TotalIn + ";" + inf.TotalOut); + } + inf.Reset(); + finished = true; + } + break; + + case (int)CompressionMethod.Stored: + if (len > csize && csize >= 0) { + len = (int)csize; + } + len = ReadBuf(b, off, len); + if (len > 0) { + csize -= len; + size -= len; + } + + if (csize == 0) { + finished = true; + } else { + if (len < 0) { + throw new ZipException("EOF in stored block"); + } + } + + // cipher text needs decrypting + if (cryptbuffer != null) { + DecryptBlock(b, off, len); + } + + break; + } + + if (len > 0) { + crc.Update(b, off, len); + } + + if (finished) { + StopDecrypting(); + if ((flags & 8) != 0) { + ReadDataDescriptor(); + } + + if ((crc.Value & 0xFFFFFFFFL) != entry.Crc && entry.Crc != -1) { + throw new ZipException("CRC mismatch"); + } + crc.Reset(); + entry = null; + } + return len; + } + + /// + /// Closes the zip input stream + /// + public override void Close() + { + base.Close(); + crc = null; + entry = null; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipOutputStream.cs b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipOutputStream.cs new file mode 100644 index 0000000..3fc8818 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/ICSharpCode.SharpZipLib/zip/ZipOutputStream.cs @@ -0,0 +1,589 @@ +// ZipOutputStream.cs +// +// Copyright (C) 2001 Mike Krueger +// Copyright (C) 2004 John Reilly +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +using System; +using System.IO; +using System.Collections; +using System.Text; + +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Zip.Compression; +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.Zip +{ + /// + /// This is a DeflaterOutputStream that writes the files into a zip + /// archive one after another. It has a special method to start a new + /// zip entry. The zip entries contains information about the file name + /// size, compressed size, CRC, etc. + /// + /// It includes support for Stored and Deflated entries. + /// This class is not thread safe. + ///
+ ///
Author of the original java version : Jochen Hoenicke + ///
+ /// This sample shows how to create a zip file + /// + /// using System; + /// using System.IO; + /// + /// using ICSharpCode.SharpZipLib.Zip; + /// + /// class MainClass + /// { + /// public static void Main(string[] args) + /// { + /// string[] filenames = Directory.GetFiles(args[0]); + /// + /// ZipOutputStream s = new ZipOutputStream(File.Create(args[1])); + /// + /// s.SetLevel(5); // 0 - store only to 9 - means best compression + /// + /// foreach (string file in filenames) { + /// FileStream fs = File.OpenRead(file); + /// + /// byte[] buffer = new byte[fs.Length]; + /// fs.Read(buffer, 0, buffer.Length); + /// + /// ZipEntry entry = new ZipEntry(file); + /// + /// s.PutNextEntry(entry); + /// + /// s.Write(buffer, 0, buffer.Length); + /// + /// } + /// + /// s.Finish(); + /// s.Close(); + /// } + /// } + /// + /// + public class ZipOutputStream : DeflaterOutputStream + { + private ArrayList entries = new ArrayList(); + private Crc32 crc = new Crc32(); + private ZipEntry curEntry = null; + + int defaultCompressionLevel = Deflater.DEFAULT_COMPRESSION; + CompressionMethod curMethod = CompressionMethod.Deflated; + + + private long size; + private long offset = 0; + + private byte[] zipComment = new byte[0]; + + /// + /// Gets boolean indicating central header has been added for this archive... + /// No further entries can be added once this has been done. + /// + public bool IsFinished { + get { + return entries == null; + } + } + + /// + /// Creates a new Zip output stream, writing a zip archive. + /// + /// + /// The output stream to which the archive contents are written. + /// + public ZipOutputStream(Stream baseOutputStream) : base(baseOutputStream, new Deflater(Deflater.DEFAULT_COMPRESSION, true)) + { + } + + /// + /// Set the zip file comment. + /// + /// + /// The comment string + /// + /// + /// Encoding of comment is longer than 0xffff bytes. + /// + public void SetComment(string comment) + { + byte[] commentBytes = ZipConstants.ConvertToArray(comment); + if (commentBytes.Length > 0xffff) { + throw new ArgumentOutOfRangeException("comment", "Comment too long."); + } + zipComment = commentBytes; + } + + /// + /// Sets default compression level. The new level will be activated + /// immediately. + /// + /// + /// Level specified is not supported. + /// + /// + public void SetLevel(int level) + { + defaultCompressionLevel = level; + def.SetLevel(level); + } + + /// + /// Get the current deflate compression level + /// + /// The current compression level + public int GetLevel() + { + return def.GetLevel(); + } + + /// + /// Write an unsigned short in little endian byte order. + /// + private void WriteLeShort(int value) + { + baseOutputStream.WriteByte((byte)value); + baseOutputStream.WriteByte((byte)(value >> 8)); + } + + /// + /// Write an int in little endian byte order. + /// + private void WriteLeInt(int value) + { + WriteLeShort(value); + WriteLeShort(value >> 16); + } + + /// + /// Write an int in little endian byte order. + /// + private void WriteLeLong(long value) + { + WriteLeInt((int)value); + WriteLeInt((int)(value >> 32)); + } + + + bool patchEntryHeader = false; + + long headerPatchPos = -1; + + /// + /// Starts a new Zip entry. It automatically closes the previous + /// entry if present. + /// All entry elements bar name are optional, but must be correct if present. + /// If the compression method is stored and the output is not patchable + /// the compression for that entry is automatically changed to deflate level 0 + /// + /// + /// the entry. + /// + /// + /// if an I/O error occured. + /// + /// + /// if stream was finished + /// + /// + /// Too many entries in the Zip file
+ /// Entry name is too long
+ /// Finish has already been called
+ ///
+ public void PutNextEntry(ZipEntry entry) + { + if (entries == null) { + throw new InvalidOperationException("ZipOutputStream was finished"); + } + + if (curEntry != null) { + CloseEntry(); + } + + if (entries.Count >= 0xffff) { + throw new ZipException("Too many entries for Zip file"); + } + + CompressionMethod method = entry.CompressionMethod; + int compressionLevel = defaultCompressionLevel; + + entry.Flags = 0; + patchEntryHeader = false; + bool headerInfoAvailable = true; + + if (method == CompressionMethod.Stored) { + if (entry.CompressedSize >= 0) { + if (entry.Size < 0) { + entry.Size = entry.CompressedSize; + } else if (entry.Size != entry.CompressedSize) { + throw new ZipException("Method STORED, but compressed size != size"); + } + } else { + if (entry.Size >= 0) { + entry.CompressedSize = entry.Size; + } + } + + if (entry.Size < 0 || entry.Crc < 0) { + if (CanPatchEntries == true) { + headerInfoAvailable = false; + } + else { + method = CompressionMethod.Deflated; + compressionLevel = 0; + } + } + } + + if (method == CompressionMethod.Deflated) { + if (entry.Size == 0) { + entry.CompressedSize = entry.Size; + entry.Crc = 0; + method = CompressionMethod.Stored; + } else if (entry.CompressedSize < 0 || entry.Size < 0 || entry.Crc < 0) { + headerInfoAvailable = false; + } + } + + if (headerInfoAvailable == false) { + if (CanPatchEntries == false) { + entry.Flags |= 8; + } else { + patchEntryHeader = true; + } + } + + if (Password != null) { + entry.IsCrypted = true; + if (entry.Crc < 0) { + entry.Flags |= 8; + } + } + entry.Offset = (int)offset; + entry.CompressionMethod = (CompressionMethod)method; + + curMethod = method; + + // Write the local file header + WriteLeInt(ZipConstants.LOCSIG); + + WriteLeShort(entry.Version); + WriteLeShort(entry.Flags); + WriteLeShort((byte)method); + WriteLeInt((int)entry.DosTime); + if (headerInfoAvailable == true) { + WriteLeInt((int)entry.Crc); + WriteLeInt(entry.IsCrypted ? (int)entry.CompressedSize + ZipConstants.CRYPTO_HEADER_SIZE : (int)entry.CompressedSize); + WriteLeInt((int)entry.Size); + } else { + if (patchEntryHeader == true) { + headerPatchPos = baseOutputStream.Position; + } + WriteLeInt(0); // Crc + WriteLeInt(0); // Compressed size + WriteLeInt(0); // Uncompressed size + } + + byte[] name = ZipConstants.ConvertToArray(entry.Name); + + if (name.Length > 0xFFFF) { + throw new ZipException("Entry name too long."); + } + + byte[] extra = entry.ExtraData; + if (extra == null) { + extra = new byte[0]; + } + + if (extra.Length > 0xFFFF) { + throw new ZipException("Extra data too long."); + } + + WriteLeShort(name.Length); + WriteLeShort(extra.Length); + baseOutputStream.Write(name, 0, name.Length); + baseOutputStream.Write(extra, 0, extra.Length); + + offset += ZipConstants.LOCHDR + name.Length + extra.Length; + + // Activate the entry. + curEntry = entry; + crc.Reset(); + if (method == CompressionMethod.Deflated) { + def.Reset(); + def.SetLevel(compressionLevel); + } + size = 0; + + if (entry.IsCrypted == true) { + if (entry.Crc < 0) { // so testing Zip will says its ok + WriteEncryptionHeader(entry.DosTime << 16); + } else { + WriteEncryptionHeader(entry.Crc); + } + } + } + + /// + /// Closes the current entry, updating header and footer information as required + /// + /// + /// An I/O error occurs. + /// + /// + /// No entry is active. + /// + public void CloseEntry() + { + if (curEntry == null) { + throw new InvalidOperationException("No open entry"); + } + + // First finish the deflater, if appropriate + if (curMethod == CompressionMethod.Deflated) { + base.Finish(); + } + + long csize = curMethod == CompressionMethod.Deflated ? def.TotalOut : size; + + if (curEntry.Size < 0) { + curEntry.Size = size; + } else if (curEntry.Size != size) { + throw new ZipException("size was " + size + ", but I expected " + curEntry.Size); + } + + if (curEntry.CompressedSize < 0) { + curEntry.CompressedSize = csize; + } else if (curEntry.CompressedSize != csize) { + throw new ZipException("compressed size was " + csize + ", but I expected " + curEntry.CompressedSize); + } + + if (curEntry.Crc < 0) { + curEntry.Crc = crc.Value; + } else if (curEntry.Crc != crc.Value) { + throw new ZipException("crc was " + crc.Value + ", but I expected " + curEntry.Crc); + } + + offset += csize; + + if (offset > 0xffffffff) { + throw new ZipException("Maximum Zip file size exceeded"); + } + + if (curEntry.IsCrypted == true) { + curEntry.CompressedSize += ZipConstants.CRYPTO_HEADER_SIZE; + } + + // Patch the header if possible + if (patchEntryHeader == true) { + long curPos = baseOutputStream.Position; + baseOutputStream.Seek(headerPatchPos, SeekOrigin.Begin); + WriteLeInt((int)curEntry.Crc); + WriteLeInt((int)curEntry.CompressedSize); + WriteLeInt((int)curEntry.Size); + baseOutputStream.Seek(curPos, SeekOrigin.Begin); + patchEntryHeader = false; + } + + // Add data descriptor if flagged as required + if ((curEntry.Flags & 8) != 0) { + WriteLeInt(ZipConstants.EXTSIG); + WriteLeInt((int)curEntry.Crc); + WriteLeInt((int)curEntry.CompressedSize); + WriteLeInt((int)curEntry.Size); + offset += ZipConstants.EXTHDR; + } + + entries.Add(curEntry); + curEntry = null; + } + + void WriteEncryptionHeader(long crcValue) + { + offset += ZipConstants.CRYPTO_HEADER_SIZE; + + InitializePassword(Password); + + byte[] cryptBuffer = new byte[ZipConstants.CRYPTO_HEADER_SIZE]; + Random rnd = new Random(); + rnd.NextBytes(cryptBuffer); + cryptBuffer[11] = (byte)(crcValue >> 24); + + EncryptBlock(cryptBuffer, 0, cryptBuffer.Length); + baseOutputStream.Write(cryptBuffer, 0, cryptBuffer.Length); + } + + /// + /// Writes the given buffer to the current entry. + /// + /// + /// Archive size is invalid + /// + /// + /// No entry is active. + /// + public override void Write(byte[] b, int off, int len) + { + if (curEntry == null) { + throw new InvalidOperationException("No open entry."); + } + + if (len <= 0) + return; + + crc.Update(b, off, len); + size += len; + + if (size > 0xffffffff || size < 0) { + throw new ZipException("Maximum entry size exceeded"); + } + + + switch (curMethod) { + case CompressionMethod.Deflated: + base.Write(b, off, len); + break; + + case CompressionMethod.Stored: + if (Password != null) { + byte[] buf = new byte[len]; + Array.Copy(b, off, buf, 0, len); + EncryptBlock(buf, 0, len); + baseOutputStream.Write(buf, off, len); + } else { + baseOutputStream.Write(b, off, len); + } + break; + } + } + + /// + /// Finishes the stream. This will write the central directory at the + /// end of the zip file and flush the stream. + /// + /// + /// This is automatically called when the stream is closed. + /// + /// + /// An I/O error occurs. + /// + /// + /// Comment exceeds the maximum length
+ /// Entry name exceeds the maximum length + ///
+ public override void Finish() + { + if (entries == null) { + return; + } + + if (curEntry != null) { + CloseEntry(); + } + + int numEntries = 0; + int sizeEntries = 0; + + foreach (ZipEntry entry in entries) { + CompressionMethod method = entry.CompressionMethod; + WriteLeInt(ZipConstants.CENSIG); + WriteLeShort(ZipConstants.VERSION_MADE_BY); + WriteLeShort(entry.Version); + WriteLeShort(entry.Flags); + WriteLeShort((short)method); + WriteLeInt((int)entry.DosTime); + WriteLeInt((int)entry.Crc); + WriteLeInt((int)entry.CompressedSize); + WriteLeInt((int)entry.Size); + + byte[] name = ZipConstants.ConvertToArray(entry.Name); + + if (name.Length > 0xffff) { + throw new ZipException("Name too long."); + } + + byte[] extra = entry.ExtraData; + if (extra == null) { + extra = new byte[0]; + } + + byte[] entryComment = entry.Comment != null ? ZipConstants.ConvertToArray(entry.Comment) : new byte[0]; + if (entryComment.Length > 0xffff) { + throw new ZipException("Comment too long."); + } + + WriteLeShort(name.Length); + WriteLeShort(extra.Length); + WriteLeShort(entryComment.Length); + WriteLeShort(0); // disk number + WriteLeShort(0); // internal file attr + // external file attribute + + if (entry.ExternalFileAttributes != -1) { + WriteLeInt(entry.ExternalFileAttributes); + } else { + if (entry.IsDirectory) { // mark entry as directory (from nikolam.AT.perfectinfo.com) + WriteLeInt(16); + } else { + WriteLeInt(0); + } + } + + WriteLeInt(entry.Offset); + + baseOutputStream.Write(name, 0, name.Length); + baseOutputStream.Write(extra, 0, extra.Length); + baseOutputStream.Write(entryComment, 0, entryComment.Length); + ++numEntries; + sizeEntries += ZipConstants.CENHDR + name.Length + extra.Length + entryComment.Length; + } + + WriteLeInt(ZipConstants.ENDSIG); + WriteLeShort(0); // number of this disk + WriteLeShort(0); // no of disk with start of central dir + WriteLeShort(numEntries); // entries in central dir for this disk + WriteLeShort(numEntries); // total entries in central directory + WriteLeInt(sizeEntries); // size of the central directory + WriteLeInt((int)offset); // offset of start of central dir + WriteLeShort(zipComment.Length); + baseOutputStream.Write(zipComment, 0, zipComment.Length); + baseOutputStream.Flush(); + entries = null; + } + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/AssemblyInfo.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/AssemblyInfo.cs new file mode 100644 index 0000000..2a20445 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Chapter 5 - Zip pipeline sample.suo b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Chapter 5 - Zip pipeline sample.suo new file mode 100644 index 0000000..c01dbb8 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Chapter 5 - Zip pipeline sample.suo differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/FileStreamReadWrite.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/FileStreamReadWrite.cs new file mode 100644 index 0000000..5ec36a2 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/FileStreamReadWrite.cs @@ -0,0 +1,62 @@ +namespace Microsoft.Samples.PipelineUtilities +{ + using System; + using System.IO; + + /// + /// Summary description for FileStreamReadWrite. + /// + public abstract class FileStreamReadWrite + { + public static void DumpStreamToFile (Stream fromStream, string toFilename) + { + FileStream file = null; + try + { + file = new FileStream(toFilename, System.IO.FileMode.Create); + byte[] tmpBuff = new byte[4096]; + int bytesRead = 0; + + while ((bytesRead = fromStream.Read(tmpBuff, 0, tmpBuff.Length)) != 0) + { + file.Write(tmpBuff, 0, bytesRead); + } + + file.Close(); + file = null; + } + finally + { + if (file != null) file.Close(); + } + } + + public static MemoryStream ReadFileToMemoryStream (string fromFilename) + { + FileStream file = null; + try + { + file = new FileStream(fromFilename, System.IO.FileMode.Open); + MemoryStream memStream = new MemoryStream(); + byte[] tmpBuff = new byte[4096]; + int bytesRead = 0; + + while ((bytesRead = file.Read(tmpBuff, 0, tmpBuff.Length)) != 0) + { + memStream.Write(tmpBuff, 0, bytesRead); + } + + file.Close(); + file = null; + + memStream.Position = 0; + return memStream; + } + finally + { + if (file != null) file.Close(); + } + } + + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj new file mode 100644 index 0000000..488f189 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj @@ -0,0 +1,109 @@ + + + Local + 8.0.50727 + 2.0 + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3} + Debug + AnyCPU + + + + + Microsoft.Samples.PipelineUtilities + + + JScript + Grid + IE50 + false + Library + Microsoft.Samples.PipelineUtilities + OnBuildSuccess + + + + + + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + Microsoft.BizTalk.Pipeline + ..\..\..\Program Files\Microsoft BizTalk Server 2004\Microsoft.BizTalk.Pipeline.dll + + + System + + + System.Data + + + System.XML + + + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user new file mode 100644 index 0000000..7e53e79 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/Microsoft.Samples.PipelineUtilities.csproj.user @@ -0,0 +1,57 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Program Files\Microsoft BizTalk Server 2004\ + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs new file mode 100644 index 0000000..0a43cea --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/PropertyBagReadWrite.cs @@ -0,0 +1,55 @@ +using System; + +namespace Microsoft.Samples.PipelineUtilities +{ + /// + /// Summary description for PropertyBagReadWrite. + /// + public abstract class PropertyBagReadWrite + { + /// + /// Reads property value from property bag. + /// + /// Property bag. + /// Name of property. + /// Value of the property. + public static object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName) + { + object val = null; + + try + { + pb.Read(propName, out val, 0); + } + catch(ArgumentException) + { + return val; + } + catch(Exception ex) + { + throw new ApplicationException(ex.Message); + } + + return val; + } + + /// + /// Writes property values into a property bag. + /// + /// Property bag. + /// Name of property. + /// Value of property. + public static void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val) + { + try + { + pb.Write(propName, ref val); + } + catch(Exception ex) + { + throw new ApplicationException(ex.Message); + } + } + + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll new file mode 100644 index 0000000..ce86d67 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb new file mode 100644 index 0000000..c5335f3 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Samples.PipelineUtilities.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll new file mode 100644 index 0000000..7cc9402 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb new file mode 100644 index 0000000..4478349 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/bin/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll new file mode 100644 index 0000000..ce86d67 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb new file mode 100644 index 0000000..c5335f3 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Samples.PipelineUtilities.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll new file mode 100644 index 0000000..7cc9402 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb new file mode 100644 index 0000000..4478349 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata new file mode 100644 index 0000000..dbcaa24 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Debug/Microsoft.Utility.PipelinePropertyAttribute.projdata differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt new file mode 100644 index 0000000..358d4c7 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Samples.PipelineUtilities.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\Microsoft.Samples.PipelineUtilities.dll +bin\Debug\Microsoft.Samples.PipelineUtilities.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Samples.PipelineUtilities.dll +obj\Debug\Microsoft.Samples.PipelineUtilities.pdb diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt new file mode 100644 index 0000000..77536ff --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Samples.Utilities/obj/Microsoft.Utility.PipelinePropertyAttribute.csproj.FileList.txt @@ -0,0 +1,5 @@ +bin\Debug\Microsoft.Utility.PipelinePropertyAttribute.dll +bin\Debug\Microsoft.Utility.PipelinePropertyAttribute.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Utility.PipelinePropertyAttribute.dll +obj\Debug\Microsoft.Utility.PipelinePropertyAttribute.pdb diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/AssemblyInfo.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/AssemblyInfo.cs new file mode 100644 index 0000000..f30d972 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("Microsoft.Utility.PipelineZip")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile(@"..\..\..\..\SigningKey.snk")] +[assembly: AssemblyKeyName("")] diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj new file mode 100644 index 0000000..091a119 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj @@ -0,0 +1,128 @@ + + + Local + 8.0.50727 + 2.0 + {548FA7AD-797A-4437-A5D5-2EBF4F718281} + Debug + AnyCPU + + + + + Microsoft.Utility.PipelineZip + + + JScript + Grid + IE50 + false + Library + Microsoft.Utility.PipelineZip + OnBuildSuccess + + + + + + + + + C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + Microsoft.BizTalk.Pipeline + ..\..\..\Program Files\Microsoft BizTalk Server 2004\Microsoft.BizTalk.Pipeline.dll + + + System + + + System.Data + + + System.Drawing + + + System.XML + + + ICSharpCode.SharpZipLib + {7F1C5F40-A2C9-4B92-8A23-78E95A74C194} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + {74CE9A86-DF65-4D45-A7AF-1AC351E5B5C3} + Microsoft.Samples.PipelineUtilities + + + + + Code + + + Code + + + Code + + + + ZipDecodeComponent.cs + + + ZipEncodeComponent.cs + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj.user b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj.user new file mode 100644 index 0000000..06d9ca8 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/Microsoft.Utility.PipelineZip.csproj.user @@ -0,0 +1,55 @@ + + + 7.10.3077 + Debug + AnyCPU + C:\Program Files\Microsoft BizTalk Server 2004\ + + + + + 0 + ProjectFiles + 0 + + + false + false + false + false + false + + + Program + "C:\test\PipelineComponents\BtpTest\ZipDecode.btp" -d "C:\test\PipelineComponents\BtpTest\test.zip" -c + + + C:\Program Files\Microsoft BizTalk Server 2004\SDK\Utilities\PipelineTools\Pipeline.exe + + + + + true + + + false + false + false + false + false + + + Project + + + + + + + + + + + true + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/PipelineZip.resx b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/PipelineZip.resx new file mode 100644 index 0000000..17bc7a8 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/PipelineZip.resx @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Qk02EAAAAAAAADYAAAAoAAAAIAAAACAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AIFoVgBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJ + NQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUAY0k1AGNJNQBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AhGtZAPTbzgDewLEA3L6uANu8rADbu6oA2bmoANi3 + pQDYtaMA17OhANaxnwDWsJwA1K2aANSrlwDSqpYA0qiTANCmkQDQpI8Az6ONAM+giwDNn4kAzZ6HAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCGblsA9NzRAPru6QD57OYA+erjAPfn + 3wD45dwA9+PaAPbg1wD139QA9N3RAPTbzgDz2MsA89bIAPLTxQDx0cIA8c+/APDNvADvy7kA78m2AO7H + tADNoIkAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AIlwXgD139MA+vDsAPnu + 6AD56+YA+eniAPjn3wD45dwA9uPaAPXh1gD13tQA9d3RAPTazQDz2MsA89XIAPLTxQDx0cEA8M++AO/N + vADvyrkA78i3AM+hiwBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8Ai3NhAPbg + 1gD78u4A+vHrAKyZiwCJcV8A0L6yAM66rgDNuKsAy7aoAMy1qADeyLoA79fLAPTazQD02MoA89XIAPLT + xADx0MEA8c6/APDMuwDvy7kA0KKNAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCNdmQA9uLYAPz08gD88+4Ahm5bALyjlgB6YE0AdVxJAHJYRABuVUAAfGNQALihkgDdxbgA9dzQAPTZ + zgDz2MoA89XIAPHTxADx0MEA8M6/APDMvADQpI8AY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AI94ZwD35NsA/Pb0APz08QCKcmAAzLivAHNaRwB/ZlUAjHNjAI11ZgB/Z1gAblVBAK+X + iAD13tMA9NzQAPTazgDz18oA89XHAPLTxADx0cEA8M6+ANGmkQBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8AkntpAPjm3gD9+fYA/PfzAI52ZQDe0coAp4+CANXGvQDEsKQAuqOVAKyQ + fgCVemcAfGNQAPXh1gD13tMA9dzQAPTazQDz18oA89XHAPLSwwDx0cEA0qmUAGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wCVfWwA+OjhAP76+QD9+PYAk3tqAPHq6ACxmIsA6eLeAOPZ + 0wDXyL8AvaaZAJV6ZwBuVUEA9+LZAPXg1QD13tMA9NzQAPTZzQD018oA8tXHAPLSxADTq5YAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AJZ/bwD56uMA/vz6AP76+ACWf24A////AI11 + ZACAaVYArJiKANfIvwDPu7IAl3xpAHJYRQD25NsA9uLYAPXg1gD13tIA9NzQAPTZzQDz18kA89TGANSs + mQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AmIJxAPns5gD//f0A/vz7AL6v + ogCum40A/PbzAM3AtgCJcF4A39PNANfIwACcgnAAdl1JAPjn3gD25NsA9uHYAPXg1QD13dMA9dzPAPTa + zADz18kA1a6bAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wCbhHMA+u7oAP/+ + /gD+/f0A/vv6AP35+AD9+PYA/fbyAI10YgB7XksAjHJiAIFmVAB7YU8A+OjgAPfm3QD349sA9uLYAPbf + 1gD13dIA9NvPAPPZzADWsZ4AY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AJ2H + dgD68esA////AP/+/gD+/fwA/vv6APn18gCijX0AqZKDAKuWiQChjYAAmYJ0AJB2ZACJcV8A+OjgAPfm + 3QD349oA9uLYAPbg1QD13dMA9NvPANezoABjSTUA////AP///wD///8A////AP///wD///8A////AP// + /wD///8An4l5APvy7gD///8A////AP/+/QD+/fwA+/j2AL+soQD9/PsA8evoAOLX0ADUxLsAxrGmAKiU + hQD56uMA+OjgAPjm3QD249oA9uHYAPbg1AD13dIA17WjAGNJNQD///8A////AP///wD///8A////AP// + /wD///8A////AP///wCijHsA+/TxAP///wD///8A////AP/+/gD+/fwA+/j2AKeThADWzcYA49nTALif + kQCHcF0A+u/pAPns5wD46uMA+OjgAPjm3QD349oA9uHYAPbf1ADZt6UAY0k1AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AKSOfgD///8A////AP///wD///8A////AP///wD+/PwAqZSHANXM + xQDk2dMAvaaYAIx0YgD78ewA+u/pAPns5gD46uMA+OjgAPjl3AD249oA9uHXANq5pwBjSTUA////AP// + /wD///8A////AP///wD///8A////AP///wD///8AppGBAP///wD///8A////AP///wD///8A////AP7+ + /QCsmYoA2M7HAOXa1QDBq58AkHpoAPvz7wD78OwA+u/pAI94ZwCTfGsA+OjgAPjm3QD349oA27qqAGNJ + NQD///8A////AP///wD///8A////AP///wD///8A////AP///wCfiXkA+/LuAP///wD///8A////AP// + /wD///8A////ALCdjwDe1tAA6uLeAMu4rQCmjHwAknloAItzYQCHblwAr5WHAH1kUQD46uIA+OjgAPjl + 3ADbvKwAY0k1AP///wD///8A////AP///wD///8A////AP///wD///8A////AKKMewD79PEA////AP// + /wD///8A////AP///wD///8AtaSWAO3o5QDz7+0A283GALqjmACulYcAmYBvAJyDcgC6oZQAgmlWAPrs + 5gD56uMA+OffANy+rgBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8ApI5+AP// + /wD///8A////AP///wD///8A////AP///wDQxbwA5uDbAPLu7ADs5+MA1ca/AMStoAC0m4wArpWGAMey + pgCFbVsA+u7pAPrr5gD56eIA3cGxAGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wCmkYEA////AP///wD///8A////AP///wD///8A////APTx7wDLvbUA5d3YAO/q5wDo4d0A39XPANvQ + yQCwmIkA1MS6AIpyYQD78OsA+u7oAPnr5QDfwrMAY0k1AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AJ+JeQD78u4A////AP///wD///8A////AP///wD///8A////APPw7QDOwrkAu6qeALGe + kQCql4gApZKDAKOOfgDh1tAAjndlAPvy7gD78OsA+u7oAN/EtgBjSTUA////AP///wD///8A////AP// + /wD///8A////AP///wD///8Aoox7APv08QD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP/+/AD+/PsA+fTxAMS3rAC4p5wA/PXxAPvz7QD68OsA4Me4AGNJNQD///8A////AP// + /wD///8A////AP///wD///8A////AP///wC4o5QA////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A//7+AP/+/AD++/sA/vr5AP349gDJtKkAvaWXALKZiQCkingAY0k1AP// + /wD///8A////AP///wD///8A////AP///wD///8A////ALqmmAD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A///+AP79/AD+/PsAnod2AGNJNQBjSTUAY0k1AGNJ + NQBjSTUA////AP///wD///8A////AP///wD///8A////AP///wD///8AvKiaAP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP/9/ACgiXkA1cW9AMex + pQC5oZIAbFI+AGNJNQD///8A////AP///wD///8A////AP///wD///8A////AP///wC+qpwA////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A///+AKKM + fADj2tMA1cW8AHlgTABsUj4A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AMCt + nwD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8ApY5+APPv7QCIcF0AeWBMAP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8Awq+hAP///wD///8A////AP///wD//fwA/vv7AP35+AD9+PUA/PXyAPvz7wD78OsA+u3oAPnr + 5AD46eIA9+fdAPfk2wCnkYIAln9uAIhwXQD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wDFsaMAw6+hAMKuoADArJ8Av6ucAL2pmwC8p5oAu6aXALiklQC3opQAtqGSALOf + kACynY8AsJuNAK6aiwCtmIgAq5aHAKmUhACWf24A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP// + /wD///8A////AA== + + + \ No newline at end of file diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/SharpZipLib.csproj.user b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/SharpZipLib.csproj.user new file mode 100644 index 0000000..686cccb --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/SharpZipLib.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.cs new file mode 100644 index 0000000..0b14ff6 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.cs @@ -0,0 +1,181 @@ +namespace Microsoft.Utility.PipelineZip +{ + using System; + using System.ComponentModel; + using System.Collections; + using System.Diagnostics; + using System.Drawing; + using System.IO; + using System.Reflection; + using Microsoft.BizTalk.Component.Interop; + using Microsoft.Samples.PipelineUtilities; + using ICSharpCode.SharpZipLib.Zip; + + [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] + [ComponentCategory(CategoryTypes.CATID_Decoder)] + [System.Runtime.InteropServices.Guid("67C8CFB9-D89A-4415-A112-76187FC294D1")] + public class ZipDecodeComponent : + IBaseComponent, + Microsoft.BizTalk.Component.Interop.IComponent, + Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, + IComponentUI + { + + // Component information + #region IBaseComponent + [Browsable(false)] public string Name { get { return "ZIP decoder"; } } + [Browsable(false)] public string Version { get { return "1.0"; } } + [Browsable(false)] public string Description { get { return "Zip Decode Pipeline Component"; } } + [Browsable(false)] public System.IntPtr Icon { get { return ((Bitmap)resourceManager.GetObject("IconBitmap")).GetHicon(); } } + #endregion + + private System.Resources.ResourceManager resourceManager = + new System.Resources.ResourceManager("Microsoft.Utility.PipelineGnuPG.ZipDecodeComponent", Assembly.GetExecutingAssembly()); + + // Property: Password + private string _password; + [ + DisplayName("Password"), + Description("Password used to unzip messages.") + ] + public string Password + { + get { return _password; } + set { _password = value; } + } + + private Stream Decode (Stream inStream) + { + Stream outStream = inStream; + string inFile = Path.GetTempFileName(); + string outFile = Path.ChangeExtension(inFile, "txt"); + + try + { + ZipInputStream zipStream = new ZipInputStream( inStream ); + + // get password, if supplied + if ((_password != null) && (_password != "")) + zipStream.Password = _password; + + // this algorithm demands that the zip archive contain exactly one file + ZipEntry entry = zipStream.GetNextEntry(); + if (entry == null) + throw new ApplicationException( "Input ZIP archive does not contain any files - expecting exactly one file" ); + if (entry.IsDirectory) + throw new ApplicationException( "Input ZIP contains a directory - expecting exactly one file" ); + + // copy the compressed stream into the output stream + outStream = new MemoryStream(); + byte[] buffer = new byte[4096]; + int count = 0; + while ((count = zipStream.Read(buffer, 0, buffer.Length)) != 0) + outStream.Write( buffer, 0, count ); + + // make sure that was the one and only file + entry = zipStream.GetNextEntry(); + if (entry != null) + throw new ApplicationException( "Input ZIP archive contains multiple files and/or directories - expecting exactly one file" ); + + zipStream.Close(); + +#if DEBUG + outStream.Seek( 0, SeekOrigin.Begin ); + Microsoft.Samples.PipelineUtilities.FileStreamReadWrite.DumpStreamToFile( outStream, outFile ); +#endif + + outStream.Seek( 0, SeekOrigin.Begin ); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + throw; + } + finally + { + if (File.Exists(inFile)) + { + File.Delete(inFile); + } + + if (File.Exists(outFile)) + { + File.Delete(outFile); + } + } + + return outStream; + } + + #region IPersistPropertyBag Members + + public void InitNew() + { + } + + public void GetClassID(out Guid classID) + { + classID = new Guid ("19800584-283D-44da-B1EE-0968387DA088"); + } + + public void Load(IPropertyBag propertyBag, int errorLog) + { + string text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "Password" ); + if (text != null) _password = text; + } + + public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) + { + object val; + val = (object)_password; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "Password", val ); + } + + #endregion + + + #region IComponent Members + + public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) + { + try + { + if (pInMsg != null) + { + Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream(); + pInMsg.BodyPart.Data = Decode( originalStream ); + pContext.ResourceTracker.AddResource( pInMsg.BodyPart.Data ); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine( "Exception caught in ZipDecodeComponent::Execute: " + ex.Message ); + throw new ApplicationException( "ZipDecodeComponent was unable to decompress input stream. This may occur if there is more than one file in the zip archive. See inner exception for more information.", ex ); + } + return pInMsg; + } + + #endregion + + #region IComponentUI Members + + /// + /// The Validate method is called by the BizTalk Editor during the build + /// of a BizTalk project. + /// + /// An Object containing the configuration properties. + /// The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + public IEnumerator Validate(object projectSystem) + { + // example implementation: + // ArrayList errorList = new ArrayList(); + // errorList.Add("This is a compiler error"); + // return errorList.GetEnumerator(); + return null; + } + + + #endregion + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.resx b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipDecodeComponent.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.cs b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.cs new file mode 100644 index 0000000..feeb721 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.cs @@ -0,0 +1,209 @@ +namespace Microsoft.Utility.PipelineZip +{ + using System; + using System.ComponentModel; + using System.Collections; + using System.Diagnostics; + using System.Drawing; + using System.IO; + using System.Reflection; + using Microsoft.BizTalk.Component.Interop; + using Microsoft.Samples.PipelineUtilities; + using ICSharpCode.SharpZipLib.Zip; + + [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] + [ComponentCategory(CategoryTypes.CATID_Encoder)] + [System.Runtime.InteropServices.Guid("56C7B68B-F288-4f78-A67F-20043CA4943E")] + public class ZipEncodeComponent : + IBaseComponent, + Microsoft.BizTalk.Component.Interop.IComponent, + Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, + IComponentUI + { + + // Component information + #region IBaseComponent + [Browsable(false)] public string Name { get { return "ZIP encoder"; } } + [Browsable(false)] public string Version { get { return "1.0"; } } + [Browsable(false)] public string Description { get { return "Zip Encode Pipeline Component"; } } + [Browsable(false)] public System.IntPtr Icon { get { return ((Bitmap)resourceManager.GetObject("IconBitmap")).GetHicon(); } } + #endregion + + private System.Resources.ResourceManager resourceManager = + new System.Resources.ResourceManager("Microsoft.Utility.PipelineGnuPG.ZipEncodeComponent", Assembly.GetExecutingAssembly()); + + // Property: Password + private string _password; + [ + DisplayName("Password"), + Description("Password used to zip messages.") + ] + public string Password + { + get { return _password; } + set { _password = value; } + } + + // Property: Filename + private const string DEFAULT_FILENAME = "file"; + private string _filename; + [ + DisplayName("Filename"), + Description(@"The name of the file that contains the output message. This file will be added to the ZIP compressed output archive. Default is """ + DEFAULT_FILENAME + @""".") + ] + public string Filename + { + get { return _filename; } + set { _filename = value; } + } + + // Property: CompressionLevel + const string DEFAULT_COMPRESSIONLEVEL_TEXT = "5"; + const int DEFAULT_COMPRESSIONLEVEL= 5; + private string _compressionlevel; + [ + DisplayName("CompressionLevel"), + Description(@"Compression level: 0=Store Only, to 9=Best Compression. Default is '" + DEFAULT_COMPRESSIONLEVEL_TEXT + "'.") + ] + public string CompressionLevel + { + get { return _compressionlevel; } + set { _compressionlevel = value; } + } + + private Stream Encode (Stream inStream) + { + Stream outStream = inStream; + string inFile = Path.GetTempFileName(); + string outFile = Path.ChangeExtension(inFile, "zip"); + + try + { + ZipOutputStream zipStream = new ZipOutputStream( File.Create( outFile ) ); + + // get password, if supplied + if ((_password != null) && (_password != "")) + zipStream.Password = _password; + + // get compression level, if supplied + int compressionlevel = DEFAULT_COMPRESSIONLEVEL; + if ((_compressionlevel != null) && (_compressionlevel != "")) + compressionlevel = Convert.ToInt32( _compressionlevel ); + if ((compressionlevel < 0) || (compressionlevel > 9)) + compressionlevel = DEFAULT_COMPRESSIONLEVEL; + zipStream.SetLevel( compressionlevel ); + + // get message filename, if supplied + string filename = (((_filename != null) && (_filename != "")) ? _filename : DEFAULT_FILENAME ); + ZipEntry entry = new ZipEntry( filename ); + zipStream.PutNextEntry( entry ); + + // copy the input into the compressed output stream + byte[] buffer = new byte[4096]; + int count = 0; + while ((count = inStream.Read(buffer, 0, buffer.Length)) != 0) + zipStream.Write( buffer, 0, count ); + zipStream.Finish(); + zipStream.Close(); + + outStream = Microsoft.Samples.PipelineUtilities.FileStreamReadWrite.ReadFileToMemoryStream(outFile); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine(ex); + } + finally + { + if (File.Exists(inFile)) + { + File.Delete(inFile); + } + + if (File.Exists(outFile)) + { + File.Delete(outFile); + } + } + + return outStream; + } + + #region IPersistPropertyBag Members + + public void InitNew() + { + } + + public void GetClassID(out Guid classID) + { + classID = new Guid ("0F94CF83-0B04-49a6-B73C-70473E0CF96F"); + } + + public void Load(IPropertyBag propertyBag, int errorLog) + { + string text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "Password" ); + if (text != null) _password = text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "Filename" ); + if (text != null) _filename = text; + text = (string)PropertyBagReadWrite.ReadPropertyBag( propertyBag, "CompressionLevel" ); + if (text != null) _compressionlevel = text; + } + + public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) + { + object val; + val = (object)_password; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "Password", val ); + val = (object)_filename; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "Filename", val ); + val = (object)_compressionlevel; + PropertyBagReadWrite.WritePropertyBag( propertyBag, "CompressionLevel", val ); + } + + #endregion + + + #region IComponent Members + + public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(IPipelineContext pContext, Microsoft.BizTalk.Message.Interop.IBaseMessage pInMsg) + { + try + { + if (pInMsg != null) + { + Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream(); + pInMsg.BodyPart.Data = Encode( originalStream ); + pContext.ResourceTracker.AddResource( pInMsg.BodyPart.Data ); + } + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine( "Exception caught in ZipEncodeComponent::Execute: " + ex.Message ); + } + return pInMsg; + } + + #endregion + + #region IComponentUI Members + + /// + /// The Validate method is called by the BizTalk Editor during the build + /// of a BizTalk project. + /// + /// An Object containing the configuration properties. + /// The IEnumerator enables the caller to enumerate through a collection of strings containing error messages. These error messages appear as compiler error messages. To report successful property validation, the method should return an empty enumerator. + public IEnumerator Validate(object projectSystem) + { + // example implementation: + // ArrayList errorList = new ArrayList(); + // errorList.Add("This is a compiler error"); + // return errorList.GetEnumerator(); + return null; + } + + + #endregion + } +} diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.resx b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/ZipEncodeComponent.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.dll new file mode 100644 index 0000000..72dfaaf Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.pdb new file mode 100644 index 0000000..47a8e80 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/ICSharpCode.SharpZipLib.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.dll new file mode 100644 index 0000000..7c0a830 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.pdb new file mode 100644 index 0000000..a73da33 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/bin/Debug/Microsoft.Utility.PipelineZip.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.PipelineZip.resources b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.PipelineZip.resources new file mode 100644 index 0000000..b354bcb Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.PipelineZip.resources differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipDecodeComponent.resources b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipDecodeComponent.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipDecodeComponent.resources differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipEncodeComponent.resources b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipEncodeComponent.resources new file mode 100644 index 0000000..06c24d0 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.ZipEncodeComponent.resources differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.csproj.GenerateResource.Cache b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.csproj.GenerateResource.Cache new file mode 100644 index 0000000..7f9f6f3 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.csproj.GenerateResource.Cache differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.dll b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.dll new file mode 100644 index 0000000..72a8fb2 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.dll differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.pdb b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.pdb new file mode 100644 index 0000000..1ed7ef8 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.pdb differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.projdata b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.projdata new file mode 100644 index 0000000..4c28e1e Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/Microsoft.Utility.PipelineZip.projdata differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/ResolveAssemblyReference.cache b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/ResolveAssemblyReference.cache new file mode 100644 index 0000000..6040571 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/ResolveAssemblyReference.cache differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/SharpZipLib.projdata b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/SharpZipLib.projdata new file mode 100644 index 0000000..e214529 Binary files /dev/null and b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Debug/SharpZipLib.projdata differ diff --git a/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Microsoft.Utility.PipelineZip.csproj.FileList.txt b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Microsoft.Utility.PipelineZip.csproj.FileList.txt new file mode 100644 index 0000000..046fa8c --- /dev/null +++ b/Samples/Chapter5/Zip Pipeline Component/Microsoft.Utility.PipelineZip/obj/Microsoft.Utility.PipelineZip.csproj.FileList.txt @@ -0,0 +1,11 @@ +..\..\..\Program Files\Microsoft BizTalk Server 2004\Pipeline Components\Microsoft.Utility.PipelineZip.dll +..\..\..\Program Files\Microsoft BizTalk Server 2004\Pipeline Components\Microsoft.Utility.PipelineZip.pdb +obj\Debug\ResolveAssemblyReference.cache +obj\Debug\Microsoft.Utility.PipelineZip.PipelineZip.resources +obj\Debug\Microsoft.Utility.PipelineZip.ZipDecodeComponent.resources +obj\Debug\Microsoft.Utility.PipelineZip.ZipEncodeComponent.resources +obj\Debug\Microsoft.Utility.PipelineZip.csproj.GenerateResource.Cache +obj\Debug\Microsoft.Utility.PipelineZip.dll +obj\Debug\Microsoft.Utility.PipelineZip.pdb +C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\Microsoft.Utility.PipelineZip.dll +C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components\Microsoft.Utility.PipelineZip.pdb diff --git a/Samples/README.txt b/Samples/README.txt new file mode 100644 index 0000000..3452a79 --- /dev/null +++ b/Samples/README.txt @@ -0,0 +1 @@ +This code is provided as is with no guarantees. It may be reused or editied in commercial and non-commercial applications at your own risk. diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file