Exemplo n.º 1
0
        private static List <IScriptAction> getCommandlineReferences(ScriptContext context)
        {
            List <IScriptAction> preScript = new List <IScriptAction>();

            if (context.IsSet(xs.@ref))
            {
                foreach (var param in context.GetStr(xs.@ref ?? string.Empty).Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                {
                    string r         = param.Trim();
                    bool   withTypes = false;
                    bool   file      = false;

                    if (r.StartsWith("#", StringComparison.Ordinal))
                    {
                        withTypes = true;
                        r         = r.Substring(1);
                    }
                    if (r.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                    {
                        file = true;
                    }

                    if (!string.IsNullOrEmpty(r))
                    {
                        Reference rr       = null;
                        bool      addUsing = false;
                        if (r.StartsWith("@", StringComparison.Ordinal))
                        {
                            r        = r.Substring(1);
                            addUsing = true;
                        }
                        if (file)
                        {
                            rr = new Reference {
                                From = r, WithTypes = withTypes, Transform = TransformRules.None, AddUsing = addUsing
                            };
                            preScript.Add(new Embed {
                                From = r, IsAssembly = true, Transform = TransformRules.None
                            });
                        }
                        else
                        {
                            rr = new Reference {
                                Name = r, WithTypes = withTypes, Transform = TransformRules.None, AddUsing = addUsing
                            }
                        };
                        if (withTypes)
                        {
                            context.AddAssembly(rr.AddReference(context, true), true);
                        }
                        preScript.Add(rr);
                    }
                }
            }
            return(preScript);
        }
    }