/// <summary> /// Initializes a new instance of this class. /// </summary> public MemberDefinition(string typeName, string name, PSMemberTypes memberType, string definition) { Name = name; Definition = definition; MemberType = memberType; TypeName = typeName; }
public MemberDefinition(string typeName, string name, PSMemberTypes memberType, string definition) { this.name = name; this.definition = definition; this.memberType = memberType; this.typeName = typeName; }
public MemberDefinition(string typeName, string name, PSMemberTypes memberType, string definition) { TypeName = typeName; Name = name; MemberType = memberType; Definition = definition; }
internal override ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes, MshMemberMatchOptions matchOptions) { if (string.IsNullOrEmpty(name)) { throw PSTraceSource.NewArgumentException("name"); } return(new ReadOnlyPSMemberInfoCollection <T>(MemberMatch.Match <T>(this.GetInternalMembers(matchOptions), name, MemberMatch.GetNamePattern(name), memberTypes))); }
public override ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes) { if (string.IsNullOrEmpty(name)) { throw PSTraceSource.NewArgumentException("name"); } return(this.Match(name, memberTypes, MshMemberMatchOptions.None)); }
public override ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes) { WildcardPattern pattern = new WildcardPattern(name, WildcardOptions.IgnoreCase); return(new ReadOnlyPSMemberInfoCollection <T>( from value in _collection where (value.MemberType & memberTypes) != 0 && pattern.IsMatch(value.Name) select value )); }
internal override ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes, MshMemberMatchOptions matchOptions) { using (PSObject.memberResolution.TraceScope("Matching \"{0}\"", new object[] { name })) { if (string.IsNullOrEmpty(name)) { throw PSTraceSource.NewArgumentException("name"); } if (this.mshOwner != null) { this.GenerateAllReservedMembers(); } WildcardPattern namePattern = MemberMatch.GetNamePattern(name); ReadOnlyPSMemberInfoCollection <T> infos = new ReadOnlyPSMemberInfoCollection <T>(MemberMatch.Match <T>(this.GetIntegratedMembers(matchOptions), name, namePattern, memberTypes)); PSObject.memberResolution.WriteLine("{0} total matches.", new object[] { infos.Count }); return(infos); } }
internal static PSMemberInfoInternalCollection <T> Match <T>( PSMemberInfoInternalCollection <T> memberList, string name, WildcardPattern nameMatch, PSMemberTypes memberTypes) where T : PSMemberInfo { PSMemberInfoInternalCollection <T> internalCollection = new PSMemberInfoInternalCollection <T>(); if (memberList == null) { throw MemberMatch.tracer.NewArgumentNullException(nameof(memberList)); } if (string.IsNullOrEmpty(name)) { throw MemberMatch.tracer.NewArgumentException(nameof(name)); } if (nameMatch == null) { object hashedMember = memberList.hashedMembers[(object)name]; if (hashedMember != null) { PSMemberInfo member = (PSMemberInfo)memberList.members[((int?)hashedMember).Value]; if ((member.MemberType & memberTypes) != (PSMemberTypes)0) { internalCollection.Add(member as T); } } return(internalCollection); } foreach (T member in (PSMemberInfoCollection <T>)memberList) { PSMemberInfo psMemberInfo = (PSMemberInfo)member; if (nameMatch.IsMatch(psMemberInfo.Name) && (psMemberInfo.MemberType & memberTypes) != (PSMemberTypes)0) { internalCollection.Add(psMemberInfo as T); } } return(internalCollection); }
protected override void Validate(object arguments, EngineIntrinsics engineIntrinsics) { PSMemberTypes types; string valueToConvert = arguments as string; if ((valueToConvert == null) || !LanguagePrimitives.TryConvertTo <PSMemberTypes>(valueToConvert, out types)) { return; } PSMemberTypes types2 = types; if (types2 <= PSMemberTypes.ScriptProperty) { switch (types2) { case PSMemberTypes.AliasProperty: case PSMemberTypes.CodeProperty: case PSMemberTypes.NoteProperty: case PSMemberTypes.ScriptProperty: goto Label_005C; } return; } if (types2 <= PSMemberTypes.CodeMethod) { if ((types2 != PSMemberTypes.PropertySet) && (types2 != PSMemberTypes.CodeMethod)) { return; } } else if ((types2 != PSMemberTypes.ScriptMethod) && (types2 != PSMemberTypes.MemberSet)) { return; } Label_005C: return; //TODO: REVIEW WHY? throw new ValidationMetadataException(StringUtil.Format(AddMember.InvalidValueForNotePropertyName, typeof(PSMemberTypes).FullName), true); }
public MemberNameCompletionAttribute(Type type, PSMemberTypes memberTypes, bool includePrivateMembers) : this(new PSTypeName(type), memberTypes, includePrivateMembers) { }
public abstract ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes);
protected override void ProcessRecord() { if ((this.typeName != null) && string.IsNullOrWhiteSpace(this.typeName)) { base.ThrowTerminatingError(this.NewError("TypeNameShouldNotBeEmpty", "TypeNameShouldNotBeEmpty", this.typeName, new object[0])); } if (base.ParameterSetName == "TypeNameSet") { this.UpdateTypeNames(); if (this.passThru) { base.WriteObject(this.inputObject); } return; } if (base.ParameterSetName == "NotePropertyMultiMemberSet") { this.ProcessNotePropertyMultiMemberSet(); return; } PSMemberInfo member = null; if (base.ParameterSetName == "NotePropertySingleMemberSet") { member = new PSNoteProperty(this._notePropertyName, this._notePropertyValue); } else { int memberType = (int)this.memberType; int num2 = 0; while (memberType != 0) { if ((memberType & 1) != 0) { num2++; } memberType = memberType >> 1; } if (num2 != 1) { base.ThrowTerminatingError(this.NewError("WrongMemberCount", "WrongMemberCount", null, new object[] { this.memberType.ToString() })); return; } switch (this.memberType) { case PSMemberTypes.AliasProperty: member = this.GetAliasProperty(); goto Label_01D1; case PSMemberTypes.CodeProperty: member = this.GetCodeProperty(); goto Label_01D1; case PSMemberTypes.NoteProperty: member = this.GetNoteProperty(); goto Label_01D1; case PSMemberTypes.ScriptProperty: member = this.GetScriptProperty(); goto Label_01D1; case PSMemberTypes.ScriptMethod: member = this.GetScriptMethod(); goto Label_01D1; case PSMemberTypes.MemberSet: member = this.GetMemberSet(); goto Label_01D1; case PSMemberTypes.PropertySet: member = this.GetPropertySet(); goto Label_01D1; case PSMemberTypes.CodeMethod: member = this.GetCodeMethod(); goto Label_01D1; } base.ThrowTerminatingError(this.NewError("CannotAddMemberType", "CannotAddMemberType", null, new object[] { this.memberType.ToString() })); } Label_01D1: if (member == null) { return; } if (this.AddMemberToTarget(member)) { if (this.typeName != null) { this.UpdateTypeNames(); } if (this.passThru) { base.WriteObject(this.inputObject); } } }
internal abstract ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes, MshMemberMatchOptions matchOptions);
private MemberNameValidationAttribute(PSTypeName type, PSMemberTypes memberTypes, bool includePrivateMembers) { _typeName = type; PSMemberTypes = memberTypes; IncludePrivateMembers = includePrivateMembers; }
protected override void ProcessRecord() { if ((this.typeName != null) && string.IsNullOrWhiteSpace(this.typeName)) { base.ThrowTerminatingError(this.NewError("TypeNameShouldNotBeEmpty", "TypeNameShouldNotBeEmpty", this.typeName, new object[0])); } if (base.ParameterSetName == "TypeNameSet") { this.UpdateTypeNames(); if (this.passThru) { base.WriteObject(this.inputObject); } return; } if (base.ParameterSetName == "NotePropertyMultiMemberSet") { this.ProcessNotePropertyMultiMemberSet(); return; } PSMemberInfo member = null; if (base.ParameterSetName == "NotePropertySingleMemberSet") { member = new PSNoteProperty(this._notePropertyName, this._notePropertyValue); } else { int memberType = (int) this.memberType; int num2 = 0; while (memberType != 0) { if ((memberType & 1) != 0) { num2++; } memberType = memberType >> 1; } if (num2 != 1) { base.ThrowTerminatingError(this.NewError("WrongMemberCount", "WrongMemberCount", null, new object[] { this.memberType.ToString() })); return; } switch (this.memberType) { case PSMemberTypes.AliasProperty: member = this.GetAliasProperty(); goto Label_01D1; case PSMemberTypes.CodeProperty: member = this.GetCodeProperty(); goto Label_01D1; case PSMemberTypes.NoteProperty: member = this.GetNoteProperty(); goto Label_01D1; case PSMemberTypes.ScriptProperty: member = this.GetScriptProperty(); goto Label_01D1; case PSMemberTypes.ScriptMethod: member = this.GetScriptMethod(); goto Label_01D1; case PSMemberTypes.MemberSet: member = this.GetMemberSet(); goto Label_01D1; case PSMemberTypes.PropertySet: member = this.GetPropertySet(); goto Label_01D1; case PSMemberTypes.CodeMethod: member = this.GetCodeMethod(); goto Label_01D1; } base.ThrowTerminatingError(this.NewError("CannotAddMemberType", "CannotAddMemberType", null, new object[] { this.memberType.ToString() })); } Label_01D1: if (member == null) { return; } if (this.AddMemberToTarget(member)) { if (this.typeName != null) { this.UpdateTypeNames(); } if (this.passThru) { base.WriteObject(this.inputObject); } } }
public MemberNameValidationAttribute(string typeName, PSMemberTypes memberTypes, bool includePrivateMembers) : this(new PSTypeName(typeName), memberTypes, includePrivateMembers) { }
// MUST: implement this to do the PSObject ValueFromPipelineByPropertyName public override ReadOnlyPSMemberInfoCollection <T> Match(string name, PSMemberTypes memberTypes) { throw new NotImplementedException(); }
protected override void ProcessRecord() { if ((this.InputObject != null) && (this.InputObject != AutomationNull.Value)) { string fullName; Type type = null; Adapter dotNetStaticAdapter = null; if (this.Static == 1) { dotNetStaticAdapter = PSObject.dotNetStaticAdapter; object baseObject = this.InputObject.BaseObject; type = baseObject as Type; if (type == null) { type = baseObject.GetType(); } fullName = type.FullName; } else { ConsolidatedString internalTypeNames = this.InputObject.InternalTypeNames; if (internalTypeNames.Count != 0) { fullName = internalTypeNames[0]; } else { fullName = "<null>"; } } if (!this.typesAlreadyDisplayed.Contains(fullName)) { PSMemberInfoCollection <PSMemberInfo> infos; this.typesAlreadyDisplayed.Add(fullName, ""); PSMemberTypes memberType = this.memberType; PSMemberViewTypes view = this.view; if (((this.view & PSMemberViewTypes.Extended) == 0) && !typeof(PSMemberSet).ToString().Equals(fullName, StringComparison.OrdinalIgnoreCase)) { memberType ^= PSMemberTypes.MemberSet | PSMemberTypes.ScriptMethod | PSMemberTypes.CodeMethod | PSMemberTypes.PropertySet | PSMemberTypes.ScriptProperty | PSMemberTypes.NoteProperty | PSMemberTypes.CodeProperty | PSMemberTypes.AliasProperty; } if (((this.view & PSMemberViewTypes.Adapted) == 0) && ((this.view & PSMemberViewTypes.Base) == 0)) { memberType ^= PSMemberTypes.ParameterizedProperty | PSMemberTypes.Method | PSMemberTypes.Property; } if (((this.view & PSMemberViewTypes.Base) == PSMemberViewTypes.Base) && (this.InputObject.InternalBaseDotNetAdapter == null)) { view |= PSMemberViewTypes.Adapted; } if (this.Static == 1) { infos = dotNetStaticAdapter.BaseGetMembers <PSMemberInfo>(type); } else { Collection <CollectionEntry <PSMemberInfo> > memberCollection = PSObject.GetMemberCollection(view); infos = new PSMemberInfoIntegratingCollection <PSMemberInfo>(this.InputObject, memberCollection); } foreach (string str3 in this.Name) { ReadOnlyPSMemberInfoCollection <PSMemberInfo> infos2 = infos.Match(str3, memberType, this.matchOptions); MemberDefinition[] array = new MemberDefinition[infos2.Count]; int index = 0; foreach (PSMemberInfo info in infos2) { if (this.Force == 0) { PSMethod method = info as PSMethod; if ((method != null) && method.IsSpecial) { continue; } } array[index] = new MemberDefinition(fullName, info.Name, info.MemberType, info.ToString()); index++; } Array.Sort <MemberDefinition>(array, 0, index, new MemberComparer()); for (int i = 0; i < index; i++) { base.WriteObject(array[i]); } } } } }
public MemberNameCompletionAttribute(Type type, PSMemberTypes memberTypes) : this(new PSTypeName(type), memberTypes, false) { }
private MemberNameCompletionAttribute(PSTypeName type, PSMemberTypes memberTypes, bool includePrivateMembers) : base( () => new Completer(type, memberTypes, includePrivateMembers) ) { }
public Completer(PSTypeName type, PSMemberTypes memberTypes, bool includePrivateMembers) { _typeName = type; _memberTypes = memberTypes; _includePrivateMembers = includePrivateMembers; }
/// <summary> /// This method implements the ProcessRecord method for get-member command. /// </summary> protected override void ProcessRecord() { if (this.InputObject == null || this.InputObject == AutomationNull.Value) { return; } Type baseObjectAsType = null; string typeName; Adapter staticAdapter = null; if (this.Static == true) { staticAdapter = PSObject.DotNetStaticAdapter; object baseObject = this.InputObject.BaseObject; baseObjectAsType = baseObject as System.Type ?? baseObject.GetType(); typeName = baseObjectAsType.FullName; } else { var typeNames = this.InputObject.InternalTypeNames; if (typeNames.Count != 0) { typeName = typeNames[0]; } else { // This is never used for display. It is used only as a key to typesAlreadyDisplayed typeName = "<null>"; } } if (_typesAlreadyDisplayed.Contains(typeName)) { return; } else { _typesAlreadyDisplayed.Add(typeName, string.Empty); } PSMemberTypes memberTypeToSearch = MemberType; PSMemberViewTypes viewToSearch = View; if (((View & PSMemberViewTypes.Extended) == 0) && (!typeof(PSMemberSet).ToString().Equals(typeName, StringComparison.OrdinalIgnoreCase))) { // PSMemberSet is an internal memberset and its properties/methods are populated differently. // PSMemberSet instance is created to represent PSExtended, PSAdapted, PSBase, PSObject hidden // properties. We should honor extended properties for such case. // request is to search dotnet or adapted or both members. // dotnet,adapted members cannot be Script*,Note*,Code* memberTypeToSearch ^= (PSMemberTypes.AliasProperty | PSMemberTypes.CodeMethod | PSMemberTypes.CodeProperty | PSMemberTypes.MemberSet | PSMemberTypes.NoteProperty | PSMemberTypes.PropertySet | PSMemberTypes.ScriptMethod | PSMemberTypes.ScriptProperty); } if (((View & PSMemberViewTypes.Adapted) == 0) && (View & PSMemberViewTypes.Base) == 0) { // base and adapted are not mentioned in the view so ignore respective properties memberTypeToSearch ^= (PSMemberTypes.Property | PSMemberTypes.ParameterizedProperty | PSMemberTypes.Method); } if (((View & PSMemberViewTypes.Base) == PSMemberViewTypes.Base) && (InputObject.InternalBaseDotNetAdapter == null)) { // the input object don't have a custom adapter.. // for this case adapted view and base view are the same. viewToSearch |= PSMemberViewTypes.Adapted; } PSMemberInfoCollection <PSMemberInfo> membersToSearch; if (this.Static == true) { membersToSearch = staticAdapter.BaseGetMembers <PSMemberInfo>(baseObjectAsType); } else { Collection <CollectionEntry <PSMemberInfo> > memberCollection = PSObject.GetMemberCollection(viewToSearch); membersToSearch = new PSMemberInfoIntegratingCollection <PSMemberInfo>(this.InputObject, memberCollection); } foreach (string nameElement in this.Name) { ReadOnlyPSMemberInfoCollection <PSMemberInfo> readOnlyMembers; readOnlyMembers = membersToSearch.Match(nameElement, memberTypeToSearch, _matchOptions); MemberDefinition[] members = new MemberDefinition[readOnlyMembers.Count]; int resultCount = 0; foreach (PSMemberInfo member in readOnlyMembers) { if (!Force) { PSMethod memberAsPSMethod = member as PSMethod; if ((memberAsPSMethod != null) && (memberAsPSMethod.IsSpecial)) { continue; } } members[resultCount] = new MemberDefinition(typeName, member.Name, member.MemberType, member.ToString()); resultCount++; } Array.Sort <MemberDefinition>(members, 0, resultCount, new MemberComparer()); for (int index = 0; index < resultCount; index++) { this.WriteObject(members[index]); } } }
public override ReadOnlyPSMemberInfoCollection <T> Match( string name, PSMemberTypes memberTypes) { return(!string.IsNullOrEmpty(name) ? this.Match(name, memberTypes, MshMemberMatchOptions.None) : throw PSMemberInfoIntegratingCollection <T> .tracer.NewArgumentException(nameof (name))); }
internal static PSMemberInfoInternalCollection <T> Match <T>(PSMemberInfoInternalCollection <T> memberList, string name, WildcardPattern nameMatch, PSMemberTypes memberTypes) where T : PSMemberInfo { PSMemberInfoInternalCollection <T> internals = new PSMemberInfoInternalCollection <T>(); if (memberList == null) { throw PSTraceSource.NewArgumentNullException("memberList"); } if (string.IsNullOrEmpty(name)) { throw PSTraceSource.NewArgumentException("name"); } if (nameMatch == null) { T member = memberList[name]; if ((member != null) && ((member.MemberType & memberTypes) != 0)) { internals.Add(member); } return(internals); } foreach (T local2 in memberList) { if (nameMatch.IsMatch(local2.Name) && ((local2.MemberType & memberTypes) != 0)) { internals.Add(local2); } } return(internals); }
public MemberNameValidationAttribute(string typeName, PSMemberTypes memberTypes) : this(new PSTypeName(typeName), memberTypes, false) { }