Exemplo n.º 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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GorgonEditorDependency"/> class.
 /// </summary>
 /// <param name="name">The name of the dependency.</param>
 /// <param name="type">The type of dependency.</param>
 internal GorgonEditorDependency(string name, string type)
 {
     Path       = name;
     Properties = new GorgonEditorDependencyPropertyCollection(null);
     Type       = type;
 }