Example #1
0
    public double Calc(XmlReader xr)
    {
        Decimal dResult = 0;	// Numerical value of the checksum
        int i = 0;				// Generic counter
        int iLength = 0;		// Length of the data
        CXmlCache xc;			// Cached output from XslTransform

        _strXml = "";

        // Load the data into the cache
        xc = new CXmlCache();
        xc.ExpandAttributeValues = true;
        xc.Trace = _fTrace;

        xc.Load(xr);
        _strXml = xc.Xml;

        // If there is data to write and omit-xml-declaration is "no", then write the XmlDecl to the stream

        if (_strXml.Length > 0)
            _strXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + _strXml;

        // Calculate the checksum
        iLength = _strXml.Length;

        for (i = 0; i < iLength; i++)
        {
            dResult += Math.Round((Decimal)(_strXml[i] / (i + 1.0)), 10);
            //_output.WriteLine("#{0}({1})", _strXml[i].ToByte(), dResult);
        }
        return Convert.ToDouble(dResult, NumberFormatInfo.InvariantInfo);
    }
Example #2
0
    public double Calc(XmlReader xr)
    {
        Decimal   dResult = 0;  // Numerical value of the checksum
        int       i       = 0;  // Generic counter
        int       iLength = 0;  // Length of the data
        CXmlCache xc;           // Cached output from XslTransform

        _strXml = "";

        // Load the data into the cache
        xc = new CXmlCache();
        xc.ExpandAttributeValues = true;
        xc.Trace = _fTrace;

        xc.Load(xr);
        _strXml = xc.Xml;

        // If there is data to write and omit-xml-declaration is "no", then write the XmlDecl to the stream

        if (_strXml.Length > 0)
        {
            _strXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + _strXml;
        }

        // Calculate the checksum
        iLength = _strXml.Length;

        for (i = 0; i < iLength; i++)
        {
            dResult += Math.Round((Decimal)(_strXml[i] / (i + 1.0)), 10);
            //_output.WriteLine("#{0}({1})", _strXml[i].ToByte(), dResult);
        }
        return(Convert.ToDouble(dResult, NumberFormatInfo.InvariantInfo));
    }