コード例 #1
0
ファイル: App.xaml.cs プロジェクト: mauroservienti/Jason
        static void SetupJasonClient()
        {
            var reader = XmlReader.Create(Application.GetResourceStream(new Uri("AppManifest.xaml", UriKind.Relative)).Stream);
            var parts  = new AssemblyPartCollection();

            if (reader.Read())
            {
                reader.ReadStartElement();

                if (reader.ReadToNextSibling("Deployment.Parts"))
                {
                    while (reader.ReadToFollowing("AssemblyPart"))
                    {
                        parts.Add(new AssemblyPart()
                        {
                            Source = reader.GetAttribute("Source")
                        });
                    }
                }
            }

            foreach (var part in parts)
            {
                if (part.Source.ToLower().EndsWith(".dll"))
                {
                    var stream   = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative)).Stream;
                    var assembly = part.Load(stream);
                    var allTypes = assembly.GetTypes();

                    allTypes.Where(t => !t.IsGenericType && t.IsAttributeDefined <ServiceKnownTypeAttribute>(true))
                    .ForEach(t => ServiceKnownTypesProvider.RegisterKnownType(t));
                }
            }
        }
コード例 #2
0
        public void Initialize(IJasonServerConfiguration configuration, IEnumerable <Type> types)
        {
            configuration.Container.RegisterAsTransient(new[] { typeof(IWorkerService) }, this.WorkerServiceType);

            types.Where(t =>
            {
                return((!t.IsGenericType && t.IsAttributeDefined <Jason.Configuration.ServiceKnownTypeAttribute>(true)) ||
                       this.CommandsSelector(t));
            })
            .ForEach(t => ServiceKnownTypesProvider.RegisterKnownType(t));

            if (this.EnableSelfHosting)
            {
                this.host = new BasicDependencyInjectionServiceHost(configuration.Container, this.WorkerServiceType);
                this.host.Open();
            }
        }
コード例 #3
0
        public async Task Initialize()
        {
            var assemblies = await this.GetCompositionAssemblies();

            foreach (var dll in assemblies)
            {
                dll.ExportedTypes
                .Select(t => t.GetTypeInfo())
                .Where(t =>
                {
                    return((!t.IsGenericType && t.GetCustomAttribute <ServiceKnownTypeAttribute>(true) != null) ||
                           this.CommandsSelector(t));
                })
                .ForEach(t => ServiceKnownTypesProvider.RegisterKnownType(t.AsType()));
            }

            this.clientFactory.QueueChannelFactoryReset();
        }
コード例 #4
0
        public Task Initialize()
        {
            return(Task.Factory.StartNew(() =>
            {
                Directory.EnumerateFiles(this.path, "*.dll")
                .ForEach(dll =>
                {
                    var name = Path.GetFileNameWithoutExtension(dll);
                    if (this.AssemblySelector(name))
                    {
                        var allTypes = Assembly.Load(name).GetTypes();

                        allTypes.Where(t =>
                        {
                            return (!t.IsGenericType && t.IsAttributeDefined <ServiceKnownTypeAttribute>(true)) ||
                            this.CommandsSelector(t);
                        })
                        .ForEach(t => ServiceKnownTypesProvider.RegisterKnownType(t));
                    }
                });

                this.clientFactory.QueueChannelFactoryReset();
            }));
        }