public static AxParameterData[] Convert(System.Reflection.ParameterInfo[] infos, bool ignoreByRefs)
        {
            if (infos == null)
            {
                return(new AxParameterData[0]);
            }
            int num = 0;

            AxParameterData[] dataArray = new AxParameterData[infos.Length];
            for (int i = 0; i < infos.Length; i++)
            {
                dataArray[i] = new AxParameterData(infos[i], ignoreByRefs);
                if ((dataArray[i].Name == null) || (dataArray[i].Name == ""))
                {
                    dataArray[i].Name = "param" + num++;
                }
            }
            return(dataArray);
        }
Example #2
0
        /// <include file='doc\AxParameterData.uex' path='docs/doc[@for="AxParameterData.Convert1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static AxParameterData[] Convert(ParameterInfo[] infos, bool ignoreByRefs)
        {
            if (infos == null)
            {
                return(new AxParameterData[0]);
            }

            int noname = 0;

            AxParameterData[] parameters = new AxParameterData[infos.Length];
            for (int i = 0; i < infos.Length; ++i)
            {
                parameters[i] = new AxParameterData(infos[i], ignoreByRefs);
                if (parameters[i].Name == null || parameters[i].Name == "")
                {
                    parameters[i].Name = "param" + (noname++);
                }
            }

            return(parameters);
        }
 public static AxParameterData[] Convert(System.Reflection.ParameterInfo[] infos, bool ignoreByRefs)
 {
     if (infos == null)
     {
         return new AxParameterData[0];
     }
     int num = 0;
     AxParameterData[] dataArray = new AxParameterData[infos.Length];
     for (int i = 0; i < infos.Length; i++)
     {
         dataArray[i] = new AxParameterData(infos[i], ignoreByRefs);
         if ((dataArray[i].Name == null) || (dataArray[i].Name == ""))
         {
             dataArray[i].Name = "param" + num++;
         }
     }
     return dataArray;
 }
Example #4
0
 /// <include file='doc\AxParameterData.uex' path='docs/doc[@for="AxParameterData.Convert"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public static AxParameterData[] Convert(ParameterInfo[] infos)
 {
     return(AxParameterData.Convert(infos, false));
 }
 private CodeMethodReturnStatement GetPropertyGetRValue(PropertyInfo pinfo, CodeExpression reference, ComAliasEnum alias, AxParameterData[] parameters, bool fMethodSyntax)
 {
     CodeExpression expression = null;
     if (fMethodSyntax)
     {
         expression = new CodeMethodInvokeExpression(reference, pinfo.GetGetMethod().Name, new CodeExpression[0]);
         for (int i = 0; i < parameters.Length; i++)
         {
             ((CodeMethodInvokeExpression) expression).Parameters.Add(new CodeFieldReferenceExpression(null, parameters[i].Name));
         }
     }
     else if (parameters.Length > 0)
     {
         expression = new CodeIndexerExpression(reference, new CodeExpression[0]);
         for (int j = 0; j < parameters.Length; j++)
         {
             ((CodeIndexerExpression) expression).Indices.Add(new CodeFieldReferenceExpression(null, parameters[j].Name));
         }
     }
     else
     {
         expression = new CodePropertyReferenceExpression(reference, (parameters.Length == 0) ? pinfo.Name : "");
     }
     if (alias == ComAliasEnum.None)
     {
         return new CodeMethodReturnStatement(expression);
     }
     string comToManagedConverter = ComAliasConverter.GetComToManagedConverter(alias);
     string comToWFParamConverter = ComAliasConverter.GetComToWFParamConverter(alias);
     CodeExpression[] expressionArray = null;
     if (comToWFParamConverter.Length == 0)
     {
         expressionArray = new CodeExpression[] { expression };
     }
     else
     {
         CodeCastExpression expression2 = new CodeCastExpression(comToWFParamConverter, expression);
         expressionArray = new CodeExpression[] { expression2 };
     }
     return new CodeMethodReturnStatement(new CodeMethodInvokeExpression(null, comToManagedConverter, expressionArray));
 }
 public EventEntry(string eventName, string eventCls, string eventHandlerCls, System.Type retType, AxParameterData[] parameters, bool conflict)
 {
     this.eventName = eventName;
     this.eventCls = eventCls;
     this.eventHandlerCls = eventHandlerCls;
     this.retType = retType;
     this.parameters = parameters;
     this.eventParam = eventName.ToLower(CultureInfo.InvariantCulture) + "Event";
     this.resovledEventName = conflict ? (eventName + "Event") : eventName;
     this.invokeMethodName = "RaiseOn" + this.resovledEventName;
     this.eventFlags = MemberAttributes.Public | MemberAttributes.Final;
 }
 private static CodeExpression GetDefaultExpressionForInvoke(MethodInfo method, AxParameterData parameterInfo)
 {
     object rawDefaultValue = parameterInfo.ParameterInfo.RawDefaultValue;
     System.Type parameterBaseType = parameterInfo.ParameterBaseType;
     if (rawDefaultValue == Missing.Value)
     {
         if (!parameterBaseType.IsPrimitive)
         {
             if (!parameterBaseType.IsEnum)
             {
                 if (parameterBaseType == typeof(object))
                 {
                     return new CodeFieldReferenceExpression(new CodeFieldReferenceExpression(null, "System.Reflection.Missing"), "Value");
                 }
                 if (parameterBaseType.IsValueType)
                 {
                     if (parameterBaseType.GetConstructor(new System.Type[0]) != null)
                     {
                         return new CodeObjectCreateExpression(parameterBaseType, new CodeExpression[0]);
                     }
                     if (parameterBaseType == typeof(decimal))
                     {
                         return new CodeObjectCreateExpression(typeof(decimal), new CodeExpression[] { new CodePrimitiveExpression(0.0) });
                     }
                     if (parameterBaseType != typeof(DateTime))
                     {
                         throw new Exception(System.Design.SR.GetString("AxImpNoDefaultValue", new object[] { method.Name, parameterInfo.Name, parameterBaseType.FullName }));
                     }
                     return new CodeObjectCreateExpression(typeof(DateTime), new CodeExpression[] { new CodePrimitiveExpression(0L) });
                 }
                 if (parameterBaseType == typeof(string))
                 {
                     rawDefaultValue = "";
                 }
                 else
                 {
                     rawDefaultValue = null;
                 }
                 parameterBaseType = null;
             }
             else
             {
                 rawDefaultValue = 0;
                 if (!Enum.IsDefined(parameterBaseType, 0) && (Enum.GetValues(parameterBaseType).Length > 0))
                 {
                     rawDefaultValue = Enum.GetValues(parameterBaseType).GetValue(0);
                 }
             }
         }
         else
         {
             rawDefaultValue = GetPrimitiveDefaultValue(parameterBaseType);
         }
     }
     else if (parameterBaseType.IsPrimitive)
     {
         rawDefaultValue = GetClsPrimitiveValue(rawDefaultValue);
         rawDefaultValue = GetDefaultValueForUnsignedType(parameterBaseType, rawDefaultValue);
     }
     else if (((rawDefaultValue != null) && parameterBaseType.IsInstanceOfType(rawDefaultValue)) && (((rawDefaultValue is DateTime) || (rawDefaultValue is decimal)) || (rawDefaultValue is bool)))
     {
         if (rawDefaultValue is DateTime)
         {
             CodeExpression[] parameters = new CodeExpression[1];
             DateTime time = (DateTime) rawDefaultValue;
             parameters[0] = new CodeCastExpression(typeof(long), new CodePrimitiveExpression(time.Ticks));
             return new CodeObjectCreateExpression(typeof(DateTime), parameters);
         }
         if (rawDefaultValue is decimal)
         {
             return new CodeObjectCreateExpression(typeof(decimal), new CodeExpression[] { new CodeCastExpression(typeof(double), new CodePrimitiveExpression(decimal.ToDouble((decimal) rawDefaultValue))) });
         }
         if (rawDefaultValue is bool)
         {
             return new CodePrimitiveExpression((bool) rawDefaultValue);
         }
         if (!(rawDefaultValue is string))
         {
             throw new Exception(System.Design.SR.GetString("AxImpUnrecognizedDefaultValueType", new object[] { method.Name, parameterInfo.Name, parameterBaseType.FullName }));
         }
         parameterBaseType = null;
     }
     else if (!parameterBaseType.IsValueType)
     {
         if (rawDefaultValue is DispatchWrapper)
         {
             rawDefaultValue = null;
         }
         if ((rawDefaultValue != null) && !(rawDefaultValue is string))
         {
             throw new Exception(System.Design.SR.GetString("AxImpUnrecognizedDefaultValueType", new object[] { method.Name, parameterInfo.Name, parameterBaseType.FullName }));
         }
         parameterBaseType = null;
         return new CodePrimitiveExpression(rawDefaultValue);
     }
     if ((parameterBaseType != null) && parameterBaseType.IsEnum)
     {
         rawDefaultValue = (int) rawDefaultValue;
     }
     CodeExpression expression = new CodePrimitiveExpression(rawDefaultValue);
     if (parameterBaseType != null)
     {
         expression = new CodeCastExpression(parameterBaseType, expression);
     }
     return expression;
 }
 private void WritePropertySetterProp(CodeMemberProperty prop, PropertyInfo pinfo, ComAliasEnum alias, AxParameterData[] parameters, bool fOverride, bool useLet)
 {
     CodeExpression left = null;
     CodeBinaryOperatorExpression expression2 = null;
     CodeConditionStatement statement = null;
     CodeExpression expression3;
     if (fOverride)
     {
         if (parameters.Length > 0)
         {
             left = new CodeIndexerExpression(this.memIfaceRef, new CodeExpression[0]);
         }
         else
         {
             left = new CodePropertyReferenceExpression(new CodeBaseReferenceExpression(), pinfo.Name);
         }
         expression2 = new CodeBinaryOperatorExpression(this.memIfaceRef, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
         statement = new CodeConditionStatement {
             Condition = expression2
         };
     }
     if (parameters.Length > 0)
     {
         expression3 = new CodeIndexerExpression(this.memIfaceRef, new CodeExpression[0]);
     }
     else
     {
         expression3 = new CodePropertyReferenceExpression(this.memIfaceRef, pinfo.Name);
     }
     for (int i = 0; i < parameters.Length; i++)
     {
         if (fOverride)
         {
             ((CodeIndexerExpression) left).Indices.Add(new CodeFieldReferenceExpression(null, parameters[i].Name));
         }
         ((CodeIndexerExpression) expression3).Indices.Add(new CodeFieldReferenceExpression(null, parameters[i].Name));
     }
     CodeFieldReferenceExpression right = new CodeFieldReferenceExpression(null, "value");
     CodeExpression propertySetRValue = this.GetPropertySetRValue(alias, pinfo.PropertyType);
     if (fOverride)
     {
         prop.SetStatements.Add(new CodeAssignStatement(left, right));
         statement.TrueStatements.Add(new CodeAssignStatement(expression3, propertySetRValue));
         prop.SetStatements.Add(statement);
     }
     else
     {
         prop.SetStatements.Add(new CodeAssignStatement(expression3, propertySetRValue));
     }
 }
 private void WritePropertySetterMethod(CodeMemberProperty prop, PropertyInfo pinfo, ComAliasEnum alias, AxParameterData[] parameters, bool fOverride, bool useLet)
 {
     CodeExpression left = null;
     CodeBinaryOperatorExpression expression2 = null;
     CodeConditionStatement statement = null;
     CodeFieldReferenceExpression expression3;
     if (fOverride)
     {
         if (parameters.Length > 0)
         {
             left = new CodeIndexerExpression(this.memIfaceRef, new CodeExpression[0]);
         }
         else
         {
             left = new CodePropertyReferenceExpression(new CodeBaseReferenceExpression(), pinfo.Name);
         }
         expression2 = new CodeBinaryOperatorExpression(this.memIfaceRef, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null));
         statement = new CodeConditionStatement {
             Condition = expression2
         };
     }
     string methodName = useLet ? ("let_" + pinfo.Name) : pinfo.GetSetMethod().Name;
     CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression(this.memIfaceRef, methodName, new CodeExpression[0]);
     for (int i = 0; i < parameters.Length; i++)
     {
         if (fOverride)
         {
             ((CodeIndexerExpression) left).Indices.Add(new CodeFieldReferenceExpression(null, parameters[i].Name));
         }
         expression.Parameters.Add(new CodeFieldReferenceExpression(null, parameters[i].Name));
     }
     CodeFieldReferenceExpression right = new CodeFieldReferenceExpression(null, "value");
     CodeExpression propertySetRValue = this.GetPropertySetRValue(alias, pinfo.PropertyType);
     if (alias != ComAliasEnum.None)
     {
         CodeParameterDeclarationExpression expression7;
         string wFToComParamConverter = ComAliasConverter.GetWFToComParamConverter(alias, pinfo.PropertyType);
         if (wFToComParamConverter.Length == 0)
         {
             expression7 = this.CreateParamDecl(MapTypeName(pinfo.PropertyType), "paramTemp", false);
         }
         else
         {
             expression7 = this.CreateParamDecl(wFToComParamConverter, "paramTemp", false);
         }
         prop.SetStatements.Add(new CodeAssignStatement(expression7, propertySetRValue));
         expression3 = new CodeFieldReferenceExpression(null, "paramTemp");
     }
     else
     {
         expression3 = right;
     }
     expression.Parameters.Add(new CodeDirectionExpression(useLet ? FieldDirection.In : FieldDirection.Ref, expression3));
     if (fOverride)
     {
         prop.SetStatements.Add(new CodeAssignStatement(left, right));
         statement.TrueStatements.Add(new CodeExpressionStatement(expression));
         prop.SetStatements.Add(statement);
     }
     else
     {
         prop.SetStatements.Add(new CodeExpressionStatement(expression));
     }
 }
 private void WritePropertySetter(CodeMemberProperty prop, PropertyInfo pinfo, ComAliasEnum alias, AxParameterData[] parameters, bool fMethodSyntax, bool fOverride, bool useLet, bool dataSourceProp)
 {
     if (!fOverride && !dataSourceProp)
     {
         prop.SetStatements.Add(this.CreateInvalidStateException(prop.Name, "PropertySet"));
     }
     if (dataSourceProp)
     {
         string dataSourceName = this.CreateDataSourceFieldName(pinfo.Name);
         this.WriteDataSourcePropertySetter(prop, pinfo, dataSourceName);
     }
     else if (!fMethodSyntax)
     {
         this.WritePropertySetterProp(prop, pinfo, alias, parameters, fOverride, useLet);
     }
     else
     {
         this.WritePropertySetterMethod(prop, pinfo, alias, parameters, fOverride, useLet);
     }
 }
 private void WritePropertyGetter(CodeMemberProperty prop, PropertyInfo pinfo, ComAliasEnum alias, AxParameterData[] parameters, bool fMethodSyntax, bool fOverride, bool dataSourceProp)
 {
     if (dataSourceProp)
     {
         string fieldName = this.CreateDataSourceFieldName(pinfo.Name);
         CodeMethodReturnStatement statement = new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName));
         prop.GetStatements.Add(statement);
     }
     else if (fOverride)
     {
         CodeConditionStatement statement2 = this.CreateValidStateCheck();
         statement2.TrueStatements.Add(this.GetPropertyGetRValue(pinfo, this.memIfaceRef, alias, parameters, fMethodSyntax));
         statement2.FalseStatements.Add(this.GetPropertyGetRValue(pinfo, new CodeBaseReferenceExpression(), ComAliasEnum.None, parameters, false));
         prop.GetStatements.Add(statement2);
     }
     else
     {
         prop.GetStatements.Add(this.CreateInvalidStateException(prop.Name, "PropertyGet"));
         prop.GetStatements.Add(this.GetPropertyGetRValue(pinfo, this.memIfaceRef, alias, parameters, fMethodSyntax));
     }
 }
 private EventEntry AddEvent(string name, string eventCls, string eventHandlerCls, System.Type retType, AxParameterData[] parameters)
 {
     if (this.events == null)
     {
         this.events = new ArrayList();
     }
     if (this.axctlTypeMembers == null)
     {
         this.axctlTypeMembers = new Hashtable();
         foreach (MemberInfo info in this.axctlType.GetMembers())
         {
             string key = info.Name;
             if (!this.axctlTypeMembers.Contains(key))
             {
                 this.axctlTypeMembers.Add(key, info);
             }
         }
     }
     bool conflict = (this.axctlTypeMembers.Contains(name) || this.AxHostMembers.Contains(name)) || this.ConflictableThings.Contains(name);
     EventEntry entry = new EventEntry(name, eventCls, eventHandlerCls, retType, parameters, conflict);
     this.events.Add(entry);
     return entry;
 }