C# Class Framework.Profile

Inheritance: IProfile
Afficher le fichier Open project: CarlosX/DarkEmu Class Usage Examples

Méthodes publiques

Méthode Description
Clone ( ) : object

Retrieves a copy of itself.

This method needs to be implemented by derived classes.

CloneReadOnly ( ) : IReadOnlyProfile

Retrieves a copy of itself and makes it read-only.

This method serves as a convenient way to pass a read-only copy of the profile to methods that are not allowed to modify it.

GetDataSet ( ) : DataSet

Retrieves a DataSet object containing every section, entry, and value in the profile.

The returned DataSet will be named using the Name property. It will contain one table for each section, and each entry will be represented by a column inside the table. Each table will contain only one row where the values will stored corresponding to each column (entry).

This method serves as a convenient way to extract the profile's data to this generic medium known as the DataSet. This allows it to be moved to many different places, including a different type of profile object (eg., INI to XML conversion).

This method calls GetSectionNames, GetEntryNames, and GetValue of the derived class, so check the documentation to see what other exceptions may be raised.

GetEntryNames ( string section ) : string[]

Retrieves the names of all the entries inside a section.

This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise.

GetSectionNames ( ) : string[]

Retrieves the names of all the sections.

This method needs to be implemented by derived classes. Check the documentation to see what exceptions derived versions may raise.

GetValue ( string section, string entry, bool defaultValue ) : bool

Retrieves the bool value of an entry inside a section, or a default value if the entry does not exist.

Note: Boolean values are stored as "True" or "False".

This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.

GetValue ( string section, string entry, double defaultValue ) : double

Retrieves the double value of an entry inside a section, or a default value if the entry does not exist.

This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.

GetValue ( string section, string entry, int defaultValue ) : int

Retrieves the integer value of an entry inside a section, or a default value if the entry does not exist.

This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.

GetValue ( string section, string entry ) : object

Retrieves the value of an entry inside a section.

This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise.

GetValue ( string section, string entry, string defaultValue ) : string

Retrieves the string value of an entry inside a section, or a default value if the entry does not exist.

This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.

HasEntry ( string section, string entry ) : bool

Determines if an entry exists inside a section.

This method calls GetEntryNames of the derived class, so check its documentation to see what other exceptions may be raised.

HasSection ( string section ) : bool

Determines if a section exists.

RemoveEntry ( string section, string entry ) : void

Removes an entry from a section.

This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.RemoveEntry for additional remarks.

RemoveSection ( string section ) : void

Removes a section.

This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.RemoveSection for additional remarks.

SetDataSet ( DataSet ds ) : void

Writes the data of every table from a DataSet into this profile.

Each table in the DataSet represents a section of the profile. Each column of each table represents an entry. And for each column, the corresponding value of the first row is the value to be passed to SetValue. Note that only the first row is imported; additional rows are ignored.

This method serves as a convenient way to take any data inside a generic DataSet and write it to any of the available profiles.

This method calls SetValue of the derived class, so check its documentation to see what other exceptions may be raised.

SetValue ( string section, string entry, object value ) : void

Sets the value for an entry inside a section.

This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.SetValue for additional remarks.

Méthodes protégées

Méthode Description
OnChanged ( ProfileChangedArgs e ) : void

Raises the Changed event.

This method should be invoked after a change to the profile has been made so that the Changed event is raised, giving a chance to the handlers to be notified of the change.

OnChanging ( ProfileChangingArgs e ) : void

Raises the Changing event.

This method should be invoked prior to making a change to the profile so that the Changing event is raised, giving a chance to the handlers to prevent the change from happening (by setting e.Cancel to true). This method calls each individual handler associated with the Changing event and checks the resulting e.Cancel flag. If it's true, it stops and does not call of any remaining handlers since the change needs to be prevented anyway.

Profile ( ) : System

Initializes a new instance of the Profile class by setting the Name to DefaultName.

Profile ( Profile profil ) : System

Initializes a new instance of the Profile class based on another Profile object.

Profile ( string name ) : System

Initializes a new instance of the Profile class by setting the Name to a value.

RaiseChangeEvent ( bool changing, ProfileChangeType changeType, string section, string entry, object value ) : bool

Raises either the Changing or Changed event.

This method may be used by derived classes as a convenient alternative to calling OnChanging and OnChanged. For example, a typical call to OnChanging would require four lines of code, which this method reduces to two.

VerifyAndAdjustEntry ( string &entry ) : void

Verifies the given entry name is not null and trims it.

This method may be used by derived classes to make sure that a valid entry name has been passed, and to make any necessary adjustments to it before passing it to the corresponding APIs.

VerifyAndAdjustSection ( string &section ) : void

Verifies the given section name is not null and trims it.

This method may be used by derived classes to make sure that a valid section name has been passed, and to make any necessary adjustments to it before passing it to the corresponding APIs.

VerifyName ( ) : void

Verifies the Name property is not empty or null.

This method may be used by derived classes to make sure that the APIs are working with a valid Name (file name)

VerifyNotReadOnly ( ) : void

Verifies the ReadOnly property is not true.

This method may be used by derived classes as a convenient way to validate that modifications to the profile can be made.

Method Details

Clone() public abstract méthode

Retrieves a copy of itself.
This method needs to be implemented by derived classes.
public abstract Clone ( ) : object
Résultat object

CloneReadOnly() public méthode

Retrieves a copy of itself and makes it read-only.
This method serves as a convenient way to pass a read-only copy of the profile to methods that are not allowed to modify it.
public CloneReadOnly ( ) : IReadOnlyProfile
Résultat IReadOnlyProfile

GetDataSet() public méthode

Retrieves a DataSet object containing every section, entry, and value in the profile.
The returned DataSet will be named using the Name property. It will contain one table for each section, and each entry will be represented by a column inside the table. Each table will contain only one row where the values will stored corresponding to each column (entry).

This method serves as a convenient way to extract the profile's data to this generic medium known as the DataSet. This allows it to be moved to many different places, including a different type of profile object (eg., INI to XML conversion).

This method calls GetSectionNames, GetEntryNames, and GetValue of the derived class, so check the documentation to see what other exceptions may be raised.

/// is null or empty.
public GetDataSet ( ) : DataSet
Résultat System.Data.DataSet

GetEntryNames() public abstract méthode

Retrieves the names of all the entries inside a section.
This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise.
/// section is null.
public abstract GetEntryNames ( string section ) : string[]
section string /// The name of the section holding the entries.
Résultat string[]

GetSectionNames() public abstract méthode

Retrieves the names of all the sections.
This method needs to be implemented by derived classes. Check the documentation to see what exceptions derived versions may raise.
public abstract GetSectionNames ( ) : string[]
Résultat string[]

GetValue() public méthode

Retrieves the bool value of an entry inside a section, or a default value if the entry does not exist.
Note: Boolean values are stored as "True" or "False".

This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.

/// is null or empty. /// Either section or entry is null.
public GetValue ( string section, string entry, bool defaultValue ) : bool
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
defaultValue bool /// The value to return if the entry (or section) does not exist.
Résultat bool

GetValue() public méthode

Retrieves the double value of an entry inside a section, or a default value if the entry does not exist.
This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.
/// is null or empty. /// Either section or entry is null.
public GetValue ( string section, string entry, double defaultValue ) : double
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
defaultValue double /// The value to return if the entry (or section) does not exist.
Résultat double

GetValue() public méthode

Retrieves the integer value of an entry inside a section, or a default value if the entry does not exist.
This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.
/// is null or empty. /// Either section or entry is null.
public GetValue ( string section, string entry, int defaultValue ) : int
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
defaultValue int /// The value to return if the entry (or section) does not exist.
Résultat int

GetValue() public abstract méthode

Retrieves the value of an entry inside a section.
This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise.
/// is null or empty. /// Either section or entry is null.
public abstract GetValue ( string section, string entry ) : object
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
Résultat object

GetValue() public méthode

Retrieves the string value of an entry inside a section, or a default value if the entry does not exist.
This method calls GetValue(section, entry) of the derived class, so check its documentation to see what other exceptions may be raised.
/// is null or empty. /// Either section or entry is null.
public GetValue ( string section, string entry, string defaultValue ) : string
section string /// The name of the section that holds the entry with the value.
entry string /// The name of the entry where the value is stored.
defaultValue string /// The value to return if the entry (or section) does not exist.
Résultat string

HasEntry() public méthode

Determines if an entry exists inside a section.
This method calls GetEntryNames of the derived class, so check its documentation to see what other exceptions may be raised.
/// section is null.
public HasEntry ( string section, string entry ) : bool
section string /// The name of the section that holds the entry.
entry string /// The name of the entry to be checked for existence.
Résultat bool

HasSection() public méthode

Determines if a section exists.
public HasSection ( string section ) : bool
section string /// The name of the section to be checked for existence.
Résultat bool

OnChanged() protected méthode

Raises the Changed event.
This method should be invoked after a change to the profile has been made so that the Changed event is raised, giving a chance to the handlers to be notified of the change.
protected OnChanged ( ProfileChangedArgs e ) : void
e ProfileChangedArgs /// The arguments object associated with the Changed event.
Résultat void

OnChanging() protected méthode

Raises the Changing event.
This method should be invoked prior to making a change to the profile so that the Changing event is raised, giving a chance to the handlers to prevent the change from happening (by setting e.Cancel to true). This method calls each individual handler associated with the Changing event and checks the resulting e.Cancel flag. If it's true, it stops and does not call of any remaining handlers since the change needs to be prevented anyway.
protected OnChanging ( ProfileChangingArgs e ) : void
e ProfileChangingArgs /// The arguments object associated with the Changing event.
Résultat void

Profile() protected méthode

Initializes a new instance of the Profile class by setting the Name to DefaultName.
protected Profile ( ) : System
Résultat System

Profile() protected méthode

Initializes a new instance of the Profile class based on another Profile object.
protected Profile ( Profile profil ) : System
profil Profile
Résultat System

Profile() protected méthode

Initializes a new instance of the Profile class by setting the Name to a value.
protected Profile ( string name ) : System
name string /// The name to initialize the property with.
Résultat System

RaiseChangeEvent() protected méthode

Raises either the Changing or Changed event.
This method may be used by derived classes as a convenient alternative to calling OnChanging and OnChanged. For example, a typical call to OnChanging would require four lines of code, which this method reduces to two.
protected RaiseChangeEvent ( bool changing, ProfileChangeType changeType, string section, string entry, object value ) : bool
changing bool /// If true, the Changing event is raised otherwise it's Changed.
changeType ProfileChangeType /// The type of change being made.
section string /// The name of the section that was involved in the change or null if not applicable.
entry string /// The name of the entry that was involved in the change or null if not applicable. /// If changeType is equal to Other, entry is the name of the property involved in the change.
value object /// The value that was changed or null if not applicable.
Résultat bool

RemoveEntry() public abstract méthode

Removes an entry from a section.
This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.RemoveEntry for additional remarks.
/// is true. /// Either section or entry is null.
public abstract RemoveEntry ( string section, string entry ) : void
section string /// The name of the section that holds the entry.
entry string /// The name of the entry to remove.
Résultat void

RemoveSection() public abstract méthode

Removes a section.
This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.RemoveSection for additional remarks.
/// is true. /// section is null.
public abstract RemoveSection ( string section ) : void
section string /// The name of the section to remove.
Résultat void

SetDataSet() public méthode

Writes the data of every table from a DataSet into this profile.
Each table in the DataSet represents a section of the profile. Each column of each table represents an entry. And for each column, the corresponding value of the first row is the value to be passed to SetValue. Note that only the first row is imported; additional rows are ignored.

This method serves as a convenient way to take any data inside a generic DataSet and write it to any of the available profiles.

This method calls SetValue of the derived class, so check its documentation to see what other exceptions may be raised.

/// is true or /// is null or empty. /// ds is null.
public SetDataSet ( DataSet ds ) : void
ds System.Data.DataSet /// The DataSet object containing the data to be set.
Résultat void

SetValue() public abstract méthode

Sets the value for an entry inside a section.
This method needs to be implemented by derived classes. Check the documentation to see what other exceptions derived versions may raise. See IProfile.SetValue for additional remarks.
/// is true or /// is null or empty. /// Either section or entry is null.
public abstract SetValue ( string section, string entry, object value ) : void
section string /// The name of the section that holds the entry.
entry string /// The name of the entry where the value will be set.
value object /// The value to set. If it's null, the entry should be removed.
Résultat void

VerifyAndAdjustEntry() protected méthode

Verifies the given entry name is not null and trims it.
This method may be used by derived classes to make sure that a valid entry name has been passed, and to make any necessary adjustments to it before passing it to the corresponding APIs.
/// entry is null.
protected VerifyAndAdjustEntry ( string &entry ) : void
entry string /// The entry name to verify and adjust.
Résultat void

VerifyAndAdjustSection() protected méthode

Verifies the given section name is not null and trims it.
This method may be used by derived classes to make sure that a valid section name has been passed, and to make any necessary adjustments to it before passing it to the corresponding APIs.
/// section is null.
protected VerifyAndAdjustSection ( string &section ) : void
section string /// The section name to verify and adjust.
Résultat void

VerifyName() protected méthode

Verifies the Name property is not empty or null.
This method may be used by derived classes to make sure that the APIs are working with a valid Name (file name)
/// name is empty or null.
protected VerifyName ( ) : void
Résultat void

VerifyNotReadOnly() protected méthode

Verifies the ReadOnly property is not true.
This method may be used by derived classes as a convenient way to validate that modifications to the profile can be made.
/// ReadOnly is true.
protected VerifyNotReadOnly ( ) : void
Résultat void