private CodeExpression GetPropertySetRValue(ComAliasEnum alias, System.Type propertyType)
 {
     CodeExpression expression = new CodePropertySetValueReferenceExpression();
     if (alias == ComAliasEnum.None)
     {
         return expression;
     }
     string wFToComConverter = ComAliasConverter.GetWFToComConverter(alias);
     string wFToComParamConverter = ComAliasConverter.GetWFToComParamConverter(alias, propertyType);
     CodeExpression[] parameters = new CodeExpression[] { expression };
     CodeMethodInvokeExpression expression2 = new CodeMethodInvokeExpression(null, wFToComConverter, parameters);
     if (wFToComParamConverter.Length == 0)
     {
         return expression2;
     }
     return new CodeCastExpression(wFToComParamConverter, expression2);
 }
 private bool IsPropertyBrowsable(PropertyInfo pinfo, ComAliasEnum alias)
 {
     MethodInfo getMethod = pinfo.GetGetMethod();
     if (getMethod == null)
     {
         return false;
     }
     CustomAttributeData[] attributeData = GetAttributeData(getMethod, typeof(TypeLibFuncAttribute));
     if ((attributeData != null) && (attributeData.Length > 0))
     {
         CustomAttributeTypedArgument argument = attributeData[0].ConstructorArguments[0];
         int num = int.Parse(argument.Value.ToString());
         if (((num & 0x400) != 0) || ((num & 0x40) != 0))
         {
             return false;
         }
     }
     System.Type propertyType = pinfo.PropertyType;
     if (((alias == ComAliasEnum.None) && propertyType.IsInterface) && !propertyType.GUID.Equals(Guid_DataSource))
     {
         return false;
     }
     return true;
 }
 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));
 }
 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));
     }
 }