Beispiel #1
0
        /// <summary>
        /// Helper function that will allow a surrogate to check to see if a collection should be treated
        /// as if it were an interface as opposed to being treated as a full class.
        /// </summary>
        /// <param name="_framework">The (de)serialization framework in charge of this operation</param>
        /// <returns>TRUE if the collection SHOULD be treated as if it were a simple interface</returns>
        public static bool TreatAsInterface(CFramework _framework)
        {
            var attr = _framework.GetAttribute <ATreatAsInterface>();

            if (attr == null)
            {
                return(true);
            }

            return(attr.UseSpecialSerialization);
        }
Beispiel #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // The rest of the file contains the code to actually serialize or deserialize using the data constructed above. //
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


        /// <summary>
        /// Create the parameter array for an implicit surrogate using the data created by the rest of this class.
        /// </summary>
        /// <param name="_implicit">The implicit surrogate</param>
        /// <param name="_xmlToSerializeTo">The XML that the object will serialize itself to</param>
        /// <param name="_framework">The Context that the object will use (optionally) to serialize the data.</param>
        /// <param name="_object">The "Working Object" useful to a deserializer</param>
        /// <returns>an object[] containing the parameter data as dictated by the implicitSurrogate object</returns>
        private static object[] BuildParamArray(CImplicitSurrogate _implicit,
                                                XmlElement _xmlToSerializeTo,
                                                CFramework _framework,
                                                CWorkingObject _object)
        {
            var arr = new object[_implicit.m_parameterCount];

            arr[_implicit.m_indexXml] = _xmlToSerializeTo;

            if (_implicit.m_indexFramework != -1)
            {
                arr[_implicit.m_indexFramework] = _framework;
            }

            if (_implicit.m_indexObject != -1)
            {
                arr[_implicit.m_indexObject] = _object;
            }

            return(arr);
        }
Beispiel #3
0
        /// <summary>
        /// Deserialize an object of this type.
        /// </summary>
        /// <param name="_object">A reference to an object that is being deserialized. NULL --> The serializer needs to create the object!</param>
        /// <param name="_xml">The XML node that contains the data for the deserialization</param>
        /// <param name="_framework">The serialization context to help with deserialization</param>
        /// <returns>TRUE if the deserialization is complete, FALSE if the framework needs to complete the deserialization</returns>
        internal bool Deserialize(CWorkingObject _object, XmlElement _xml, CFramework _framework)
        {
            var surrogate = m_implicitDeserializer;

            if (surrogate == null)
            {
                return(false);
            }

            var paramArray = BuildParamArray(surrogate, _xml, _framework, _object);

            var isComplete = surrogate.m_method.Invoke(null, paramArray);   // deserializer is always a static method

            if (isComplete is bool)
            {
                return((bool)isComplete);
            }
            else
            {
                return(true);
            }
            // An implicit deserializer is assumed to completely serialize the Type and all base classes unless explicitly stated otherwise.
        }
Beispiel #4
0
 public void IncorrectSerializer(CFramework _framework)
 {
 }