예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpInitializedObjectExpression"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly expression from which the C# expression is created.</param>
        protected CSharpInitializedObjectExpression(ICSharpContext context, IInitializedObjectExpression source)
            : base(context, source)
        {
            Class = context.GetClass(source.ResolvedClassType.Item.BaseClass);

            foreach (IAssignmentArgument Argument in source.AssignmentList)
            {
                ICSharpAssignmentArgument NewAssignment = CSharpAssignmentArgument.Create(context, Argument);
                AssignmentList.Add(NewAssignment);
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new C# argument.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly argument from which the C# argument is created.</param>
        public static ICSharpArgument Create(ICSharpContext context, IArgument source)
        {
            ICSharpArgument Result = null;

            switch (source)
            {
            case IPositionalArgument AsPositionalArgument:
                Result = CSharpPositionalArgument.Create(context, AsPositionalArgument);
                break;

            case IAssignmentArgument AsAssignmentArgument:
                Result = CSharpAssignmentArgument.Create(context, AsAssignmentArgument);
                break;
            }

            Debug.Assert(Result != null);

            return(Result);
        }