示例#1
0
        /// <summary>
        /// Returns the <see cref="FeedSynchronizationRelatedInformationType"/> enumeration value that corresponds to the specified relation type name.
        /// </summary>
        /// <param name="name">The name of the relation type.</param>
        /// <returns>A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration value that corresponds to the specified string, otherwise returns <b>FeedSynchronizationRelatedInformationType.None</b>.</returns>
        /// <remarks>This method disregards case of specified relation type name.</remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="name"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="name"/> is an empty string.</exception>
        public static FeedSynchronizationRelatedInformationType RelationTypeByName(string name)
        {
            FeedSynchronizationRelatedInformationType relationType = FeedSynchronizationRelatedInformationType.None;

            Guard.ArgumentNotNullOrEmptyString(name, "name");
            foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationRelatedInformationType).GetFields())
            {
                if (fieldInfo.FieldType == typeof(FeedSynchronizationRelatedInformationType))
                {
                    FeedSynchronizationRelatedInformationType type = (FeedSynchronizationRelatedInformationType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name);
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false);

                    if (customAttributes != null && customAttributes.Length > 0)
                    {
                        EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute;

                        if (String.Compare(name, enumerationMetadata.AlternateValue, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            relationType = type;
                            break;
                        }
                    }
                }
            }

            return(relationType);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <param name="title">The name or description of this related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type, string title) : this(link, type)
 {
     //------------------------------------------------------------
     //	Initialize class state using guarded properties
     //------------------------------------------------------------
     this.Title = title;
 }
示例#3
0
        /// <summary>
        /// Returns the relation type identifier for the supplied <see cref="FeedSynchronizationRelatedInformationType"/>.
        /// </summary>
        /// <param name="type">The <see cref="FeedSynchronizationRelatedInformationType"/> to get the relation type identifier for.</param>
        /// <returns>The relation type identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns>
        public static string RelationTypeAsString(FeedSynchronizationRelatedInformationType type)
        {
            string name = String.Empty;

            foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationRelatedInformationType).GetFields())
            {
                if (fieldInfo.FieldType == typeof(FeedSynchronizationRelatedInformationType))
                {
                    FeedSynchronizationRelatedInformationType relationType = (FeedSynchronizationRelatedInformationType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name);

                    if (relationType == type)
                    {
                        object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false);

                        if (customAttributes != null && customAttributes.Length > 0)
                        {
                            EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute;

                            name = enumerationMetadata.AlternateValue;
                            break;
                        }
                    }
                }
            }

            return(name);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type)
 {
     //------------------------------------------------------------
     //	Initialize class state using guarded properties
     //------------------------------------------------------------
     this.Link           = link;
     this.RelationType   = type;
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type)
 {
     //------------------------------------------------------------
     //	Initialize class state using guarded properties
     //------------------------------------------------------------
     this.Link         = link;
     this.RelationType = type;
 }
示例#6
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="FeedSynchronizationRelatedInformation"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="FeedSynchronizationRelatedInformation"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="FeedSynchronizationRelatedInformation"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasAttributes)
            {
                string linkAttribute  = source.GetAttribute("link", String.Empty);
                string titleAttribute = source.GetAttribute("title", String.Empty);
                string typeAttribute  = source.GetAttribute("type", String.Empty);

                if (!String.IsNullOrEmpty(linkAttribute))
                {
                    Uri link;
                    if (Uri.TryCreate(linkAttribute, UriKind.Absolute, out link))
                    {
                        this.Link = link;
                        wasLoaded = true;
                    }
                }

                if (!String.IsNullOrEmpty(titleAttribute))
                {
                    this.Title = titleAttribute;
                    wasLoaded  = true;
                }

                if (!String.IsNullOrEmpty(typeAttribute))
                {
                    FeedSynchronizationRelatedInformationType type = FeedSynchronizationRelatedInformation.RelationTypeByName(typeAttribute);
                    if (type != FeedSynchronizationRelatedInformationType.None)
                    {
                        this.RelationType = type;
                        wasLoaded         = true;
                    }
                }
            }

            return(wasLoaded);
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <param name="title">The name or description of this related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type, string title) : this(link, type)
 {
     this.Title = title;
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type)
 {
     this.Link         = link;
     this.RelationType = type;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FeedSynchronizationRelatedInformation"/> class using the supplied <see cref="Uri"/> and <see cref="FeedSynchronizationRelatedInformationType"/>.
 /// </summary>
 /// <param name="link">A <see cref="Uri"/> that represents the URI for this related feed.</param>
 /// <param name="type">A <see cref="FeedSynchronizationRelatedInformationType"/> enumeration values that represents the type of the related feed.</param>
 /// <param name="title">The name or description of this related feed.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="link"/> is a null reference (Nothing in Visual Basic).</exception>
 /// <exception cref="ArgumentException">The <paramref name="type"/> is equal to <see cref="FeedSynchronizationRelatedInformationType.None"/>.</exception>
 public FeedSynchronizationRelatedInformation(Uri link, FeedSynchronizationRelatedInformationType type, string title)
     : this(link, type)
 {
     //------------------------------------------------------------
     //	Initialize class state using guarded properties
     //------------------------------------------------------------
     this.Title  = title;
 }
        /// <summary>
        /// Returns the relation type identifier for the supplied <see cref="FeedSynchronizationRelatedInformationType"/>.
        /// </summary>
        /// <param name="type">The <see cref="FeedSynchronizationRelatedInformationType"/> to get the relation type identifier for.</param>
        /// <returns>The relation type identifier for the supplied <paramref name="vocabulary"/>, otherwise returns an empty string.</returns>
        public static string RelationTypeAsString(FeedSynchronizationRelatedInformationType type)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            string name = String.Empty;

            //------------------------------------------------------------
            //	Return alternate value based on supplied protocol
            //------------------------------------------------------------
            foreach (System.Reflection.FieldInfo fieldInfo in typeof(FeedSynchronizationRelatedInformationType).GetFields())
            {
                if (fieldInfo.FieldType == typeof(FeedSynchronizationRelatedInformationType))
                {
                    FeedSynchronizationRelatedInformationType relationType  = (FeedSynchronizationRelatedInformationType)Enum.Parse(fieldInfo.FieldType, fieldInfo.Name);

                    if (relationType == type)
                    {
                        object[] customAttributes   = fieldInfo.GetCustomAttributes(typeof(EnumerationMetadataAttribute), false);

                        if (customAttributes != null && customAttributes.Length > 0)
                        {
                            EnumerationMetadataAttribute enumerationMetadata = customAttributes[0] as EnumerationMetadataAttribute;

                            name    = enumerationMetadata.AlternateValue;
                            break;
                        }
                    }
                }
            }

            return name;
        }