예제 #1
0
        public override CBORObject EncodeToCBORObject(Cori coriBase, CoralDictionary dictionary)
        {
            CBORObject node = CBORObject.NewArray();

            node.Add(3);
            node.Add(dictionary.Lookup(OperationType, false));

            CBORObject o = dictionary.Lookup(Target, false);

            if (o.Type == CBORType.Integer)
            {
                node.Add(o);
            }
            else
            {
                node.Add(Target.MakeRelative(coriBase).Data);
            }

            if (FormFields.Count > 0)
            {
                CBORObject fields = CBORObject.NewArray();
                foreach (CoralFormField f in FormFields)
                {
                    f.EncodeToCBOR(fields, coriBase, dictionary);
                }

                node.Add(fields);
            }

            return(node);
        }
예제 #2
0
        // link = [2, relation-type, link-target, ?body]
        // relation-type = text
        // link-target = CoRI / literal
        // CoRI = <Defined in Section X of RFC XXXX>
        // literal = bool / int / float / time / bytes / text / null

        public override CBORObject EncodeToCBORObject(Cori coriBase, CoralDictionary dictionary)
        {
            CBORObject node = CBORObject.NewArray();

            node.Add(2);
            if (RelationType != null)
            {
                node.Add(dictionary.Lookup(RelationType, false));
            }
            else
            {
                node.Add(RelationTypeInt);
            }


            if (Target != null)
            {
                CBORObject o = dictionary.Lookup(Target, true);
                if (o.Type == CBORType.Integer)
                {
                    node.Add(o);
                }
                else
                {
                    if (coriBase != null)
                    {
                        Cori relative = Target.MakeRelative(coriBase);
                        node.Add(relative.Data);
                    }
                    else
                    {
                        node.Add(Target.Data);
                    }
                }
            }
            else if (Value != null)
            {
                node.Add(dictionary.Lookup(Value, true));
            }
            else if (TargetInt != null)
            {
                node.Add(CBORObject.FromObjectAndTag(TargetInt, CoralDictionary.DictionaryTag));
            }

            if (Body != null)
            {
                node.Add(Body.EncodeToCBORObject(coriBase, dictionary));
            }

            return(node);
        }
예제 #3
0
        public override CBORObject EncodeToCBORObject(CoralDictionary dictionary)
        {
            CBORObject node = CBORObject.NewArray();

            node.Add(3);
            node.Add(dictionary.Lookup(_operationType));
            node.Add(dictionary.Lookup(_target));
            if (Body.Length > 0)
            {
                node.Add(Body.EncodeToCBORObject(dictionary));
            }

            return(node);
        }
예제 #4
0
        public override CBORObject EncodeToCBORObject(CoralDictionary dictionary)
        {
            CBORObject node = CBORObject.NewArray();

            node.Add(2);
            node.Add(dictionary.Lookup(RelationType));
            node.Add(dictionary.Lookup(Target));
            if (Body != null)
            {
                node.Add(Body.EncodeToCBORObject(dictionary));
            }

            return(node);
        }
예제 #5
0
        public CBORObject EncodeToCBOR(CBORObject fieldArray, Cori baseCori, CoralDictionary dictionary)
        {
            fieldArray.Add(dictionary.Lookup(FieldType, false));

            if (Literal != null)
            {
                fieldArray.Add(dictionary.Lookup(Literal, true));
            }
            else
            {
                CBORObject x = dictionary.Lookup(Url, true);
                if (x.Type == CBORType.Integer)
                {
                    fieldArray.Add(x);
                }
                else
                {
                    fieldArray.Add(Url.MakeRelative(baseCori).Data);
                }
            }

            return(fieldArray);
        }