Ejemplo n.º 1
0
 internal static ParameterAttributes ConvertToParameterAttributes(FieldDirection direction)
 {
     ParameterAttributes paramAttributes = ParameterAttributes.None;
     // Only few param attributes are supported
     switch (direction)
     {
         case FieldDirection.In:
             paramAttributes = ParameterAttributes.In;
             break;
         case FieldDirection.Out:
             paramAttributes = ParameterAttributes.Out;
             break;
         default:
             paramAttributes = default(ParameterAttributes);
             break;
     }
     return paramAttributes;
 }
Ejemplo n.º 2
0
 public DirectionExpression(FieldDirection fieldDirection, Expression expression)
 {
 }
Ejemplo n.º 3
0
 public ParamCodeTypeHolderProperty(CodeTypeFactory codetypeFactory, FieldDirection fieldDirection)
     : base(codetypeFactory, fieldDirection)
 {
 }
 internal CandidateParameter(Type type)
 {
     this.type = type;
     this.direction = FieldDirection.In;
 }
 internal Argument(CodeExpression expr, RuleValidation validation)
 {
     this.expression = expr;
     this.direction = FieldDirection.In;
     CodeDirectionExpression expression = expr as CodeDirectionExpression;
     if (expression != null)
     {
         this.direction = expression.Direction;
     }
     this.type = validation.ExpressionInfo(expr).ExpressionType;
 }
Ejemplo n.º 6
0
		public DirectionExpression(FieldDirection fieldDirection, Expression expression) {
			FieldDirection = fieldDirection;
			Expression = expression;
		}
Ejemplo n.º 7
0
 public static UdbusMessageMethodArgumentException Create(FieldDirection direction, uint index, string argument, Type argumentType, int result,
     string method,
     Udbus.Serialization.DbusConnectionParameters connectionParams,
     Udbus.Serialization.NMessageStruct.UdbusMessageHandle msgStruct,
     string message)
 {
     return new UdbusMessageMethodArgumentException(direction, index, argument, argumentType, result, method, connectionParams, msgStruct,
         ExceptionFormatter.FormatExceptionMessage(message, CreateMessage(direction, index, argument, argumentType, result, method, connectionParams, msgStruct)));
 }
 public CodeDirectionExpression(FieldDirection direction, CodeExpression expression)
 {
 }
 public ParamCodeTypeHolderMarshalBase(CodeTypeFactory codetypeFactory, FieldDirection fieldDirection)
     : base(codetypeFactory, fieldDirection)
 {
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Generates the proxy class events.
        /// </summary>
        /// <param name="genClass">The generated class.</param>
        /// <param name="constructor">The generated class constructor.</param>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <param name="sourceType">Type of the source.</param>
        private static void GenerateProxyClassEvents(CodeTypeDeclaration genClass, CodeConstructor constructor, Type interfaceType, Type sourceType)
        {
            List <string> processed = new List <string>();

            foreach (Type type in GetInterfaceTypes(interfaceType)) //zos
            {
                foreach (EventInfo eventInfo in type.GetEvents())
                {
                    if (processed.Contains(eventInfo.Name))
                    {
                        continue;
                    }

                    processed.Add(eventInfo.Name);

                    // Event Definition
                    CodeMemberEvent genEvent = new CodeMemberEvent();
                    genEvent.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                    genEvent.Name       = eventInfo.Name;
                    genEvent.Type       = new CodeTypeReference(eventInfo.EventHandlerType);

                    genClass.Members.Add(genEvent);

                    // Create event handler
                    CodeMemberMethod genMethod = new CodeMemberMethod();
                    genMethod.Name       = "On" + eventInfo.Name;
                    genMethod.Attributes = MemberAttributes.Private | MemberAttributes.Final;
                    genMethod.ReturnType = new CodeTypeReference(typeof(void));

                    CodeDelegateInvokeExpression genEventDalegate = new CodeDelegateInvokeExpression(new CodeVariableReferenceExpression("eventDelegate"));

                    foreach (ParameterInfo paramInfo in eventInfo.EventHandlerType.GetMethod("Invoke").GetParameters())
                    {
                        FieldDirection dir = FieldDirection.In;
                        Type           paramType;
                        if (paramInfo.ParameterType.IsByRef)
                        {
                            paramType = paramInfo.ParameterType.GetElementType();
                            if (paramInfo.IsOut)
                            {
                                dir = FieldDirection.Out;
                            }
                            else
                            {
                                dir = FieldDirection.Ref;
                            }
                        }
                        else
                        {
                            paramType = paramInfo.ParameterType;
                        }

                        genMethod.Parameters.Add(new CodeParameterDeclarationExpression(paramType, paramInfo.Name)
                        {
                            Direction = dir
                        });

                        if (paramInfo.ParameterType == typeof(object) && paramInfo.Name == "sender" && !paramInfo.ParameterType.IsByRef)
                        {
                            genEventDalegate.Parameters.Add(new CodeThisReferenceExpression());
                        }
                        else
                        {
                            genEventDalegate.Parameters.Add(new CodeDirectionExpression(dir, new CodeArgumentReferenceExpression(paramInfo.Name)));
                        }
                    }

                    genMethod.Statements.Add(new CodeVariableDeclarationStatement(eventInfo.EventHandlerType,
                                                                                  "eventDelegate",
                                                                                  new CodeVariableReferenceExpression(eventInfo.Name)));

                    genMethod.Statements.Add(new CodeConditionStatement(
                                                 new CodeBinaryOperatorExpression(
                                                     new CodeVariableReferenceExpression("eventDelegate"),
                                                     CodeBinaryOperatorType.IdentityInequality,
                                                     new CodePrimitiveExpression(null)
                                                     ),
                                                 new CodeExpressionStatement(genEventDalegate)
                                                 ));

                    genClass.Members.Add(genMethod);

                    // Subscribe to source event
                    constructor.Statements.Add(
                        new CodeAttachEventStatement(
                            new CodeEventReferenceExpression(
                                new CodeVariableReferenceExpression("_obj"),
                                eventInfo.Name),
                            new CodeMethodReferenceExpression(
                                new CodeThisReferenceExpression(),
                                genMethod.Name
                                )));
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Generates the proxy class methods.
        /// </summary>
        /// <param name="genClass">The generated class.</param>
        /// <param name="interfaceType">Type of the interface.</param>
        /// <param name="sourceType">Type of the source.</param>
        private static void GenerateProxyClassMethods(CodeTypeDeclaration genClass, Type interfaceType, Type sourceType)
        {
            List <string> processed = new List <string>();

            foreach (Type type in GetInterfaceTypes(interfaceType)) //zos
            {
                foreach (MethodInfo method in type.GetMethods())
                {
                    if ((method.Attributes & MethodAttributes.SpecialName) != 0)
                    {
                        continue;
                    }

                    if (processed.Contains(method.Name))
                    {
                        continue;
                    }

                    processed.Add(method.Name);

                    CodeMemberMethod genMethod = new CodeMemberMethod();
                    genMethod.Name       = method.Name;
                    genMethod.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                    genMethod.ReturnType = new CodeTypeReference(method.ReturnType);

                    CodeMethodReturnStatement  returnStatement    = null;
                    CodeMethodInvokeExpression genMethodStatement = new CodeMethodInvokeExpression(
                        new CodeVariableReferenceExpression("_obj"), method.Name);

                    if (method.ReturnType != typeof(void))
                    {
                        returnStatement = new CodeMethodReturnStatement(genMethodStatement);
                    }

                    foreach (ParameterInfo param in method.GetParameters())
                    {
                        FieldDirection dir = FieldDirection.In;
                        Type           paramType;
                        if (param.ParameterType.IsByRef)
                        {
                            paramType = param.ParameterType.GetElementType();
                            if (param.IsOut)
                            {
                                dir = FieldDirection.Out;
                            }
                            else
                            {
                                dir = FieldDirection.Ref;
                            }
                        }
                        else
                        {
                            paramType = param.ParameterType;
                        }

                        genMethod.Parameters.Add(
                            new CodeParameterDeclarationExpression(paramType, param.Name)
                        {
                            Direction = dir
                        }
                            );

                        genMethodStatement.Parameters.Add(new CodeDirectionExpression(dir, new CodeArgumentReferenceExpression(param.Name)));
                    }

                    if (returnStatement == null)
                    {
                        genMethod.Statements.Add(genMethodStatement);
                    }
                    else
                    {
                        genMethod.Statements.Add(returnStatement);
                    }

                    genClass.Members.Add(genMethod);
                }
            }
        }
Ejemplo n.º 12
0
 public DirectionExpression(FieldDirection fieldDirection, Expression expression)
 {
 }
Ejemplo n.º 13
0
 protected virtual void OutputDirection(FieldDirection dir)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
        CodeParameterDeclarationExpression GenerateParameter(XmlMemberMapping member, FieldDirection dir)
        {
#if NET_2_0
            string type = member.GenerateTypeName(CodeGenerator);
#else
            string type = member.TypeFullName;
#endif
            CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression(type, member.MemberName);
            par.Direction = dir;
            return(par);
        }
Ejemplo n.º 15
0
        public static CodeExpression Create(LanguageType lang, CodeExpression symbolExpr, FieldDirection dir)
        {
            if (lang == Transform.LanguageType.VisualBasic)
            {
                return(symbolExpr);
            }

            return(new CodeDirectionalSymbolExpression(lang, symbolExpr, dir));
        }
Ejemplo n.º 16
0
		protected virtual void OutputDirection (FieldDirection direction)
		{
			switch (direction) {
			case FieldDirection.In:
				//output.Write ("in ");
				break;
			case FieldDirection.Out:
				output.Write ("out ");
				break;
			case FieldDirection.Ref:
				output.Write ("ref ");
				break;
			}
		}
Ejemplo n.º 17
0
 /// <include file='doc\CodeDirectionExpression.uex' path='docs/doc[@for="CodeDirectionExpression.CodeDirectionExpression1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public CodeDirectionExpression(FieldDirection direction, CodeExpression expression) {
     this.expression = expression;
     this.direction = direction;
 }
Ejemplo n.º 18
0
 public CodeDirectionExpression(FieldDirection direction, CodeExpression expression)
 {
     this.expression = expression;
     this.direction  = direction;
 }
Ejemplo n.º 19
0
 public UdbusMessageMethodArgumentException(FieldDirection direction, uint index, string argument, Type argumentType, int result,
     string method, Udbus.Serialization.DbusConnectionParameters connectionParams,
     Udbus.Serialization.NMessageStruct.UdbusMessageHandle msgStruct,
     string message, Exception inner)
     : base(method, connectionParams, msgStruct, message, inner)
 {
     this.direction = direction;
     this.index = index;
     this.argument = argument;
     this.argumentType = argumentType;
     this.result = result;
 }
Ejemplo n.º 20
0
        /// <include file='doc\VsCodeDomParser.uex' path='docs/doc[@for="VsCodeDomParser.OnMethodPopulateParameters"]/*' />
        /// <devdoc>
        ///     Populate the parameter list from a function.
        /// </devdoc>
        private void OnMethodPopulateParameters(object sender, EventArgs e)
        {
            CodeMemberMethod codeMethod = (CodeMemberMethod)sender;
            CodeFunction     vsFunction = (CodeFunction)GetVsElementFromCodeObject(codeMethod);

            try {
                ITypeResolutionService typeService = provider.TypeLoader;
                foreach (CodeElement codeElement in vsFunction.Parameters)
                {
                    if (codeElement.Kind == vsCMElement.vsCMElementParameter)
                    {
                        CodeParameter  codeParam   = (CodeParameter)codeElement;
                        FieldDirection fieldDir    = FieldDirection.In;
                        StringBuilder  type        = new StringBuilder(GetUrtTypeFromVsType(codeParam.Type));
                        Type           paramType   = typeService.GetType(type.ToString());
                        bool           typeChanged = false;

                        if (codeParam is IParameterKind)
                        {
                            IParameterKind         paramKind = (IParameterKind)codeParam;
                            PARAMETER_PASSING_MODE passMode  = (PARAMETER_PASSING_MODE)paramKind.GetParameterPassingMode();
                            switch (passMode)
                            {
                            case PARAMETER_PASSING_MODE.cmParameterTypeOut:
                                fieldDir = FieldDirection.Out;
                                break;

                            case PARAMETER_PASSING_MODE.cmParameterTypeInOut:
                                fieldDir = FieldDirection.Ref;
                                break;
                            }

                            if (paramType != null)
                            {
                                // we have to walk these backwards...
                                //
                                for (int i = paramKind.GetParameterArrayCount() - 1; i >= 0; i--)
                                {
                                    typeChanged = true;
                                    type.Append("[");
                                    for (int d = 1; d < paramKind.GetParameterArrayDimensions(i); d++)
                                    {
                                        type.Append(",");
                                    }
                                    type.Append("]");
                                }
                            }
                        }

                        if (paramType != null && typeChanged)
                        {
                            paramType = paramType.Assembly.GetType(type.ToString());
                        }

                        CodeParameterDeclarationExpression parameterDecl = new CodeParameterDeclarationExpression(new CodeTypeReference(paramType), codeParam.Name);
                        parameterDecl.Direction = fieldDir;

                        codeMethod.Parameters.Add(parameterDecl);
                    }
                }
            }
            catch {
            }
        }
Ejemplo n.º 21
0
 private CodeDirectionalSymbolExpression(LanguageType lang, CodeExpression symbolExpr, FieldDirection direction) : base(lang)
 {
     _symbolExpr = symbolExpr;
     _direction  = direction;
 }
Ejemplo n.º 22
0
 public DirectionExpression(FieldDirection direction, Expression expression)
 {
     this.FieldDirection = direction;
     AddChild(expression, Roles.Expression);
 }
 internal Argument(Type type)
 {
     this.direction = FieldDirection.In;
     this.type = type;
 }
Ejemplo n.º 24
0
	// Output a field direction value.
	protected virtual void OutputDirection(FieldDirection dir)
			{
				if(dir == FieldDirection.Out)
				{
					Output.Write("out ");
				}
				else if(dir == FieldDirection.Ref)
				{
					Output.Write("ref ");
				}
			}
 internal CandidateParameter(ParameterInfo paramInfo)
 {
     this.direction = FieldDirection.In;
     if (paramInfo.IsOut)
     {
         this.direction = FieldDirection.Out;
     }
     else if (paramInfo.ParameterType.IsByRef)
     {
         this.direction = FieldDirection.Ref;
     }
     this.type = paramInfo.ParameterType;
 }
Ejemplo n.º 26
0
 protected override void OutputDirection(FieldDirection dir)
 {
     // not supported in Python
 }
Ejemplo n.º 27
0
 public ArrayParamCodeTypeHolderProperty(ParamCodeTypeHolderProperty owner, CodeTypeFactory codetypeFactory, FieldDirection fieldDirection)
     : base(owner, codetypeFactory, fieldDirection)
 {
     this.owner = owner;
 }
 private static CodeMethodReturnStatement GenerateParameters(CodeMemberMethod helperMethod, CodeTypeDeclaration codeTypeDeclaration, CodeExpression target, FieldDirection dir)
 {
     CodeMethodReturnStatement statement = null;
     foreach (CodeTypeMember member in codeTypeDeclaration.Members)
     {
         CodeMemberField field = member as CodeMemberField;
         if (field != null)
         {
             CodeFieldReferenceExpression left = new CodeFieldReferenceExpression(target, field.Name);
             CodeTypeDeclaration codeType = ServiceContractGenerator.NamespaceHelper.GetCodeType(field.Type);
             if (codeType != null)
             {
                 if (dir == FieldDirection.In)
                 {
                     helperMethod.Statements.Add(new CodeAssignStatement(left, new CodeObjectCreateExpression(field.Type, new CodeExpression[0])));
                 }
                 statement = GenerateParameters(helperMethod, codeType, left, dir);
                 continue;
             }
             CodeParameterDeclarationExpression expression2 = GetRefParameter(helperMethod.Parameters, dir, field);
             if (((expression2 == null) && (dir == FieldDirection.Out)) && (helperMethod.ReturnType.BaseType == voidTypeRef.BaseType))
             {
                 helperMethod.ReturnType = field.Type;
                 statement = new CodeMethodReturnStatement(left);
             }
             else
             {
                 if (expression2 == null)
                 {
                     expression2 = new CodeParameterDeclarationExpression(field.Type, NamingHelper.GetUniqueName(field.Name, new NamingHelper.DoesNameExist(ClientClassGenerator.DoesParameterNameExist), helperMethod));
                     expression2.Direction = dir;
                     helperMethod.Parameters.Add(expression2);
                 }
                 if (dir == FieldDirection.Out)
                 {
                     helperMethod.Statements.Add(new CodeAssignStatement(new CodeArgumentReferenceExpression(expression2.Name), left));
                     continue;
                 }
                 helperMethod.Statements.Add(new CodeAssignStatement(left, new CodeArgumentReferenceExpression(expression2.Name)));
             }
         }
     }
     return statement;
 }
 public ParamCodeTypeHolderMarshalBase(CodeTypeFactory codetypeFactory, FieldDirection fieldDirection)
     : base(codetypeFactory, fieldDirection)
 {
 }
 private static CodeParameterDeclarationExpression GetRefParameter(CodeParameterDeclarationExpressionCollection parameters, FieldDirection dir, CodeMemberField field)
 {
     foreach (CodeParameterDeclarationExpression expression in parameters)
     {
         if (expression.Name == field.Name)
         {
             if ((expression.Direction != dir) && (expression.Type.BaseType == field.Type.BaseType))
             {
                 expression.Direction = FieldDirection.Ref;
                 return expression;
             }
             return null;
         }
     }
     return null;
 }
 /// <devdoc>
 ///    <para>
 ///       Generates code for the specified System.CodeDom.FieldDirection.
 ///    </para>
 /// </devdoc>
 private void OutputDirection(FieldDirection dir) {
     switch (dir) {
         case FieldDirection.In:
             break;
         case FieldDirection.Out:
             Output.Write("out ");
             break;
         case FieldDirection.Ref:
             Output.Write("ref ");
             break;
     }
 }
        internal static ParameterAttributes ConvertToParameterAttributes(FieldDirection direction)
        {
            switch (direction)
            {
                case FieldDirection.In:
                    return ParameterAttributes.In;

                case FieldDirection.Out:
                    return ParameterAttributes.Out;
            }
            return ParameterAttributes.None;
        }
Ejemplo n.º 33
0
		protected override void OutputDirection (FieldDirection direction)
		{
			switch (direction) {
			case FieldDirection.In:
				Output.Write ("ByVal ");
				break;
			case FieldDirection.Out:
			case FieldDirection.Ref:
				Output.Write ("ByRef ");
				break;
			}
		}
 public DirectionExpression(FieldDirection fieldDirection, Expression expression)
 {
     this.fieldDirection = fieldDirection;
     this.expression = expression;
 }
Ejemplo n.º 35
0
        protected override void OutputDirection(FieldDirection dir)
        {
            switch (dir)
            {
                case FieldDirection.In:
                    base.Output.Write("ByVal ");
                    return;

                case FieldDirection.Out:
                case FieldDirection.Ref:
                    base.Output.Write("ByRef ");
                    return;
            }
        }
 protected override void OutputDirection(FieldDirection dir) {
   switch (dir) {
     case FieldDirection.In:
       break;
     case FieldDirection.Out:
     case FieldDirection.Ref:
       if (!this.isArgumentList)
         throw new Exception(JScriptException.Localize("No parameter direction", CultureInfo.CurrentUICulture));
       else
         Output.Write("&");
       break;
   }
 }
		CodeParameterDeclarationExpression GenerateParameter (XmlMemberMapping member, FieldDirection dir)
		{
			CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression (member.TypeFullName, member.MemberName);
			par.Direction = dir;
			return par;
		}
Ejemplo n.º 38
0
        private void OutputDirection(FieldDirection dir)
        {
            switch (dir)
            {
                case FieldDirection.In:
                    return;

                case FieldDirection.Out:
                    this.Output.Write("out ");
                    return;

                case FieldDirection.Ref:
                    this.Output.Write("ref ");
                    return;
            }
        }
Ejemplo n.º 39
0
 public UdbusMessageMethodArgumentException(FieldDirection direction, uint index, string argument, Type argumentType, int result,
     string method, Udbus.Serialization.DbusConnectionParameters connectionParams,
     Udbus.Serialization.NMessageStruct.UdbusMessageHandle msgStruct, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(method, connectionParams, msgStruct, info, context)
 {
     this.direction = direction;
     this.index = index;
     this.argument = argument;
     this.argumentType = argumentType;
     this.result = result;
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Outputs field direction (used for formal parameters).
 /// </summary>
 /// <remarks><c>&amp;</c></remarks>
 protected override void OutputDirection(FieldDirection dir)
 {
     if (dir != FieldDirection.In) Output.Write(Tokens.Reference);
 }
Ejemplo n.º 41
0
 protected static string CreateMessage(FieldDirection direction, uint index, string argument, Type argumentType, int result,
     string method, Udbus.Serialization.DbusConnectionParameters connectionParams,
     Udbus.Serialization.NMessageStruct.UdbusMessageHandle msgStruct)
 {
     string message = string.Format("dbus {0} argument[{1}]: '{2} {3} {4}'. result={5}. {6}. {7}"
         , method, index, direction, argumentType.Name, argument, result
         , msgStruct.ToString(), connectionParams.ToString()
     );
     return message;
 }
Ejemplo n.º 42
0
 // Constructor with full optionality
 public BendingMagnet(float B, Material material, int GLenght, BendingRadius beta, FieldDirection fd) : base(B, material, GLenght)
 {
     this.beta = beta;
     this.fd   = fd;
 }