/// <summary>
        /// Writes an item or property in Monad namespace
        /// </summary>
        /// <param name="serializer">The serializer to which the object is serialized.</param>
        /// <param name="property">name of property. Pass null for item</param>
        /// <param name="source">object to be written</param>
        /// <param name="entry">serialization information about source</param>
        /// <param name="result"></param>
        private static void CreateCimInstanceForOnePrimitiveKnownType
        (
            InternalMISerializer serializer,
            string property,
            object source,
            MITypeSerializationInfo entry,
            out CimInstance result
        )
        {
            Dbg.Assert(serializer != null, "caller should have validated the information");
            Dbg.Assert(source != null, "caller should have validated the information");
            Dbg.Assert(entry != null, "caller should have validated the information");

            if (entry != null && entry.Serializer == null)
            {
                // we are not using GetToString, because we assume that
                // ToString() for primitive types never throws
                string value = Convert.ToString(source, CultureInfo.InvariantCulture);
                Dbg.Assert(value != null, "ToString shouldn't return null for primitive types");
                result = CreateRawStringCimInstance(property, value, entry);
            }
            else
            {
                result = entry.Serializer(property, source, entry);
            }
        }
        internal static CimInstance CreatePSNegotiationData(Version powerShellVersion)
        {
            CimInstance c = InternalMISerializer.CreateCimInstance("PS_NegotiationData");
            CimProperty versionproperty = InternalMISerializer.CreateCimProperty("PSVersion", powerShellVersion.ToString(), Microsoft.Management.Infrastructure.CimType.String);

            c.CimInstanceProperties.Add(versionproperty);
            return(c);
        }
Exemple #3
0
 public MISerializer(int depth)
 {
     internalSerializer = new InternalMISerializer(depth);
 }
        /// <summary>
        /// Writes an item or property in Monad namespace
        /// </summary>
        /// <param name="serializer">The serializer to which the object is serialized.</param>
        /// <param name="property">name of property. Pass null for item</param>
        /// <param name="source">object to be written</param>
        /// <param name="entry">serialization information about source</param>
        /// <param name="result"></param>
        private static void CreateCimInstanceForOnePrimitiveKnownType
        (
            InternalMISerializer serializer,
            string property,
            object source,
            MITypeSerializationInfo entry,
            out CimInstance result
        )
        {
            Dbg.Assert(serializer != null, "caller should have validated the information");
            Dbg.Assert(source != null, "caller should have validated the information");
            Dbg.Assert(entry != null, "caller should have validated the information");

            if (entry != null && entry.Serializer == null)
            {
                // we are not using GetToString, because we assume that
                // ToString() for primitive types never throws
                string value = Convert.ToString(source, CultureInfo.InvariantCulture);
                Dbg.Assert(value != null, "ToString shouldn't return null for primitive types");
                result = CreateRawStringCimInstance(property, value, entry);
            }
            else
            {
                result = entry.Serializer(property, source, entry);
            }
        }
Exemple #5
0
 public MISerializer(int depth)
 {
     internalSerializer = new InternalMISerializer(depth);
 }