internal ConfigurationManagerDeclarationImpl(ServiceCompositeAssemblyDeclaration decl, ConfigurationManagerInfo info)
        {
            ArgumentValidator.ValidateNotNull("Service declaration", decl);
            ArgumentValidator.ValidateNotNull("Configuration manager info", info);

            this._decl = decl;
            this._info = info;
        }
Beispiel #2
0
        internal FunctionInfo(ServiceCompositeAssemblyDeclaration assDecl)
        {
            this._functionMethods      = new Dictionary <MethodInfo, MethodInfo>();
            this._preArgTransformers   = new Dictionary <MethodInfo, Func <Object[], Object[]> >();
            this._postArgTransformers  = new Dictionary <MethodInfo, Action <Object[], Object[]> >();
            this._invocationHelpers    = new Dictionary <MethodInfo, FunctionInvocationHelper>();
            this._compositeInfoMethods = new Dictionary <Type, IEnumerable <MethodInfo> >();
            //this._additionalRoles = new Dictionary<MethodInfo, Func<TKey, TComposite, Object[], IEnumerable<Tuple<String, Object>>>>();

            this._lookupFuncs           = new Dictionary <MethodInfo, Func <Object[], IEnumerable <TKey> > >();
            this._directLookupFailFuncs = new Dictionary <MethodInfo, Func <Application, IEnumerable <TKey>, IEnumerable <KeyValuePair <TKey, Lazy <TComposite> > >, Object[], Tuple <TKey, TComposite, Boolean> > >();

            this._defaultFunctions = new List <Tuple <TKey[], Func <StructureServiceProvider, TComposite> > >();
        }
Beispiel #3
0
        private FunctionInfo <TKey, TComposite> GetInfo()
        {
            ServiceCompositeAssemblyDeclaration assemblyDeclaration = this._assemblyDeclaration;
            FunctionInfo <TKey, TComposite>     info = (FunctionInfo <TKey, TComposite>)assemblyDeclaration.Get <FunctionInfo <TKey, TComposite> >();

            if (info == null)
            {
                info = new FunctionInfo <TKey, TComposite>(this._assemblyDeclaration);
                assemblyDeclaration.Use(info);
                assemblyDeclaration.Assembler.ApplicationArchitecture.CompositeModelCreatedEvent += new EventHandler <CompositeModelCreatedArgs>((sender, args) =>
                {
                    // Subscribe to validation event - in order to generate or load code for invocation helpers.
                    if (assemblyDeclaration.AffectedCompositeIDs.Contains(args.Model.CompositeModelID))
                    {
                        args.Model.ApplicationModel.ApplicationCodeResolveEvent += new EventHandler <ApplicationCodeResolveArgs>((sender2, args2) =>
                        {
                            foreach (var kvp in info.FunctionMethods)
                            {
                                var typeName = this.GetInvocationHandlerName(args.Model, kvp.Key);
                                var t        = args2.Assemblies[kvp.Value.DeclaringType.Assembly].GetType(typeName, false);
                                if (t != null)
                                {
                                    info.InvocationHelpers.Add(kvp.Key, (FunctionInvocationHelper)t.GetConstructors().First().Invoke(null));
                                }
                            }
                        });

#if QI4CS_SDK
                        args.Model.ApplicationModel.ApplicationCodeGenerationEvent += new EventHandler <ApplicationCodeGenerationArgs>((sender2, args2) =>
                        {
                            this.GenerateType(args.Model, info, args2);
                        });
#endif
                    }
                });
            }
            return(info);
        }
Beispiel #4
0
    /// <summary>
    /// Specifies that this <see cref="ServiceCompositeAssemblyDeclaration"/> should act as aggregator service.
    /// </summary>
    /// <typeparam name="TKey">The type of the keys by which aggregated objects are indexed.</typeparam>
    /// <typeparam name="TComposite">The type that aggregated objects should implement.</typeparam>
    /// <param name="assemblyDeclaration">The <see cref="ServiceCompositeAssemblyDeclaration"/>.</param>
    /// <returns>A <see cref="FunctionAggregatorDeclaration{TKey, TComposite}"/> which may be used to further configure aggregator service.</returns>
    /// <exception cref="NullReferenceException">If <paramref name="assemblyDeclaration"/> is <c>null</c>.</exception>
    /// <seealso cref="FunctionAggregatorDeclaration{TKey, TComposite}"/>
    public static FunctionAggregatorDeclaration <TKey, TComposite> AsFunctionAggregator <TKey, TComposite>(this ServiceCompositeAssemblyDeclaration assemblyDeclaration)
        where TComposite : class
    {
        var dic = assemblyDeclaration.Assembler.ApplicationArchitecture.AdditionalInjectionFunctionalities;

        dic[RoleInjectionFunctionality.SCOPE] = RoleInjectionFunctionality.INSTANCE;
        dic[FunctionInvocationDataInjectionFunctionality.SCOPE] = FunctionInvocationDataInjectionFunctionality.INSTANCE;
        return(new FunctionAggregatorDeclarationImpl <TKey, TComposite>(assemblyDeclaration));
    }
Beispiel #5
0
        internal FunctionAggregatorDeclarationImpl(ServiceCompositeAssemblyDeclaration assemblyDeclaration)
        {
            ArgumentValidator.ValidateNotNull("Service assembly declaration", assemblyDeclaration);

            this._assemblyDeclaration = assemblyDeclaration;
        }
Beispiel #6
0
    // TODO implementing value composite model type should be done via extension
    //public static Boolean ForNewOrExistingValue( this Assembler assembler, IEnumerable<Type> types, out CompositeAssemblyDeclaration result )
    //{
    //   return assembler.ForNewOrExistingComposite<CompositeAssemblyDeclaration>( CompositeModelType.VALUE, types, out result );
    //}

    //public static Boolean ForNewOrExistingValue<TCompositeDeclaration>( this Assembler assembler, IEnumerable<Type> types, out TCompositeDeclaration result )
    //   where TCompositeDeclaration : CompositeAssemblyDeclaration
    //{
    //   return assembler.ForNewOrExistingComposite<TCompositeDeclaration>( CompositeModelType.VALUE, types, out result );
    //}

    /// <summary>
    /// Helper method to invoke <see cref="Assembler.ForNewOrExistingComposite{T}(CompositeModelType,IEnumerable{System.Type},out T)"/> method with <see cref="CompositeModelType.SERVICE"/> as parameter.
    /// </summary>
    /// <param name="assembler">The <see cref="Assembler"/>.</param>
    /// <param name="types">The composite types.</param>
    /// <param name="result">This parameter will hold the resulting composite declaration.</param>
    /// <returns>The return value of <see cref="Assembler.ForNewOrExistingComposite{T}(CompositeModelType,IEnumerable{System.Type},out T)"/>.</returns>
    public static Boolean ForNewOrExistingService(this Assembler assembler, IEnumerable <Type> types, out ServiceCompositeAssemblyDeclaration result)
    {
        return(assembler.ForNewOrExistingComposite <ServiceCompositeAssemblyDeclaration>(CompositeModelType.SERVICE, types, out result));
    }