<commit_before>//  ------------------------------------------------------------------------------------
//  Copyright (c) Microsoft Corporation
//  All rights reserved. 
//  
//  Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this 
//  file except in compliance with the License. You may obtain a copy of the License at 
//  http://www.apache.org/licenses/LICENSE-2.0  
//  
//  THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
//  EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR 
//  CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR 
//  NON-INFRINGEMENT. 
// 
//  See the Apache Version 2.0 License for specific language governing permissions and 
//  limitations under the License.
//  ------------------------------------------------------------------------------------

namespace Amqp.Types
{
    using System;
    using System.Collections;
#if !NETMF
    using System.Collections.Generic;
#endif
    using System.Text;
    using System.Globalization;

    /// <summary>
    /// The delegate to create a described object.
    /// </summary>
    /// <returns></returns>
    public delegate Described CreateDescribed();

    /// <summary>
    /// The delegate to encode an object into a buffer.
    /// </summary>
    /// <param name="buffer">The buffer to write the encoded object.</param>
    /// <param name="value">The object to be written.</param>
    /// <param name="smallEncoding">If true, use compact encoding when possible.</param>
    public delegate void Encode(ByteBuffer buffer, object value, bool smallEncoding);

    /// <summary>
    /// The delegate to decode an object from a buffer.
    /// </summary>
    /// <param name="buffer">The buffer to read the object.</param>
    /// <param name="formatCode">The format code of the expected object type.</param>
    /// <returns>An object decoded from the buffer.</returns>
    public delegate object Decode(ByteBuffer buffer, byte formatCode);

    /// <summary>
    /// Encodes or decodes AMQP types.
    /// </summary>
    public static class Encoder
    {
        class Serializer
        {
            public Type Type;
            public Encode Encoder;
            public Decode Decoder;
        }

#if NETMF
        // NETMF DateTime ticks origin is 1601/1/1
        const long epochTicks = 116444736000000000; // 1970-1-1 00:00:00 UTC
#else
        const long epochTicks = 621355968000000000; // 1970-1-1 00:00:00 UTC
#endif
        internal const long TicksPerMillisecond = 10000;
        static Serializer[] serializers;
        static Map codecByType;
        static byte[][] codecIndexTable;
        static Map knownDescribed;<commit_msg>Update Encoder.cs (#435)<commit_after>//  ------------------------------------------------------------------------------------
//  Copyright (c) Microsoft Corporation
//  All rights reserved. 
//  
//  Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this 
//  file except in compliance with the License. You may obtain a copy of the License at 
//  http://www.apache.org/licenses/LICENSE-2.0  
//  
//  THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
//  EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR 
//  CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR 
//  NON-INFRINGEMENT. 
// 
//  See the Apache Version 2.0 License for specific language governing permissions and 
//  limitations under the License.
//  ------------------------------------------------------------------------------------

namespace Amqp.Types
{
    using System;
    using System.Collections;
#if !NETMF
    using System.Collections.Generic;
#endif
    using System.Text;
    using System.Globalization;

    /// <summary>
    /// The delegate to create a described object.
    /// </summary>
    /// <returns></returns>
    public delegate Described CreateDescribed();

    /// <summary>
    /// The delegate to encode an object into a buffer.
    /// </summary>
    /// <param name="buffer">The buffer to write the encoded object.</param>
    /// <param name="value">The object to be written.</param>
    /// <param name="smallEncoding">If true, use compact encoding when possible.</param>
    public delegate void Encode(ByteBuffer buffer, object value, bool smallEncoding);

    /// <summary>
    /// The delegate to decode an object from a buffer.
    /// </summary>
    /// <param name="buffer">The buffer to read the object.</param>
    /// <param name="formatCode">The format code of the expected object type.</param>
    /// <returns>An object decoded from the buffer.</returns>
    public delegate object Decode(ByteBuffer buffer, byte formatCode);

    /// <summary>
    /// Encodes or decodes AMQP types.
    /// </summary>
    public static class Encoder
    {
        class Serializer
        {
            public Type Type;
            public Encode Encoder;
            public Decode Decoder;
        }

#if NETMF && !NANOFRAMEWORK_1_0 
        // NETMF DateTime ticks origin is 1601/1/1
        const long epochTicks = 116444736000000000; // 1970-1-1 00:00:00 UTC
#else
        const long epochTicks = 621355968000000000; // 1970-1-1 00:00:00 UTC
#endif
        internal const long TicksPerMillisecond = 10000;
        static Serializer[] serializers;
        static Map codecByType;
        static byte[][] codecIndexTable;
        static Map knownDescribed;
{'fraction_non_alphanumeric': 0.16123778501628663, 'fraction_numerical': 0.028773072747014114, 'mean_word_length': 2.075681691708403, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6397323', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1409, 'n_words': 532}