Esempio n. 1
0
        public void ToDictionary()
        {
            var dictionary = new[] { Pairs.Create("Hello", "World") }.ToDictionary();

            dictionary["Hello"]
            .Should()
            .Be("World");
        }
        ActivationContextActivator Activator(ConstructorInfo constructor, ImmutableArray <IMember> members)
        {
            var activator = new Source(constructor).ToDelegate();
            var contexts  = new ActivationContexts(_accessors, members, activator);
            var defaults  = constructor.GetParameters()
                            .Where(x => x.IsOptional)
                            .Select(x => Pairs.Create(x.Name, x.DefaultValue))
                            .ToImmutableArray();
            var result = new ActivationContextActivator(contexts, defaults);

            return(result);
        }
Esempio n. 3
0
 public IEnumerable <KeyValuePair <TypeInfo, IIdentity> > Get(IEnumerable <TypeInfo> parameter)
 {
     foreach (var type in parameter.SelectMany(_types).Distinct())
     {
         var key = _identity.Get(type);
         if (key != null)
         {
             var identifier = key.Value.Identifier.NullIfEmpty() ?? _formatter.Get(type);
             var name       = key.Value.Name.NullIfEmpty() ?? type.Name;
             var identity   = _store.Get(name, identifier);
             yield return(Pairs.Create(type, identity));
         }
     }
 }
Esempio n. 4
0
 public static Pair <Type, Func <string, Func <object, IProjection> > > Entry <T>(this IFormattedProjection <T> @this)
 => Pairs.Create(A.Type <T>(),
                 @this.Select(Compose.Start.A.Selection.Of.Any.AndOf <T>().By.Cast.Or.Throw.Select)
                 .Select(x => x.ToDelegate())
                 .ToDelegate());
Esempio n. 5
0
 public Pair <GroupName, IList <T> > Get(IGroup <T> parameter)
 => Pairs.Create(parameter.Name, (IList <T>)parameter);