Пример #1
0
        private Dictionary <string, System.Management.Automation.PSObject> GetParameters(System.Collections.ObjectModel.Collection <FieldDescription> descriptions)
        {
            Dictionary <string, System.Management.Automation.PSObject> rtn = new Dictionary <string, System.Management.Automation.PSObject>();
            PSParamType parm = new PSParamType();

            foreach (FieldDescription descr in descriptions)
            {
                PSParameter prm = new PSParameter();
                prm.Name = descr.Name;
                if (descr.IsMandatory)
                {
                    prm.Category = "Required";
                }
                else
                {
                    prm.Category = "Optional";
                }
                prm.DefaultValue = descr.DefaultValue;
                prm.Description  = descr.HelpMessage;
                prm.Type         = Type.GetType(descr.ParameterAssemblyFullName);
                if (prm.Name.ToLower() == "file" || prm.Name.ToLower() == "filename")
                {
                    prm.IsFileName = true;
                }
                if (prm.Name.ToLower() == "credential")
                {
                    prm.IsCredential = true;
                }
                parm.Properties.Add(prm);
            }
            return(rtn);
        }
Пример #2
0
 private Dictionary<string, System.Management.Automation.PSObject> GetParameters(System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
 {
     Dictionary<string, System.Management.Automation.PSObject> rtn = new Dictionary<string, System.Management.Automation.PSObject>();
     PSParamType parm = new PSParamType();
     foreach (FieldDescription descr in descriptions)
     {
         PSParameter prm = new PSParameter();
         prm.Name = descr.Name;
         if (descr.IsMandatory)
         {
             prm.Category = "Required";
         }
         else
         {
             prm.Category = "Optional";
         }
         prm.DefaultValue = descr.DefaultValue;
         prm.Description = descr.HelpMessage;
         prm.Type = Type.GetType(descr.ParameterAssemblyFullName);
         if (prm.Name.ToLower() == "file" || prm.Name.ToLower() == "filename")
         {
             prm.IsFileName = true;
         }
         if (prm.Name.ToLower() == "credential")
         {
             prm.IsCredential = true;
         }
         parm.Properties.Add(prm);
     }
     return rtn;
 }
Пример #3
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                var                props   = base.GetProperties(context, value, attributes);
                PSParamType        parm    = value as PSParamType;
                List <PSParameter> psprops = null;
                int                propcnt = props.Count;

                if (parm != null)
                {
                    psprops  = parm.Properties;
                    propcnt += psprops.Count;
                }
                PropertyDescriptor[] psdescs = new PropertyDescriptor[propcnt];
                props.CopyTo(psdescs, 0);

                if (psprops != null)
                {
                    int idx = props.Count;
                    foreach (PSParameter psparam in psprops)
                    {
                        psdescs[idx++] = new PSParamDescriptor(psparam);
                    }
                }
                return(new PropertyDescriptorCollection(psdescs));
            }