@@ -1371,41 +1371,39 @@ Converts this CBOR object to an object of an arbitrary type. See the
13711371 for Plain-Old-Data deserialization, then this method checks the
13721372 given type for eligible setters as follows:</li > <li >(* ) In the .NET
13731373 version, eligible setters are the public, nonstatic setters of
1374- properties with a public, nonstatic getter. If a class has two
1375- properties of the form "X" and "IsX", where "X" is any name, or has
1376- multiple properties with the same name, those properties are
1377- ignored.</li > <li >(* ) In the Java version, eligible setters are
1378- public, nonstatic methods starting with "set" followed by a
1379- character other than a basic digit or lower-case letter, that is,
1380- other than "a" to "z" or "0" to "9", that take one parameter. The
1381- class containing an eligible setter must have a public, nonstatic
1382- method with the same name, but starting with "get" or "is" rather
1383- than "set", that takes no parameters and does not return void. (For
1384- example, if a class has "public setValue(string)" and "public
1385- getValue()", "setValue" is an eligible setter. However, "setValue()"
1386- and "setValue(string, int)" are not eligible setters.) If a class
1387- has two or more otherwise eligible setters with the same name, but
1388- different parameter type, they are not eligible setters.</li >
1389- <li >Then, the method creates an object of the given type and invokes
1390- each eligible setter with the corresponding value in the CBOR map,
1391- if any. Key names in the map are matched to eligible setters
1392- according to the rules described in the <code >PODOptions</code > documentation. Note that for
1374+ properties with a public, nonstatic getter. Eligible setters also
1375+ include public, nonstatic, non- <code >readonly</code > fields. If a class
1376+ has two properties and/or fields of the form "X" and "IsX", where
1377+ "X" is any name, or has multiple properties and/or fields with the
1378+ same name, those properties and fields are ignored.</li > <li >(* ) In
1379+ the Java version, eligible setters are public, nonstatic methods
1380+ starting with "set" followed by a character other than a basic digit
1381+ or lower-case letter, that is, other than "a" to "z" or "0" to "9",
1382+ that take one parameter. The class containing an eligible setter
1383+ must have a public, nonstatic method with the same name, but
1384+ starting with "get" or "is" rather than "set", that takes no
1385+ parameters and does not return void. (For example, if a class has
1386+ "public setValue(string)" and "public getValue()", "setValue" is an
1387+ eligible setter. However, "setValue()" and "setValue(string, int)"
1388+ are not eligible setters.) In addition, public, nonstatic, nonfinal
1389+ fields are also eligible setters. If a class has two or more
1390+ otherwise eligible setters (methods and/or fields) with the same
1391+ name, but different parameter type, they are not eligible
1392+ setters.</li > <li >Then, the method creates an object of the given
1393+ type and invokes each eligible setter with the corresponding value
1394+ in the CBOR map, if any. Key names in the map are matched to
1395+ eligible setters according to the rules described in the <code >PODOptions</code > documentation. Note that for
13931396 security reasons, certain types are not supported even if they
1394- contain eligible setters.</li > </ul > <p >REMARK: A certain
1395- consistency between .NET and Java and between FromObject and
1396- ToObject are sought for version 4.0. It is also hoped that the
1397- ToObject method will support deserializing to objects consisting of
1398- fields and not getters ("getX()" methods), both in .NET and in
1399- Java.</p ><p > </p ><p >Java offers no easy way to express a generic type,
1400- at least none as easy as C#'s <code >typeof</code > operator. The following
1401- example, written in Java, is a way to specify that the return value
1402- will be an ArrayList of string objects.</p > <pre >Type
1403- arrayListString = new ParameterizedType() { public Type[ ]
1404- getActualTypeArguments() { // Contains one type parameter, string
1405- return new Type[ ] { string.class }; } public Type getRawType() { /*
1406- Raw type is ArrayList * / return ArrayList.class; } public Type
1407- getOwnerType() { return null; } }; ArrayList< ; string> ; array =
1408- (ArrayList< ; string> ; )
1397+ contain eligible setters.</li > </ul ><p > </p ><p >Java offers no easy way
1398+ to express a generic type, at least none as easy as C#'s
1399+ <code >typeof</code > operator. The following example, written in Java, is a
1400+ way to specify that the return value will be an ArrayList of string
1401+ objects.</p > <pre >Type arrayListString = new ParameterizedType() {
1402+ public Type[ ] getActualTypeArguments() { // Contains one type
1403+ parameter, string return new Type[ ] { string.class }; } public Type
1404+ getRawType() { /* Raw type is ArrayList * / return ArrayList.class; }
1405+ public Type getOwnerType() { return null; } };
1406+ ArrayList< ; string> ; array = (ArrayList< ; string> ; )
14091407 cborArray.ToObject(arrayListString);</pre > <p >By comparison, the C#
14101408 version is much shorter.</p > <pre >List< ; string> ; array =
14111409 (List< ; string> ; )cborArray.ToObject(
@@ -1832,24 +1830,27 @@ Generates a CBORObject from an arbitrary object. See the overload of this
18321830 specially handled above, this method checks the <paramref name =' obj ' /> parameter for eligible getters as follows:</li > <li >(* )
18331831 In the .NET version, eligible getters are the public, nonstatic
18341832 getters of read/write properties (and also those of read-only
1835- properties in the case of a compiler-generated type). If a class has
1836- two properties of the form "X" and "IsX", where "X" is any name, or
1837- has multiple properties with the same name, those properties are
1833+ properties in the case of a compiler-generated type). Eligible
1834+ getters also include public, nonstatic, non- <code >readonly</code > fields.
1835+ If a class has two properties and/or fields of the form "X" and
1836+ "IsX", where "X" is any name, or has multiple properties and/or
1837+ fields with the same name, those properties and fields are
18381838 ignored.</li > <li >(* ) In the Java version, eligible getters are
18391839 public, nonstatic methods starting with "get" or "is" (either word
18401840 followed by a character other than a basic digit or lower-case
18411841 letter, that is, other than "a" to "z" or "0" to "9"), that take no
18421842 parameters and do not return void, except that methods named
1843- "getClass" are not eligible getters. If a class has two otherwise
1844- eligible getters of the form "isX" and "getX", where "X" is the same
1845- in both, or two such getters with the same name but different return
1846- type, they are not eligible getters.</li > <li >Then, the method
1847- returns a CBOR map with each eligible getter's name or property name
1848- as each key, and with the corresponding value returned by that
1849- getter as that key's value. Before adding a key-value pair to the
1850- map, the key's name is adjusted according to the rules described in
1851- the <code >PODOptions</code > documentation. Note that
1852- for security reasons, certain types are not supported even if they
1843+ "getClass" are not eligible getters. In addition, public, nonstatic,
1844+ nonfinal fields are also eligible getters. If a class has two
1845+ otherwise eligible getters (methods and/or fields) of the form "isX"
1846+ and "getX", where "X" is the same in both, or two such getters with
1847+ the same name but different return type, they are not eligible
1848+ getters.</li > <li >Then, the method returns a CBOR map with each
1849+ eligible getter's name or property name as each key, and with the
1850+ corresponding value returned by that getter as that key's value.
1851+ Before adding a key-value pair to the map, the key's name is
1852+ adjusted according to the rules described in the <code >PODOptions</code > documentation. Note that for
1853+ security reasons, certain types are not supported even if they
18531854 contain eligible getters.</li ></ul > <p ><b >REMARK:</b >.NET
18541855 enumeration (<code >Enum</code >) constants could also have been converted
18551856 to text strings with <code >toString()</code >, but that method will return
@@ -1859,11 +1860,6 @@ Generates a CBORObject from an arbitrary object. See the overload of this
18591860 text strings, constants from Enum types with the <code >Flags</code >
18601861 attribute, and constants from the same Enum type that share an
18611862 underlying value, should not be passed to this method.</p >
1862- <p >REMARK: A certain consistency between .NET and Java and between
1863- FromObject and ToObject are sought for version 4.0. It is also hoped
1864- that the ToObject method will support deserializing to objects
1865- consisting of fields and not getters ("getX()" methods), both in
1866- .NET and in Java.</p >
18671863
18681864** Parameters:**
18691865
@@ -3201,9 +3197,10 @@ Determines whether a value of the given key exists in this object.
32013197 or is a CBOR map itself, the keys to the map are written out to the
32023198 byte array in an undefined order. The example code given in <see cref =' PeterO.Cbor.CBORObject.WriteTo(System.IO.InputStream) ' /> can be
32033199 used to write out certain keys of a CBOR map in a given order. For
3204- the CTAP2 canonical ordering, which is useful for implementing Web
3205- Authentication, call <code >EncodeToBytes(new CBOREncodeOptions(false,
3206- false, true))</code > rather than this method.</p >
3200+ the CTAP2 (FIDO Client-to-Authenticator Protocol 2) canonical
3201+ ordering, which is useful for implementing Web Authentication, call
3202+ <code >EncodeToBytes(new CBOREncodeOptions("ctap2canonical=true"))</code >
3203+ rather than this method.</p >
32073204
32083205** Returns:**
32093206
@@ -3213,10 +3210,11 @@ Determines whether a value of the given key exists in this object.
32133210 public byte[] EncodeToBytes(CBOREncodeOptions options)
32143211Writes the binary representation of this CBOR object and returns a byte
32153212 array of that representation, using the specified options for
3216- encoding the object to CBOR format. For the CTAP2 canonical
3217- ordering, which is useful for implementing Web Authentication, call
3218- this method as follows: <code >EncodeToBytes(new
3219- CBOREncodeOptions(false, false, true))</code >.
3213+ encoding the object to CBOR format. For the CTAP2 (FIDO
3214+ Client-to-Authenticator Protocol 2) canonical ordering, which is
3215+ useful for implementing Web Authentication, call this method as
3216+ follows: <code >EncodeToBytes(new
3217+ CBOREncodeOptions("ctap2canonical=true"))</code >.
32203218
32213219** Parameters:**
32223220
0 commit comments