示例#1
0
        internal CimInstance ToCimInstance()
        {
            CimInstance c = InternalMISerializer.CreateCimInstance("PS_Command");
            CimProperty commandTextProperty = InternalMISerializer.CreateCimProperty("CommandText",
                                                                                     this.CommandText,
                                                                                     Microsoft.Management.Infrastructure.CimType.String);

            c.CimInstanceProperties.Add(commandTextProperty);
            CimProperty isScriptProperty = InternalMISerializer.CreateCimProperty("IsScript",
                                                                                  this.IsScript,
                                                                                  Microsoft.Management.Infrastructure.CimType.Boolean);

            c.CimInstanceProperties.Add(isScriptProperty);

            if (this.Parameters != null && this.Parameters.Count > 0)
            {
                List <CimInstance> parameterInstances = new List <CimInstance>();
                foreach (var p in this.Parameters)
                {
                    parameterInstances.Add(p.ToCimInstance());
                }

                if (parameterInstances.Count > 0)
                {
                    CimProperty parametersProperty = InternalMISerializer.CreateCimProperty("Parameters",
                                                                                            parameterInstances.ToArray(),
                                                                                            Microsoft.Management.Infrastructure.CimType.ReferenceArray);
                    c.CimInstanceProperties.Add(parametersProperty);
                }
            }

            return(c);
        }
示例#2
0
        internal CimInstance ToCimInstance()
        {
            CimInstance c            = InternalMISerializer.CreateCimInstance("PS_Parameter");
            CimProperty nameProperty = InternalMISerializer.CreateCimProperty("Name", this.Name,
                                                                              Microsoft.Management.Infrastructure.CimType.String);

            c.CimInstanceProperties.Add(nameProperty);
            Microsoft.Management.Infrastructure.CimType cimType = CimConverter.GetCimType(this.Value.GetType());
            CimProperty valueProperty;

            if (cimType == Microsoft.Management.Infrastructure.CimType.Unknown)
            {
                valueProperty = InternalMISerializer.CreateCimProperty("Value", (object)PSMISerializer.Serialize(this.Value),
                                                                       Microsoft.Management.Infrastructure.CimType.Instance);
            }
            else
            {
                valueProperty = InternalMISerializer.CreateCimProperty("Value", this.Value, cimType);
            }

            c.CimInstanceProperties.Add(valueProperty);
            return(c);
        }