Exemple #1
0
        public CompositeType(SerializationInfo info, StreamingContext ctxt)
            : base(info, ctxt)
        {
            int i;
            int field_count     = info.GetInt32("_num_fields");
            int operation_count = info.GetInt32("_num_operations");

            RaiseChangedEvent = false;
            for (i = 0; i < field_count; i++)
            {
                Field field = AddField();
                field.InitFromString(
                    info.GetString("_field" + i));
            }
            for (i = 0; i < operation_count; i++)
            {
                Operation operation = GetOperation(
                    info.GetString("_operation_type" + i));

                if (operation == null)
                {
                    throw new InvalidDataException(
                              Strings.GetString("error_corrupt_save_format"));
                }
                operation.InitFromString(
                    info.GetString("_operation" + i));
            }

            RaiseChangedEvent = true;
        }
Exemple #2
0
        /// <exception cref="BadSyntaxException">
        /// An error occured while deserializing.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The XML document is corrupt.
        /// </exception>
        protected internal override void Deserialize(XmlElement node)
        {
            RaisePreChangedEvent = RaiseChangedEvent = false;

            foreach (XmlElement childNode in node.SelectNodes("Member|Field|Operation"))
            {
                string type = childNode.GetAttribute("type");

                if (type == "Field" || type == "CSharpField")
                {
                    Field field = AddField();
                    field.InitFromString(childNode.InnerText);
                }
                else
                {
                    Operation operation = GetOperation(type);

                    if (operation == null)
                    {
                        throw new InvalidDataException(
                                  Strings.ErrorCorruptSaveFormat);
                    }
                    operation.InitFromString(childNode.InnerText);
                }
            }

            base.Deserialize(node);
            RaisePreChangedEvent = RaiseChangedEvent = true;
        }
Exemple #3
0
        /// <exception cref="BadSyntaxException">
        /// An error occured while deserializing.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The XML document is corrupt.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="node"/> is null.
        /// </exception>
        protected internal override void Deserialize(XmlElement node)
        {
            RaiseChangedEvent = false;

            foreach (XmlElement childNode in node.SelectNodes("Member|Field|Operation"))             // old file format
            {
                string type = childNode.GetAttribute("type");

                if (type == "Field" || type == "CSharpField" || type == "JavaField")
                {
                    Field field = AddField();
                    field.InitFromString(childNode.InnerText);
                }
                else
                {
                    Operation operation = GetOperation(type);

                    if (operation == null)
                    {
                        throw new InvalidDataException(
                                  Strings.ErrorCorruptSaveFormat);
                    }
                    operation.InitFromString(childNode.InnerText);

                    if (operation is Property)
                    {
                        operation.NHMColumnName = childNode.GetAttribute("nhmColumnName");
                        operation.IsIdentity    = (childNode.GetAttribute("isIdentity") == "True") ? true : false;
                        operation.ManyToOne     = childNode.GetAttribute("manyToOne");
                        operation.IsUnique      = (childNode.GetAttribute("isUnique") == "True") ? true : false;
                        operation.IsNotNull     = (childNode.GetAttribute("isNotNull") == "True") ? true : false;
                    }
                }
            }

            base.Deserialize(node);
            RaiseChangedEvent = true;
        }