YAXLib.YAXSerializer.MakeBaseElement C# (CSharp) Method

MakeBaseElement() private method

Makes an XML element with the specified name, corresponding to the object specified.
private MakeBaseElement ( XElement insertionLocation, XName name, object value, bool &alreadyAdded ) : XElement
insertionLocation XElement The insertion location.
name XName The name of the element.
value object The object to be serialized in an XML element.
alreadyAdded bool if set to true specifies the element returned is /// already added to the parent element and should not be added once more.
return XElement
        private XElement MakeBaseElement(XElement insertionLocation, XName name, object value, out bool alreadyAdded)
        {
            alreadyAdded = false;
            if (value == null || ReflectionUtils.IsBasicType(value.GetType()))
            {
                if (value != null)
                    value = value.ToXmlValue();

                return new XElement(name, value);
            }
            else if (ReflectionUtils.IsStringConvertibleIFormattable(value.GetType()))
            {
                object elementValue = value.GetType().InvokeMember("ToString", BindingFlags.InvokeMethod, null, value, new object[0]);
                return new XElement(name, elementValue);
            }
            else
            {
                var ser = NewInternalSerializer(value.GetType(), name.Namespace, insertionLocation);
                XElement elem = ser.SerializeBase(value, name);
                FinalizeNewSerializer(ser, true);
                alreadyAdded = true;
                return elem;
            }
        }