/// <summary>
        /// Encodes an object.
        /// </summary>
        /// <param name="Object">Object to encode.</param>
        /// <param name="Encoding">Desired encoding of text. Can be null if no desired encoding is speified.</param>
        /// <param name="ContentType">Content Type of encoding. Includes information about any text encodings used.</param>
        /// <param name="AcceptedContentTypes">Optional array of accepted content types. If array is empty, all content types are accepted.</param>
        /// <returns>Encoded object.</returns>
        /// <exception cref="ArgumentException">If the object cannot be encoded.</exception>
        public byte[] Encode(object Object, Encoding Encoding, out string ContentType, params string[] AcceptedContentTypes)
        {
            LinkDocument Doc = Object as LinkDocument;

            if (Doc is null)
            {
                throw new ArgumentException("Object not a CoRE link document.", nameof(Object));
            }

            if (Encoding is null)
            {
                Encoding = Encoding.UTF8;
            }

            ContentType = LinkFormatContentType + "; charset=" + Encoding.WebName;

            return(Encoding.GetBytes(Doc.Text));
        }
Beispiel #2
0
        public async Task CoAP_Client_Test_03_Discover()
        {
            LinkDocument Doc = await this.Get("coap://californium.eclipse.org/.well-known/core") as LinkDocument;

            Assert.IsNotNull(Doc);
        }
        public async Task CoAP_Server_Test_03_Discover()
        {
            LinkDocument Doc = await this.Get("coaps://127.0.0.1/.well-known/core") as LinkDocument;

            Assert.IsNotNull(Doc);
        }