/// <summary>
        /// The static constructor calls this method to initialize the singleton
        /// returned by the base constructor.
        /// </summary>
        /// <param name="psettingsPropertyValueCollection">
        /// Pass a reference to a System.Configuration.SettingsPropertyCollection
        /// collection to display.
        /// </param>
        /// <param name="pstrDisplayNameTemplate">
        /// This paramter specifies a template from which to construct the name
        /// of a managed string resource in the calling assembly to use as the
        /// display name. If no such string exists, the InternalName property is
        /// the display name. Likewise, if this string is a null reference or
        /// the empty string, the InternalName property is the display name.
        /// </param>
        /// <param name="penmDefaultParameterSource">
        /// This parameter specifies the value source enumeration member to use
        /// as the parameter source for any OperatingParameter for which the
        /// ApplicationSettings has a value.
        /// </param>
        private void InitiaalizeInstance (
			System.Configuration.SettingsPropertyCollection psettingsPropertyValueCollection ,
			string pstrDisplayNameTemplate ,
			U penmDefaultParameterSource )
		{
			//	----------------------------------------------------------------
			//	Generic dictionary _dctOperatingParameters, which holds the
			//	collection of OperatingParameter objects, indexed by name, is
			//	initialized and sized per the count of argument names, while the
			//	local dctParameterTypeInfo dictionary is initialized from the
			//	string array constructed from PARAMETER_TYPE_INFO_RESOURCE_NAME,
			//	an embedded text file resource. Iterating the argument names in
			//	pastrArgNames, the foreach loop extracts its internally-defined
			//	properties from dctParameterTypeInfo, the local dictionary, so
			//	that an OperatingParameter object, with its Value property left
			//	uninitialized, can be stored in the _dctOperatingParameters
			//	dictionary, so that it can be quickly found and updated with the
			//	value read from a command line argument, which happens in the
			//	calling routine after this method returns the fully loaded
			//	_dctOperatingParameters dictionary.
			//
			//	Since everything that went into dctParameterTypeInfo is encoded
			//	into an OperatingParameter, local object dctParameterTypeInfo is
			//	redundant, and is allowed to vanish when the method returns.
			//	----------------------------------------------------------------

			Dictionary<string , ParameterTypeInfo<T>> dctParameterTypeInfo = GetParameterTypeInfo (
				EmbeddedTextFile.Readers.LoadTextFileFromEntryAssembly (
					PARAMETER_TYPE_INFO_RESOURCE_NAME ) );
			_dctOperatingParameters = new Dictionary<string , OperatingParameter<T , U>> ( dctParameterTypeInfo.Count );

			foreach ( string strName in dctParameterTypeInfo.Keys )
			{
				ParameterTypeInfo<T> ptiForThis = null;

				if ( dctParameterTypeInfo.TryGetValue ( strName , out ptiForThis ) )
				{   // Create the uninitialized parameter object, and add it to the collection.
					OperatingParameter<T , U> opThis = new OperatingParameter<T , U> (
						psettingsPropertyValueCollection ,
						strName ,                                                       // string pstrInternalName
						pstrDisplayNameTemplate ,                                       // string pstrDisplayName - The constructor will sort it out.
						ptiForThis.ParameterType ,                                      // T penmParameterType
						penmDefaultParameterSource );									// U penmDefaultParameterSource
					_dctOperatingParameters.Add (										// Add it to the collection.
						strName ,														// Key
						opThis );														// Value
				}   // TRUE (anticipated outcome) block, if ( dctParameterTypeInfo.TryGetValue ( strName , out ptiForThis ) )
				else
				{	// Prepare and log a detailed exception report.
					string strMessage = string.Format (									// Assemble a detailed diagnostic message.
						Properties.Resources.ERRMSG_INTERNAL_PROCESSING_ERROR_005 ,		// Format control string
						strName ,														// Format Item 0: Type information for the {0} parameter
						PARAMETER_TYPE_INFO_RESOURCE_NAME ,								// Format Item 1: cannot be found in the embedded {1} resource
						Environment.NewLine );                                          // Format Item 2: Platform-dependent newline sequence
					throw new InvalidOperationException ( strMessage );					// Toss cookies and die.
				}   // FALSE (unanticipated outcome) block, if ( dctParameterTypeInfo.TryGetValue ( strName , out ptiForThis ) )
			}   // foreach ( string strName in dctParameterTypeInfo.Keys )
		}   // InitiaalizeInstance Method
示例#2
0
 //終了時処理
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     //全ての(DataItemの)プロパティを保存
     System.Configuration.SettingsPropertyCollection settings = Properties.Settings.Default.Properties;  //全てのプロパティ取得
     foreach (System.Configuration.SettingsProperty settingsProperty in settings)
     {
         string   propertyName = settingsProperty.Name;
         DataItem dataItem     = GetDataItem(propertyName);
         if (dataItem != null)
         {
             Properties.Settings.Default[propertyName] = dataItem.PathStr;
         }
     }
     Properties.Settings.Default.Save();
 }
示例#3
0
        private void Initialize()
        {
            //リソースディクショナリ設定
            //this.Resources.Source = new Uri("/AnimDic.xaml", UriKind.Relative);

            //ファイル・ディレクトリパス読み取り・設定
            //全ての(DataItemの)プロパティを取得・設定
            System.Configuration.SettingsPropertyCollection settings = Properties.Settings.Default.Properties;  //全てのプロパティ取得
            foreach (System.Configuration.SettingsProperty settingsProperty in settings)
            {
                string   propertyName = settingsProperty.Name;
                DataItem dataItem     = GetDataItem(propertyName);
                if (dataItem != null)
                {
                    string pathStr = (string)Properties.Settings.Default[propertyName];
                    if (File.Exists(pathStr))
                    {
                        this.Persona.SetFile(dataItem, pathStr);
                    }
                    else if (Directory.Exists(pathStr))
                    {
                        this.Persona.SetDirectory(dataItem, pathStr);
                    }
                    else
                    {
                        //無効なパス(失敗アクションもあるので一応)
                    }
                }
            }

            //開始時アニメーション実行
            try
            {
                Storyboard sb = FindResource("Initialize") as Storyboard;
                if (sb != null)
                {
                    sb.Begin();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("アニメーションInitializeでエラーが発生しました\n" + e, "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }
		}   // OperatingParameters constructor


        /// <summary>
        /// Access to the single instance is gated through this method, which is
        /// called as needed to get references, so that the parameters need not
        /// be passed around or stored in a global variable.
        /// </summary>
        /// <param name="psettingsPropertyValueCollection">
        /// Pass a reference to a System.Configuration.SettingsPropertyCollection
        /// collection from which to obtain default values.
        /// </param>
        /// <param name="pstrDisplayNameTemplate">
        /// This paramter specifies a template from which to construct the name
        /// of a managed string resource in the calling assembly to use as the
        /// display name. If no such string exists, the InternalName property is
        /// the display name. Likewise, if this string is a null reference or
        /// the empty string, the InternalName property is the display name.
        /// </param>
        /// <param name="penmDefaultParameterSource">
        /// Specify the member of the ParameterSource, generic type U,
        /// enumeration with which to mark the object if the ApplicationSettings
        /// collection includes a default value.
        /// 
        /// Please <see cref="OperatingParametersCollection{T, U}"/> for more
        /// details.
        /// </param>
        /// <returns>
        /// Unless something causes it to fail, the return value is reference to
        /// a fully initialized object, ready to be loaded with parameters.
        /// </returns>
        public static OperatingParametersCollection<T , U> GetTheSingleInstance (
			System.Configuration.SettingsPropertyCollection psettingsPropertyValueCollection ,
			string pstrDisplayNameTemplate ,
			U penmDefaultParameterSource )
		{
            OperatingParametersCollection<T , U> rtheOperatingParametersCollection = null;

            lock ( s_srCriticalSection )
            {   // Make this call thread-safe.
                rtheOperatingParametersCollection = s_genTheOnlyInstance;

                rtheOperatingParametersCollection.InitiaalizeInstance (
                    psettingsPropertyValueCollection ,
                    pstrDisplayNameTemplate ,
                    penmDefaultParameterSource );
            }   // lock ( s_srCriticalSection )

            return rtheOperatingParametersCollection;
		}   // GetTheSingleInstance Method
 /// <summary>
 /// Recupera os valores das propriedades do perfil.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="collection"></param>
 /// <returns></returns>
 public override System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection)
 {
     throw new NotImplementedException();
 }
示例#6
0
 public virtual void Initialize(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection properties, System.Configuration.SettingsProviderCollection providers)
 {
     this._profileBase.Initialize(context, properties, providers);
 }
 public abstract virtual System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection)
 {
 }
 public void Initialize(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection properties, System.Configuration.SettingsProviderCollection providers)
 {
 }
 public void Upgrade(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection properties)
 {
     throw new NotImplementedException();
 }
示例#10
0
 public System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext context, System.Configuration.SettingsPropertyCollection collection)
 {
     return(profileProvider.GetPropertyValues(context, collection));
 }
 public override System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext sc, System.Configuration.SettingsPropertyCollection properties)
 {
     return(default(System.Configuration.SettingsPropertyValueCollection));
 }
 public virtual System.Configuration.SettingsPropertyValueCollection GetPropertyValues(System.Configuration.SettingsContext sc, System.Configuration.SettingsPropertyCollection properties)
 {
 }
        public void GetPropertyValues()
        {
            User p = new User()
            {
                Application = app,
                IsAnonymous = false,
                UserName = "******"
            };
            p.Save();

            System.Configuration.SettingsContext sc = new System.Configuration.SettingsContext();
            sc.Add("UserName", "user1");
            sc.Add("IsAuthenticated", true);

            System.Configuration.SettingsPropertyValueCollection properties = new System.Configuration.SettingsPropertyValueCollection();

            var propVal = new System.Configuration.SettingsPropertyValue(
                new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType = typeof(string) }
                );
            propVal.PropertyValue = "test string";
            properties.Add(propVal);
            ProfileManager.Provider.SetPropertyValues(sc, properties);
            User.Evict(p.ID);

            System.Configuration.SettingsPropertyCollection outCol = new System.Configuration.SettingsPropertyCollection();
            outCol.Add(new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType = typeof(string) });
            System.Configuration.SettingsPropertyValueCollection collection = ProfileManager.Provider.GetPropertyValues(sc, outCol);

            Assert.Equal("test string", collection["Test"].PropertyValue);
        }