void FindActivationConstructor() { var tt = type.GetTypeInfo(); if (tt.IsAbstract) { // Composable providers can be abstract if (type.IsProviderType() && tt.IsDefined(typeof(ComposableAttribute), false)) { var composeMember = App.GetProviderMember(type, "compose"); if (composeMember == null) { throw new NotImplementedException(); } activationConstructor = ReflectedProviderFactoryDefinitionBase.Create(type, composeMember); } } else { MethodBase ctor = TypeHelper.FindActivationConstructor(type); if (ctor != null) { activationConstructor = ReflectedPropertyTreeFactoryDefinition.Create(null, ctor); } } }
private void FindAllOperators() { HashSet <MethodInfo> explicitOperators = new HashSet <MethodInfo>(); foreach (MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) { bool match = false; // TODO Check signature of these methods because they could be illegal foreach (var attribute in FindRoleAttributes(method)) { var result = attribute.BuildInstance(method); if (result != null) { this.operators.Add(result); match = true; } } if (match) { explicitOperators.Add(method); } } foreach (var mi in type.GetMethods().Except(explicitOperators)) { if (!mi.IsPublic || mi.IsStatic) { continue; } ParameterInfo[] parameters = mi.GetParameters(); switch (mi.Name) { case "Add": if (IsValidAddon(mi, parameters)) { // TODO We're consuming duplicated names (here, below); they should be errors this.operators.TryAdd(ReflectedPropertyTreeFactoryDefinition.FromListAddMethod(mi)); var natural = ReflectedPropertyTreeFactoryDefinition.FromListAddMethod(mi, true); if (natural != null && !this.operators.ContainsKey(natural.QualifiedName)) { this.operators.Add(natural); } } break; case "Clear": this.operators.Add(new ReflectedClearDefinition(null, mi)); break; case "RemoveAt": this.operators.TryAdd(new ReflectedRemoveDefinition(null, mi)); break; case "Remove": break; } } }
private static void ApplyFilters(ReflectedPropertyTreeDefinition def) { // TODO This should be structured instead if (typeof(NameValueCollection) == def.SourceClrType) { // Make sure that Add(string,string) is the addon, and not Add(NameValueCollection) which isn't useful var mi = typeof(NameValueCollection).GetMethod("Add", new[] { typeof(string), typeof(string) }); def.Operators.RemoveInternal(NamespaceUri.Default + "Add"); def.Operators.Add(ReflectedPropertyTreeFactoryDefinition.Create(null, mi)); } }
internal void AddFactoryDefinition(ReflectedPropertyTreeFactoryDefinition definition) { this.operators.AddInternal(definition); }
internal void AddFactoryDefinition(ReflectedPropertyTreeFactoryDefinition definition) { this.operators.TryAdd(definition); }