コード例 #1
0
        /// <summary>
        /// Function to deserialize a dependency from an XML node.
        /// </summary>
        /// <param name="element">Element containing the serialized dependency.</param>
        /// <returns>A dependency deserialized from the XML node.</returns>
        internal static GorgonEditorDependency Deserialize(XElement element)
        {
            XAttribute typeAttr = element.Attribute(DependencyTypeAttr);
            XElement   pathNode = element.Element(DependencyPathNode);

            if ((typeAttr == null) ||
                (pathNode == null) ||
                (string.IsNullOrWhiteSpace(typeAttr.Value)) ||
                (string.IsNullOrWhiteSpace(pathNode.Value)))
            {
                throw new GorgonException(GorgonResult.CannotRead, Resources.GORFS_ERR_DEPENDENCY_CORRUPT);
            }

            var result = new GorgonEditorDependency(pathNode.Value, typeAttr.Value);

            XElement propertiesNode = element.Element(GorgonEditorDependencyPropertyCollection.PropertiesNode);

            if (propertiesNode != null)
            {
                result.Properties = GorgonEditorDependencyPropertyCollection.Deserialize(propertiesNode);
            }

            return(result);
        }