/// <summary>
        /// Initializes a new instance of the <see cref="TranslationContainer"/> class.
        /// </summary>
        /// <param name="id">The Id of the container.</param>
        /// <param name="canOverrideNotes">True if notes can be replaced during deserialization, false if they cannot.
        /// </param>
        internal TranslationContainer(string id, bool canOverrideNotes)
        {
            this.RegisterElementInformation(ElementInformationFromReflection.Create(this));
            this.EnableAttribute(TranslationContainer.PropertyNames.EquivalentStorage, false);

            this.extensions    = new Lazy <List <IExtension> >();
            this.noteContainer = new NoteContainer();
            Utilities.SetParent(this.noteContainer, this);

            this.Id             = id;
            this.SubFormatStyle = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            this.storedNotes    = !canOverrideNotes;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="File"/> class.
        /// </summary>
        /// <param name="id">The Id of the file.</param>
        public File(string id)
        {
            this.RegisterElementInformation(ElementInformationFromReflection.Create(this));

            this.extensions    = new Lazy <List <IExtension> >();
            this.noteContainer = new NoteContainer();
            Utilities.SetParent(this.noteContainer, this);

            this.Containers     = new ParentAttachedList <TranslationContainer>(this);
            this.Id             = id;
            this.SubFormatStyle = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            this.storedNotes = true;

            this.EnableAttribute(File.PropertyNames.EquivalentStorage, false);
        }
        /// <summary>
        /// Stores the <see cref="XliffElement"/> as a child of this <see cref="XliffElement"/>.
        /// </summary>
        /// <param name="child">The child to add.</param>
        /// <returns>True if the child was stored, otherwise false.</returns>
        protected override bool StoreChild(ElementInfo child)
        {
            bool result;

            result = true;
            if (child.Element is ChangeTrack)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Changes, this.Changes);
                this.Changes = (ChangeTrack)child.Element;
            }
            else if (child.Element is MetadataContainer)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Metadata, this.Metadata);
                this.Metadata = (MetadataContainer)child.Element;
            }
            else if (child.Element is NoteContainer)
            {
                if (this.storedNotes)
                {
                    Utilities.ThrowIfPropertyNotNull(this, "Notes", this.noteContainer);
                }

                this.noteContainer = child.Element as NoteContainer;
                Utilities.SetParent(this.noteContainer, this);
                this.storedNotes = true;
            }
            else if (child.Element is ProfileData)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.ProfileData, this.ProfileData);
                this.ProfileData = (ProfileData)child.Element;
            }
            else if (child.Element is Validation)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.ValidationRules, this.ValidationRules);
                this.ValidationRules = (Validation)child.Element;
            }
            else
            {
                result = base.StoreChild(child);
            }

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stores the <see cref="XliffElement"/> as a child of this <see cref="XliffElement"/>.
        /// </summary>
        /// <param name="child">The child to add.</param>
        /// <returns>True if the child was stored, otherwise false.</returns>
        protected override bool StoreChild(ElementInfo child)
        {
            bool result;

            result = true;
            if (child.Element is ChangeTrack)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Changes, this.Changes);
                this.Changes = (ChangeTrack)child.Element;
            }
            else if (child.Element is MetadataContainer)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Metadata, this.Metadata);
                this.Metadata = (MetadataContainer)child.Element;
            }
            else if (child.Element is ProfileData)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.ProfileData, this.ProfileData);
                this.ProfileData = (ProfileData)child.Element;
            }
            else if (child.Element is Profiles)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.RestrictionProfiles, this.RestrictionProfiles);
                this.RestrictionProfiles = (Profiles)child.Element;
            }
            else if (child.Element is ResourceData)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.ResourceData, this.ResourceData);
                this.ResourceData = (ResourceData)child.Element;
            }
            else if (child.Element is TranslationContainer)
            {
                this.Containers.Add((TranslationContainer)child.Element);
            }
            else if (child.Element is NoteContainer)
            {
                if (this.storedNotes)
                {
                    Utilities.ThrowIfPropertyNotNull(this, "Notes", this.noteContainer);
                }

                this.noteContainer = child.Element as NoteContainer;
                Utilities.SetParent(this.noteContainer, this);
                this.storedNotes = true;
            }
            else if (child.Element is Skeleton)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Skeleton, this.Skeleton);
                this.Skeleton = child.Element as Skeleton;
                Utilities.SetParent(this.Skeleton, this);
            }
            else if (child.Element is Validation)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.ValidationRules, this.ValidationRules);
                this.ValidationRules = (Validation)child.Element;
            }
            else
            {
                result = base.StoreChild(child);
            }

            return result;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="File"/> class.
        /// </summary>
        /// <param name="id">The Id of the file.</param>
        public File(string id)
        {
            this.RegisterElementInformation(ElementInformationFromReflection.Create(this));

            this.extensions = new Lazy<List<IExtension>>();
            this.noteContainer = new NoteContainer();
            Utilities.SetParent(this.noteContainer, this);

            this.Containers = new ParentAttachedList<TranslationContainer>(this);
            this.Id = id;
            this.SubFormatStyle = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

            this.storedNotes = true;

            this.EnableAttribute(File.PropertyNames.EquivalentStorage, false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TranslationContainer"/> class.
        /// </summary>
        /// <param name="id">The Id of the container.</param>
        /// <param name="canOverrideNotes">True if notes can be replaced during deserialization, false if they cannot.
        /// </param>
        internal TranslationContainer(string id, bool canOverrideNotes)
        {
            this.RegisterElementInformation(ElementInformationFromReflection.Create(this));
            this.EnableAttribute(TranslationContainer.PropertyNames.EquivalentStorage, false);

            this.extensions = new Lazy<List<IExtension>>();
            this.noteContainer = new NoteContainer();
            Utilities.SetParent(this.noteContainer, this);

            this.Id = id;
            this.SubFormatStyle = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            this.storedNotes = !canOverrideNotes;
        }