当前位置: 首页>>代码示例>>C#>>正文


C# SettingsContext.Add方法代码示例

本文整理汇总了C#中System.Configuration.SettingsContext.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SettingsContext.Add方法的具体用法?C# SettingsContext.Add怎么用?C# SettingsContext.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Configuration.SettingsContext的用法示例。


在下文中一共展示了SettingsContext.Add方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SettingValuesCreatesAnAppAndUserId

    public void SettingValuesCreatesAnAppAndUserId()
    {
      MySQLProfileProvider provider = InitProfileProvider();
      SettingsContext ctx = new SettingsContext();
      ctx.Add("IsAuthenticated", false);
      ctx.Add("UserName", "user1");

      SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
      SettingsProperty property1 = new SettingsProperty("color");
      property1.PropertyType = typeof(string);
      property1.Attributes["AllowAnonymous"] = true;
      SettingsPropertyValue value = new SettingsPropertyValue(property1);
      value.PropertyValue = "blue";
      values.Add(value);

      provider.SetPropertyValues(ctx, values);

      DataTable dt = FillTable("SELECT * FROM my_aspnet_applications");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_users");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_profiles");
      Assert.AreEqual(1, dt.Rows.Count);

      values["color"].PropertyValue = "green";
      provider.SetPropertyValues(ctx, values);

      dt = FillTable("SELECT * FROM my_aspnet_applications");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_users");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_profiles");
      Assert.AreEqual(1, dt.Rows.Count);
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:34,代码来源:ProfileTests.cs

示例2: AuthenticatedDateTime

        public void AuthenticatedDateTime()
        {
            ProfileBase profile = ProfileBase.Create("foo", true);
            ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
            DateTime date = DateTime.Now;
            profile["BirthDate"] = date;
            profile.Save();

            SettingsPropertyCollection getProps = new SettingsPropertyCollection();
            SettingsProperty getProp1 = new SettingsProperty("BirthDate");
            getProp1.PropertyType = typeof(DateTime);
            getProp1.SerializeAs = SettingsSerializeAs.Xml;
            getProps.Add(getProp1);

            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext ctx = new SettingsContext();
            ctx.Add("IsAuthenticated", true);
            ctx.Add("UserName", "foo");

            SettingsPropertyValueCollection getValues = provider.GetPropertyValues(ctx, getProps);
            Assert.AreEqual(1, getValues.Count);
            SettingsPropertyValue getValue1 = getValues["BirthDate"];
            Assert.AreEqual(date, getValue1.PropertyValue);
        }
开发者ID:noahvans,项目名称:mariadb-connector-net,代码行数:24,代码来源:ProfileTests.cs

示例3: GetAllProfiles

    public void GetAllProfiles()
    {
      ProfileBase profile = ProfileBase.Create("foo", true);
      ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
      profile["Name"] = "Fred Flintstone";
      profile.Save();

      SettingsPropertyCollection getProps = new SettingsPropertyCollection();
      SettingsProperty getProp1 = new SettingsProperty("Name");
      getProp1.PropertyType = typeof(String);
      getProps.Add(getProp1);

      MySQLProfileProvider provider = InitProfileProvider();
      SettingsContext ctx = new SettingsContext();
      ctx.Add("IsAuthenticated", true);
      ctx.Add("UserName", "foo");

      int total;
      ProfileInfoCollection profiles = provider.GetAllProfiles(
          ProfileAuthenticationOption.All, 0, 10, out total);
      Assert.AreEqual(1, total);
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:22,代码来源:ProfileTests.cs

示例4: AuthenticatedStringProperty

    public void AuthenticatedStringProperty()
    {
      ProfileBase profile = ProfileBase.Create("foo", true);
      ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
      profile["Name"] = "Fred Flintstone";
      profile.Save();

      SettingsPropertyCollection getProps = new SettingsPropertyCollection();
      SettingsProperty getProp1 = new SettingsProperty("Name");
      getProp1.PropertyType = typeof(String);
      getProps.Add(getProp1);

      MySQLProfileProvider provider = InitProfileProvider();
      SettingsContext ctx = new SettingsContext();
      ctx.Add("IsAuthenticated", true);
      ctx.Add("UserName", "foo");

      SettingsPropertyValueCollection getValues = provider.GetPropertyValues(ctx, getProps);
      Assert.AreEqual(1, getValues.Count);
      SettingsPropertyValue getValue1 = getValues["Name"];
      Assert.AreEqual("Fred Flintstone", getValue1.PropertyValue);
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:22,代码来源:ProfileTests.cs

示例5: StringCollectionAsProperty

    public void StringCollectionAsProperty()
    {
      ProfileBase profile = ProfileBase.Create("foo", true);
      ResetAppId(profile.Providers["MySqlProfileProvider"] as MySQLProfileProvider);
      StringCollection colors = new StringCollection();
      colors.Add("red");
      colors.Add("green");
      colors.Add("blue");
      profile["FavoriteColors"] = colors;
      profile.Save();

      DataTable dt = FillTable("SELECT * FROM my_aspnet_applications");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_users");
      Assert.AreEqual(1, dt.Rows.Count);
      dt = FillTable("SELECT * FROM my_aspnet_profiles");
      Assert.AreEqual(1, dt.Rows.Count);

      // now retrieve them
      SettingsPropertyCollection getProps = new SettingsPropertyCollection();
      SettingsProperty getProp1 = new SettingsProperty("FavoriteColors");
      getProp1.PropertyType = typeof(StringCollection);
      getProp1.SerializeAs = SettingsSerializeAs.Xml;
      getProps.Add(getProp1);

      MySQLProfileProvider provider = InitProfileProvider();
      SettingsContext ctx = new SettingsContext();
      ctx.Add("IsAuthenticated", true);
      ctx.Add("UserName", "foo");
      SettingsPropertyValueCollection getValues = provider.GetPropertyValues(ctx, getProps);
      Assert.AreEqual(1, getValues.Count);
      SettingsPropertyValue getValue1 = getValues["FavoriteColors"];
      StringCollection outValue = (StringCollection)getValue1.PropertyValue;
      Assert.AreEqual(3, outValue.Count);
      Assert.AreEqual("red", outValue[0]);
      Assert.AreEqual("green", outValue[1]);
      Assert.AreEqual("blue", outValue[2]);
    }
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:38,代码来源:ProfileTests.cs

示例6: SetProfileProperties

        public void SetProfileProperties( object appName, object userID, System.Configuration.SettingsPropertyValueCollection values, System.Collections.Generic.List<SettingsPropertyColumn> settingsColumnsList)
        {
            if (YAF.Classes.Config.GetConfigValueAsBool("YAF.OldProfileProvider", true))
                SetProfilePropertiesOld(appName, userID, values, settingsColumnsList);
            // Apply here new profile properties
            SettingsContext sc=new SettingsContext();
            sc.Add( "IsAuthenticated", true );
            sc.Add( "UserID", userID );
            sc.Add( "ApplicationName", appName );

            bool isAuthenticated = true;

            if ( String.IsNullOrEmpty( userID.ToString() ) ) return;
            if ( values.Count < 1 ) return;

            string index = String.Empty;
            string stringData = String.Empty;
            byte[] binaryData = null;

            if (PackProfileData(values, isAuthenticated, ref index, ref stringData, ref binaryData) < 1 ) return;

                     using (MySqlCommand cmd = MsSqlDbAccess.GetCommand("prov_setprofileproperties"))

                        {
                            cmd.CommandType = CommandType.StoredProcedure;

                            cmd.Parameters.Clear();
                            cmd.Parameters.Add("@i_userId",MySqlDbType.VarChar).Value=MsSqlDbAccess.GuidConverter(new Guid(userID.ToString())).ToString();
                            cmd.Parameters.Add("@i_index",MySqlDbType.LongText).Value=index;
                            cmd.Parameters.Add("@i_stringData",MySqlDbType.LongText).Value=stringData;
                            cmd.Parameters.Add("@i_binaryData",MySqlDbType.LongBlob).Value=binaryData;

                            _msSqlDbAccess.ExecuteNonQuery( cmd) ;
                        }

            // EOF 'apply new profile properties'
        }
开发者ID:vzrus,项目名称:YetAnotherForumExtraDataLayers,代码行数:37,代码来源:DB.cs

示例7: Initialize

 public void Initialize(string username, bool isAuthenticated) {
     if (username != null)
         _UserName = username.Trim();
     else
         _UserName = username;
     //if (string.IsNullOrEmpty(_UserName))
     //    throw new ArgumentException(SR.GetString(SR.Membership_InvalidUserName), "username");
     SettingsContext sc = new SettingsContext();
     sc.Add("UserName", _UserName);
     sc.Add("IsAuthenticated", isAuthenticated);
     _IsAuthenticated = isAuthenticated;
     base.Initialize(sc, s_Properties, ProfileManager.Providers);
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:13,代码来源:HttpProfileBase.cs

示例8: Initialize

		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);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:ProfileBase.cs

示例9: SetProfileProperties

        public void SetProfileProperties(string connectionStringName, object appName, object userID, SettingsPropertyValueCollection values, List<SettingsPropertyColumn> settingsColumnsList)
        {
            if (YAF.Classes.Config.GetConfigValueAsBool("YAF.OldProfileProvider", true))
                SetProfilePropertiesOld(connectionStringName, appName, userID, values, settingsColumnsList);
            // Apply here new profile properties
            SettingsContext sctxt = new SettingsContext();
            sctxt.Add("IsAuthenticated", true);
            sctxt.Add("UserID", userID);
            sctxt.Add("ApplicationName", appName);

            bool isAuthenticated = true;

            if (string.IsNullOrEmpty(userID.ToString())) return;
            if (values.Count < 1) return;

            string index = string.Empty;
            string stringData = string.Empty;
            byte[] binaryData = null;

            if (PackProfileData(values, isAuthenticated, ref index, ref stringData, ref binaryData) < 1) return;

            using (var sc = new VzfSqlCommand(connectionStringName))
            {
                sc.Parameters.Add(sc.CreateParameter(DbType.String, "i_userId", MySqlHelpers.GuidConverter(new Guid(userID.ToString())).ToString()));
                sc.Parameters.Add(sc.CreateParameter(DbType.Binary, "I_index", index));
                sc.Parameters.Add(sc.CreateParameter(DbType.Binary, "I_stringdata", stringData));
                sc.Parameters.Add(sc.CreateParameter(DbType.Binary, "I_binarydata", binaryData));


                // cmd.Parameters.Add(new FbParameter("@I_USERID", FbDbType.VarChar)).Value = userID;

                sc.CommandText.AppendObjectQuery("prov_setprofileproperties", connectionStringName);
                sc.ExecuteNonQuery(CommandType.StoredProcedure, false);
            }

            // EOF 'apply new profile properties'
        }
开发者ID:vzrus,项目名称:VZF,代码行数:37,代码来源:DB.cs

示例10: Initialize

 public void Initialize(string username, bool isAuthenticated)
 {
     if (username != null)
     {
         this._UserName = username.Trim();
     }
     else
     {
         this._UserName = username;
     }
     SettingsContext context = new SettingsContext();
     context.Add("UserName", this._UserName);
     context.Add("IsAuthenticated", isAuthenticated);
     this._IsAuthenticated = isAuthenticated;
     base.Initialize(context, s_Properties, ProfileManager.Providers);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:ProfileBase.cs

示例11: __SetProfileProperties

        public void __SetProfileProperties(  object appName, object userID, System.Configuration.SettingsPropertyValueCollection values, System.Collections.Generic.List<SettingsPropertyColumn> settingsColumnsList )
        {
            SettingsContext sc = new SettingsContext();
            sc.Add("IsAuthenticated", true);
            sc.Add("UserID", userID);
            sc.Add("ApplicationName", appName);

            __SetPropertyValues( sc, values, settingsColumnsList);
        }
开发者ID:vzrus,项目名称:YetAnotherForumExtraDataLayers,代码行数:9,代码来源:DB.cs

示例12: Create

        public static new ProfileCommon Create(string applicationSpace, string groupId, string username, bool isAuthenticated)
        {
            ProfileProvider profileProvider = System.Web.Profile.ProfileManager.Provider;
            if (profileProvider != null)
            {
                ProfileCommon profileCommon = new ProfileCommon();
                profileCommon.Initialize(username, isAuthenticated);

                SettingsContext settingsContext = new SettingsContext();
                settingsContext.Add("UserName", username);
                settingsContext.Add("IsAuthenticated", isAuthenticated);

                SettingsPropertyValueCollection pvc = profileProvider.GetPropertyValues(settingsContext, ProfileCommon.Properties);

                foreach (SettingsPropertyValue pv in pvc)
                {
                    //Only basic types and a List<String> are supported.
                    if (pv.PropertyValue != null && pv.Property.PropertyType == typeof(List<String>))
                    {
                        if (pv.PropertyValue is IEnumerable<String>)
                        {
                            profileCommon.SetPropertyValue(pv.Property.Name, new List<String>((IEnumerable<String>)pv.PropertyValue));
                        }
                        else
                        {
                            // Write an event. Assume a trace source
                            new TraceSource("Default").TraceEvent(TraceEventType.Warning, -1, "Could not parse the property '{0}' in the ProfileCommon object.", pv.Property.Name);

                            // Something went wrong while setting this property.
                            System.Diagnostics.Debugger.Break();
                        }
                    }
                    else
                    {
                        profileCommon.SetPropertyValue(pv.Property.Name, pv.PropertyValue);
                    }
                }

                return profileCommon;
            }
            else
            {
                return ProfileBase.Create(username, isAuthenticated) as ProfileCommon;
            }
        }
开发者ID:agarcian,项目名称:MongoDBASPNetProviders,代码行数:45,代码来源:ProfileCommon.cs


注:本文中的System.Configuration.SettingsContext.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。