Parameters.cs :  » Aspect-Oriented-Frameworks » Runtime-Assembly-Instrumentation-Library » rail » Reflect » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Aspect Oriented Frameworks » Runtime Assembly Instrumentation Library 
Runtime Assembly Instrumentation Library » rail » Reflect » Parameters.cs
/*
  The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); 
  you may not use this file except in compliance with the License. You may obtain a copy of the License at 
  http://www.mozilla.org/MPL/ 
  Software distributed under the License is distributed on an "AS IS" basis, 
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language 
  governing rights and limitations under the License. 

  The Original Code is RAIL(Runtime Assembly Instrumentation Library) Alpha Version.
  The Initial Developer of the Original Code is University of Coimbra,
  Computer Science Department, Dependable Systems Group. Copyright (C) University of Coimbra. 
  All Rights Reserved.  
*/
using System;
using System.Reflection;

namespace Rail.Reflect{
  /// <summary>
  /// 
  /// </summary>
  public class RParameter : CustomAttributeOwner, ICustomAttributeOwnerDef
  {
    #region fields
    /// <summary>
    /// 
    /// </summary>
    private ParameterAttributes attributes;
    /// <summary>
    /// 
    /// </summary>
    private String name;
    /// <summary>
    /// 
    /// </summary>
    private RType parameterType;
    /// <summary>
    /// 
    /// </summary>
    private int sequence;
    /// <summary>
    /// 
    /// </summary>
    private RAssemblyDef rad;
    /// <summary>
    /// 
    /// </summary>
    private MarshalSpec marshalSpec;
    #endregion
    
    /// <summary>
    /// Verify if the field has marshal information
    /// </summary>
    public bool HasMarshal
    {
      get
      {
        return this.marshalSpec!=null;
      }
    }
    
    /// <summary>
    /// Get the field marshaling information
    /// </summary>
    public MarshalSpec MarshalSpec
    {
      get
      {
        return this.marshalSpec;
      }
      set
      {
        this.marshalSpec = value;
      }
    }
    
    /// <summary>
    /// Define the MarshalSpec
    /// </summary>
    /// <param name="typ"></param>
    /// <returns></returns>
    public MarshalSpec DefineMarshalSpec(System.Runtime.InteropServices.UnmanagedType typ)
    {
      this.marshalSpec = new MarshalSpec(typ);
      return this.marshalSpec;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="arrayType"></param>
    /// <param name="ParamNum"></param>
    /// <param name="ElemMult"></param>
    /// <param name="NumElem"></param>
    /// <returns></returns>
    public MarshalSpec DefineMarshalSpecAsArray(System.Runtime.InteropServices.UnmanagedType arrayType,
      int ParamNum, int ElemMult, int NumElem)
    {
      this.marshalSpec = new MarshalSpec(System.Runtime.InteropServices.UnmanagedType.ByValArray);
      this.marshalSpec.ElemMult = ElemMult;
      this.marshalSpec.NumElem = NumElem;
      this.marshalSpec.ParamNum = ParamNum;
      return this.marshalSpec;
    }

    /// <summary>
    /// Remove the marshal information
    /// </summary>
    public void RemoveMarshal()
    {
      this.marshalSpec = null;
    }

    /// <summary>
    /// 
    /// </summary>
    public int Sequence
    {
      get 
      {
        return this.sequence;
      }
      set 
      {
        this.sequence = value;
      }
    }

    /// <summary>
    /// 
    /// </summary>
    public ParameterAttributes Attributes 
    {
      get 
      {
        return this.attributes;
      }
      set 
      {
        this.attributes = value;
      }
    }

    /// <summary>
    /// 
    /// </summary>
    public String Name 
    {
      get 
      {
        return this.name;
      }
      set 
      {
        this.name = value;
      }
    }

    /// <summary>
    /// 
    /// </summary>
    public RType ParameterType 
    {
      get 
      {
        return this.parameterType;
      }
      set 
      {
        this.parameterType = value;
      }
    }    
  
    /// <summary>
    /// Creates a new RParamenter
    /// </summary>
    /// <param name="sequence">The position</param>
    /// <param name="attributes">The ParamAttributes</param>
    /// <param name="name">The name of the Parameter</param>
    /// <param name="type">The Rtype of the parameter</param>
    public RParameter(int sequence, int attributes, string name, RType type) 
    {
      this.sequence = sequence;
      this.attributes = (ParameterAttributes)attributes;
      this.name = name;
      this.parameterType = type;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sequence"></param>
    /// <param name="type"></param>
    public RParameter(int sequence, RType type) 
    {
      this.sequence = sequence;
      this.parameterType = type;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="param"></param>
    /// <param name="rad"></param>
    /// <param name="me"></param>
    public RParameter(ParameterInfo param,RAssemblyDef rad, MethodAttributes me) 
    {      
      if ((me & MethodAttributes.Static) != 0)
        this.sequence = param.Position;
      else
        this.sequence = param.Position + 1;
      this.rad = rad;
      this.attributes = (ParameterAttributes)param.Attributes;
      this.name = param.Name;
      this.parameterType = rad.GetRTypeRef(param.ParameterType);
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="param"></param>
    /// <param name="rad"></param>
    public RParameter(ParameterInfo param,RAssemblyDef rad) 
    {      
      this.sequence = param.Position + 1;
      this.rad = rad;
      this.attributes = (ParameterAttributes)param.Attributes;
      this.name = param.Name;
      this.parameterType = rad.GetRTypeRef(param.ParameterType);
    }

    #region Custom Attributes
    /// <summary>
    /// 
    /// </summary>
    /// <param name="attribute"></param>
    public void AddCustomAttributtes(RCustomAttrib attribute) 
    {
      InternalAddCustomAttributtes(attribute);
    }

    /// <summary>
    /// TODO: How should the attribute be specified?
    /// </summary>
    /// <param name="attribute"></param>
    public void RemoveCustomAttribute(RCustomAttrib attribute) 
    {
      InternalRemoveCustomAttribute(attribute);
    }

    #endregion

  }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.