Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LiveJournalSecurity"/> class using the supplied <see cref="LiveJournalSecurityType"/>.
 /// </summary>
 /// <param name="accessType">A <see cref="LiveJournalSecurityType"/> enumeration value that represents the access type.</param>
 public LiveJournalSecurity(LiveJournalSecurityType accessType)
 {
     //------------------------------------------------------------
     //	Initialize class state using property setters
     //------------------------------------------------------------
     this.Accessibility = accessType;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LiveJournalSecurity"/> class using the supplied <see cref="LiveJournalSecurityType"/>.
 /// </summary>
 /// <param name="accessType">A <see cref="LiveJournalSecurityType"/> enumeration value that represents the access type.</param>
 public LiveJournalSecurity(LiveJournalSecurityType accessType)
 {
     //------------------------------------------------------------
     //	Initialize class state using property setters
     //------------------------------------------------------------
     this.Accessibility  = accessType;
 }
Ejemplo n.º 3
0
        //============================================================
        //	STATIC METHODS
        //============================================================
        #region AccessibilityAsString(LiveJournalSecurityType level)
        /// <summary>
        /// Returns the access level identifier for the supplied <see cref="LiveJournalSecurityType"/>.
        /// </summary>
        /// <param name="level">The <see cref="LiveJournalSecurityType"/> to get the access level identifier for.</param>
        /// <returns>The access level identifier for the supplied <paramref name="level"/>, otherwise returns an empty string.</returns>
        public static string AccessibilityAsString(LiveJournalSecurityType level)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            string name = String.Empty;

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

                    if (accessLevel == level)
                    {
                        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>
        /// Loads this <see cref="LiveJournalSecurity"/> 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="LiveJournalSecurity"/> 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="LiveJournalSecurity"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            if (source.HasAttributes)
            {
                string typeAttribute = source.GetAttribute("type", String.Empty);
                string maskAttribute = source.GetAttribute("mask", String.Empty);

                if (!String.IsNullOrEmpty(typeAttribute))
                {
                    LiveJournalSecurityType accessLevel = LiveJournalSecurity.AccessibilityByName(typeAttribute);
                    if (accessLevel != LiveJournalSecurityType.None)
                    {
                        this.Accessibility = accessLevel;
                        wasLoaded          = true;
                    }
                }

                if (!String.IsNullOrEmpty(maskAttribute))
                {
                    int mask;
                    if (Int32.TryParse(maskAttribute, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out mask))
                    {
                        this.Mask = mask;
                        wasLoaded = true;
                    }
                }
            }

            return(wasLoaded);
        }
        /// <summary>
        /// Returns the <see cref="LiveJournalSecurityType"/> enumeration value that corresponds to the specified access level name.
        /// </summary>
        /// <param name="name">The name of the access level.</param>
        /// <returns>A <see cref="LiveJournalSecurityType"/> enumeration value that corresponds to the specified string, otherwise returns <b>LiveJournalSecurityType.None</b>.</returns>
        /// <remarks>This method disregards case of specified access level 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 LiveJournalSecurityType AccessibilityByName(string name)
        {
            LiveJournalSecurityType accessLevel = LiveJournalSecurityType.None;

            Guard.ArgumentNotNullOrEmptyString(name, "name");
            foreach (System.Reflection.FieldInfo fieldInfo in typeof(LiveJournalSecurityType).GetFields())
            {
                if (fieldInfo.FieldType == typeof(LiveJournalSecurityType))
                {
                    LiveJournalSecurityType level = (LiveJournalSecurityType)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)
                        {
                            accessLevel = level;
                            break;
                        }
                    }
                }
            }

            return(accessLevel);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns the access level identifier for the supplied <see cref="LiveJournalSecurityType"/>.
        /// </summary>
        /// <param name="level">The <see cref="LiveJournalSecurityType"/> to get the access level identifier for.</param>
        /// <returns>The access level identifier for the supplied <paramref name="level"/>, otherwise returns an empty string.</returns>
        public static string AccessibilityAsString(LiveJournalSecurityType level)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            string name = String.Empty;

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

                    if (accessLevel == level)
                    {
                        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="LiveJournalSecurity"/> class using the supplied <see cref="LiveJournalSecurityType"/>.
 /// </summary>
 /// <param name="accessType">A <see cref="LiveJournalSecurityType"/> enumeration value that represents the access type.</param>
 /// <param name="mask">An integer indicating the friend-groups mask.</param>
 public LiveJournalSecurity(LiveJournalSecurityType accessType, int mask)
 {
     this.Accessibility = accessType;
     this.Mask          = mask;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LiveJournalSecurity"/> class using the supplied <see cref="LiveJournalSecurityType"/>.
 /// </summary>
 /// <param name="accessType">A <see cref="LiveJournalSecurityType"/> enumeration value that represents the access type.</param>
 public LiveJournalSecurity(LiveJournalSecurityType accessType)
 {
     this.Accessibility = accessType;
 }