Ejemplo n.º 1
0
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="profileProvider"></param>
        public ProfileWrapper(ProfileProviderServiceReference.Profile profile, RemoteProfileProvider profileProvider)
        {
            _profileProvider = profileProvider;
            _instance        = profile;
            _roleSet         = profile.RoleSet ?? new ProfileRoleSet();

            if (_instance != null)
            {
                _instance.RoleSet = _roleSet;
            }

            //profile.RoleSet = null;

            if (profile.Source != null)
            {
                _source = new AuthenticationSourceWrapper(profile.Source);
            }

            if (profile.Properties != null)
            {
                foreach (var property in profile.Properties)
                {
                    if (property != null)
                    {
                        _properties.Add(property.Name, property.Value);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void IXmlSerializable.ReadXml(System.Xml.XmlReader a)
        {
            a.ReadStartElement();
            DefaultValueGroupId = int.Parse(a.ReadElementString("DefaultValueGroupId"));
            FullName            = a.ReadElementString("FullName");
            GroupRoleId         = int.Parse(a.ReadElementString("GroupRoleId"));
            IsAnonymous         = a.ReadElementContentAsBoolean();
            ProfileSearchMode b = ProfileSearchMode.All;

            if (Enum.TryParse <ProfileSearchMode> (a.ReadElementString("SearchMode"), out b))
            {
                SearchMode = b;
            }
            LastActivityDate = a.ReadDateTimeOffset();
            LastUpdatedDate  = a.ReadDateTimeOffset();
            ProfileId        = a.ReadElementContentAsInt();
            if (!a.IsEmptyElement)
            {
                a.ReadStartElement("Properties");
                var c = new List <ProfileProperty> ();
                var d = new XmlSerializer(typeof(ProfileProperty), new XmlRootAttribute("ProfileProperty"));
                while (a.LocalName == "ProfileProperty" && a.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    c.Add((ProfileProperty)d.Deserialize(a));
                }
                this.Properties = c.ToArray();
                a.ReadEndElement();
            }
            else
            {
                a.Skip();
            }
            if (!a.IsEmptyElement)
            {
                RoleSet = new ProfileRoleSet();
                ((IXmlSerializable)RoleSet).ReadXml(a);
            }
            else
            {
                a.Skip();
            }
            if (!a.IsEmptyElement)
            {
                Source = new AuthenticationSource();
                ((IXmlSerializable)Source).ReadXml(a);
            }
            else
            {
                a.Skip();
            }
            SourceId = a.ReadElementContentAsInt();
            UserId   = a.ReadElementContentAsInt();
            UserName = a.ReadElementString("UserName");
            if (!a.IsEmptyElement)
            {
                MarkGroupId = a.ReadElementContentAsInt();
            }
            else
            {
                a.Skip();
            }
            if (!a.IsEmptyElement)
            {
                SellerTreeId = a.ReadElementContentAsInt();
            }
            else
            {
                a.Skip();
            }
            if (!a.IsEmptyElement)
            {
                IntermediateId = a.ReadElementContentAsInt();
            }
            else
            {
                a.Skip();
            }
            a.ReadEndElement();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Lê os dados do xml para a instancia.
        /// </summary>
        /// <param name="reader"></param>
        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            DefaultValueGroupId = int.Parse(reader.ReadElementString("DefaultValueGroupId"));
            FullName            = reader.ReadElementString("FullName");
            GroupRoleId         = int.Parse(reader.ReadElementString("GroupRoleId"));
            IsAnonymous         = reader.ReadElementContentAsBoolean();

            ProfileSearchMode searchMode = ProfileSearchMode.All;

            if (Enum.TryParse <ProfileSearchMode>(reader.ReadElementString("SearchMode"), out searchMode))
            {
                SearchMode = searchMode;
            }

            LastActivityDate = reader.ReadDateTimeOffset();
            LastUpdatedDate  = reader.ReadDateTimeOffset();

            ProfileId = reader.ReadElementContentAsInt();

            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Properties");

                var properties = new List <ProfileProperty>();
                var serializer = new XmlSerializer(typeof(ProfileProperty), new XmlRootAttribute("ProfileProperty"));

                while (reader.LocalName == "ProfileProperty" &&
                       reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    properties.Add((ProfileProperty)serializer.Deserialize(reader));
                }

                this.Properties = properties.ToArray();
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }

            if (!reader.IsEmptyElement)
            {
                RoleSet = new ProfileRoleSet();
                ((IXmlSerializable)RoleSet).ReadXml(reader);
            }
            else
            {
                reader.Skip();
            }

            if (!reader.IsEmptyElement)
            {
                Source = new AuthenticationSource();
                ((IXmlSerializable)Source).ReadXml(reader);
            }
            else
            {
                reader.Skip();
            }

            SourceId = reader.ReadElementContentAsInt();
            UserId   = reader.ReadElementContentAsInt();
            UserName = reader.ReadElementString("UserName");

            // MarkGroupId
            if (!reader.IsEmptyElement)
            {
                MarkGroupId = reader.ReadElementContentAsInt();
            }
            else
            {
                reader.Skip();
            }

            // SellerTreeId
            if (!reader.IsEmptyElement)
            {
                SellerTreeId = reader.ReadElementContentAsInt();
            }
            else
            {
                reader.Skip();
            }

            // IntermediateId
            if (!reader.IsEmptyElement)
            {
                IntermediateId = reader.ReadElementContentAsInt();
            }
            else
            {
                reader.Skip();
            }

            reader.ReadEndElement();
        }