119 lines
3.7 KiB
C#
119 lines
3.7 KiB
C#
/*
|
|
* DTS.Slice.Control.ReviewableAttribute.cs
|
|
*
|
|
* Copyright © 2009
|
|
* Diversified Technical Systems, Inc.
|
|
* All Rights Reserved
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DTS.Utilities;
|
|
using DTS.Utilities.DotNetProgrammingConstructs;
|
|
|
|
namespace DTS.Slice.Control
|
|
{
|
|
/// <summary>
|
|
/// Representation of a "reviewable" attribute.
|
|
/// </summary>
|
|
abstract public class ReviewableAttribute : Exceptional
|
|
{ ///
|
|
/// <summary>
|
|
/// Initialize an instance of the ReviewableAttribute class.
|
|
/// </summary>
|
|
///
|
|
/// <param name="name">
|
|
/// The <see cref="string"/> name of the attribute represented by this object.
|
|
/// </param>
|
|
///
|
|
/// <param name="value">
|
|
/// The value of the attribute represented by this object.
|
|
/// </param>
|
|
///
|
|
public ReviewableAttribute(string name, DetermineValueString calculateValue)
|
|
{
|
|
try
|
|
{
|
|
this.Name = name;
|
|
this.CalculateValue = calculateValue;
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new ReviewableAttribute.Exception("encountered problem constructing " + this.GetType().FullName, ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The <see cref="string"/> name associated with this review tab-displayable attribute.
|
|
/// </summary>
|
|
public string Name
|
|
{
|
|
get { return _Name.Value; }
|
|
private set { _Name.Value = value; }
|
|
}
|
|
private Property<string> _Name
|
|
= new Property<string>(
|
|
typeof(ReviewableAttribute).Namespace + ".ReviewableAttribute.Name",
|
|
null,
|
|
false
|
|
);
|
|
|
|
/// <summary>
|
|
/// Get the value <see cref="string"/> for this attribute.
|
|
/// </summary>
|
|
public string Value
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
return CalculateValue();
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
Utilities.Logging.APILogger.Log("encountered problem getting ReviewableAttribute value", ex);
|
|
return "N/A";
|
|
//throw new ReviewableAttribute.Exception( "encountered problem getting ReviewableAttribute value", ex );
|
|
}
|
|
}
|
|
}
|
|
|
|
// Need to attach the list of attribute "accessors" to the channel in a similar way
|
|
// we do with filters. Have an "available" list. And then an "active" list.
|
|
public delegate string DetermineValueString();
|
|
|
|
/// <summary>
|
|
/// Determine the value associated with this review tab-displayable attribute.
|
|
/// </summary>
|
|
private DetermineValueString CalculateValue
|
|
{
|
|
get
|
|
{
|
|
try
|
|
{
|
|
if (!_CalculateValueIsInitialized)
|
|
throw new ApplicationException("method property \"CalculateValue\" has not been initialized");
|
|
else return _CalculateValue;
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
throw new ReviewableAttribute.Exception("encountered problem getting property value", ex);
|
|
}
|
|
}
|
|
|
|
set
|
|
{
|
|
_CalculateValue = value;
|
|
_CalculateValueIsInitialized = true;
|
|
}
|
|
}
|
|
private DetermineValueString _CalculateValue;
|
|
private bool _CalculateValueIsInitialized = false;
|
|
}
|
|
}
|