protected override bool OnWrite(XType <DictionaryEntry> xType, IXWriteOperation writer,
                                        DictionaryEntry obj, XElement element, XObjectArgs args)
        {
            XName keyName   = XComponents.Component <XAutoCollections>().KeyName,
                  valueName = XComponents.Component <XAutoCollections>().ValueName;

            if (obj.Key != null)
            {
                element.Add(writer.WriteTo(new XElement(keyName), obj.Key));

                if (obj.Value != default)
                {
                    element.Add(writer.WriteTo(new XElement(valueName), obj.Value));
                }
            }

            return(true);
        }
Beispiel #2
0
        protected override bool OnWrite <T>(IXWriteOperation writer, T obj, XAttribute attribute, XObjectArgs args)
        {
            if (obj != null && Identifier.CanId(obj.GetType()))
            {
                object id = Identifier.GetId(obj);

                if (id != null && referenceObjects.ContainsKey(id))
                {
                    _ = writer.WriteTo(attribute, id);
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        protected override bool OnWrite(IXWriteOperation writer, T[,] obj, XElement element, XObjectArgs args)
        {
            // Get lower bound and length

            int lb = obj.GetLowerBound(0), n = obj.GetLength(0);

            int[] lb1 = new int[1] {
                obj.GetLowerBound(1)
            }, n1 = new int[1] {
                obj.GetLength(1)
            };

            if (lb != 0)
            {
                element.SetAttributeValue(XComponents.Component <XAutoCollections>().ArrayLowerBoundName, XmlTools.Write(lb));
            }

            // Copy each second rank into a new array and write them as 1-dimensional arrays

            for (int i = lb, I = lb + n; i < I; i++)
            {
                T[] dim1 = (T[])Array.CreateInstance(typeof(T), n1, lb1);

                for (int j = lb1[0], J = n1[0]; j < J; j++)
                {
                    dim1[j] = obj[i, j];
                }

                XElement li = writer.WriteTo(new XElement(ItemName), dim1);
                if (lb1[0] != 0)
                {
                    li.SetAttributeValue(XComponents.Component <XAutoCollections>().ArrayLowerBoundName, XmlTools.Write(lb1[0]));
                }
                element.Add(li);
            }

            return(true);
        }
 protected override bool OnWrite(IXWriteOperation writer, LinkedListNode <T> obj, XElement element, XObjectArgs args)
 {
     _ = writer.WriteTo(element, obj.Value);
     return(true);
 }