Example #1
0
        public MethodTemplateModel(Method source, string owner, string packageName, MethodScopeProvider methodScope, bool next)
        {
            this.LoadFrom(source);

            MethodScope        = methodScope;
            Owner              = owner;
            PackageName        = packageName;
            NextAlreadyDefined = next;

            var parameter = Parameters.Find(p => p.Type.IsPrimaryType(KnownPrimaryType.Stream) &&
                                            !(p.Location == ParameterLocation.Body || p.Location == ParameterLocation.FormData));

            if (parameter != null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          Resources.IllegalStreamingParameter, parameter.Name));
            }

            if (string.IsNullOrEmpty(Description))
            {
                Description = string.Format("sends the {0} request.", ScopedName.ToPhrase());
            }

            if (this.IsLongRunningOperation())
            {
                Description += lroDescription;
            }
        }
 public static IUnityContainer RegisterType <TFrom, TTo>(
     this IUnityContainer container,
     ScopedName <TTo> scopedName,
     LifetimeManager lifetimeManager,
     params InjectionMember[] injectionMembers) where TTo : TFrom
 {
     return(container.RegisterType(typeof(TFrom), typeof(TTo), scopedName, lifetimeManager, injectionMembers));
 }
    public static IEnumerable <T> ResolveAll <T>(this IUnityContainer container, ScopedName <T> name, params ResolverOverride[] resolverOverrides)
    {
        var matches = container.Registrations.Where(r => name.IsMatach(r.Name));

        foreach (var registration in matches)
        {
            yield return(container.Resolve <T>(registration.Name, resolverOverrides));
        }
    }
Example #4
0
        public ParsingTypes.ValueType ParseType(ArrayEnumerator <LexerToken> ts, ref bool isend)
        {
            if (isend)
            {
                throw MakeException("型名がありません");
            }
            var top = ts.GetNext(out isend);

            if (top is Name n)
            {
                var ret = ParseScopedName(ts, ref isend, ScopedName.NewAtomic(n.Item));
                if (isend)
                {
                    if (ret is ScopedName.Atomic b && this.typekeyword.Contains(b.Item))
                    {
                        throw MakeException("型名に使えないキーワードが含まれています");
                    }
                    return(ParsingTypes.ValueType.NewAtomic(ret));
                }
                var next = ts.GetNext(out isend);
                if (next != CurlyStart)
                {
                    ts.MovePrev(out isend);
                    return(ParsingTypes.ValueType.NewAtomic(ret));
                }
                var list = new List <ParsingTypes.ValueType>();
                while (!isend)
                {
                    list.Add(ParseType(ts, ref isend));
                    if (isend)
                    {
                        throw MakeException("\"{\" が閉じられていません");
                    }
                    next = ts.GetNext(out isend);
                    if (next == CurlyEnd)
                    {
                        if (ret is ScopedName.Atomic b && this.typekeyword.Contains(b.Item))
                        {
                            if (list.Count() != 1)
                            {
                                throw MakeException("\"{  }\"内の型が多すぎます");
                            }
                            if (b.Item == "ref")
                            {
                                return(ParsingTypes.ValueType.NewRef(list[0]));
                            }
                            else if (b.Item == "const")
                            {
                                return(ParsingTypes.ValueType.NewConst(list[0]));
                            }
                            else if (b.Item == "const_ref")
                            {
                                return(ParsingTypes.ValueType.NewConstRef(list[0]));
                            }
                        }
                        return(ParsingTypes.ValueType.NewTemplate(ret, list));
                    }
                    else if (next is Operator op && op.Item == ",")
                    {
                        continue;
                    }
                    else
                    {
                        throw MakeException("不明なトークンが含まれています");
                    }
                }