Example #1
0
        internal void AddToTypesXmlCache(T member, bool preValidated)
        {
            if (member == null)
            {
                throw PSTraceSource.NewArgumentNullException("member");
            }
            if (!preValidated && PSMemberInfoCollection <T> .IsReservedName(member.Name))
            {
                throw new ExtendedTypeSystemException("PSObjectMembersMembersAddReservedName", null, ExtendedTypeSystem.ReservedMemberName, new object[] { member.Name });
            }
            PSMemberInfo info = member.Copy();

            if (this.mshOwner != null)
            {
                if (!preValidated)
                {
                    TypeTable typeTable = this.mshOwner.GetTypeTable();
                    if ((typeTable != null) && (typeTable.GetMembers <T>(this.mshOwner.InternalTypeNames)[member.Name] != null))
                    {
                        throw new ExtendedTypeSystemException("AlreadyPresentInTypesXml", null, ExtendedTypeSystem.MemberAlreadyPresentFromTypesXml, new object[] { member.Name });
                    }
                }
                info.ReplicateInstance(this.mshOwner);
                this.mshOwner.InstanceMembers.Add(info, preValidated);
                PSGetMemberBinder.SetHasInstanceMember(info.Name);
                PSVariableAssignmentBinder.NoteTypeHasInstanceMemberOrTypeName(PSObject.Base(this.mshOwner).GetType());
            }
            else
            {
                this.memberSetOwner.InternalMembers.Add(info, preValidated);
            }
        }
Example #2
0
        internal ScriptParameterBinder(ScriptBlock script, InvocationInfo invocationInfo, ExecutionContext context, InternalCommand command, SessionStateScope localScope) : base(invocationInfo, context, command)
        {
            this._copyMutableValueSite = CallSite <Func <CallSite, object, object> > .Create(PSVariableAssignmentBinder.Get());

            this.Script     = script;
            this.LocalScope = localScope;
        }