Beispiel #1
0
 public PSObject AdaptCardObject(Cmdlet myCmdlet, card cardObject)
 {
     var promotedObject = new PSObject(cardObject);
     promotedObject.TypeNames.Insert(1, cardObject.GetType().FullName);
     promotedObject.TypeNames[0] = String.Format(CultureInfo.CurrentCulture, "CardObject#{0}",cardObject.className);
     // loop through the properties and promote them into the PSObject we're going to return
     foreach ( var p in cardObject.attributeList)
     {
         try
         {
             promotedObject.Members.Add(new PSNoteProperty(p.name, p.value));
         }
         catch (ExtendedTypeSystemException ets)
         {
             myCmdlet.WriteWarning(String.Format("The property '{0}' already exists, skipping.\nException: {1}", p.name, ets.Message));
         }
         catch (Exception e)
         {
             myCmdlet.WriteError(new ErrorRecord(e, "Property", ErrorCategory.NotSpecified, p.name));
         }
     }
     return promotedObject;
 }