Example #1
0
        public void ApplyToScriptManager(IScriptManagerService scriptManager)
        {
            var services = new Dictionary <Type, object>();

            GatherServicesAndInvokeBeforeWriteScriptsCallbacks(scriptManager, services);
            foreach (var asm in         _createdObjects.Select(o => o.Item1.GetType().Assembly)
                     .Concat(services.Values.Select(o => o.GetType().Assembly))
                     .Concat(_registeredClientUsableTypes.Select(t => t.Assembly))
                     .Distinct())
            {
                scriptManager.RegisterClientAssembly(asm);
            }

            foreach (var svc in services.Concat(_createdObjects.Where(t => t.Item2 != null)
                                                .Select(t => new KeyValuePair <Type, object>(t.Item2, t.Item1)))
                     .Where(svc => !scriptManager.IsClientServiceRegistered(svc.Key))
                     .Distinct())
            {
                scriptManager.RegisterClientService(svc.Key, svc.Value);
            }
        }