Exemplo n.º 1
0
        public static PropertyWrapper[] GetProperties(ISerializable obj)
        {
            var buf = new List <PropertyWrapper>();

            SerializationInfo info = new SerializationInfo(obj.GetType(), new FormatterConverter());

            obj.GetObjectData(info, new StreamingContext());

            var mData    = (object[])info.GetMemberValue("m_data");
            var mTypes   = (Type[])info.GetMemberValue("m_types");
            var mMembers = (string[])info.GetMemberValue("m_members");
            var indexes  = (Dictionary <string, int>)info.GetMemberValue("m_nameToIndex");

            foreach (var pair in indexes)
            {
                var member = pair.Key;

                if (indexes.ContainsKey(member))
                {
                    var prp = new PropertyWrapper()
                    {
                        PropertyName  = member,
                        PropertyValue = Wrap(mData[indexes[member]])
                    };

                    buf.Add(prp);
                }
            }


            return(buf.ToArray());

            throw new NotImplementedException();
        }
Exemplo n.º 2
0
        private void WriteProperty(XmlTextWriter rwtr, PropertyWrapper prp)
        {
            if (prp.PropertyValue.IsPremitive)
            {
                rwtr.WriteAttributeString(prp.PropertyName, prp.PropertyValue.PrimitiveValue.ToString());
            }

            if (prp.PropertyValue.IsNull)
            {
                rwtr.WriteAttributeString(prp.PropertyName, "x", "null");
            }

            if (prp.PropertyValue.IsArray)
            {
                rwtr.WriteAttributeString(prp.PropertyName, "x", "null");
            }

            if (prp.PropertyValue.IsArray)
            {
            }


            throw new NotImplementedException();
        }