Пример #1
0
        public static ManagementPackTypeProjection GetTypeProjectionByName(string strName, EnterpriseManagementGroup emg)
        {
            ManagementPackTypeProjectionCriteria mptpc = new ManagementPackTypeProjectionCriteria(String.Format("Name = '{0}'", strName));
            IList <ManagementPackTypeProjection> listTypeProjections = emg.EntityTypes.GetTypeProjections(mptpc);

            if (listTypeProjections.Count > 0)
            {
                return(listTypeProjections[0]);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public static ManagementPackTypeProjection GetManagementPackTypeProjectionByName(string strTypeProjectionName, string strManagementPackName, EnterpriseManagementGroup emg)
        {
            ManagementPackTypeProjection         mptpToReturn = null;
            ManagementPackTypeProjectionCriteria mptpc        = new ManagementPackTypeProjectionCriteria(String.Format("Name = '{0}'", strTypeProjectionName));

            foreach (ManagementPackTypeProjection mptp in emg.EntityTypes.GetTypeProjections(mptpc))
            {
                if (mptp.GetManagementPack().Name == strManagementPackName)
                {
                    mptpToReturn = mptp;
                }
            }
            return(mptpToReturn);
        }
Пример #3
0
        private string BuildTargetCriteria()
        {
            if (this.Target != null)
            {
                WriteVerbose(string.Format("Build criteria based on {0}", this.Target.Name));
                List <string> targets = new List <string>();
                targets.Add(string.Format("Target = '{0}'", this.Target.Id));
                if (this.Target is ManagementPackClass)
                {
                    // get all type projections for this class
                    var crTP   = new ManagementPackTypeProjectionCriteria(string.Format("Type = '{0}'", this.Target.Id));
                    var allTPs = _mg.EntityTypes.GetTypeProjections(crTP);
                    foreach (var tp in allTPs)
                    {
                        targets.Add(string.Format("Target = '{0}'", tp.Id));
                    }
                }
                var criteria = string.Join(" OR ", targets.ToArray());
                WriteVerbose(string.Format("Target criteria: {0}", criteria));
                return(criteria);
            }

            return("");
        }