Inheritance: System.Configuration.Provider.ProviderCollection
 ////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////
 public void Initialize(
     SettingsContext context,
     SettingsPropertyCollection properties,
     SettingsProviderCollection providers)
 {
     _Context    = context;
     _Properties = properties;
     _Providers  = providers;
 }
Ejemplo n.º 2
0
 public void Initialize(SettingsContext context,
                        SettingsPropertyCollection properties,
                        SettingsProviderCollection providers)
 {
     this.context    = context;
     this.properties = properties;
     this.providers  = providers;
     // values do not seem to be reset here!! (otherwise one of the SettingsBaseTest will fail)
 }
Ejemplo n.º 3
0
		public void Initialize (SettingsContext context,
					SettingsPropertyCollection properties,
					SettingsProviderCollection providers)
		{
			this.context = context;
			this.properties = properties;
			this.providers = providers;
			// values do not seem to be reset here!! (otherwise one of the SettingsBaseTest will fail)
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Ensures this class is initialized. Initialization involves reflecting over properties and building
        /// a list of SettingsProperty's.
        /// </summary>
        private void EnsureInitialized()
        {
            // Initialization method -
            // be careful not to access properties here to prevent stack overflow.

            if (!_initialized)
            {
                _initialized = true;

                Type type = GetType();

                if (_context == null)
                {
                    _context = new SettingsContext();
                }
                _context["GroupName"]         = type.FullName;
                _context["SettingsKey"]       = SettingsKey;
                _context["SettingsClassType"] = type;

                PropertyInfo[] properties = SettingsFilter(type.GetProperties(BindingFlags.Instance | BindingFlags.Public));
                _classAttributes = type.GetCustomAttributes(false);

                if (_settings == null)
                {
                    _settings = new SettingsPropertyCollection();
                }

                if (_providers == null)
                {
                    _providers = new SettingsProviderCollection();
                }

                for (int i = 0; i < properties.Length; i++)
                {
                    SettingsProperty sp = CreateSetting(properties[i]);
                    if (sp != null)
                    {
                        _settings.Add(sp);

                        if (sp.Provider != null && _providers[sp.Provider.Name] == null)
                        {
                            _providers.Add(sp.Provider);
                        }
                    }
                }
            }
        }
 private void EnsureInitialized()
 {
     if (!this._initialized)
     {
         this._initialized = true;
         Type type = base.GetType();
         if (this._context == null)
         {
             this._context = new SettingsContext();
         }
         this._context["GroupName"]         = type.FullName;
         this._context["SettingsKey"]       = this.SettingsKey;
         this._context["SettingsClassType"] = type;
         PropertyInfo[] infoArray = this.SettingsFilter(type.GetProperties(BindingFlags.Public | BindingFlags.Instance));
         this._classAttributes = type.GetCustomAttributes(false);
         if (this._settings == null)
         {
             this._settings = new SettingsPropertyCollection();
         }
         if (this._providers == null)
         {
             this._providers = new SettingsProviderCollection();
         }
         for (int i = 0; i < infoArray.Length; i++)
         {
             SettingsProperty property = this.CreateSetting(infoArray[i]);
             if (property != null)
             {
                 this._settings.Add(property);
                 if ((property.Provider != null) && (this._providers[property.Provider.Name] == null))
                 {
                     this._providers.Add(property.Provider);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 public virtual void Initialize(SettingsContext context, SettingsPropertyCollection properties, SettingsProviderCollection providers)
 {
     _profileBase.Initialize(context, properties, providers);
 }
Ejemplo n.º 7
0
		public void Initialize (string username, bool isAuthenticated)
		{
			_settingsContext = new SettingsContext ();
			_settingsContext.Add ("UserName", username);
			_settingsContext.Add ("IsAuthenticated", isAuthenticated);
			SettingsProviderCollection spc = new SettingsProviderCollection();
			spc.Add (ProfileManager.Provider);
			base.Initialize (Context, ProfileBase.Properties, spc);
		}
Ejemplo n.º 8
0
 public void Initialize(SettingsContext context, SettingsPropertyCollection properties, SettingsProviderCollection providers)
 {
     throw new NotImplementedException();
 }
		public void ProviderCollectionAddDuplicate ()
		{
			SettingsProviderCollection c = new SettingsProviderCollection ();
			c.Add (new MyProvider ());
			c.Add (new MyProvider ());
		}
 private void EnsureInitialized()
 {
     if (!this._initialized)
     {
         this._initialized = true;
         Type type = base.GetType();
         if (this._context == null)
         {
             this._context = new SettingsContext();
         }
         this._context["GroupName"] = type.FullName;
         this._context["SettingsKey"] = this.SettingsKey;
         this._context["SettingsClassType"] = type;
         PropertyInfo[] infoArray = this.SettingsFilter(type.GetProperties(BindingFlags.Public | BindingFlags.Instance));
         this._classAttributes = type.GetCustomAttributes(false);
         if (this._settings == null)
         {
             this._settings = new SettingsPropertyCollection();
         }
         if (this._providers == null)
         {
             this._providers = new SettingsProviderCollection();
         }
         for (int i = 0; i < infoArray.Length; i++)
         {
             SettingsProperty property = this.CreateSetting(infoArray[i]);
             if (property != null)
             {
                 this._settings.Add(property);
                 if ((property.Provider != null) && (this._providers[property.Provider.Name] == null))
                 {
                     this._providers.Add(property.Provider);
                 }
             }
         }
     }
 }
		public void AddPropertyNoProviderButInProviders ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), null, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (100, s.Foo);
		}
		public void AddPropertyTypeMismatch ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), p, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			int i = s.Foo; // it still works as int, regardless of the settings property type...
		}
		public void PropertyValuesInitialized ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();
			int i;

			try {
				i = s.Foo;
				Assert.Fail ("#1-2");
			} catch (SettingsPropertyNotFoundException) {
			}

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#2-1");
			Assert.AreEqual (0, s.Context.Count, "#2-2");

			props.Add (new SettingsProperty ("Foo", typeof (int), p, false, 10, SettingsSerializeAs.String, null, true, true));
			// initialize w/o the provider
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#3-0");
			Assert.AreEqual (100, s.Foo, "#3-1");
			// ... !!!
			Assert.AreEqual (1, s.PropertyValues.Count, "#3-2");
			SettingsPropertyValue v = s.PropertyValues ["Foo"];
			Assert.AreEqual (100, v.PropertyValue, "#3-3");
			Assert.AreEqual (0, s.Context.Count, "#3-4");

			// initialize w/ the provider
			provs.Add (p);
			provs.Add (new MyProvider2 ("Bar", 25));
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider2"], false, 10, SettingsSerializeAs.String, null, true, true));
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (1, s.PropertyValues.Count, "#4-1");
			Assert.AreEqual (100, s.Foo, "#4-2");
			Assert.AreEqual (25, s.Bar, "#4-3");
			// ... !!!
			Assert.AreEqual (2, s.PropertyValues.Count, "#4-3-2");
			Assert.AreEqual (0, s.Context.Count, "#4-4");

			// wrong provider
			props.Remove ("Bar");
			props.Add (new SettingsProperty ("Bar", typeof (int), provs ["MyProvider"], false, 10, SettingsSerializeAs.String, null, true, true));
			s = new MySettings ();
			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.PropertyValues.Count, "#5-1");
			Assert.AreEqual (100, s.Foo, "#5-2");
			Assert.AreEqual (10, s.Bar, "#5-3");
		}
		public void PropertyValuesInstance ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider p = new MyProvider ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), p, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (s.PropertyValues, s.PropertyValues);
		}
        /// <devdoc>
        ///     Ensures this class is initialized. Initialization involves reflecting over properties and building
        ///     a list of SettingsProperty's.
        /// 
        ///     Implementation note: Initialization method - be careful not to access properties here
        ///                          to prevent stack overflow.
        /// </devdoc>
        private void EnsureInitialized() {
            if (!_initialized) {
                _initialized = true;

                Type type = this.GetType();
                
                if (_context == null) {
                    _context = new SettingsContext();
                }
                _context["GroupName"] = type.FullName;
                _context["SettingsKey"] = SettingsKey;
                _context["SettingsClassType"] = type; 

                PropertyInfo[] properties = SettingsFilter(type.GetProperties(BindingFlags.Instance | BindingFlags.Public));
                _classAttributes = type.GetCustomAttributes(false); 

                if (_settings == null) {
                    _settings = new SettingsPropertyCollection();
                }

                if (_providers == null) {
                    _providers = new SettingsProviderCollection();
                }
                
                for (int i = 0; i < properties.Length; i++) {
                    SettingsProperty sp = CreateSetting(properties[i]);
                    if (sp != null) {
                        _settings.Add(sp);

                        if (sp.Provider != null && _providers[sp.Provider.Name] == null) {
                            _providers.Add(sp.Provider);
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 ////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////
 public void Initialize(
         SettingsContext                  context,
         SettingsPropertyCollection       properties,
         SettingsProviderCollection       providers)
 {
     _Context = context;
     _Properties = properties;
     _Providers = providers;
 }
		public void ExceptionalGetPropertyValues ()
		{
			SettingsPropertyCollection props = new SettingsPropertyCollection ();
			SettingsProviderCollection provs = new SettingsProviderCollection ();

			MyProvider3 p = new MyProvider3 ();
			MySettings s = new MySettings ();

			props.Add (new SettingsProperty ("Foo", typeof (string), p, false, 10, SettingsSerializeAs.String, null, true, true));
			provs.Add (p);

			s.Initialize (new SettingsContext (), props, provs);
			Assert.AreEqual (0, s.Context.Count, "#0");
			try {
				Assert.AreEqual (100, s.Foo, "#1");
				Assert.Fail ("#2");
#if !TARGET_JVM
			} catch (Win32Exception) {
#else
			} catch (CustomerException) {
#endif
			}
		}
Ejemplo n.º 18
0
 public virtual void Initialize(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection properties, System.Configuration.SettingsProviderCollection providers)
 {
     this._profileBase.Initialize(context, properties, providers);
 }