using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Management.Automation;
namespace Intel.Management.Module
{
///
/// Base definition of an AmtDriveItem
///
public class AmtDriveItem
{
protected string _name;
protected object _value;
// defines an Empty Container
protected static readonly AmtDriveItem[] _emptyContainer = new AmtDriveItem[0];
protected static readonly string[] _emptyProperties = new string[0];
public AmtDriveItem(String name)
{
_name = name;
_value = string.Empty;
}
public AmtDriveItem(String name,object value)
{
_name = name;
_value = value;
}
public virtual void SetItem(AmtDriveInfo driveInfo,object values, bool force)
{
}
public virtual object GetProperty(AmtDriveInfo info, Collection propList)
{
return null;
}
public virtual void SetProperty(AmtDriveInfo info, PSObject propertyValue, bool force)
{
}
public virtual void Invoke(AmtDriveInfo driveInfo)
{
}
public virtual object InvokeDefaultActionDynamicParameters(AmtDriveInfo driveInfo)
{
return null;
}
public virtual AmtDriveItem NewItem(AmtDriveInfo driveInfo, string name, string type, object newItem)
{
throw new InvalidOperationException();
}
public virtual void RemoveItem(AmtDriveInfo driveInfo, bool force)
{
throw new InvalidOperationException();
}
public virtual string Name
{
get { return _name; }
}
public virtual object Value
{
get { return _value; }
}
public virtual string[] Properties
{
get { return _emptyProperties; }
}
public virtual AmtDriveItem[] GetChildItems(AmtDriveInfo driveInfo)
{
return _emptyContainer;
}
public virtual void ClearItemCache()
{
}
protected object GetProperties(IDictionary props, Collection propList)
{
object result = null;
if (propList.Count == 0)
{
result = new PSObject();
//write all the properties
foreach (KeyValuePair pair in props)
{
((PSObject)result).Properties.Add(
new PSNoteProperty(pair.Key, pair.Value));
}
}
else if (propList.Count == 1)
{
result = props[propList[0]];
}
else
{
result = new PSObject();
foreach (string propName in propList)
{
((PSObject)result).Properties.Add(
new PSNoteProperty(propName, props[propName]));
}
}
return result;
}
}
}