private static string IntToHex(int number)
        {
            byte[]        bin      = new byte[] { (byte)(number >> 0x18), (byte)(number >> 0x10), (byte)(number >> 8), (byte)number };
            StringBuilder hex      = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();

            MQMessage.BinToHex(bin, 0, bin.Length, hex);
            bool flag = false;

            foreach (char ch in hex.ToString().ToCharArray())
            {
                if (flag || (ch != '0'))
                {
                    flag = true;
                    builder2.Append(ch);
                }
            }
            return(builder2.ToString());
        }
        private void WriteTriplet(StringBuilder output, string name, object value, bool newStyle)
        {
            uint method = 0x106;

            this.TrEntry(method, new object[] { output, name, value, newStyle });
            try
            {
                output.Append("<");
                if (newStyle)
                {
                    output.Append("elt name=\"" + name + "\"");
                }
                else
                {
                    output.Append(name);
                }
                if (value is string)
                {
                    output.Append(">");
                    this.EscapeXMLChars(output, (string)value);
                }
                else if (value is int)
                {
                    output.Append(" dt='i4'>");
                    output.Append((int)value);
                }
                else if (value is short)
                {
                    output.Append(" dt='i2'>");
                    output.Append((short)value);
                }
                else if (value is sbyte)
                {
                    output.Append(" dt='i1'>");
                    output.Append((sbyte)value);
                }
                else if (value is byte)
                {
                    output.Append(" dt='i1'>");
                    output.Append((sbyte)((byte)value));
                }
                else if (value is long)
                {
                    output.Append(" dt='i8'>");
                    output.Append((long)value);
                }
                else if (value is float)
                {
                    output.Append(" dt='r4'>");
                    output.Append((float)value);
                }
                else if (value is double)
                {
                    output.Append(" dt='r8'>");
                    output.Append((double)value);
                }
                else
                {
                    if (value is byte[])
                    {
                        output.Append(" dt='bin.hex'>");
                        try
                        {
                            StringBuilder hex = new StringBuilder();
                            MQMessage.BinToHex((byte[])value, 0, ((byte[])value).Length, hex);
                            output.Append(hex.ToString());
                            goto Label_025A;
                        }
                        catch (Exception exception)
                        {
                            base.TrException(method, exception);
                            throw exception;
                        }
                    }
                    if (value is bool)
                    {
                        output.Append(" dt='boolean'>");
                        output.Append(((bool)value) ? "1" : "0");
                    }
                    else if (value is char)
                    {
                        output.Append(" dt='char'>");
                        this.EscapeXMLChars(output, value.ToString());
                    }
                    else if (value == null)
                    {
                        output.Append(" xsi:nil='true'>");
                    }
                    else
                    {
                        output.Append("<");
                        this.EscapeXMLChars(output, value.ToString());
                    }
                }
Label_025A:
                output.Append("</");
                if (newStyle)
                {
                    output.Append("elt");
                }
                else
                {
                    output.Append(name);
                }
                output.Append(">");
            }
            finally
            {
                base.TrExit(method);
            }
        }
        private void SetContent(RFH2Folder element, object value)
        {
            uint method = 260;

            this.TrEntry(method, new object[] { element, value });
            try
            {
                StringBuilder output = new StringBuilder(10);
                if (value is string)
                {
                    element.SetContent(this.EscapeXMLChars(output, (string)value), 0);
                }
                else if (value is int)
                {
                    element.SetContent(value.ToString(), 5);
                }
                else if (value is short)
                {
                    element.SetContent(value.ToString(), 4);
                }
                else if (value is sbyte)
                {
                    element.SetContent(value.ToString(), 3);
                }
                else if (value is byte)
                {
                    element.SetContent(((sbyte)((byte)value)).ToString(), 3);
                }
                else if (value is long)
                {
                    element.SetContent(value.ToString(), 6);
                }
                else if (value is float)
                {
                    element.SetContent(value.ToString(), 8);
                }
                else if (value is double)
                {
                    element.SetContent(value.ToString(), 9);
                }
                else
                {
                    if (value is byte[])
                    {
                        try
                        {
                            StringBuilder hex = new StringBuilder();
                            MQMessage.BinToHex((byte[])value, 0, ((byte[])value).Length, hex);
                            element.SetContent(hex.ToString(), 2);
                            return;
                        }
                        catch (Exception exception)
                        {
                            base.TrException(method, exception, 1);
                            throw exception;
                        }
                    }
                    if (value is bool)
                    {
                        element.SetContent(value.ToString(), 1);
                    }
                    else if (value == null)
                    {
                        element.SetContent(null);
                    }
                    else
                    {
                        element.SetContent(this.EscapeXMLChars(output, value.ToString()), 0);
                    }
                }
            }
            catch (Exception)
            {
                MQException ex = new MQException(2, 0x9a2);
                base.TrException(method, ex);
                throw ex;
            }
            finally
            {
                base.TrExit(method);
            }
        }
Ejemplo n.º 4
0
        private void CheckForPropertyDescriptorAttributes(ref MQPropertyDescriptor pd, ref XmlTextReader xmlReader)
        {
            uint method = 0xfd;

            this.TrEntry(method, new object[] { pd, xmlReader });
            try
            {
                switch (xmlReader.GetAttribute("context"))
                {
                case "none":
                    pd.Context = 0;
                    break;

                case "user":
                    pd.Context = 1;
                    break;
                }
                string attribute = xmlReader.GetAttribute("support");
                if (attribute != null)
                {
                    StringBuilder hex = new StringBuilder(attribute);
                    byte[]        bin = new byte[attribute.Length / 2];
                    MQMessage.BinToHex(bin, 0, bin.Length, hex);
                    Array.Reverse(bin);
                    pd.Support = BitConverter.ToInt32(bin, 0);
                }
                string str3 = xmlReader.GetAttribute("copy");
                if (str3 != null)
                {
                    foreach (string str4 in str3.Split(new char[] { ',' }))
                    {
                        if (str4 == "none")
                        {
                            pd.CopyOptions = 0;
                        }
                        else if (str4 == "All")
                        {
                            pd.CopyOptions = 1;
                        }
                        else
                        {
                            if (pd.CopyOptions == 0x16)
                            {
                                pd.CopyOptions = 0;
                            }
                            if (str4 == "forward")
                            {
                                pd.CopyOptions += 2;
                            }
                            if (str4 == "reply")
                            {
                                pd.CopyOptions += 8;
                            }
                            if (str4 == "report")
                            {
                                pd.CopyOptions += 0x10;
                            }
                        }
                    }
                }
            }
            finally
            {
                base.TrExit(method);
            }
        }