当前位置: 首页>>代码示例>>C#>>正文


C# ServiceContainer.AddService方法代码示例

本文整理汇总了C#中ServiceContainer.AddService方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer.AddService方法的具体用法?C# ServiceContainer.AddService怎么用?C# ServiceContainer.AddService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceContainer的用法示例。


在下文中一共展示了ServiceContainer.AddService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateServiceContainer

 public virtual IServiceContainer CreateServiceContainer(Type dataServiceType, IPrincipal principal) 
 { 
     var serviceContainer = new ServiceContainer();
     var authorizer = new AuthorizerClass(dataServiceType, principal);
     serviceContainer.AddService(typeof(IAuthorizer), authorizer);
     var valueConverter = new ValueConverter(serviceContainer);
     serviceContainer.AddService(typeof(IValueConverter), valueConverter);
     var dataHelper =  new DataHelper(serviceContainer);
     serviceContainer.AddService(typeof(IDataHelper), dataHelper);
     var validationHelper = new ValidationHelper(serviceContainer);
     serviceContainer.AddService(typeof(IValidationHelper), validationHelper);
     var queryHelper = new QueryHelper(serviceContainer);
     serviceContainer.AddService(typeof(IQueryHelper), queryHelper);
     return serviceContainer;
 }
开发者ID:cbsistem,项目名称:JRIAppTS,代码行数:15,代码来源:ServiceContainerFactory.cs

示例2: Project

        public Project()
        {
            Uid = Guid.NewGuid();
            _services = new ServiceContainer();

            Name = "Project";

            _levels = new NamedResourceCollection<Level>();
            _levels.Modified += (s, e) => OnModified(EventArgs.Empty);

            _libraryManager = new LibraryManager();
            _libraryManager.Libraries.Modified += (s, e) => OnModified(EventArgs.Empty);

            Library defaultLibrary = new Library();

            _libraryManager.Libraries.Add(defaultLibrary);

            Extra = new List<XmlElement>();

            _texturePool = new MetaTexturePool();
            _texturePool.AddPool(defaultLibrary.Uid, defaultLibrary.TexturePool);

            _tilePools = new MetaTilePoolManager(_texturePool);
            _tilePools.AddManager(defaultLibrary.Uid, defaultLibrary.TilePoolManager);
            _objectPools = new MetaObjectPoolManager(_texturePool);
            _objectPools.AddManager(defaultLibrary.Uid, defaultLibrary.ObjectPoolManager);
            _tileBrushes = new MetaTileBrushManager();
            _tileBrushes.AddManager(defaultLibrary.Uid, defaultLibrary.TileBrushManager);

            SetDefaultLibrary(defaultLibrary);

            _services.AddService(typeof(TilePoolManager), _tilePools);

            ResetModified();
        }
开发者ID:jaquadro,项目名称:Treefrog,代码行数:35,代码来源:Project.cs

示例3: MoveCreatorForm

        public MoveCreatorForm()
        {
            //set up defaults
            this.movelist = new Dictionary<String, Move>();
            this.directoryHome = "../../../HeroesOfRock";
            this.FormClosing += ContentList_FormClosing; ;
            this.appClose = true;

            //set up content manager
            GraphicsDeviceService gds = GraphicsDeviceService.AddRef(this.Handle,
                     this.ClientSize.Width, this.ClientSize.Height);
            ServiceContainer services = new ServiceContainer();
            services.AddService<IGraphicsDeviceService>(gds);
            this.content = new ContentManager(services, String.Concat(directoryHome, "/HeroesOfRock/bin/x86/Debug/Content"));

            //Load and/or parse predefined objects
            LoadMoveList(content.Load<Move[]>("Movelist"));
            this.audioClips = Directory.GetFiles(String.Concat(content.RootDirectory, "/Audio")).ToList<string>();
            this.particleFX = Directory.GetFiles(String.Concat(content.RootDirectory, "/ParticleFX")).ToList<string>();
            //if null, will back up to the content default
            BackUpMoveList(null);
            InitializeComponent();

            RefreshList();
        }
开发者ID:scotttorgeson,项目名称:HeroesOfRock,代码行数:25,代码来源:ContentList.cs

示例4: Workspace

        public Workspace()
        {
            Services = new ServiceContainer();
            Services.AddService<IIconReaderService>(new IconReaderService());
            buildLogger = new BuildLogger(Tracer.TraceSource);

            LoadPlugins();

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:10,代码来源:Workspace.cs

示例5: GenerateBabylonFile

        public void GenerateBabylonFile(string file, string outputFile, bool skinned, bool rightToLeft)
        {
            if (OnImportProgressChanged != null)
                OnImportProgressChanged(0);


            var scene = new BabylonScene(Path.GetDirectoryName(outputFile));

            var services = new ServiceContainer();

            // Create a graphics device
            var form = new Form();
            
            services.AddService<IGraphicsDeviceService>(GraphicsDeviceService.AddRef(form.Handle, 1, 1));

            var contentBuilder = new ContentBuilder(ExtraPipelineAssemblies);
            var contentManager = new ContentManager(services, contentBuilder.OutputDirectory);

            // Tell the ContentBuilder what to build.
            contentBuilder.Clear();
            contentBuilder.Add(Path.GetFullPath(file), "Model", Importer, skinned ? "SkinnedModelProcessor" : "ModelProcessor");

            // Build this new model data.
            string buildError = contentBuilder.Build();

            if (string.IsNullOrEmpty(buildError))
            {
                var model = contentManager.Load<Model>("Model");
                ParseModel(model, scene, rightToLeft);
            }
            else
            {
                throw new Exception(buildError);
            }

            // Output
            scene.Prepare();
            using (var outputStream = new FileStream(outputFile, FileMode.Create, FileAccess.Write))
            {
                var ser = new DataContractJsonSerializer(typeof(BabylonScene));
                ser.WriteObject(outputStream, scene);
            }

            // Cleaning
            foreach (var path in exportedTexturesFilename.Values)
            {
                File.Delete(path);
            }

            if (OnImportProgressChanged != null)
                OnImportProgressChanged(100);
        }
开发者ID:har777,项目名称:Babylon.js,代码行数:52,代码来源:XNAExporter.cs

示例6: instance

        public void instance(string[] args)
        {
            try
            {

                Form form = new Form();
                GraphicsDeviceService gds = GraphicsDeviceService.AddRef(form.Handle, form.ClientSize.Width, form.ClientSize.Height);
                ServiceContainer services = new ServiceContainer();
                services.AddService<IGraphicsDeviceService>(gds);
                var content = new ContentManager(services);

                foreach (string p in args)
                {
                    Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + " " + p);
                    if (File.Exists(p))
                    {
                        if (Path.GetExtension(p).Equals(".xnb"))
                        {
                            ConvertToPng(content, p);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid file path or file");
                    }
                }

                foreach (string f in filesToDelete)
                {
                    File.Delete(f);
                }
                content.Unload();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
开发者ID:Silentspy,项目名称:terrariaxnb2png,代码行数:38,代码来源:Program.cs

示例7: AdaptShouldReturnValidationContextAdapter

        public void AdaptShouldReturnValidationContextAdapter()
        {
            // arrange
            var instance = new object();
            var service = new object();
            var serviceProvider = new ServiceContainer();
            var items = new Dictionary<object, object>() { { "Test", "Test" } };
            var expected = new ValidationContext( instance, serviceProvider, items );

            expected.MemberName = "Foo";
            serviceProvider.AddService( typeof( object ), service );

            // act
            var actual = expected.Adapt();

            // assert
            Assert.Equal( expected.DisplayName, actual.DisplayName );
            Assert.Same( expected.Items["Test"], actual.Items["Test"] );
            Assert.Equal( expected.MemberName, actual.MemberName );
            Assert.Same( expected.ObjectInstance, actual.ObjectInstance );
            Assert.Equal( expected.ObjectType, actual.ObjectType );
            Assert.Same( expected.GetService( typeof( object ) ), actual.GetService( typeof( object ) ) );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:23,代码来源:ValidationAdapterExtensionsTest.cs

示例8: ValidatableObjectTest

 public ValidatableObjectTest()
 {
     var container = new ServiceContainer();
     container.AddService( typeof( IValidator ), new ValidatorAdapter() );
     ServiceProvider.SetCurrent( container );
 }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:6,代码来源:ValidatableObjectTest.cs

示例9: loadContent

        /// <summary>
        /// Invoked after either control has created its graphics device.
        /// </summary>
        private void loadContent(object sender, GraphicsDeviceEventArgs e)
        {
            // Because this same event is hooked for both controls, we check if the Stopwatch
            // is running to avoid loading our content twice.
            if (!totalTime.IsRunning)
            {

                ServiceContainer = new ServiceContainer();
                contentBuilder = new ContentBuilder();
                ResourceBuilder.Instance.ContentBuilder = contentBuilder;

                resourceContent.Activate();

                errors = new List<Error>();
                outputTextBlock = output;
                EditorStatus = EditorStatus.STARTING;
                EditMode = AridiaEditor.EditMode.STANDARD;
                errorDataGrid.ItemsSource = errors;
                Output.AddToOutput("WELCOME TO ARIDIA WORLD EDITOR ------------");

                GameApplication.Instance.SetGraphicsDevice(e.GraphicsDevice);
                MouseDevice.Instance.ResetMouseAfterUpdate = false;
                ServiceContainer.AddService<IGraphicsDeviceService>(GraphicsDeviceService.AddRef(new IntPtr(), 100, 100));
                ResourceManager.Instance.Content = new ContentManager(ServiceContainer, contentBuilder.OutputDirectory);
                ResourceManager.Instance.Content.Unload();

                sceneGraph = new SceneGraphManager();
                sceneGraph.CullingActive = true;
                sceneGraph.LightingActive = false; //deactivate lighting on beginning!

                spriteBatch = new SpriteBatch(e.GraphicsDevice);
                grid = new GridComponent(e.GraphicsDevice, 2);

                e.GraphicsDevice.RasterizerState = RasterizerState.CullNone;

                var versionAttribute = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

                AssemblyBuild.Content = "Build: (Alpha) " + versionAttribute;
                if (File.Exists(Settings.Default.LayoutFile))
                    dockManager.RestoreLayout(Settings.Default.LayoutFile);

                // after we initialized everything we need start loading the content
                // in a new thread!
                StartContentBuilding();

                // Start the watch now that we're going to be starting our draw loop
                totalTime.Start();
            }
        }
开发者ID:gbarnes12,项目名称:atlantis-xna,代码行数:52,代码来源:MainWindow.xaml.cs

示例10: OnCreateControl

        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void OnCreateControl()
        {
            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                Services = new ServiceContainer();

                graphicsDeviceService = GraphicsDeviceService.AddRef(profile, Handle, ClientSize.Width, ClientSize.Height);

                // Register the service, so components like ContentManager can find it.
                Services.AddService<IGraphicsDeviceService>(graphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize();
            }

            base.OnCreateControl();
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:21,代码来源:GraphicsDeviceControl.cs

示例11: TestInitialize

 public void TestInitialize()
 {
     cmdService = new MockUIComandService();
     services = new ServiceContainer();
     services.AddService(typeof(IUICommandService), cmdService);
 }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:6,代码来源:SqlConfigurationSourceRegistrarFixture.cs

示例12: CreateServiceProvider

        IServiceProvider CreateServiceProvider()
        {
            var container = new ServiceContainer(this.Application.RootServiceProvider);

            container.AddService(typeof(ToolsUIWindow), this);
            this.documentTracker = new WindowDocumentTracker(this, this.Application.RootServiceProvider);
            container.AddService(typeof(IActiveDocumentTracker), this.documentTracker);
            return container;
        }
开发者ID:UnaNancyOwen,项目名称:Kinect-Studio-Sample,代码行数:9,代码来源:ToolsUIWindow.cs

示例13: OnCreateControl

        protected override void OnCreateControl()
        {
            if(!DesignMode) {
                services = new ServiceContainer();
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle, Width, Height);
                services.AddService<IGraphicsDeviceService>(graphicsDeviceService); // Register the service, so components like ContentManager can find it.
                spriteBatch = new SpriteBatch(GraphicsDevice);
                content = new ContentManager(services, "Content");
                viewport = new Viewport();
                surfaceRectangle = new XNARectangle(0, 0, Width, Height);
                canUpdate = true;

                Initialize();
            }
            base.OnCreateControl();
        }
开发者ID:adamxi,项目名称:SharpDXFramework,代码行数:16,代码来源:GraphicsDeviceControl.cs

示例14: Build

        public ServiceContainer Build()
        {
            ServiceContainer container = new ServiceContainer();
            NodeNameCreationService nodeNameCreationService = new NodeNameCreationService();
            ConfigurationUIHierarchyService configurationUIHierarchy = new ConfigurationUIHierarchyService();

            container.AddService(typeof(INodeNameCreationService), nodeNameCreationService);
            container.AddService(typeof(IConfigurationUIHierarchyService), configurationUIHierarchy);
            container.AddService(typeof(IUIService), this);
            container.AddService(typeof(IErrorLogService), new ErrorLogService());
            container.AddService(typeof(INodeCreationService), new NodeCreationService());
            container.AddService(typeof(IUICommandService), new UICommandService(configurationUIHierarchy));
            return container;
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:14,代码来源:MainForm.cs

示例15: SetSLForm

 /// <summary>
 /// Set SLForm State
 /// </summary>
 /// <param name="isshowcursor"></param>
 /// <param name="isborder"></param>
 /// <param name="issizable"></param>
 public void SetSLForm(bool isshowcursor, bool isborder, bool issizable)
 {
     if (config == null)
     {
         config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     }
     if (services == null)
     {
         services = new ServiceContainer();
         // Register the service, so components like ContentManager can find it.
         services.AddService<IGraphicsDeviceService>(this);
         cm = new ContentManager(services, config["content"]);
         // Hook the idle event to constantly redraw, getting a game style loop as default.
         Application.Idle += delegate { Invalidate(); };
         this.KeyDown += new KeyEventHandler(SLForm_KeyDown);
         this.MouseDown += new MouseEventHandler(SLForm_MouseDown);
         this.MouseMove += new MouseEventHandler(SLForm_MouseMove);
         this.MouseWheel += new MouseEventHandler(SLForm_MouseWheel);
     }
     // Cursor State
     if (!isshowcursor)
     {
         Cursor.Hide();
     }
     // Border and Sizable States
     if (isborder)
     {
         if (issizable)
         {
             this.Resize += new EventHandler(SLForm_Resize);
         }
         else
         {
             this.MaximizeBox = false;
             this.FormBorderStyle = FormBorderStyle.FixedSingle;
         }
     }
     else
     {
         this.FormBorderStyle = FormBorderStyle.None;
     }
 }
开发者ID:babaq,项目名称:StiLib,代码行数:48,代码来源:SLForm.cs


注:本文中的ServiceContainer.AddService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。