예제 #1
0
            InvocationResolveResult GetCtorInvocation()
            {
                ResolveResult rr = LazyInit.VolatileRead(ref this.ctorInvocation);

                if (rr != null)
                {
                    return(rr as InvocationResolveResult);
                }
                else
                {
                    CSharpResolver  resolver           = new CSharpResolver(context);
                    int             totalArgumentCount = unresolved.positionalArguments.Count + unresolved.namedCtorArguments.Count;
                    ResolveResult[] arguments          = new ResolveResult[totalArgumentCount];
                    string[]        argumentNames      = new string[totalArgumentCount];
                    int             i = 0;
                    while (i < unresolved.positionalArguments.Count)
                    {
                        IConstantValue cv = unresolved.positionalArguments[i];
                        arguments[i] = cv.Resolve(context);
                        i++;
                    }
                    foreach (var pair in unresolved.namedCtorArguments)
                    {
                        argumentNames[i] = pair.Key;
                        arguments[i]     = pair.Value.Resolve(context);
                        i++;
                    }
                    rr = resolver.ResolveObjectCreation(attributeType, arguments, argumentNames);
                    return(LazyInit.GetOrSet(ref this.ctorInvocation, rr) as InvocationResolveResult);
                }
            }