Exemplo n.º 1
0
        /// <summary>
        /// Adds the given constructors to the given type.
        /// </summary>
        /// <param name="type">The entity to add the fields to.</param>
        /// <param name="tp">.</param>
        private void AddConstructors(CompositeType type, TypeDeclaration tp)
        {
            foreach (ConstructorDeclaration cp in tp.Descendants.OfType <ConstructorDeclaration>())
            {
                // Skip subclass
                if (type.Name != cp.Name)
                {
                    continue;
                }

                Constructor cons = type.AddConstructor();

                cons.Name           = cp.Name;
                cons.AccessModifier = cp.Modifiers.ToEnClass();

                CSharpArgumentList Arg = new CSharpArgumentList();

                foreach (ParameterDeclaration ichParameter in cp.Parameters)
                {
                    Arg.Add(ichParameter.Name, ichParameter.Type.ToString(), ichParameter.ParameterModifier.ToEnClass(), ichParameter.DefaultExpression.ToString());
                }

                cons.ArgumentList = Arg;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the given methods to the given type.
        /// </summary>
        private void AddMethods(CompositeType type, TypeDeclaration tp)
        {
            foreach (MethodDeclaration mp in tp.Descendants.OfType <MethodDeclaration>())
            {
                Method method = type.AddMethod();

                method.Name = mp.Name;

                method.Type           = mp.ReturnType.ToString();
                method.AccessModifier = mp.Modifiers.ToEnClass();

                CSharpArgumentList Arg = new CSharpArgumentList();

                foreach (ParameterDeclaration ichParameter in mp.Parameters)
                {
                    string defaultValue = string.Empty;
                    if (ichParameter.DefaultExpression is PrimitiveExpression)
                    {
                        PrimitiveExpression defaultExpression = (PrimitiveExpression)ichParameter.DefaultExpression;
                        defaultValue = defaultExpression.Value.ToString();
                    }

                    Arg.Add(ichParameter.Name, ichParameter.Type.ToString(), ichParameter.ParameterModifier.ToEnClass(), defaultValue);
                }

                method.ArgumentList = Arg;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the given operators to the given type.
        /// </summary>
        private void AddOperators(CompositeType type, TypeDeclaration tp)
        {
            foreach (OperatorDeclaration op in tp.Descendants.OfType <OperatorDeclaration>())
            {
                Method method = type.AddMethod();

                method.Name           = op.Name;
                method.Type           = op.ReturnType.ToString();
                method.AccessModifier = op.Modifiers.ToEnClass();

                CSharpArgumentList Arg = new CSharpArgumentList();

                foreach (ParameterDeclaration ichParameter in op.Parameters)
                {
                    Arg.Add(ichParameter.Name, ichParameter.Type.ToString(), ichParameter.ParameterModifier.ToEnClass(), ichParameter.DefaultExpression.ToString());
                }

                method.ArgumentList = Arg;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Adds the given constructors to the given type.
        /// </summary>
        /// <param name="type">The entity to add the fields to.</param>
        /// <param name="tp">.</param>
        private void AddConstructors(CompositeType type, TypeDeclaration tp)
        {
            foreach (var cp in tp.Descendants.OfType <ConstructorDeclaration>())
            {
                var cons = type.AddConstructor();

                cons.Name           = cp.Name;
                cons.AccessModifier = cp.Modifiers.ToNClass();

                var Arg = new CSharpArgumentList();

                foreach (var ichParameter in cp.Parameters)
                {
                    Arg.Add(ichParameter.Name,
                            ichParameter.Type.ToString(),
                            ichParameter.ParameterModifier.ToNClass(),
                            ichParameter.DefaultExpression.ToString());
                }

                cons.ArgumentList = Arg;
            }
        }