コード例 #1
0
        /// <summary>
        /// Invoke the "special enumeration" in order to get collection of association classes (by filter)
        /// </summary>
        /// <param name="wsmanClient">the client to connect</param>
        /// <param name="EPR">the EPR representing the "main object"</param>
        /// <param name="resultClassName">the class name which will be returned from the enumeration</param>
        /// <param name="role">the role name of the "main class"</param>
        /// <returns>Collection of the result classes after executing the enumeration</returns>
        private static Collection<CimBaseReferencePair> EnumerateAssociationImpl(IWSManClient wsmanClient, CimReference EPR, Type resultClass, string role)
        {
            EnumerationOptions enumOptions = new EnumerationOptions();

            enumOptions.Filter = new AssociationFilter(
                EPR,
                resultClass.UnderlyingSystemType.Name,
                role,
                null); // This includeResultProperty is not supported by AMT

            Collection<CimBaseReferencePair> objCollection = CimBase.Enumerate(wsmanClient, enumOptions);

            return objCollection;
        }
コード例 #2
0
        /// <summary>
        /// Return a single instance of association class (when it is known that a single instance exist)
        /// </summary>
        /// <param name="wsmanClient">the client to connect</param>
        /// <param name="EPR">the EPR representing the "main object"</param>
        /// <param name="resultClass">the class name which will be returned from the enumeration</param>
        /// <param name="role">the role name of the "main class"</param>
        /// <returns>The requested instance</returns>
        public static CimBase GetAssociation(IWSManClient wsmanClient, CimReference EPR, Type resultClass, string role)
        {
            Collection<CimBase> objCollection = EnumerateAssociations(wsmanClient, EPR, resultClass, role);

            if (objCollection.Count > 1)
                throw new AssociationTraversalException(GET_FAILURE_EXCEPTION);

            // If the collection is empty it might be that one of the properties is wrong
            // Or that no instances exist.
            if (objCollection.Count == 0)
                throw new AssociationTraversalException(NO_INSTANCES_EXCEPTION);

            return objCollection[0];
        }
コード例 #3
0
        /// <summary>
        /// Invoke the "special enumeration" in order to get collection of classes (by filter)
        /// </summary>
        /// <param name="wsmanClient">the client to connect</param>
        /// <param name="EPR">the EPR representing the "main object"</param>
        /// <param name="resultClassName">the class name which will be returned from the enumeration</param>
        /// <param name="associationClassName">the association class name, this class define the relation between the EPR and the result classes</param>
        /// <param name="role">the role name of the "main class"</param>
        /// <param name="resultRole">the role name of the result class</param>
        /// <returns>Collection of the result classes after executing the enumeration</returns>
        private static Collection<CimBaseReferencePair> EnumerateAssociatedImpl(IWSManClient wsmanClient, CimReference EPR, Type resultClass, Type associationClass, string role, string resultRole)
        {
            EnumerationOptions enumOptions = new EnumerationOptions();

            enumOptions.Filter = new AssociatedFilter(
                EPR,
                (resultClass != null) ? resultClass.UnderlyingSystemType.Name : null, // Validate the resultClass property
                role,
                null, // The includeResultProperty is not supported by AMT
                (associationClass != null) ? associationClass.UnderlyingSystemType.Name : null, // Validate the associationClass property
                resultRole);

            Collection<CimBaseReferencePair> objCollection = CimBase.Enumerate(wsmanClient, enumOptions);

            return objCollection;
        }
コード例 #4
0
 /// <summary>
 /// Return a single instance of association class (when it is known that a single instance exist)
 /// </summary>
 /// <param name="wsmanClient">the client to connect</param>
 /// <param name="EPR">the EPR representing the "main object"</param>
 /// <param name="resultClass">the class name which will be returned from the enumeration</param>
 /// <returns>The requested instance</returns>
 public static CimBase GetAssociation(IWSManClient wsmanClient, CimReference EPR, Type resultClass)
 {
     return GetAssociation(wsmanClient, EPR, resultClass, null);
 }
コード例 #5
0
        /// <summary>
        /// Return collection of the associations classes 
        /// </summary>
        /// <param name="wsmanClient">the client to connect</param>
        /// <param name="EPR">the EPR representing the "main object"</param>
        /// <param name="role">the role of the association class</param>
        /// <param name="resultClassPropertiesList">list of properties and their values for getting just the relevant classes</param>
        /// <returns>Collection of the requested classes</returns>
        public static Collection<CimBase> EnumerateAssociations(IWSManClient wsmanClient, CimReference EPR, Type resultClass, string role, List<KeyValuePair<string, string>> resultClassPropertiesList)
        {
            // Validate the EPR as it is necessary field
            if (EPR == null)
                throw new AssociationTraversalException(REQUIRED_PARAMETER_MISSING_EXCEPTION);

            // Invoke the special enumeration
            Collection<CimBaseReferencePair> objCollection = EnumerateAssociationImpl(wsmanClient, EPR, resultClass, role);

            // If the collection is empty, no need to search for instances - return the collection
            if (objCollection.Count == 0)
                return GetCimBaseFromCollection(objCollection);

            return (resultClassPropertiesList != null) ? GetObjectsByResultPropertyList(objCollection, resultClassPropertiesList) : GetCimBaseFromCollection(objCollection);
        }
コード例 #6
0
        /// <summary>
        /// Return collection of the associations classes 
        /// </summary>
        /// <param name="wsmanClient">the client to connect</param>
        /// <param name="EPR">the EPR representing the "main object"</param>
        /// <param name="role">the role of the association class</param>
        /// <returns>Collection of the requested classes</returns>
        public static Collection<CimBase> EnumerateAssociations(IWSManClient wsmanClient, CimReference EPR, Type resultClass, string role)
        {
            // Validate the EPR as it is necessary field
            if (EPR == null)
                throw new AssociationTraversalException(REQUIRED_PARAMETER_MISSING_EXCEPTION);

            // Invoke the special enumeration
            Collection<CimBaseReferencePair> objCollection = EnumerateAssociationImpl(wsmanClient, EPR, resultClass, role);

            Collection<CimBase> baseCollection = GetCimBaseFromCollection(objCollection);

            return baseCollection;
        }
コード例 #7
0
 /// <summary>
 /// Return collection of the associations classes 
 /// </summary>
 /// <param name="wsmanClient">the client to connect</param>
 /// <param name="EPR">the EPR representing the "main object"</param>
 /// <param name="resultClass">the association class name which will be returned from the enumeration</param>
 /// <param name="resultClassPropertiesList">list of properties and their values for getting just the relevant classes</param>
 /// <returns>Collection of the requested classes</returns>
 public static Collection<CimBase> EnumerateAssociations(IWSManClient wsmanClient, CimReference EPR, Type resultClass, List<KeyValuePair<string, string>> resultClassPropertiesList)
 {
     return EnumerateAssociations(wsmanClient, EPR, resultClass, null, resultClassPropertiesList);
 }
コード例 #8
0
 /// <summary>
 /// Return collection of the associations classes 
 /// </summary>
 /// <param name="wsmanClient">the client to connect</param>
 /// <param name="EPR">the EPR representing the "main object"</param>
 /// <param name="resultClass">the association class name which will be returned from the enumeration</param>
 /// <returns>Collection of the requested classes</returns>
 public static Collection<CimBase> EnumerateAssociations(IWSManClient wsmanClient, CimReference EPR, Type resultClass)
 {
     return EnumerateAssociations(wsmanClient, EPR, resultClass, (string)null);
 }