Example #1
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);
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Type for which this entry is created</param>
 /// <param name="serializer">TypeSerializerDelegate for serializing the type</param>
 /// <param name="cimType">CimType corresponding to the .NET type </param>
 /// For some .NET types (Guid, Decimal, etc.), there are no equivalent Cim Types. So, we serialize them as string
 /// <param name="cimClassName">The CimClass name whose instance needs to be created for this type</param>
 internal MITypeSerializationInfo(Type type, MITypeSerializerDelegate serializer,
                                  Microsoft.Management.Infrastructure.CimType cimType, string cimClassName) : this(type, serializer, cimClassName)
 {
     CimType = cimType;
 }