Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added the option of to set MEF component attribute values from the …
…web.config file.
- Loading branch information
1 parent
a73854d
commit 930c3e4
Showing
6 changed files
with
301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// <copyright> | ||
// Copyright by the Spark Development Network | ||
// | ||
// Licensed under the Rock Community License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.rockrms.com/license | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
// | ||
using System.Configuration; | ||
|
||
namespace Rock.Configuration | ||
{ | ||
/// <summary> | ||
/// Read Attribute Value node in rockConffig | ||
/// </summary> | ||
public class AttributeValueConfig : ConfigurationElement | ||
{ | ||
public AttributeValueConfig() | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Gets the attribute key. | ||
/// </summary> | ||
/// <value> | ||
/// The attribute key. | ||
/// </value> | ||
[ConfigurationProperty( "attributeKey", IsRequired = true )] | ||
public string AttributeKey | ||
{ | ||
get | ||
{ | ||
return this["attributeKey"] as string; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the entitytype Id. | ||
/// </summary> | ||
/// <value> | ||
/// The entitytype Id. | ||
/// </value> | ||
[ConfigurationProperty( "entityTypeId", IsRequired = true )] | ||
public string EntityTypeId | ||
{ | ||
get | ||
{ | ||
return this["entityTypeId"] as string; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the entitytype qualifier column. | ||
/// </summary> | ||
/// <value> | ||
/// The entitytype qualifier column. | ||
/// </value> | ||
[ConfigurationProperty( "entityTypeQualifierColumm" )] | ||
public string EntityTypeQualifierColumm | ||
{ | ||
get | ||
{ | ||
return this["entityTypeQualifierColumm"] as string; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the entitytype qualifier value. | ||
/// </summary> | ||
/// <value> | ||
/// The entitytype qualifier value. | ||
/// </value> | ||
[ConfigurationProperty( "entityTypeQualifierValue" )] | ||
public string EntityTypeQualifierValue | ||
{ | ||
get | ||
{ | ||
return this["entityTypeQualifierValue"] as string; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the entity Id. | ||
/// </summary> | ||
/// <value> | ||
/// The entity Id. | ||
/// </value> | ||
[ConfigurationProperty( "entityId", IsRequired = true )] | ||
public string EntityId | ||
{ | ||
get | ||
{ | ||
return this["entityId"] as string; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the attribute value. | ||
/// </summary> | ||
/// <value> | ||
/// The attribute value. | ||
/// </value> | ||
[ConfigurationProperty( "value", IsRequired = true )] | ||
public string Value | ||
{ | ||
get | ||
{ | ||
return this["value"] as string; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// <copyright> | ||
// Copyright by the Spark Development Network | ||
// | ||
// Licensed under the Rock Community License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.rockrms.com/license | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
// | ||
using System.Configuration; | ||
|
||
namespace Rock.Configuration | ||
{ | ||
/// <summary> | ||
/// Attribute Value Collection | ||
/// </summary> | ||
public class AttributeValuesConfig : ConfigurationElementCollection | ||
{ | ||
public AttributeValueConfig this[int index] | ||
{ | ||
get | ||
{ | ||
return base.BaseGet( index ) as AttributeValueConfig; | ||
} | ||
set | ||
{ | ||
if ( base.BaseGet( index ) != null ) | ||
{ | ||
base.BaseRemoveAt( index ); | ||
} | ||
this.BaseAdd( index, value ); | ||
} | ||
} | ||
|
||
public new AttributeValueConfig this[string responseString] | ||
{ | ||
get { return ( AttributeValueConfig ) BaseGet( responseString ); } | ||
set | ||
{ | ||
if ( BaseGet( responseString ) != null ) | ||
{ | ||
BaseRemoveAt( BaseIndexOf( BaseGet( responseString ) ) ); | ||
} | ||
BaseAdd( value ); | ||
} | ||
} | ||
|
||
protected override System.Configuration.ConfigurationElement CreateNewElement() | ||
{ | ||
return new AttributeValueConfig(); | ||
} | ||
|
||
protected override object GetElementKey( System.Configuration.ConfigurationElement element ) | ||
{ | ||
return string.Format("{0}-{1}", ( ( AttributeValueConfig ) element ).AttributeKey, ( ( AttributeValueConfig ) element ).EntityId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// <copyright> | ||
// Copyright by the Spark Development Network | ||
// | ||
// Licensed under the Rock Community License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.rockrms.com/license | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
// | ||
using System; | ||
using System.Configuration; | ||
|
||
namespace Rock.Configuration | ||
{ | ||
/// <summary> | ||
/// Read RockConfig section from Web.Config | ||
/// </summary> | ||
public class RockConfig : ConfigurationSection | ||
{ | ||
private static RockConfig config | ||
= ConfigurationManager.GetSection( "rockConfig" ) as RockConfig; | ||
|
||
public static RockConfig Config | ||
{ | ||
get | ||
{ | ||
return config; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the attribute Value Collection. | ||
/// </summary> | ||
/// <value> | ||
/// The attribute values. | ||
/// </value> | ||
[System.Configuration.ConfigurationProperty( "attributeValues" )] | ||
[ConfigurationCollection( typeof( AttributeValuesConfig ), AddItemName = "attributeValue" )] | ||
public AttributeValuesConfig AttributeValues | ||
{ | ||
get | ||
{ | ||
object o = this["attributeValues"]; | ||
return o as AttributeValuesConfig; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters