コード例 #1
0
        private static Stream Transform(XmlReader reader, Type map, System.Xml.Xsl.XsltArgumentList arguments)
        {
            if (_logger.IsDebugEnabled)
            {
                _logger.DebugFormat("About to execute transform '{0}'.", map.AssemblyQualifiedName);
            }
            var transformDescriptor = XsltCache.Instance[map];

            using (reader)
            {
                var outputStream   = new VirtualStream(DEFAULT_BUFFER_SIZE, DEFAULT_THRESHOLD_SIZE);
                var writerSettings = transformDescriptor.XslCompiledTransform.OutputSettings.Override(
                    s => {
                    s.CloseOutput = false;
                    s.Encoding    = Encoding.UTF8;
                });
                using (var writer = XmlWriter.Create(outputStream, writerSettings))
                {
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.DebugFormat("Executing transform '{0}'.", map.AssemblyQualifiedName);
                    }
                    var xsltArguments = transformDescriptor.Arguments.Union(arguments);
                    transformDescriptor.XslCompiledTransform.Transform(reader, xsltArguments, writer);
                }
                outputStream.Seek(0, SeekOrigin.Begin);
                return(outputStream);
            }
        }
コード例 #2
0
        private Stream Apply(XslCompiledTransform xsl, XsltArgumentList arguments, Encoding encoding)
        {
            var output = new VirtualStream(DEFAULT_BUFFER_SIZE, DEFAULT_THRESHOLD_SIZE);
            // Clone() to have a modifiable copy of the transform's settings
            var settings = xsl.OutputSettings.Clone();

            settings.CloseOutput = false;
            settings.Encoding    = encoding;
            using (var writer = XmlWriter.Create(output, settings))
            {
                if (_streams.Length == 1)
                {
                    // TODO ?? *always* skip CompositeStream.Read() and wraps CompositeStream.Streams in a CompositeXmlReader instead ??
                    //var compositeStream = _streams[0] as CompositeStream;
                    //if (compositeStream != null)
                    //   xsl.Transform(compositeStream.Streams, arguments, writer);
                    //else
                    xsl.Transform(_streams[0], arguments, writer);
                }
                else
                {
                    xsl.Transform(_streams, arguments, writer);
                }
                output.Seek(0, SeekOrigin.Begin);
                return(output);
            }
        }
コード例 #3
0
        /// <summary>
        /// Parses an StwUser structure into a dictionary of key-value-pairs
        /// </summary>
        /// <param name="tableStream">The input table stream</param>
        /// <param name="fcStwUser">fcStwUser (4 bytes): An unsigned integer that specifies an offset into the Table Stream.
        /// An StwUser that specifies the user-defined variables and VBA digital signature (2), as specified by
        /// [MS-OSHARED] section 2.3.2, begins at this offset.
        ///
        /// If lcbStwUser is zero, fcStwUser is undefined and MUST be ignored.</param>
        /// <param name="lcbStwUser">lcbStwUser (4 bytes): An unsigned integer that specifies the size, in bytes,
        /// of the StwUser at offset fcStwUser</param>
        public StwUser(VirtualStream tableStream, UInt32 fcStwUser, UInt32 lcbStwUser)
        {
            if (lcbStwUser == 0)
            {
                return;
            }
            tableStream.Seek(fcStwUser, System.IO.SeekOrigin.Begin);

            // parse the names
            var names = new StringTable(typeof(string), tableStream, fcStwUser, lcbStwUser);

            // parse the values
            var values = new List <string>();

            while (tableStream.Position < fcStwUser + lcbStwUser)
            {
                values.Add(Utils.ReadXst(tableStream));
            }

            // map to the dictionary
            if (names.Strings.Count == values.Count)
            {
                for (int i = 0; i < names.Strings.Count; i++)
                {
                    this.Add(names.Strings[i], values[i]);
                }
            }
        }
コード例 #4
0
        private Stream Apply(XslCompiledTransform xsl, XsltArgumentList arguments, Encoding encoding)
        {
            var output = new VirtualStream(DEFAULT_BUFFER_SIZE, DEFAULT_THRESHOLD_SIZE);
            // Clone() to get a modifiable copy of the transform's settings
            var settings = xsl.OutputSettings.Clone();

            settings.CloseOutput = false;
            settings.Encoding    = encoding;
            using (var writer = XmlWriter.Create(output, settings))
            {
                if (_streams.Length == 1)
                {
                    if (_streams[0] is CompositeStream compositeStream)
                    {
                        xsl.Transform(compositeStream.Streams, arguments, writer);
                    }
                    else
                    {
                        xsl.Transform(_streams[0], arguments, writer);
                    }
                }
                else
                {
                    xsl.Transform(_streams, arguments, writer);
                }

                output.Seek(0, SeekOrigin.Begin);
                return(output);
            }
        }
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message.</param>
        /// <returns>Processed input message with appended or prepended data.</returns>
        /// <remarks>
        /// Converts xsl-fo transformed messages to pdf
        /// </remarks>
        public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
        {
            IBaseMessagePart bodyPart = inmsg.BodyPart;

            if (bodyPart.Data != null)
            {
                VirtualStream vtstm = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);

                FonetDriver driver = FonetDriver.Make();
                driver.CloseOnExit = false;//important for biztalk to work ... set position = 0

                PdfRendererOptions options = new PdfRendererOptions();
                options.Title        = Title;
                options.Subject      = Subject;
                options.UserPassword = Password;

                driver.Options = options;

                Stream stm = bodyPart.GetOriginalDataStream();
                stm.Seek(0, SeekOrigin.Begin);

                driver.Render(stm, vtstm);

                vtstm.Seek(0, SeekOrigin.Begin);

                bodyPart.Data = vtstm;
            }
            return(inmsg);
        }
コード例 #6
0
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message</param>
        /// <returns>Original input message</returns>
        /// <remarks>
        /// IComponent.Execute method is used to initiate
        /// the processing of the message in this pipeline component.
        /// </remarks>
        public Microsoft.BizTalk.Message.Interop.IBaseMessage ExecuteFour(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
        {
            Stream dataStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);

            pc.ResourceTracker.AddResource(dataStream);

            using (XmlWriter writer = XmlWriter.Create(dataStream))
            {
                // Start creating the message body
                writer.WriteStartDocument();
                //writer.WriteStartElement("ns0", ROOT_NODE_NAME, TARGET_NAMESPACE);

                for (int i = 0; i < inmsg.Context.CountProperties; i++)
                {
                    // Read in current property information
                    string propName      = null;
                    string propNamespace = null;
                    object propValue     = inmsg.Context.ReadAt(i, out propName, out propNamespace);

                    // Skip properties that we don't care about due to configuration (default is to allow all properties)
                    //if (ExcludeSystemProperties && propNamespace == SYSTEM_NAMESPACE) continue;

                    //if (!String.IsNullOrWhiteSpace(CustomPropertyNamespace) &&
                    //        propNamespace != CustomPropertyNamespace) continue;

                    // Create Property element
                    //writer.WriteStartElement(PROPERTY_NODE_NAME);

                    //// Create attributes on Property element
                    //writer.WriteStartAttribute(NAMESPACE_ATTRIBUTE);
                    //writer.WriteString(propNamespace);
                    //writer.WriteEndAttribute();

                    //writer.WriteStartAttribute(NAME_ATTRIBUTE);
                    writer.WriteString(propName);
                    writer.WriteEndAttribute();

                    // Write value inside property element
                    writer.WriteString(Convert.ToString(propValue));

                    writer.WriteEndElement();
                }

                // Finish out the message
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
            }

            dataStream.Seek(0, SeekOrigin.Begin);

            IBaseMessage outmsg = null;// = Utility.CloneMessage(inmsg, pc);

            //outmsg.BodyPart.Data = dataStream;

            return(outmsg);
        }
コード例 #7
0
        public AnnotationOwnerList(FileInformationBlock fib, VirtualStream tableStream) : base()
        {
            tableStream.Seek(fib.fcGrpXstAtnOwners, System.IO.SeekOrigin.Begin);

            while (tableStream.Position < (fib.fcGrpXstAtnOwners + fib.lcbGrpXstAtnOwners))
            {
                this.Add(Utils.ReadXst(tableStream));
            }
        }
コード例 #8
0
        private void parse(VirtualStream stream, int fc)
        {
            stream.Seek(fc, System.IO.SeekOrigin.Begin);
            var reader = new VirtualStreamReader(stream);

            this.lcb      = reader.ReadInt32();
            this.cbHeader = reader.ReadInt16();
            reader.ReadBytes(62);
            this.binData = reader.ReadBytes(this.lcb - this.cbHeader);
        }
コード例 #9
0
ファイル: TagData.cs プロジェクト: MikeMatt16/Abide
        /// <summary>
        /// Gets and returns a display string from a specified node type, stream, address, and map file.
        /// </summary>
        /// <param name="itemType">The item type.</param>
        /// <param name="dataStream">The data stream.</param>
        /// <param name="address">The address of the data.</param>
        /// <param name="map">The map file.</param>
        /// <returns>A string.</returns>
        private static string GetNodeDisplayName(IfpNodeType itemType, VirtualStream dataStream, long address, MapFile map)
        {
            //Goto
            dataStream.Seek(address, SeekOrigin.Begin);
            using (BinaryReader reader = dataStream.CreateReader())
                try
                {
                    switch (itemType)
                    {
                    case IfpNodeType.Byte: return(reader.ReadByte().ToString());

                    case IfpNodeType.SignedByte: return(reader.ReadSByte().ToString());

                    case IfpNodeType.Short: return(reader.ReadInt16().ToString());

                    case IfpNodeType.UnsignedShort: return(reader.ReadUInt16().ToString());

                    case IfpNodeType.Int: return(reader.ReadInt32().ToString());

                    case IfpNodeType.UnsignedInt: return(reader.ReadUInt32().ToString());

                    case IfpNodeType.Long: return(reader.ReadInt64().ToString());

                    case IfpNodeType.UnsignedLong: return(reader.ReadUInt64().ToString());

                    case IfpNodeType.Single: return(reader.ReadSingle().ToString());

                    case IfpNodeType.Double: return(reader.ReadDouble().ToString());

                    case IfpNodeType.String32: return(reader.ReadUTF8(32).Trim('\0'));

                    case IfpNodeType.String64: return(reader.ReadUTF8(64).Trim('\0'));

                    case IfpNodeType.Unicode128: return(reader.ReadUTF8(128).Trim('\0'));

                    case IfpNodeType.Unicode256: return(reader.ReadUTF8(256).Trim('\0'));

                    case IfpNodeType.TagId:
                        IndexEntry entry = map.IndexEntries[reader.Read <TagId>()];
                        if (entry == null)
                        {
                            return("Null");
                        }
                        else
                        {
                            return($"{entry.Filename}.{entry.Root}");
                        }

                    case IfpNodeType.StringId: return(map.Strings[reader.Read <StringId>().Index]);
                    }
                }
                catch { }
            return(string.Empty);
        }
コード例 #10
0
        public CommentAuthorTable(FileInformationBlock fib, VirtualStream tableStream)
        {
            tableStream.Seek(fib.fcGrpXstAtnOwners, System.IO.SeekOrigin.Begin);
            VirtualStreamReader reader = new VirtualStreamReader(tableStream);

            while (tableStream.Position < (fib.fcGrpXstAtnOwners + fib.lcbGrpXstAtnOwners))
            {
                Int16 cch = reader.ReadInt16();
                this.Add(Encoding.Unicode.GetString(reader.ReadBytes(cch * 2)));
            }
        }
コード例 #11
0
        private void CopyData(CLRDirectory datas, IntPtr hinstance, PeFile PE)
        {
            VirtualStream vs = PE.SectionHeaders.GetVirtualStream();

            foreach (CLRData data in datas.Datas)
            {
                vs.Seek(data.Address, SeekOrigin.Begin);
                Marshal.Copy((IntPtr)(data.Address.Value + hinstance.ToInt32()), data.Data, 0, data.Data.Length);
                vs.Write(data.Data, 0, data.Data.Length);
            }
        }
コード例 #12
0
ファイル: StringTable.cs プロジェクト: resgroup/B2XTranslator
        public StringTable(Type dataType, VirtualStream tableStream, UInt32 fc, UInt32 lcb)
        {
            this.Strings = new List <string>();
            this.Data    = new List <ByteStructure>();

            if (lcb > 0)
            {
                tableStream.Seek((long)fc, System.IO.SeekOrigin.Begin);
                parse(dataType, new VirtualStreamReader(tableStream), fc);
            }
        }
コード例 #13
0
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            string errorMessage;

            //if (!Validate(out errorMessage))
            //{
            //    throw new ArgumentException(errorMessage);
            //}

            //Get a reference to the BizTalk schema.
            string DocumentSpecName = "ProviderRequest";
            var    documentSpec     = pContext.GetDocumentSpecByName(DocumentSpecName);

            //Get a list of properties defined in the schema.
            var annotations = documentSpec.GetPropertyAnnotationEnumerator();
            var doc         = new XmlDocument();

            using (var sw = new StringWriter(new StringBuilder()))
            {
                //Create a new instance of the schema.
                doc.Load(((IFFDocumentSpec)documentSpec).CreateXmlInstance(sw));
            }

            //Write all properties to the message body.
            while (annotations.MoveNext())
            {
                //var annotation = (IPropertyAnnotation)annotations.Current;
                //var node = doc.SelectSingleNode(annotation.XPath);
                //object propertyValue;

                //if (pInMsg.Context.TryRead(new ContextProperty(annotation.Name, annotation.Namespace), out propertyValue))
                //{
                //    node.InnerText = propertyValue.ToString();
                //}
            }

            var data = new VirtualStream();

            pContext.ResourceTracker.AddResource(data);
            doc.Save(data);
            data.Seek(0, SeekOrigin.Begin);

            var outMsg = pInMsg;

            outMsg.BodyPart.Data = data;

            //Promote message type and SchemaStrongName
            //outMsg.Context.Promote(new ContextProperty(SystemProperties.MessageType), documentSpec.DocType);
            //outMsg.Context.Promote(new ContextProperty(SystemProperties.SchemaStrongName), documentSpec.DocSpecStrongName);

            //_outputQueue.Enqueue(outMsg);
        }
コード例 #14
0
        public Plex(int structureLength, VirtualStream tableStream, uint fc, uint lcb)
        {
            tableStream.Seek((long)fc, System.IO.SeekOrigin.Begin);
            var reader = new VirtualStreamReader(tableStream);

            int n = 0;

            if (structureLength > 0)
            {
                //this PLEX contains CPs and Elements
                n = ((int)lcb - CP_LENGTH) / (structureLength + CP_LENGTH);
            }
            else
            {
                //this PLEX only contains CPs
                n = ((int)lcb - CP_LENGTH) / CP_LENGTH;
            }

            //read the n + 1 CPs
            this.CharacterPositions = new List <int>();
            for (int i = 0; i < n + 1; i++)
            {
                this.CharacterPositions.Add(reader.ReadInt32());
            }

            //read the n structs
            this.Elements = new List <T>();
            var genericType = typeof(T);

            if (genericType == typeof(short))
            {
                this.Elements = new List <T>();
                for (int i = 0; i < n; i++)
                {
                    short value        = reader.ReadInt16();
                    var   genericValue = (T)Convert.ChangeType(value, typeof(T));
                    this.Elements.Add(genericValue);
                }
            }
            else if (structureLength > 0)
            {
                for (int i = 0; i < n; i++)
                {
                    var    constructor  = genericType.GetConstructor(new Type[] { typeof(VirtualStreamReader), typeof(int) });
                    object value        = constructor.Invoke(new object[] { reader, structureLength });
                    var    genericValue = (T)Convert.ChangeType(value, typeof(T));
                    this.Elements.Add(genericValue);
                }
            }
        }
コード例 #15
0
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            string errorMessage;

            if (!Validate(out errorMessage))
            {
                throw new ArgumentException(errorMessage);
            }

            //Get a reference to the BizTalk schema.
            var documentSpec = pContext.GetDocumentSpecByName(DocumentSpecName);

            //Get a list of properties defined in the schema.
            var annotations = documentSpec.GetPropertyAnnotationEnumerator();
            var doc = new XmlDocument();
            using (var sw = new StringWriter(new StringBuilder()))
            {
                //Create a new instance of the schema.
                doc.Load(((IFFDocumentSpec)documentSpec).CreateXmlInstance(sw));
            }

            //Write all properties to the message body.
            while (annotations.MoveNext())
            {
                var annotation = (IPropertyAnnotation)annotations.Current;
                var node = doc.SelectSingleNode(annotation.XPath);
                object propertyValue;

                if (pInMsg.Context.TryRead(new ContextProperty(annotation.Name, annotation.Namespace), out propertyValue))
                {
                    node.InnerText = propertyValue.ToString();
                }
            }

            var data = new VirtualStream();
            pContext.ResourceTracker.AddResource(data);
            doc.Save(data);
            data.Seek(0, SeekOrigin.Begin);

            var outMsg = pInMsg;
            outMsg.BodyPart.Data = data;

            //Promote message type and SchemaStrongName
            outMsg.Context.Promote(new ContextProperty(SystemProperties.MessageType), documentSpec.DocType);
            outMsg.Context.Promote(new ContextProperty(SystemProperties.SchemaStrongName), documentSpec.DocSpecStrongName);

            _outputQueue.Enqueue(outMsg);
        }
コード例 #16
0
        public AnnotationReferenceExtraTable(FileInformationBlock fib, VirtualStream tableStream)
        {
            if (fib.nFib >= FileInformationBlock.FibVersion.Fib2002)
            {
                tableStream.Seek((long)fib.fcAtrdExtra, System.IO.SeekOrigin.Begin);
                VirtualStreamReader reader = new VirtualStreamReader(tableStream);

                int n = (int)fib.lcbAtrdExtra / ARTDPost10_LENGTH;

                //read the n ATRDPost10 structs
                for (int i = 0; i < n; i++)
                {
                    this.Add(new AnnotationReferenceDescriptorExtra(reader, ARTDPost10_LENGTH));
                }
            }
        }
コード例 #17
0
        public OfficeArtContent(FileInformationBlock fib, VirtualStream tableStream)
        {
            var reader = new VirtualStreamReader(tableStream);

            tableStream.Seek(fib.fcDggInfo, System.IO.SeekOrigin.Begin);

            if (fib.lcbDggInfo > 0)
            {
                int maxPosition = (int)(fib.fcDggInfo + fib.lcbDggInfo);

                //read the DrawingGroupData
                this.DrawingGroupData = (DrawingGroup)Record.ReadRecord(reader);

                //read the Drawings
                this.Drawings = new List <OfficeArtWordDrawing>();
                while (reader.BaseStream.Position < maxPosition)
                {
                    var drawing = new OfficeArtWordDrawing
                    {
                        dgglbl    = (DrawingType)reader.ReadByte(),
                        container = (DrawingContainer)Record.ReadRecord(reader)
                    };

                    for (int i = 0; i < drawing.container.Children.Count; i++)
                    {
                        var groupChild = drawing.container.Children[i];
                        if (groupChild.TypeCode == 0xF003)
                        {
                            // the child is a subgroup
                            var group = (GroupContainer)drawing.container.Children[i];
                            group.Index = i;
                            drawing.container.Children[i] = group;
                        }
                        else if (groupChild.TypeCode == 0xF004)
                        {
                            // the child is a shape
                            var shape = (ShapeContainer)drawing.container.Children[i];
                            shape.Index = i;
                            drawing.container.Children[i] = shape;
                        }
                    }

                    this.Drawings.Add(drawing);
                }
            }
        }
コード例 #18
0
        private static void WriteMessage(Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg, XmlDocument xmlDoc)
        {
            var outputStream = new VirtualStream();

            using (var writer = XmlWriter.Create(outputStream, new XmlWriterSettings()
            {
                CloseOutput = false,
                Encoding = Encoding.UTF8
            }))
            {
                xmlDoc.WriteTo(writer);
                writer.Flush();
            }

            outputStream.Seek(0, SeekOrigin.Begin);

            inmsg.BodyPart.Charset = Encoding.UTF8.WebName;
            inmsg.BodyPart.Data    = outputStream;
        }
コード例 #19
0
        public StwStructure(VirtualStream tableStream, uint fc, uint lcb) : base()
        {
            tableStream.Seek((long)fc, System.IO.SeekOrigin.Begin);

            // parse the names
            var names = new StringTable(typeof(string), new VirtualStreamReader(tableStream));

            // parse the values
            var values = new List <string>();

            while (tableStream.Position < fc + lcb)
            {
                values.Add(Utils.ReadXst(tableStream));
            }

            // map to the dictionary
            if (names.Strings.Count == values.Count)
            {
                for (int i = 0; i < names.Strings.Count; i++)
                {
                    this.Add(names.Strings[i], values[i]);
                }
            }
        }
コード例 #20
0
        /// <summary>
        /// Transforms original stream using streaming scalable transformation from BizTalk API.
        /// </summary>
        /// <param name="inputStream"></param>
        /// <returns></returns>
        internal Stream TransformMessage(Stream inputStream, TransformMetaData map, IBaseMessage pInMsg)
        {
            XsltArgumentList args         = null;
            Context          ext          = null;
            SchemaMetadata   targetSchema = targetSchema = map.TargetSchemas[0];

            string portname = String.Empty;


            //It is possible to add a param but then you you need to work arounds in the map
            // map.ArgumentList.AddParam

            //The statement bellow caused me some problems that was solved by creating the XsltArgumentList instead
            //args = map.ArgumentList;


            try
            {
                ext = new Context(pInMsg.Context, pInMsg.MessageID.ToString());

                args = map.ArgumentList;//Include BizTalk extensions
                //args.AddExtensionObject("http://www.w3.org/1999/XSL/Transform", ext); strangely it seams i cannot use this namespace in vs 2012, but it worked in vs 2010
                args.RemoveExtensionObject("urn:schemas-microsoft-com:xslt");
                args.AddExtensionObject("urn:schemas-microsoft-com:xslt", ext);

                AddParameters(args);

                //2017-08-23 Added intermidiate stream as Transform kills the original stream,
                //this is a problem if the incomming message is a enveloped message.
                // XmlTranslatorStream stm = new XmlTranslatorStream(XmlReader.Create(inputStream));
                //Opted to use non disposable stream instead
                NonDisposableStream stm          = new NonDisposableStream(inputStream);
                VirtualStream       outputStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);

                //TODO test to add declaration and see what happens with params!!!!!!!!!!!!!!!!!!!!!!!!

                BTSXslTransform btsXslTransform = null;

                if (Transforms.ContainsKey(map))
                {
                    btsXslTransform = Transforms[map];
                }
                else
                {
                    btsXslTransform = new BTSXslTransform();
                    XmlTextReader xmlTextReader = new XmlTextReader((TextReader) new StringReader(map.XmlContent));
                    btsXslTransform.Load((XmlReader)xmlTextReader, new MemoryResourceResolver(map.Assembly), (System.Security.Policy.Evidence)null);

                    Transforms.TryAdd(map, btsXslTransform);
                }

                btsXslTransform.Transform(stm, args, outputStream, null);
                outputStream.Seek(0, SeekOrigin.Begin);



                if (_dynamicMap)
                {
                    pInMsg.Context.Write("XSLTransform", "PipelineComponents.XSLTransform", map.AssemblyQualifiedName);
                }

                pInMsg.Context.Promote("MessageType", _systemPropertiesNamespace, targetSchema.SchemaName);
                //Changed to Write as SchemaStrongName could exceed 255 chars
                pInMsg.Context.Write("SchemaStrongName", _systemPropertiesNamespace, targetSchema.ReflectedType.AssemblyQualifiedName);
                //pInMsg.MessageID.ToString()


                return(outputStream);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Error while trying to transform using MapType specification: {_mapName}\nMap Assembly {map.AssemblyQualifiedName} used\nError {ex.Message}", ex);
            }
        }
コード例 #21
0
        /// <summary>
        /// Transforms original stream using streaming scalable transformation from BizTalk API.
        /// </summary>
        /// <param name="inputStream"></param>
        /// <returns></returns>
        internal Stream TransformMessage(Stream inputStream, TransformMetaData map, IBaseMessage pInMsg)
        {
            XsltArgumentList args         = null;
            Context          ext          = null;
            SchemaMetadata   targetSchema = targetSchema = map.TargetSchemas[0];

            string portname = String.Empty;


            //It is possible to add a param but then you you need to work arounds in the map
            // map.ArgumentList.AddParam

            //The statement bellow caused me some problems that was solved by creating the XsltArgumentList instead
            //args = map.ArgumentList;


            try
            {
                ext = new Context();

                for (int i = 0; i < pInMsg.Context.CountProperties; i++)
                {
                    string name;
                    string ns;
                    string value = pInMsg.Context.ReadAt(i, out name, out ns).ToString();
                    ext.Add(name, value, ns);

                    if (m_portDirection == PortDirection.receive && name == "ReceivePortName")
                    {
                        portname = value;
                    }
                    else if (m_portDirection == PortDirection.send && name == "SPName")
                    {
                        portname = value;
                    }
                }

                //It is possible to add any information that should be available from the map
                ext.Add("MessageID", pInMsg.MessageID.ToString());


                args = new XsltArgumentList();
                //args.AddExtensionObject("http://www.w3.org/1999/XSL/Transform", ext); strangely it seams i cannot use this namespace in vs 2012, but it worked in vs 2010
                args.AddExtensionObject("urn:schemas-microsoft-com:xslt", ext);

                AddParameters(args);

                //2017-08-23 Added intermidiate stream as Transform kills the original stream,
                //this is a problem if the incomming message is a enveloped message.
                XmlTranslatorStream stm          = new XmlTranslatorStream(XmlReader.Create(inputStream));
                VirtualStream       outputStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);

                XmlTextReader   xmlTextReader   = new XmlTextReader((TextReader) new StringReader(map.XmlContent));
                BTSXslTransform btsXslTransform = new BTSXslTransform();
                btsXslTransform.Load((XmlReader)xmlTextReader, new MemoryResourceResolver(portname, m_portDirection), (System.Security.Policy.Evidence)null);

                btsXslTransform.Transform(stm, args, outputStream, null);
                outputStream.Seek(0, SeekOrigin.Begin);

                pInMsg.Context.Promote("MessageType", _systemPropertiesNamespace, targetSchema.SchemaName);
                pInMsg.Context.Promote("SchemaStrongName", _systemPropertiesNamespace, targetSchema.ReflectedType.AssemblyQualifiedName);
                //pInMsg.MessageID.ToString()


                return(outputStream);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(string.Format("Error while trying to transform using MapType specification: {0}", _mapName), ex);
            }
        }
コード例 #22
0
        public CommandTable(FileInformationBlock fib, VirtualStream tableStream)
        {
            tableStream.Seek(fib.fcCmds, System.IO.SeekOrigin.Begin);
            VirtualStreamReader reader = new VirtualStreamReader(tableStream);

            //byte[] bytes = reader.ReadBytes((int)fib.lcbCmds);
            this.MacroDatas    = new List <MacroData>();
            this.KeyMapEntries = new List <KeyMapEntry>();
            this.MacroNames    = new Dictionary <int, string>();

            //skip the version
            reader.ReadByte();

            //parse the commandtable
            while (reader.BaseStream.Position < (fib.fcCmds + fib.lcbCmds) && !breakWhile)
            {
                //read the type
                byte ch = reader.ReadByte();

                switch (ch)
                {
                case 0x1:
                    //it's a PlfMcd
                    int iMacMcd = reader.ReadInt32();
                    for (int i = 0; i < iMacMcd; i++)
                    {
                        this.MacroDatas.Add(new MacroData(reader));
                    }
                    break;

                case 0x2:
                    //it's a PlfAcd
                    //skip the ACDs
                    int iMacAcd = reader.ReadInt32();
                    reader.ReadBytes(iMacAcd * 4);
                    break;

                case 0x3:
                    //Keymap Entries
                    int iMacKme = reader.ReadInt32();
                    for (int i = 0; i < iMacKme; i++)
                    {
                        this.KeyMapEntries.Add(new KeyMapEntry(reader));
                    }
                    break;

                case 0x4:
                    //Keymap Entries
                    int iMacKmeInvalid = reader.ReadInt32();
                    for (int i = 0; i < iMacKmeInvalid; i++)
                    {
                        this.KeyMapEntries.Add(new KeyMapEntry(reader));
                    }
                    break;

                case 0x10:
                    //it's a TcgSttbf
                    this.CommandStringTable = new StringTable(typeof(String), reader);
                    break;

                case 0x11:
                    //it's a MacroNames table
                    int iMacMn = reader.ReadInt16();
                    for (int i = 0; i < iMacMn; i++)
                    {
                        Int16 ibst = reader.ReadInt16();
                        Int16 cch  = reader.ReadInt16();
                        this.MacroNames[ibst] = Encoding.Unicode.GetString(reader.ReadBytes(cch * 2));
                        //skip the terminating zero
                        reader.ReadBytes(2);
                    }
                    break;

                case 0x12:
                    //it's a CTBWRAPPER structure
                    this.CustomToolbars = new CustomToolbarWrapper(reader);
                    break;

                default:
                    breakWhile = true;
                    break;
                }
            }
        }
コード例 #23
0
        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            System.Diagnostics.Trace.Write("1. Enter Pipeline");

            try
            {
                System.Diagnostics.Trace.Write("2. Namespace Replace Enable : " + Enabled.ToString());

                //If enabled
                if (Enabled)
                {
                    //Create StreamReader, VirtualStream and StreamWriter instance
                    StreamReader  sReader   = new StreamReader(pInMsg.BodyPart.Data);
                    VirtualStream vInStream = new VirtualStream();
                    StreamWriter  sWriter   = new StreamWriter(vInStream);

                    System.Diagnostics.Trace.Write("3. Created StreamReader, VirtualStream and StreamWriter instances.");

                    //Write message body to a virutal memory stream
                    sWriter.Write(sReader.ReadToEnd());
                    sWriter.Flush();
                    sReader.Close();

                    System.Diagnostics.Trace.Write("4. Message body written to a virutal memory stream.");

                    vInStream.Seek(0, SeekOrigin.Begin);

                    //create a string
                    string body = new StreamReader(vInStream).ReadToEnd();

                    System.Diagnostics.Trace.Write("5. Message body : " + body);
                    System.Diagnostics.Trace.Write("6. Old Namespace : " + OldNamespace);
                    System.Diagnostics.Trace.Write("7. New Namespace : " + NewNamespace);

                    VirtualStream vOutStream = new VirtualStream();

                    //Add property to Namespace.
                    //Manipulate the Namespace of the message
                    body = body.Replace(OldNamespace, NewNamespace);

                    System.Diagnostics.Trace.Write("8. Namespace replaced");

                    //Write the output
                    StreamWriter writer = new StreamWriter(vOutStream);
                    writer.AutoFlush = true;
                    writer.Write(body);
                    vOutStream.Position = 0;

                    System.Diagnostics.Trace.Write("9. Write output.");

                    //Put the stream back
                    pInMsg.BodyPart.Data = vOutStream;

                    System.Diagnostics.Trace.Write("10. Exit Pipeline.");
                }

                return(pInMsg);
            }
            catch (Exception ex)
            {
                if (pInMsg != null)
                {
                    pInMsg.SetErrorInfo(ex);
                }

                throw ex;
            }
        }
コード例 #24
0
ファイル: JsonDecoder.cs プロジェクト: HydAu/QLBizTalk2013
        private static void writeMessage(Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg, XmlDocument xmlDoc)
        {
            var outputStream = new VirtualStream();

            using (var writer = XmlWriter.Create(outputStream, new XmlWriterSettings()
            {
                CloseOutput = false,
                Encoding = Encoding.UTF8
            }))
            {
                xmlDoc.WriteTo(writer);
                writer.Flush();
            }

            outputStream.Seek(0, SeekOrigin.Begin);

            inmsg.BodyPart.Charset = Encoding.UTF8.WebName;
            inmsg.BodyPart.Data = outputStream;
        }
コード例 #25
0
        private void parse(VirtualStream stream, Int32 fc)
        {
            stream.Seek(fc, System.IO.SeekOrigin.Begin);
            VirtualStreamReader reader = new VirtualStreamReader(stream);

            Int32 lcb = reader.ReadInt32();

            if (lcb > 0)
            {
                UInt16 cbHeader = reader.ReadUInt16();

                this.mfp      = new MetafilePicture();
                this.mfp.mm   = reader.ReadInt16();
                this.mfp.xExt = reader.ReadInt16();
                this.mfp.yExt = reader.ReadInt16();
                this.mfp.hMf  = reader.ReadInt16();

                if (this.mfp.mm > 98)
                {
                    this.rcWinMf = reader.ReadBytes(14);

                    //dimensions
                    this.dxaGoal = reader.ReadInt16();
                    this.dyaGoal = reader.ReadInt16();
                    this.mx      = reader.ReadUInt16();
                    this.my      = reader.ReadUInt16();

                    //cropping
                    this.dxaCropLeft   = reader.ReadInt16();
                    this.dyaCropTop    = reader.ReadInt16();
                    this.dxaCropRight  = reader.ReadInt16();
                    this.dyaCropBottom = reader.ReadInt16();

                    Int16 brcl = reader.ReadInt16();

                    //borders
                    this.brcTop    = new BorderCode(reader.ReadBytes(4));
                    this.brcLeft   = new BorderCode(reader.ReadBytes(4));
                    this.brcBottom = new BorderCode(reader.ReadBytes(4));
                    this.brcRight  = new BorderCode(reader.ReadBytes(4));

                    this.dxaOrigin = reader.ReadInt16();
                    this.dyaOrigin = reader.ReadInt16();
                    this.cProps    = reader.ReadInt16();

                    //Parse the OfficeDrawing Stuff
                    Record r = Record.ReadRecord(reader);
                    if (r is ShapeContainer)
                    {
                        this.ShapeContainer = (ShapeContainer)r;
                        long pos = reader.BaseStream.Position;
                        if (pos < (fc + lcb))
                        {
                            Record rec = Record.ReadRecord(reader);
                            if (rec.GetType() == typeof(BlipStoreEntry))
                            {
                                this.BlipStoreEntry = (BlipStoreEntry)rec;
                            }
                        }
                    }
                }
            }
        }
コード例 #26
0
        public Stream MessageWriter(Stream stream, Encoding encoding, string nsToModify, string newNamespace, string xPath)
        {
            var outStream = new VirtualStream();

            using (var reader = XmlReader.Create(stream))
            {
                using (var writer = XmlWriter.Create(outStream, new XmlWriterSettings {
                    Encoding = encoding
                }))
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.CDATA:
                            writer.WriteCData(reader.Value);
                            break;

                        case XmlNodeType.Comment:
                            writer.WriteComment(reader.Value);
                            break;

                        case XmlNodeType.DocumentType:
                            writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"),
                                                reader.GetAttribute("SYSTEM"), reader.Value);
                            break;

                        case XmlNodeType.Element:
                            var isEmpty = reader.IsEmptyElement;

                            // Will call the injected action depending if it's add, modify or remove
                            //writeElement(writer, reader, nsToModify, newNamespace, namespaceForm, xPath);

                            while (reader.MoveToNextAttribute())
                            {
                                // Copy all attributed that aren't namespaces
                                if (reader.Value != nsToModify &&
                                    reader.NamespaceURI != "http://www.w3.org/2000/xmlns/")
                                {
                                    writer.WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI,
                                                                reader.Value);
                                }
                            }

                            if (isEmpty)
                            {
                                writer.WriteEndElement();
                            }

                            break;

                        case XmlNodeType.EndElement:
                            writer.WriteFullEndElement();
                            break;

                        case XmlNodeType.EntityReference:
                            writer.WriteEntityRef(reader.Name);
                            break;

                        case XmlNodeType.XmlDeclaration:
                        case XmlNodeType.ProcessingInstruction:
                            writer.WriteProcessingInstruction(reader.Name, reader.Value);
                            break;

                        case XmlNodeType.Text:
                            writer.WriteString(reader.Value);
                            break;

                        case XmlNodeType.SignificantWhitespace:
                        case XmlNodeType.Whitespace:
                            writer.WriteWhitespace(reader.Value);
                            break;
                        }
                    }
                }
            }

            stream.Seek(0, SeekOrigin.Begin);
            outStream.Seek(0, SeekOrigin.Begin);

            return(outStream);
        }
コード例 #27
0
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message</param>
        /// <returns>Original input message</returns>
        /// <remarks>
        /// IComponent.Execute method is used to initiate
        /// the processing of the message in this pipeline component.
        /// </remarks>
        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
        {

            Stream dataStream = new VirtualStream(VirtualStream.MemoryFlag.AutoOverFlowToDisk);
            pc.ResourceTracker.AddResource(dataStream);

            using (XmlWriter writer = XmlWriter.Create(dataStream))
            {

                // Start creating the message body
                writer.WriteStartDocument();
                writer.WriteStartElement("ns0", ROOT_NODE_NAME, TARGET_NAMESPACE);

                for (int i = 0; i < inmsg.Context.CountProperties; i++)
                {

                    // Read in current property information
                    string propName = null;
                    string propNamespace = null;
                    object propValue = inmsg.Context.ReadAt(i, out propName, out propNamespace);

                    // Skip properties that we don't care about due to configuration (default is to allow all properties)
                    if (ExcludeSystemProperties && propNamespace == SYSTEM_NAMESPACE) continue;

                    if (!String.IsNullOrWhiteSpace(CustomPropertyNamespace) &&
                            propNamespace != CustomPropertyNamespace) continue;

                    // Create Property element
                    writer.WriteStartElement(PROPERTY_NODE_NAME);

                    // Create attributes on Property element
                    writer.WriteStartAttribute(NAMESPACE_ATTRIBUTE);
                    writer.WriteString(propNamespace);
                    writer.WriteEndAttribute();

                    writer.WriteStartAttribute(NAME_ATTRIBUTE);
                    writer.WriteString(propName);
                    writer.WriteEndAttribute();

                    // Write value inside property element
                    writer.WriteString(Convert.ToString(propValue));

                    writer.WriteEndElement();
                }

                // Finish out the message
                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();

            }

            dataStream.Seek(0, SeekOrigin.Begin);

            var outmsg = Utility.CloneMessage(inmsg, pc);
            outmsg.BodyPart.Data = dataStream;

            return outmsg;
        }
コード例 #28
0
        private static Stream MessageWriter(
            Action<XmlWriter, XmlReader, string, string, NamespaceFormEnum, string> writeElement, Stream stream,
            Encoding encoding, string nsToModify = null, string newNamespace = null,
            NamespaceFormEnum namespaceForm = NamespaceFormEnum.Unqualified, string xPath = "")
        {
            var outStream = new VirtualStream();

            using (var reader = XmlReader.Create(stream))
            {
                using (var writer = XmlWriter.Create(outStream, new XmlWriterSettings {Encoding = encoding}))
                {
                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.CDATA:
                                writer.WriteCData(reader.Value);
                                break;

                            case XmlNodeType.Comment:
                                writer.WriteComment(reader.Value);
                                break;

                            case XmlNodeType.DocumentType:
                                writer.WriteDocType(reader.Name, reader.GetAttribute("PUBLIC"),
                                    reader.GetAttribute("SYSTEM"), reader.Value);
                                break;

                            case XmlNodeType.Element:
                                var isEmpty = reader.IsEmptyElement;

                                // Will call the injected action depending if it's add, modify or remove
                                writeElement(writer, reader, nsToModify, newNamespace, namespaceForm, xPath);

                                while (reader.MoveToNextAttribute())
                                {
                                    // Copy all attributed that aren't namespaces
                                    if (reader.Value != nsToModify &&
                                        reader.NamespaceURI != "http://www.w3.org/2000/xmlns/")
                                        writer.WriteAttributeString(reader.Prefix, reader.LocalName, reader.NamespaceURI,
                                            reader.Value);
                                }

                                if (isEmpty)
                                    writer.WriteEndElement();

                                break;

                            case XmlNodeType.EndElement:
                                writer.WriteFullEndElement();
                                break;

                            case XmlNodeType.EntityReference:
                                writer.WriteEntityRef(reader.Name);
                                break;

                            case XmlNodeType.XmlDeclaration:
                            case XmlNodeType.ProcessingInstruction:
                                writer.WriteProcessingInstruction(reader.Name, reader.Value);
                                break;

                            case XmlNodeType.Text:
                                writer.WriteString(reader.Value);
                                break;

                            case XmlNodeType.SignificantWhitespace:
                            case XmlNodeType.Whitespace:
                                writer.WriteWhitespace(reader.Value);
                                break;
                        }
                    }
                }
            }

            stream.Seek(0, SeekOrigin.Begin);
            outStream.Seek(0, SeekOrigin.Begin);

            return outStream;
        }
コード例 #29
0
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message</param>
        /// <returns>Original input message</returns>
        /// <remarks>
        /// IComponent.Execute method is used to initiate
        /// the processing of the message in this pipeline component.
        /// </remarks>
        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
        {
            #region Copy input stream

            try
            {
                IBaseMessagePart bodyPart = inmsg.BodyPart;

                if (bodyPart != null)
                {
                    Stream originalStream = bodyPart.GetOriginalDataStream();

                    // Biztalk will not do property promotion in time if we do not touch the stream. Seems to be a quirk of how the send pipeline works.
                    // If original message is returned no property promotion will happen before the EDI assembler component gets the message.
                    if (originalStream != null)
                    {
                        StreamReader  sReader = new StreamReader(originalStream);
                        VirtualStream vStream = new VirtualStream();
                        StreamWriter  sWriter = new StreamWriter(vStream);

                        //Write message body to a virutal memory stream
                        sWriter.Write(sReader.ReadToEnd());
                        sWriter.Flush();
                        sReader.Close();

                        vStream.Seek(0, SeekOrigin.Begin);

                        pc.ResourceTracker.AddResource(vStream);
                        inmsg.BodyPart.Data = vStream;
                    }
                }

                #endregion

                #region Property promotion

                // Set the identificators. Make sure to set " " if missing to get property promoted (will make Biztalk fail the file on missing party)
                if (string.IsNullOrEmpty((string)inmsg.Context.Read(_senderId, _propertyNameSpace)))
                {
                    inmsg.Context.Promote("DestinationPartySenderIdentifier", _edifactPropertyNamespace, " ");
                }
                else
                {
                    inmsg.Context.Promote("DestinationPartySenderIdentifier", _edifactPropertyNamespace,
                                          inmsg.Context.Read(_senderId, _propertyNameSpace));
                }

                if (string.IsNullOrEmpty((string)inmsg.Context.Read(_receiverId, _propertyNameSpace)))
                {
                    inmsg.Context.Promote("DestinationPartyReceiverIdentifier", _edifactPropertyNamespace, " ");
                }
                else
                {
                    inmsg.Context.Promote("DestinationPartyReceiverIdentifier", _edifactPropertyNamespace,
                                          inmsg.Context.Read(_receiverId, _propertyNameSpace));
                }

                // If no qualifier is set in pipeline use " " since that will resolve as <no qualifier> in Biztalk.
                if (string.IsNullOrEmpty(_senderIdQualifier))
                {
                    inmsg.Context.Promote("DestinationPartySenderQualifier", _edifactPropertyNamespace, " ");
                }
                else
                {
                    // If no value is found on property set space as value (<No qualifier>)
                    if (string.IsNullOrEmpty((string)inmsg.Context.Read(_senderIdQualifier, _propertyNameSpace)))
                    {
                        inmsg.Context.Promote("DestinationPartySenderQualifier", _edifactPropertyNamespace, " ");
                    }
                    else
                    {
                        inmsg.Context.Promote("DestinationPartySenderQualifier", _edifactPropertyNamespace,
                                              inmsg.Context.Read(_senderIdQualifier, _propertyNameSpace));
                    }
                }

                // If no qualifier is set in pipeline use " " since that will resolve as <no qualifier> in Biztalk.
                if (string.IsNullOrEmpty(_receiverIdQualifier))
                {
                    inmsg.Context.Promote("DestinationPartyReceiverQualifier", _edifactPropertyNamespace, " ");
                }
                else
                {
                    // If no value is found on property set space as value (<No qualifier>)
                    if (string.IsNullOrEmpty((string)inmsg.Context.Read(_receiverIdQualifier, _propertyNameSpace)))
                    {
                        inmsg.Context.Promote("DestinationPartyReceiverQualifier", _edifactPropertyNamespace, " ");
                    }
                    else
                    {
                        inmsg.Context.Promote("DestinationPartyReceiverQualifier", _edifactPropertyNamespace,
                                              inmsg.Context.Read(_receiverIdQualifier, _propertyNameSpace));
                    }
                }
                return(inmsg);

                #endregion
            }
            catch (Exception ex)
            {
                if (inmsg != null)
                {
                    inmsg.SetErrorInfo(ex);
                }

                throw;
            }
        }
コード例 #30
0
        private IBaseMessage BuildResponseMessage(IBaseMessage message, IBaseMessageContext context, LoopBackTransmitProperties props)
        {
            Guid callToken  = TraceManager.CustomComponent.TraceIn();
            long startScope = TraceManager.CustomComponent.TraceStartScope("BuildResponseMessage", callToken);

            IBaseMessageFactory messageFactory = _transportProxy.GetMessageFactory();
            IBaseMessage        btsResponse    = messageFactory.CreateMessage();

            TraceManager.CustomComponent.TraceInfo("PropertyCopy: {0}", props.PropertyCopy);
            if (props.PropertyCopy)
            {
                btsResponse.Context = PipelineUtil.CloneMessageContext(context);
            }
            TraceManager.CustomComponent.TraceInfo("CustomPropertyCopy: {0}", props.CustomPropertyCopy);
            if (props.CustomPropertyCopy)
            {
                btsResponse.Context = messageFactory.CreateMessageContext();
                for (int i = 0; i < context.CountProperties; i++)
                {
                    string strName;
                    string strNamespace;
                    object oValue = context.ReadAt(i, out strName, out strNamespace);
                    if (!strNamespace.StartsWith("http://schemas.microsoft.com/BizTalk"))
                    {
                        if (context.IsPromoted(strName, strNamespace))
                        {
                            TraceManager.CustomComponent.TraceInfo("Promoted into context: {1}#{0}={2}", strName, strNamespace, oValue);
                            btsResponse.Context.Promote(strName, strNamespace, oValue);
                        }
                        else
                        {
                            TraceManager.CustomComponent.TraceInfo("Copied into context: {1}#{0}={2}", strName, strNamespace, oValue);
                            btsResponse.Context.Write(strName, strNamespace, oValue);
                        }
                    }
                }
            }
            TraceManager.CustomComponent.TraceInfo("PartCount: {0}", message.PartCount);
            for (int i = 0; i < message.PartCount; i++)
            {
                string        str;
                VirtualStream stream = new VirtualStream();
                StreamReader  rdr    = new StreamReader(message.GetPartByIndex(i, out str).GetOriginalDataStream(), true);
                StreamWriter  wrtr   = new StreamWriter(stream, rdr.CurrentEncoding);
                wrtr.Write(rdr.ReadToEnd());
                rdr.Close();
                wrtr.Flush();
                stream.Seek(0, SeekOrigin.Begin);
                IBaseMessagePart part = messageFactory.CreateMessagePart();
                if (props.PropertyCopy)
                {
                    part.Charset        = message.GetPart(str).Charset;
                    part.ContentType    = message.GetPart(str).ContentType;
                    part.PartProperties = PipelineUtil.CopyPropertyBag(message.GetPart(str).PartProperties, messageFactory);
                }
                btsResponse.AddPart(str, part, message.GetPart(str).PartID.Equals(message.BodyPart.PartID));
                btsResponse.GetPart(str).Data = stream;
            }

            TraceManager.CustomComponent.TraceEndScope("BuildResponseMessage", startScope, callToken);
            TraceManager.CustomComponent.TraceOut(callToken);

            return(btsResponse);
        }
コード例 #31
0
ファイル: TagData.cs プロジェクト: MikeMatt16/Abide
        /// <summary>
        /// Reads and returns the value of this data object.
        /// </summary>
        /// <returns>The value of the data object.</returns>
        public object ReadValue()
        {
            //Check
            if (!IsValid)
            {
                return(null);
            }

            //Goto
            dataStream.Seek(address, SeekOrigin.Begin);
            using (BinaryReader reader = dataStream.CreateReader())
                switch (node.Type)
                {
                case IfpNodeType.Single: value = reader.ReadSingle(); break;

                case IfpNodeType.Double: value = reader.ReadDouble(); break;

                case IfpNodeType.SignedByte: value = reader.ReadSByte(); break;

                case IfpNodeType.Byte:
                case IfpNodeType.Enumerator8:
                case IfpNodeType.Bitfield8: value = reader.ReadByte(); break;

                case IfpNodeType.Short: value = reader.ReadInt16(); break;

                case IfpNodeType.UnsignedShort:
                case IfpNodeType.Enumerator16:
                case IfpNodeType.Bitfield16: value = reader.ReadUInt16(); break;

                case IfpNodeType.Int: value = reader.ReadInt32(); break;

                case IfpNodeType.UnsignedInt:
                case IfpNodeType.Enumerator32:
                case IfpNodeType.Bitfield32: value = reader.ReadUInt32(); break;

                case IfpNodeType.Long: reader.ReadInt64(); break;

                case IfpNodeType.UnsignedLong:
                case IfpNodeType.Enumerator64:
                case IfpNodeType.Bitfield64: value = reader.ReadUInt64(); break;

                case IfpNodeType.String32: value = reader.ReadUTF8(32).Trim('\0'); break;

                case IfpNodeType.String64: value = reader.ReadUTF8(64).Trim('\0'); break;

                case IfpNodeType.Unicode128: value = reader.ReadUTF8(128).Trim('\0'); break;

                case IfpNodeType.Unicode256: value = reader.ReadUTF8(256).Trim('\0'); break;

                case IfpNodeType.Tag: value = reader.Read <TagFourCc>(); break;

                case IfpNodeType.TagId: value = reader.Read <TagId>(); break;

                case IfpNodeType.StringId: value = reader.Read <StringId>(); break;

                case IfpNodeType.TagBlock: value = reader.Read <TagBlock>(); break;
                }

            //Return
            return(value);
        }