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


C# ICommandContext.RegisterInputDependency方法代码示例

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


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

示例1: DoCommandOverride

        protected override async Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
        {
            var assetManager = new AssetManager();
            DataContainer result = null;

            switch (Source.Type)
            {
                case UrlType.File:
                    using (var fileStream = new FileStream(Source.Path, FileMode.Open, FileAccess.Read))
                    {
                        if (!WaitDelay())
                            return ResultStatus.Cancelled;

                        result = DataContainer.Load(fileStream);
                    }
                    break;
                case UrlType.ContentLink:
                case UrlType.Content:
                    var container = assetManager.Load<DataContainer>(Source.Path);

                        if (!WaitDelay())
                            return ResultStatus.Cancelled;

                     result = container.Alterate();
                  break;
            }

            assetManager.Save(OutputUrl, result);

            var tasksToWait = CommandsToSpawn.Select(commandContext.ScheduleAndExecuteCommand);
            await Task.WhenAll(tasksToWait);

            foreach (ObjectUrl inputDep in InputDependencies)
            {
                commandContext.RegisterInputDependency(inputDep);
            }
            return ResultStatus.Successful;
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:38,代码来源:InputOutputCommand.cs

示例2: DoCommandOverride

        protected override Task<ResultStatus> DoCommandOverride(ICommandContext commandContext)
        {
            var compiler = GetOrCreateEffectCompiler(context);

            // Get main effect name (before the first dot)
            var isPdxfx = ShaderMixinManager.Contains(effectName);
            var source = isPdxfx ? new ShaderMixinGeneratorSource(effectName) : (ShaderSource)new ShaderClassSource(effectName);

            int permutationCount;
            lock (PermutationCount)
            {
                PermutationCount.TryGetValue(effectName, out permutationCount);
                permutationCount++;
                PermutationCount[effectName] = permutationCount;
            }
            commandContext.Logger.Info("Trying permutation #{0} for effect [{1}]: \n{2}", permutationCount, effectName, compilerParameters.ToStringDetailed());

            var compilerResults = compiler.Compile(source, compilerParameters);

            // Copy logs and if there are errors, exit directlry
            compilerResults.CopyTo(commandContext.Logger);
            if (compilerResults.HasErrors)
            {
                return Task.FromResult(ResultStatus.Failed);
            }

            // Register all dependencies
            var allSources = new HashSet<string>(compilerResults.Bytecode.WaitForResult().Bytecode.HashSources.Select(keyPair => keyPair.Key));
            foreach (var className in allSources)
            {
                commandContext.RegisterInputDependency(new ObjectUrl(UrlType.Internal, EffectCompilerBase.GetStoragePathFromShaderType(className)));
            }

            // Generate sourcecode if configured
            if (compilerParameters.ContainsKey(EffectSourceCodeKeys.Enable))
            {
                var outputDirectory = UPath.Combine(context.Package.RootDirectory, baseUrl);
                var outputClassFile = effectName + ".bytecode." + compilerParameters.Platform + "." + compilerParameters.Profile + ".cs";
                var fullOutputClassFile = Path.Combine(outputDirectory.ToWindowsPath(), outputClassFile);

                commandContext.Logger.Info("Writing shader bytecode to .cs source [{0}]", fullOutputClassFile);
                using (var stream = new FileStream(fullOutputClassFile, FileMode.Create, FileAccess.Write, FileShare.Write))
                    EffectByteCodeToSourceCodeWriter.Write(effectName, compilerParameters, compilerResults.Bytecode.WaitForResult().Bytecode, new StreamWriter(stream, System.Text.Encoding.UTF8));
            }

            return Task.FromResult(ResultStatus.Successful);
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:47,代码来源:EffectCompileCommand.cs


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