Describes a single Parameter
        public UnixSocketEnvironment(ScriptingLanguage language, UnixSocketFuzzLocation fuzzLocation)
            : base(language)
        {
            _fuzzLocation = fuzzLocation;

            _extraImports.Add ("Fuzzer.Scripting.Environments");

            ParameterInfo fuzzLocationParameterInfo = new ParameterInfo ("fuzzLocation", typeof(UnixSocketFuzzLocation));
            base.GlobalParameters.Add (fuzzLocationParameterInfo);
            base.SetParameter (fuzzLocationParameterInfo, fuzzLocation);

            MethodInfo hookTypeGetterInfo = new MethodInfo ("HookType", typeof(UnixSocketHookType));
            base.GlobalMethods.Add (hookTypeGetterInfo);
            base.SetMethod (hookTypeGetterInfo, new GetHookTypeDelegate (GetHookType));
        }
        public TestEnvironment(ScriptingLanguage language, TextWriter strWriter)
            : base(language)
        {
            _writer = strWriter;
            MethodInfo fooMethodInfo = new MethodInfo("Foo", null, new ParameterInfo("text", typeof(string)));
            MethodInfo barMethodInfo = new MethodInfo("Bar", typeof(string));

            base.GlobalMethods.Add(fooMethodInfo);
            base.SetMethod(fooMethodInfo, new Action<string>(FooMethod));

            base.GlobalMethods.Add(barMethodInfo);
            base.SetMethod(barMethodInfo, new BarMethodDelegate(BarMethod));

            ParameterInfo writerParameterInfo = new ParameterInfo("Writer", typeof(TextWriter));
            base.GlobalParameters.Add(writerParameterInfo);
            base.SetParameter(writerParameterInfo, _writer);
        }
        /// <summary>
        /// Defines an accessor (get/set)
        /// </summary>
        /// <param name="container"></param>
        /// <param name="modifier"></param>
        /// <param name="typeInfo"></param>
        /// <param name="hasGet"></param>
        /// <param name="hasSet"></param>
        /// <param name="memberVariableName"></param>
        /// <returns></returns>
        public static CodeMemberProperty DefineAccessor(CodeTypeDeclaration container,
            ModifierEnum modifier, ParameterInfo typeInfo, bool hasGet, bool hasSet, string memberVariableName)
        {
            CodeMemberProperty property = DefineProperty(container, modifier, typeInfo, hasGet, hasSet);

            if (hasGet)
            {
                property.GetStatements.Add(new CodeMethodReturnStatement(
                    new CodeFieldReferenceExpression(
                        new CodeThisReferenceExpression(), memberVariableName
                    )
                )
                );
            }

            if (hasSet)
            {
                property.SetStatements.Add(new CodeAssignStatement(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), memberVariableName),
                    new CodePropertySetValueReferenceExpression()));
            }

            return property;
        }
 /// <summary>
 /// Defines a member variable
 /// </summary>
 /// <param name="container"></param>
 /// <param name="modifier"></param>
 /// <param name="typeInfo"></param>
 /// <returns></returns>
 public static CodeMemberField DefineField(CodeTypeDeclaration container,
     ModifierEnum modifier, ParameterInfo typeInfo)
 {
     CodeMemberField member = new CodeMemberField(new CodeTypeReference(typeInfo.ParameterType), typeInfo.Name);
     member.Attributes = (member.Attributes & ~MemberAttributes.AccessMask) | (MemberAttributes)modifier;
     container.Members.Add(member);
     return member;
 }
        /// <summary>
        /// Defines a property
        /// </summary>
        /// <param name="container"></param>
        /// <param name="modifier"></param>
        /// <param name="typeInfo"></param>
        /// <param name="hasGet"></param>
        /// <param name="hasSet"></param>
        /// <returns></returns>
        public static CodeMemberProperty DefineProperty(CodeTypeDeclaration container,
            ModifierEnum modifier, ParameterInfo typeInfo, bool hasGet, bool hasSet)
        {
            CodeMemberProperty member = new CodeMemberProperty();
            member.HasGet = hasGet;
            member.HasSet = hasSet;
            member.Name = typeInfo.Name;
            member.Type = new CodeTypeReference(typeInfo.ParameterType);
            member.Attributes = (member.Attributes & ~MemberAttributes.AccessMask) | (MemberAttributes)modifier;

            container.Members.Add(member);
            return member;
        }
        /// <summary>
        /// Defines and returns a member method with the given options
        /// </summary>
        /// <param name="name">Name of the method</param>
        /// <param name="returnType">Return type of the method</param>
        /// <param name="parameters">Parameters of the method</param>
        /// <returns></returns>
        public static CodeMemberMethod DefineMemberMethod(CodeTypeDeclaration container, 
            string name, ModifierEnum modifier, ParameterInfo returnType, params ParameterInfo[] parameters)
        {
            CodeMemberMethod member = new CodeMemberMethod();
            member.Name = name;
            member.Attributes = (member.Attributes & ~MemberAttributes.AccessMask) | (MemberAttributes)modifier;

            if (returnType == null || returnType.ParameterType == null)
                member.ReturnType = new CodeTypeReference(typeof(void));
            else
                member.ReturnType = new CodeTypeReference(returnType.ParameterType);

            if (parameters != null)
            {
                foreach (ParameterInfo parameter in parameters)
                {
                    CodeParameterDeclarationExpression codeParameter = new CodeParameterDeclarationExpression(
                        parameter.ParameterType, parameter.Name);
                    member.Parameters.Add(codeParameter);
                }
            }

            container.Members.Add(member);
            return member;
        }