729 lines
26 KiB
C#
729 lines
26 KiB
C#
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (c) Intel Corporation, 2008 - 2011 All Rights Reserved.
|
|
//
|
|
// File: CimBase.cs
|
|
//
|
|
// Contents: CimBase is a part of the CimFramework project.
|
|
// It contains an abstract class that all typed Cim
|
|
// Generated classes inherit from.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Reflection;
|
|
using System.Xml;
|
|
using Intel.Manageability.Cim.Untyped;
|
|
using Intel.Manageability.Exceptions;
|
|
using Intel.Manageability.WSManagement;
|
|
|
|
namespace Intel.Manageability.Cim.Typed
|
|
{
|
|
using Property = KeyValuePair<string, string>;
|
|
|
|
/// <summary>
|
|
/// Base Class for all typed CIM classes.
|
|
/// This class implements the CIM common methods (e.g. - get, delete, create, etc.)
|
|
/// </summary>
|
|
public abstract class CimBase
|
|
{
|
|
|
|
#region PRIVATE_PROPERTIES
|
|
|
|
/// <summary>
|
|
/// internal untyped CIM object
|
|
/// </summary>
|
|
private CimObject cimObject { get; set; }
|
|
|
|
/// <summary>
|
|
/// WsMan Client
|
|
/// </summary>
|
|
public IWSManClient WSManClient
|
|
{
|
|
get
|
|
{
|
|
return cimObject.WSManClient;
|
|
}
|
|
set
|
|
{
|
|
cimObject.WSManClient = value;
|
|
}
|
|
}
|
|
|
|
#endregion //PRIVATE_PROPERTIES
|
|
|
|
#region PUBLIC_PROPERTIES
|
|
|
|
/// <summary>
|
|
/// The CIM namespace of the object
|
|
/// </summary>
|
|
public string XmlNamespace
|
|
{
|
|
get
|
|
{
|
|
return cimObject.XmlNamespace;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get a CimReference object corresponding to the current object
|
|
/// </summary>
|
|
public CimReference Reference
|
|
{
|
|
get
|
|
{
|
|
if (WSManClient == null)
|
|
throw new CimException("Transport client not initialized");
|
|
|
|
|
|
// Create a new CimReference object and set its values
|
|
Type myObjectType = this.GetType();
|
|
// TODO: change this!!!!!
|
|
List<Intel.Manageability.Cim.Key> lst = new List<Intel.Manageability.Cim.Key>();
|
|
String fieldValue = String.Empty;
|
|
|
|
PropertyInfo[] props = myObjectType.GetProperties();
|
|
foreach (PropertyInfo propObj in props)
|
|
{
|
|
|
|
foreach (object attr in Attribute.GetCustomAttributes(propObj))
|
|
{
|
|
if (attr.GetType() == typeof(CimFieldAttribute))
|
|
{
|
|
try
|
|
{
|
|
fieldValue = propObj.GetValue(this, null).ToString();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
fieldValue = String.Empty;
|
|
}
|
|
if ((attr as CimFieldAttribute).IsKey && fieldValue != String.Empty)
|
|
{
|
|
if (propObj.PropertyType.Name.Equals("CimReference"))
|
|
{
|
|
XmlDocument XmlMembers = new XmlDocument();
|
|
XmlMembers.LoadXml(fieldValue);
|
|
CimReference value = new CimReference("EndpointReference", CimReference.WSMAN_ADDRESSING_NAMESPACE_URI, XmlMembers.DocumentElement.InnerXml);
|
|
lst.Add(new Intel.Manageability.Cim.Key(propObj.Name, value));
|
|
//fieldValue = CimReference.CreateEPR(XmlMembers.DocumentElement.InnerXml, "EndpointReference", WSMAN_ADDRESSING_NAMESPACE_URI);
|
|
}
|
|
else
|
|
{
|
|
lst.Add(new Intel.Manageability.Cim.Key(propObj.Name, fieldValue));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CimReference objRef = new CimReference("EndpointReference", CimReference.WSMAN_ADDRESSING_NAMESPACE_URI,
|
|
CimReference.WSMAN_ADDRESSING_NAMESPACE_URI,
|
|
new ReferenceParameters(XmlNamespace, lst));
|
|
//objRef.Address = ;
|
|
//objRef.Name = "EndpointReference";
|
|
//objRef.Namespace = XmlNamespace;
|
|
//objRef.referenceParameters = ;
|
|
return objRef;
|
|
}
|
|
}
|
|
|
|
#endregion //PUBLIC_PROPERTIES
|
|
|
|
#region PRIVATE_METHODS
|
|
|
|
/// <summary>
|
|
/// Get CIM Field Attribute
|
|
/// </summary>
|
|
/// <param name="name">field name</param>
|
|
/// <returns>CimFieldAttribute object corresponding to the requested field (null if name is not found)</returns>
|
|
private CimFieldAttribute GetFieldAtttribute(string name)
|
|
{
|
|
PropertyInfo[] props = this.GetType().GetProperties();
|
|
foreach (PropertyInfo propObj in props)
|
|
{
|
|
if (propObj.Name == name)
|
|
{
|
|
foreach (object attr in Attribute.GetCustomAttributes(propObj, true))
|
|
{
|
|
if (attr.GetType() == typeof(CimFieldAttribute))
|
|
{
|
|
CimFieldAttribute attr1 = attr as CimFieldAttribute;
|
|
return attr1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Factory method to create a concrete class descended from CimBase
|
|
/// </summary>
|
|
/// <param name="className">Name of the class to create.</param>
|
|
/// <returns>An instance of the class that was requested.</returns>
|
|
private static CimBase createInstanceByString(string className, string baseClassName)
|
|
{
|
|
Type type = Type.GetType(typeof(CimBase).Namespace + "." + className);
|
|
// In case we can't create the class itself - creating the base class
|
|
if (type == null)
|
|
{
|
|
type = Type.GetType(typeof(CimBase).Namespace + "." + baseClassName);
|
|
if (type == null)
|
|
{
|
|
throw (new CimException(string.Format("Received an unknown class - " + className)));
|
|
}
|
|
}
|
|
CimBase known = (CimBase)Activator.CreateInstance(type);
|
|
return known;
|
|
}
|
|
|
|
#endregion // PRIVATE_METHODS
|
|
|
|
#region PROTECTED_METHODS
|
|
|
|
/// <summary>
|
|
/// Constructor that receives a WsMan client
|
|
/// </summary>
|
|
/// <param name="client">Ws-Management client</param>
|
|
protected CimBase(IWSManClient client)
|
|
{
|
|
cimObject = new CimObject(this.GetType().Name, CimReference.GetResourceUri(this.GetType()).ToString());
|
|
cimObject.WSManClient = client;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Default constructor
|
|
/// </summary>
|
|
protected CimBase()
|
|
{
|
|
|
|
cimObject = new CimObject(this.GetType().Name, CimReference.GetResourceUri(this.GetType()).ToString());
|
|
cimObject.WSManClient = null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieves a field's values
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <returns>An array of the field's values</returns>
|
|
protected string[] GetField(string name)
|
|
{
|
|
return cimObject.GetField(name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set CIM Field value
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <param name="value">CIM Field value</param>
|
|
protected void SetField(string name, string value)
|
|
{
|
|
cimObject.SetField(name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set CIM Field value
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <param name="value">CIM Field value array</param>
|
|
protected void SetField(string name, string[] value)
|
|
{
|
|
cimObject.SetField(name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets an existing field's value, or adds the value for a new field
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <param name="value">CIM Field value</param>
|
|
protected void SetOrAddField(string name, string value)
|
|
{
|
|
cimObject.SetOrAddField(name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set an existing field's values, or adds the value for a new field
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <param name="value">CIM Field value array</param>
|
|
protected void SetOrAddField(string name, string[] value)
|
|
{
|
|
cimObject.SetOrAddField(name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get field value
|
|
/// </summary>
|
|
/// <param name="name">CIM Field name</param>
|
|
/// <returns>CIM Field value</returns>
|
|
protected string[] this[string name]
|
|
{
|
|
get
|
|
{
|
|
return GetField(name);
|
|
}
|
|
|
|
set
|
|
{
|
|
SetField(name, value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a new CIM field
|
|
/// </summary>
|
|
/// <param name="name">Field name</param>
|
|
/// <param name="value">Value of the field</param>
|
|
protected void AddField(string name, string value)
|
|
{
|
|
cimObject.AddField(name, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a new CIM Field
|
|
/// </summary>
|
|
/// <param name="item">Pair of field name and value</param>
|
|
protected void AddField(KeyValuePair<string, string> item)
|
|
{
|
|
cimObject.AddField(item.Key, item.Value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Add a new CIM Field
|
|
/// </summary>
|
|
/// <param name="item">Pair of field name and an array of values</param>
|
|
protected void AddField(KeyValuePair<string, string[]> item)
|
|
{
|
|
cimObject.AddField(item.Key, item.Value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invoke a CIM method
|
|
/// </summary>
|
|
/// <typeparam name="TInput"></typeparam>
|
|
/// <typeparam name="TOutput"></typeparam>
|
|
/// <param name="methodName">The name of the method to be invoked</param>
|
|
/// <param name="input">The input parameters</param>
|
|
/// <param name="output">The output parameters</param>
|
|
protected uint Invoke<TInput, TOutput>(string methodName, TInput input, out TOutput output)
|
|
where TInput : CimParams
|
|
where TOutput : CimParams, new()
|
|
{
|
|
CimParams tmpOut;
|
|
CimObject.CimKeys keys = new CimObject.CimKeys(Reference.GetKeys());
|
|
uint returnValue = cimObject.Invoke(methodName, keys, input, out tmpOut);
|
|
output = new TOutput();
|
|
output.Copy(tmpOut);
|
|
return returnValue;
|
|
}
|
|
|
|
|
|
#endregion //PROTECTED_METHODS
|
|
|
|
#region PUBLIC_METHODS
|
|
|
|
/// <summary>
|
|
/// Checks if the object contains a field
|
|
/// </summary>
|
|
/// <param name="name">Name of the field</param>
|
|
/// <returns>True if the object contains the field, otherwise false.</returns>
|
|
protected bool ContainsField(string name)
|
|
{
|
|
return cimObject.ContainsField(name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Removes a field.
|
|
/// </summary>
|
|
/// <param name="name">CIM Field Name</param>
|
|
protected void RemoveField(string name)
|
|
{
|
|
if (IsKey(name) || IsRequired(name))
|
|
throw new CimException("Field " + name + " can not be deleted.");
|
|
cimObject.RemoveField(name);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Checks if a given CIM field is a key
|
|
/// </summary>
|
|
/// <param name="name">Name of CIM field</param>
|
|
/// <returns>True if the given field is key, false otherwise</returns>
|
|
public bool IsKey(string name)
|
|
{
|
|
CimFieldAttribute field = GetFieldAtttribute(name);
|
|
|
|
if (field != null && field.IsKey)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if a given CIM field is Required
|
|
/// </summary>
|
|
/// <param name="name">Name of CIM Field</param>
|
|
/// <returns>True if the given field is required, false otherwise</returns>
|
|
public bool IsRequired(string name)
|
|
{
|
|
CimFieldAttribute field = GetFieldAtttribute(name);
|
|
|
|
if (field != null && field.IsRequired)
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates an object at an endpoint
|
|
/// </summary>
|
|
/// <returns>CimReference that represents the created object</returns>
|
|
public CimReference Create()
|
|
{
|
|
return cimObject.Create();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Serialize a CIM object To XML
|
|
/// </summary>
|
|
/// <returns>XML that represents the Cim object</returns>
|
|
public string Serialize()
|
|
{
|
|
return cimObject.Serialize();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Serialize a CIM object To XML
|
|
/// </summary>
|
|
/// <returns>Inner XML that represents the Cim object</returns>
|
|
public string SerializeInner()
|
|
{
|
|
return cimObject.SerializeInner();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deserialize a CIM object From XML
|
|
/// </summary>
|
|
/// <param name="xml">XML that represents the Cim object</param>
|
|
public void Deserialize(string xml)
|
|
{
|
|
cimObject.Deserialize(xml);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get an instance of a known CIM class
|
|
/// </summary>
|
|
/// <param name="reference">Reference to an object on an endpoint</param>
|
|
public void Get(CimReference reference)
|
|
{
|
|
//Arguments sanity check
|
|
if (reference == null)
|
|
throw new ArgumentNullException("reference");
|
|
|
|
cimObject.Get(reference);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get an instance of a known CIM class
|
|
/// </summary>
|
|
/// <param name="keys">Keys of the object to get</param>
|
|
public void Get(CimBase.CimKeys keys)
|
|
{
|
|
//Arguments sanity check
|
|
if (keys == null)
|
|
throw new ArgumentNullException("keys");
|
|
|
|
cimObject.Get(keys.cimObjectKeys);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get an instance of a known CIM class
|
|
/// </summary>
|
|
public void Get()
|
|
{
|
|
cimObject.Get(new CimObject.CimKeys(Reference.GetKeys()));
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="mode">The enumeration mode - Object / Reference / Object and Reference</param>
|
|
/// <param name="resultClassName">The results class name</param>
|
|
/// <param name="role">The role in the association class of the given object</param>
|
|
/// <param name="includeResultProperty">The properties should be include in the results</param>
|
|
/// <returns>Collection of pairs - CimBase, CimReference</returns>
|
|
public Collection<CimBaseReferencePair> EnumerateAssosiation(
|
|
EnumerationOptions.EnumerationMode mode,
|
|
String resultClassName,
|
|
String role,
|
|
String[] includeResultProperty)
|
|
{
|
|
EnumerationOptions enumOptions = new EnumerationOptions();
|
|
enumOptions.EnumMode = mode;
|
|
enumOptions.Filter = new AssociationFilter(this.Reference, resultClassName, role, includeResultProperty);
|
|
return CimBase.Enumerate(WSManClient, enumOptions);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="param">The enumeration mode - Object / Reference / Object and Reference</mode>
|
|
/// <param name="resultClassName">The results class name</param>
|
|
/// <param name="role">The role in the association class of the given object</param>
|
|
/// <param name="includeResultProperty">The properties should be include in the results</param>
|
|
/// <param name="associationClassName">The association class name</param>
|
|
/// <param name="resultRole">The role in the association class of the result objects</param>
|
|
/// <returns>Collection of pairs - CimBase, CimReference</returns>
|
|
public Collection<CimBaseReferencePair> EnumerateAssosiated(
|
|
EnumerationOptions.EnumerationMode mode,
|
|
String resultClassName,
|
|
String role,
|
|
String[] includeResultProperty,
|
|
String associationClassName,
|
|
String resultRole)
|
|
{
|
|
EnumerationOptions enumOptions = new EnumerationOptions();
|
|
enumOptions.EnumMode = mode;
|
|
enumOptions.Filter = new AssociatedFilter(this.Reference, resultClassName, role, includeResultProperty, associationClassName, resultRole);
|
|
return CimBase.Enumerate(WSManClient, enumOptions);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enumerate instances of CimBase class at an endpoint.
|
|
/// </summary>
|
|
/// <param name="client">WS-Management client</param>
|
|
/// <param name="options">Enumeration options</param>
|
|
/// <returns>Collection of pairs - CimBase, CimReference</returns>
|
|
public static Collection<CimBaseReferencePair> Enumerate(IWSManClient client, EnumerationOptions options)
|
|
{
|
|
if (options == null)
|
|
throw new ArgumentNullException("options");
|
|
if (options.Filter == null)
|
|
throw new ArgumentNullException("options.Filter");
|
|
|
|
|
|
Collection<CimObjectReferencePair> enumRes = CimObject.Enumerate(client, options);
|
|
|
|
Collection<CimBaseReferencePair> ret = new Collection<CimBaseReferencePair>();
|
|
|
|
foreach (CimObjectReferencePair pair in enumRes)
|
|
{
|
|
CimBase CimBaseObject = null;
|
|
if (pair.cimObject != null)
|
|
{
|
|
CimBaseObject = createInstanceByString(CimData.GetClassNameFromNamespace(pair.cimObject.XmlNamespace), string.Empty);
|
|
CimBaseObject.cimObject = pair.cimObject;
|
|
}
|
|
|
|
CimBaseReferencePair CimBaseEpr = new CimBaseReferencePair(CimBaseObject, pair.cimReference);
|
|
ret.Add(CimBaseEpr);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enumerate instances of a known CIM class
|
|
/// </summary>
|
|
/// <typeparam name="T">Cim class concrete type</typeparam>
|
|
/// <param name="client">WS-Management Client</param>
|
|
/// <param name="keys">Keys of the objects to get</param>
|
|
/// <returns>List of CIM objects</returns>
|
|
protected static List<T> Enumerate<T>(IWSManClient client, CimBase.CimKeys keys) where T : CimBase, new()
|
|
{
|
|
if (keys == null)
|
|
throw new ArgumentNullException("keys");
|
|
|
|
List<T> ret = new List<T>();
|
|
|
|
// Perform enumerate (using CimObject) into list of Cim Objects list.
|
|
Collection<CimObject> cims = CimObject.Enumerate(client, CimReference.GetResourceUri(typeof(T)), keys.cimObjectKeys);
|
|
|
|
// Create foreach Cim object concrete Cim and insert the Cim object as data member
|
|
foreach (CimObject cim in cims)
|
|
{
|
|
T concreteObject = new T();
|
|
try
|
|
{
|
|
concreteObject = (T)(createInstanceByString(CimData.GetClassNameFromNamespace(cim.XmlNamespace), CimData.GetClassNameFromNamespace(concreteObject.XmlNamespace)));
|
|
}
|
|
catch (CimException)
|
|
{
|
|
concreteObject = new T();
|
|
}
|
|
concreteObject.cimObject = cim;
|
|
ret.Add(concreteObject);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Enumerate instances of a known CIM class
|
|
/// </summary>
|
|
/// <typeparam name="T">Cim class concrete type</typeparam>
|
|
/// <param name="client">WS-Management Client</param>
|
|
/// <returns>List of CIM objects</returns>
|
|
protected static List<T> Enumerate<T>(IWSManClient client) where T : CimBase, new()
|
|
{
|
|
List<T> ret = new List<T>();
|
|
// Perform enumerate (using CimObject) into list of Cim objects
|
|
Collection<CimObject> cims = CimObject.Enumerate(client, CimReference.GetResourceUri(typeof(T)));
|
|
|
|
// Create Cim object for each concrete Cim and insert the Cim object as a data member
|
|
foreach (CimObject cim in cims)
|
|
{
|
|
T concreteObject = new T();
|
|
try
|
|
{
|
|
concreteObject = (T)(createInstanceByString(CimData.GetClassNameFromNamespace(cim.XmlNamespace), CimData.GetClassNameFromNamespace(concreteObject.XmlNamespace)));
|
|
}
|
|
catch (CimException)
|
|
{
|
|
concreteObject = new T();
|
|
}
|
|
concreteObject.cimObject = cim;
|
|
ret.Add(concreteObject);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates an object at an endpoint
|
|
/// </summary>
|
|
public void Put()
|
|
{
|
|
cimObject.Put(new CimObject.CimKeys(Reference.GetKeys()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes the current object from its endpoint
|
|
/// </summary>
|
|
public void Delete()
|
|
{
|
|
cimObject.Delete(new CimObject.CimKeys(Reference.GetKeys()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes an object at an endpoint, specified by the keys and the resourceURI
|
|
/// </summary>
|
|
/// <param name="wsmanClient"></param>
|
|
/// <param name="ResourceURI"></param>
|
|
/// <param name="keys">Keys of the object to delete</param>
|
|
public static void Delete(IWSManClient wsmanClient, Uri ResourceURI, CimBase.CimKeys keys)
|
|
{
|
|
//Arguments sanity check
|
|
if (keys == null)
|
|
throw new ArgumentNullException("keys");
|
|
|
|
CimObject.Delete(wsmanClient, ResourceURI, keys.cimObjectKeys);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes an object that is specified by a CimReference
|
|
/// </summary>
|
|
/// <param name="wsmanClient"></param>
|
|
/// <param name="reference">A reference to the object to be deleted</param>
|
|
public static void Delete(IWSManClient wsmanClient, CimReference reference)
|
|
{
|
|
CimObject.Delete(wsmanClient, reference);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes an object that is specified by a ResourceUri
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <param name="wsmanClient">IWSManClient</param>
|
|
protected static void Delete<T>(IWSManClient wsmanClient) where T : CimBase
|
|
{
|
|
CimObject.Delete(wsmanClient, CimReference.GetResourceUri(typeof(T)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieve a list of the object's fields
|
|
/// </summary>
|
|
public List<Property> Properties
|
|
{
|
|
get
|
|
{
|
|
return cimObject.Properties;
|
|
}
|
|
}
|
|
|
|
#endregion //PUBLIC_METHODS
|
|
|
|
/// <summary>
|
|
/// Generic abstract class that represents the keys of a CIM class.
|
|
/// This class is inherited by all typed CIM key classes.
|
|
/// </summary>
|
|
public abstract class CimKeys
|
|
{
|
|
/// <summary>
|
|
/// Returns the internal untyped CimObject.CimKeys object.
|
|
/// </summary>
|
|
internal CimObject.CimKeys cimObjectKeys;
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
protected CimKeys()
|
|
{
|
|
cimObjectKeys = new CimObject.CimKeys();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieves a key's value.
|
|
/// </summary>
|
|
/// <param name="name">Name of the key</param>
|
|
/// <returns>Value of the key</returns>
|
|
protected string GetKey(string name)
|
|
{
|
|
return cimObjectKeys.GetKey(name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set an existing key's value, or add a new key.
|
|
/// </summary>
|
|
/// <param name="name">Name of the key</param>
|
|
/// <param name="value">Value of the key</param>
|
|
protected void SetOrAddKey(string name, Object value)
|
|
{
|
|
cimObjectKeys.SetOrAddKey(name, value);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents a pair of CimBase object and CimReference.
|
|
/// </summary>
|
|
public struct CimBaseReferencePair
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public CimBase CimBaseObject { set; get; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public CimReference Reference { set; get; }
|
|
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
/// <param name="cimBaseObject"></param>
|
|
/// <param name="reference"></param>
|
|
public CimBaseReferencePair(CimBase cimBaseObject, CimReference reference)
|
|
: this()
|
|
{
|
|
CimBaseObject = cimBaseObject;
|
|
Reference = reference;
|
|
}
|
|
}
|
|
}
|