Ejemplo n.º 1
0
 private static PSControl RehydratePSControl(PSObject deserializedControl)
 {
     if (Deserializer.IsDeserializedInstanceOfType((object)deserializedControl, typeof(TableControl)))
     {
         return (PSControl) new TableControl()
                {
                    Headers = DeserializingTypeConverter.RehydrateList <List <TableControlColumnHeader>, TableControlColumnHeader>(deserializedControl, "Headers", DeserializingTypeConverter.RehydrationFlags.NullValueBad),
                    Rows    = DeserializingTypeConverter.RehydrateList <List <TableControlRow>, TableControlRow>(deserializedControl, "Rows", DeserializingTypeConverter.RehydrationFlags.NullValueBad)
                }
     }
     ;
     if (Deserializer.IsDeserializedInstanceOfType((object)deserializedControl, typeof(ListControl)))
     {
         return (PSControl) new ListControl()
                {
                    Entries = DeserializingTypeConverter.RehydrateList <List <ListControlEntry>, ListControlEntry>(deserializedControl, "Entries", DeserializingTypeConverter.RehydrationFlags.NullValueBad)
                }
     }
     ;
     return(Deserializer.IsDeserializedInstanceOfType((object)deserializedControl, typeof(WideControl)) ? (PSControl) new WideControl()
     {
         Alignment = DeserializingTypeConverter.GetPropertyValue <Alignment>(deserializedControl, "Alignment"),
         Columns = DeserializingTypeConverter.GetPropertyValue <uint>(deserializedControl, "Columns"),
         Entries = DeserializingTypeConverter.RehydrateList <List <WideControlEntryItem>, WideControlEntryItem>(deserializedControl, "Entries", DeserializingTypeConverter.RehydrationFlags.NullValueBad)
     } : throw DeserializingTypeConverter._trace.NewArgumentException("pso"));
 }
Ejemplo n.º 2
0
        private static ListType RehydrateList <ListType, ItemType>(
            PSObject pso,
            string propertyName,
            DeserializingTypeConverter.RehydrationFlags flags)
            where ListType : IList, new()
        {
            ArrayList propertyValue = DeserializingTypeConverter.GetPropertyValue <ArrayList>(pso, propertyName, flags);

            if (propertyValue == null)
            {
                if (DeserializingTypeConverter.RehydrationFlags.NullValueMeansEmptyList != (flags & DeserializingTypeConverter.RehydrationFlags.NullValueMeansEmptyList))
                {
                    return(default(ListType));
                }
                return(new ListType());
            }
            ListType listType = new ListType();

            foreach (object valueToConvert in propertyValue)
            {
                ItemType itemType = (ItemType)LanguagePrimitives.ConvertTo(valueToConvert, typeof(ItemType), (IFormatProvider)CultureInfo.InvariantCulture);
                listType.Add((object)itemType);
            }
            return(listType);
        }
Ejemplo n.º 3
0
        private static T RehydrateObjectSecurity <T>(PSObject pso) where T : ObjectSecurity, new()
        {
            string propertyValue = DeserializingTypeConverter.GetPropertyValue <string>(pso, "SDDL");
            T      obj           = new T();

            obj.SetSecurityDescriptorSddlForm(propertyValue);
            return(obj);
        }
Ejemplo n.º 4
0
 private static TableControlColumn RehydrateTableControlColumn(
     PSObject deserializedColumn)
 {
     return(new TableControlColumn()
     {
         Alignment = DeserializingTypeConverter.GetPropertyValue <Alignment>(deserializedColumn, "Alignment"),
         DisplayEntry = DeserializingTypeConverter.GetPropertyValue <DisplayEntry>(deserializedColumn, "DisplayEntry")
     });
 }
Ejemplo n.º 5
0
 private static ListControlEntry RehydrateListControlEntry(
     PSObject deserializedEntry)
 {
     return(new ListControlEntry()
     {
         Items = DeserializingTypeConverter.RehydrateList <List <ListControlEntryItem>, ListControlEntryItem>(deserializedEntry, "Items", DeserializingTypeConverter.RehydrationFlags.NullValueBad),
         SelectedBy = DeserializingTypeConverter.RehydrateList <List <string>, string>(deserializedEntry, "SelectedBy", DeserializingTypeConverter.RehydrationFlags.NullValueOk)
     });
 }
Ejemplo n.º 6
0
 private static ListControlEntryItem RehydrateListControlEntryItem(
     PSObject deserializedEntryItem)
 {
     return(new ListControlEntryItem()
     {
         DisplayEntry = DeserializingTypeConverter.GetPropertyValue <DisplayEntry>(deserializedEntryItem, "DisplayEntry"),
         Label = DeserializingTypeConverter.GetPropertyValue <string>(deserializedEntryItem, "Label", DeserializingTypeConverter.RehydrationFlags.NullValueOk)
     });
 }
Ejemplo n.º 7
0
        private static FormatViewDefinition RehydrateFormatViewDefinition(
            PSObject deserializedViewDefinition)
        {
            string    propertyValue1 = DeserializingTypeConverter.GetPropertyValue <string>(deserializedViewDefinition, "Name");
            Guid      propertyValue2 = DeserializingTypeConverter.GetPropertyValue <Guid>(deserializedViewDefinition, "InstanceId");
            PSControl propertyValue3 = DeserializingTypeConverter.GetPropertyValue <PSControl>(deserializedViewDefinition, "Control");

            return(new FormatViewDefinition(propertyValue1, propertyValue3, propertyValue2));
        }
Ejemplo n.º 8
0
 private static WideControlEntryItem RehydrateWideControlEntryItem(
     PSObject deserializedEntryItem)
 {
     return(new WideControlEntryItem()
     {
         DisplayEntry = DeserializingTypeConverter.GetPropertyValue <DisplayEntry>(deserializedEntryItem, "DisplayEntry"),
         SelectedBy = DeserializingTypeConverter.RehydrateList <List <string>, string>(deserializedEntryItem, "SelectedBy", DeserializingTypeConverter.RehydrationFlags.NullValueOk)
     });
 }
Ejemplo n.º 9
0
 private static TableControlColumnHeader RehydrateTableControlColumnHeader(
     PSObject deserializedHeader)
 {
     return(new TableControlColumnHeader()
     {
         Alignment = DeserializingTypeConverter.GetPropertyValue <Alignment>(deserializedHeader, "Alignment"),
         Label = DeserializingTypeConverter.GetPropertyValue <string>(deserializedHeader, "Label", DeserializingTypeConverter.RehydrationFlags.NullValueOk),
         Width = DeserializingTypeConverter.GetPropertyValue <int>(deserializedHeader, "Width")
     });
 }
Ejemplo n.º 10
0
 private static TableControlRow RehydrateTableControlRow(PSObject deserializedRow) => new TableControlRow()
 {
     Columns = DeserializingTypeConverter.RehydrateList <List <TableControlColumn>, TableControlColumn>(deserializedRow, "Columns", DeserializingTypeConverter.RehydrationFlags.NullValueBad)
 };
Ejemplo n.º 11
0
 private static DisplayEntry RehydrateDisplayEntry(PSObject deserializedDisplayEntry) => new DisplayEntry()
 {
     Value     = DeserializingTypeConverter.GetPropertyValue <string>(deserializedDisplayEntry, "Value"),
     ValueType = DeserializingTypeConverter.GetPropertyValue <DisplayEntryValueType>(deserializedDisplayEntry, "ValueType")
 };
Ejemplo n.º 12
0
 private static ParameterSetMetadata RehydrateParameterSetMetadata(
     PSObject pso)
 {
     return(new ParameterSetMetadata(DeserializingTypeConverter.GetPropertyValue <int>(pso, "Position"), (ParameterSetMetadata.ParameterFlags)DeserializingTypeConverter.GetPropertyValue <uint>(pso, "Flags"), DeserializingTypeConverter.GetPropertyValue <string>(pso, "HelpMessage")));
 }
Ejemplo n.º 13
0
 private static X500DistinguishedName RehydrateX500DistinguishedName(
     PSObject pso)
 {
     return(new X500DistinguishedName(DeserializingTypeConverter.GetPropertyValue <byte[]>(pso, "RawData")));
 }
Ejemplo n.º 14
0
 private static X509Certificate2 RehydrateX509Certificate2(PSObject pso) => new X509Certificate2(DeserializingTypeConverter.GetPropertyValue <byte[]>(pso, "RawData"));
Ejemplo n.º 15
0
 private static PSCredential RehydratePSCredential(PSObject pso) => new PSCredential(DeserializingTypeConverter.GetPropertyValue <string>(pso, "UserName"), DeserializingTypeConverter.GetPropertyValue <SecureString>(pso, "Password"));
Ejemplo n.º 16
0
 private static object RehydrateSwitchParameter(PSObject pso) => (object)DeserializingTypeConverter.GetPropertyValue <SwitchParameter>(pso, "IsPresent");
Ejemplo n.º 17
0
 private static ExtendedTypeDefinition RehydrateExtendedTypeDefinition(
     PSObject deserializedTypeDefinition)
 {
     return(new ExtendedTypeDefinition(DeserializingTypeConverter.GetPropertyValue <string>(deserializedTypeDefinition, "TypeName"), DeserializingTypeConverter.RehydrateList <List <FormatViewDefinition>, FormatViewDefinition>(deserializedTypeDefinition, "FormatViewDefinition", DeserializingTypeConverter.RehydrationFlags.NullValueBad)));
 }
Ejemplo n.º 18
0
 private static T GetPropertyValue <T>(PSObject pso, string propertyName) => DeserializingTypeConverter.GetPropertyValue <T>(pso, propertyName, DeserializingTypeConverter.RehydrationFlags.NullValueBad);