Exemple #1
0
        internal static Collection <ProfilePropertyMetadata> GetProfilePropertiesMetadata()
        {
            EnsureProfileConfigLoaded();

            if (ProfileBase.Properties == null)
            {
                return(new Collection <ProfilePropertyMetadata>());
            }

            Collection <ProfilePropertyMetadata> metadatas = new Collection <ProfilePropertyMetadata>();

            foreach (SettingsProperty property in ProfileBase.Properties)
            {
                string propertyName = property.Name;

                // only return property metadata for properties that are allowed for Reading and/or Writing
                bool allowedReadOrWrite = _profileAllowedGet.ContainsKey(propertyName) || _profileAllowedSet.ContainsKey(propertyName);
                if (!allowedReadOrWrite)
                {
                    continue;
                }

                string defaultValue = null;

                if (property.DefaultValue != null)
                {
                    if (property.DefaultValue is string)
                    {
                        defaultValue = (string)property.DefaultValue;
                    }
                    else
                    {
                        defaultValue = Convert.ToBase64String((byte[])property.DefaultValue);
                    }
                }

                ProfilePropertyMetadata metadata = new ProfilePropertyMetadata();
                metadata.PropertyName         = propertyName;
                metadata.DefaultValue         = defaultValue;
                metadata.TypeName             = property.PropertyType.AssemblyQualifiedName;
                metadata.AllowAnonymousAccess = (bool)property.Attributes["AllowAnonymous"];
                metadata.SerializeAs          = (int)property.SerializeAs;
                metadata.IsReadOnly           = property.IsReadOnly;

                metadatas.Add(metadata);
            }

            return(metadatas);
        }
Exemple #2
0
        public ProfilePropertyMetadata[] GetPropertiesMetadata()
        {
            ApplicationServiceHelper.EnsureProfileServiceEnabled();

            try {
                // todo: convert to array is temporary -- this method should just return Collection<> like the other profileservice does.

                Collection <ProfilePropertyMetadata> metadatas      = ApplicationServiceHelper.GetProfilePropertiesMetadata();
                ProfilePropertyMetadata[]            metadatasArray = new ProfilePropertyMetadata[metadatas.Count];
                metadatas.CopyTo(metadatasArray, 0);

                return(metadatasArray);
            }
            catch (Exception e) {
                LogException(e);
                throw;
            }
        }
        private static void AddToColl(ProfilePropertyMetadata p, SettingsPropertyCollection retColl, bool isAuthenticated) {
            string propName = p.PropertyName;
            Type   propType = Type.GetType(p.TypeName, false, true);
            bool   allowAnon = p.AllowAnonymousAccess;
            bool   readOnly = p.IsReadOnly;

            if (!allowAnon && !isAuthenticated)
                return;

            SettingsSerializeAs serializeAs = (SettingsSerializeAs)p.SerializeAs;
            SettingsAttributeDictionary dict = new SettingsAttributeDictionary();
            dict.Add("AllowAnonymous", allowAnon);
            retColl.Add(new SettingsProperty(propName, propType, null, readOnly,p.DefaultValue, serializeAs, dict, true, true));
        }
        internal static Collection<ProfilePropertyMetadata> GetProfilePropertiesMetadata() {
            EnsureProfileConfigLoaded();

            if (ProfileBase.Properties == null) {
                return new Collection<ProfilePropertyMetadata>();
            }

            Collection<ProfilePropertyMetadata> metadatas = new Collection<ProfilePropertyMetadata>();

            foreach (SettingsProperty property in ProfileBase.Properties) {
                string propertyName = property.Name;

                // only return property metadata for properties that are allowed for Reading and/or Writing
                bool allowedReadOrWrite = _profileAllowedGet.ContainsKey(propertyName) || _profileAllowedSet.ContainsKey(propertyName);
                if (!allowedReadOrWrite) {
                    continue;
                }

                string defaultValue = null;

                if (property.DefaultValue != null) {
                    if (property.DefaultValue is string) {
                        defaultValue = (string)property.DefaultValue;
                    }
                    else {
                        defaultValue = Convert.ToBase64String((byte[])property.DefaultValue);
                    }
                }

                ProfilePropertyMetadata metadata = new ProfilePropertyMetadata();
                metadata.PropertyName = propertyName;
                metadata.DefaultValue = defaultValue;
                metadata.TypeName = property.PropertyType.AssemblyQualifiedName;
                metadata.AllowAnonymousAccess = (bool)property.Attributes["AllowAnonymous"];
                metadata.SerializeAs = (int)property.SerializeAs;
                metadata.IsReadOnly = property.IsReadOnly;

                metadatas.Add(metadata);
            }

            return metadatas;
        }
        public ProfilePropertyMetadata[] GetPropertiesMetadata() {
            ApplicationServiceHelper.EnsureProfileServiceEnabled();

            try {
                // todo: convert to array is temporary -- this method should just return Collection<> like the other profileservice does.

                Collection<ProfilePropertyMetadata> metadatas = ApplicationServiceHelper.GetProfilePropertiesMetadata();
                ProfilePropertyMetadata[] metadatasArray = new ProfilePropertyMetadata[metadatas.Count];
                metadatas.CopyTo(metadatasArray, 0);
                
                return metadatasArray;
            }
            catch (Exception e) {
                LogException(e);
                throw;
            }
        }