Exemplo n.º 1
0
        public static void PostGenerateCode(Behaviac.Design.MethodDef method, StreamWriter stream, string indent, string typename, string var, string caller)
        {
            string paramsName = getParamsName(var, caller);

            for (int i = 0; i < method.Params.Count; ++i)
            {
                //if (method.Params[i].NativeType.EndsWith("&"))
                if (method.Params[i].NativeType.IndexOf("&") >= 0)
                {
                    object obj = method.Params[i].Value;
                    if (obj != null)
                    {
                        string nativeType = DataCsExporter.GetGeneratedNativeType(method.Params[i].NativeType);
                        string param      = getParamName(var, caller, i);
                        string paramName  = string.Format("(({0}){1}[{2}])", nativeType, paramsName, i);

                        if (!method.Params[i].IsProperty && !method.Params[i].IsPar)
                        {
                            Type type = obj.GetType();
                            if (!Plugin.IsArrayType(type) && !Plugin.IsCustomClassType(type))
                            {
                                param = paramName;
                            }
                        }
                        else
                        {
                            paramName = null;
                        }

                        ParameterCsExporter.PostGenerateCode(method.Params[i], stream, indent, nativeType, param, caller, method, paramName);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void PostGenerateCode(object obj, StreamWriter stream, string indent, string var, object parent, string paramName)
        {
            Debug.Check(obj != null);

            Type type = obj.GetType();

            Debug.Check(Plugin.IsCustomClassType(type));

            MethodDef method = parent as MethodDef;
            IList <DesignerPropertyInfo> properties = DesignerProperty.GetDesignerProperties(type);

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoSave))
                {
                    object member = property.GetValue(obj);
                    if (property.Attribute is DesignerStruct)
                    {
                        PostGenerateCode(member, stream, indent, var + "." + property.Property.Name, parent, paramName);
                    }
                    else
                    {
                        if (method != null)
                        {
                            MethodDef.Param param = method.GetParam(paramName, property);
                            if (param != null)
                            {
                                string nativeType = DataCsExporter.GetGeneratedNativeType(param.NativeType);
                                ParameterCsExporter.PostGenerateCode(param, stream, indent, nativeType, var + "." + property.Property.Name, string.Empty, method, null);
                            }
                        }
                    }
                }
            }
        }