private void LoadFieldLinksFromDefinitions()
        {
            var linkCollection = SPGENCommon.GetAllOwnAndInheritedFieldLinks(this.ID.ToString(), this.Inherits);

            foreach (KeyValuePair<Guid, XmlElement> kvp in linkCollection)
            {
                var link = new SPGENFieldLinkProperties(kvp.Value);

                _fieldLinks.Add(link, false, false, true);
            }

            if (!this.IsFromSPDefinition)
                return;

            XDocument doc = XDocument.Parse(this.ElementDefinitionXml.OuterXml);

            foreach (XElement element in doc.Descendants())
            {
                if (element.Name.LocalName != "RemoveFieldRef")
                    continue;

                var q = from a in element.Attributes()
                        where a.Name.LocalName.Equals("ID", StringComparison.InvariantCultureIgnoreCase)
                        select a;

                if (q.Count<XAttribute>() == 0)
                    continue;

                Guid id = new Guid(q.First<XAttribute>().Value);

                if (_fieldLinksToRemove.FirstOrDefault<Guid>(l => l == id) != null)
                    continue;

                _fieldLinksToRemove.Add(id);
            }
        }
        internal SPGENFieldLinkProperties Clone()
        {
            SPGENFieldLinkProperties link;
            if (this.IsFromSPDefinition)
            {
                link = new SPGENFieldLinkProperties(this.ElementDefinitionXml);
            }
            else
            {
                link = new SPGENFieldLinkProperties();
            }

            link.DisablePropertyTracking = true;

            link.AggregationFunction = this.AggregationFunction;
            link.Customization = this.Customization;
            link.DisplayName = this.DisplayName;
            link.Hidden = this.Hidden;
            link.ID = this.ID;
            link.InternalName = this.InternalName;
            link.ParentFieldElement = this.ParentFieldElement;
            link.PIAttribute = this.PIAttribute;
            link.PITarget = this.PITarget;
            link.PrimaryPIAttribute = this.PrimaryPIAttribute;
            link.PrimaryPITarget = this.PrimaryPITarget;
            link.ReadOnly = this.ReadOnly;
            link.Required = this.Required;
            link.ShowInDisplayForm = this.ShowInDisplayForm;
            link.XPath = this.XPath;

            foreach (var kvp in this.DynamicProperties)
                link.DynamicProperties.Add(kvp);

            link.DisablePropertyTracking = false;
            return link;
        }