Inheritance: MonoBehaviour
コード例 #1
0
        public void CanInterceptProperties()
        {
            CallCountHandler getHandler = new CallCountHandler();
            CallCountHandler setHandler = new CallCountHandler();

            VirtualMethodInterceptor interceptor = new VirtualMethodInterceptor();
            Assert.IsTrue(interceptor.CanIntercept(typeof(OverrideableProperies)));

            Type proxyType = interceptor.CreateProxyType(typeof(OverrideableProperies));
            OverrideableProperies instance = (OverrideableProperies)Activator.CreateInstance(proxyType);

            PipelineManager manager = new PipelineManager();
            ((IInterceptingProxy)instance).AddInterceptionBehavior(new PolicyInjectionBehavior(manager));
            SetPipeline(manager, instance, "get_IntProperty", getHandler);
            SetPipeline(manager, instance, "set_IntProperty", setHandler);

            instance.IntProperty = 12;
            instance.IntProperty = 15;

            int total = 0;
            for (int i = 0; i < 5; ++i)
            {
                total += instance.IntProperty;
            }

            Assert.AreEqual(5 * 15, total);

            Assert.AreEqual(5, getHandler.CallCount);
            Assert.AreEqual(2, setHandler.CallCount);
        }
コード例 #2
0
        public void shouldBuildSimplePipeline()
        {
            var testee = new PipelineManager();
            var results = testee.BuildPipeline(this.scheme, new TestSubject());

            for (var index = 0; index < results.Count; index++)
            {
                Assert.IsTrue(results[index].Outcome == StepBuildResults.Completed, results.PrintContentsToString('\n'));
            }
        }
コード例 #3
0
        public void shouldReturnAllMethodsFromScheme()
        {
            var testee = new PipelineManager(this.scheme);

            var expected = this.scheme.SelectMany(lom => lom.Select(m => m));

            var actual = testee.GetMetadataForMissingSteps();

            Assert.IsTrue(expected.SequenceEqual(actual), TestingHelpers.DumpTestSequencesToText(expected, actual));
        }
コード例 #4
0
        public void shouldInsertPipelineStepDirectly()
        {
            var obj = new TestSubject();
            var insertionScheme = new PipelineScheme(new[] { new StepMetadata("Bar", typeof(TestSubject), typeof(int), typeof(bool), "(0,0)") });

            var insertionTestee = new PipelineManager(insertionScheme);

            var result = insertionTestee.InsertPipelineStep<int, bool>(obj.Bar);

            Assert.IsTrue(result.Outcome == StepBuildResults.Completed);
        }
コード例 #5
0
        public async Task shouldCancelDuringBuild()
        {
            var cancellationTestee = new PipelineManager();
            var canceller = new System.Threading.CancellationTokenSource();
            var progressReporter = new PipelineProgress(canceller.Cancel, 50, false);

            var result = await cancellationTestee.BuildPipelineAsync(this.scheme, canceller.Token, progressReporter, new TestSubject());

            var refinedResults = result.Select(r => r.Outcome).ToArray();

            Assert.IsTrue(refinedResults.Contains(StepBuildResults.Cancelled) && refinedResults.Contains(StepBuildResults.Completed), "Token may have expirec before the build took place.\nResults are:\n" + refinedResults.PrintContentsToString(Environment.NewLine));
        }
コード例 #6
0
        public void CanInterceptMethods()
        {
            CallCountHandler h1 = new CallCountHandler();
            VirtualMethodInterceptor interceptor = new VirtualMethodInterceptor();
            Type proxyType = interceptor.CreateProxyType(typeof(TwoOverrideableMethods));

            TwoOverrideableMethods instance =
                (TwoOverrideableMethods)Activator.CreateInstance(proxyType);
            PipelineManager manager = new PipelineManager();
            ((IInterceptingProxy)instance).AddInterceptionBehavior(new PolicyInjectionBehavior(manager));
            SetPipeline(manager, instance, "DoSomething", h1);

            instance.DoSomething();

            Assert.IsTrue(instance.DidSomething);
            Assert.AreEqual(1, h1.CallCount);
        }
コード例 #7
0
        SignatureTestTarget GetTarget()
        {
            TransparentProxyInterceptor interceptor = new TransparentProxyInterceptor();
            PolicySet policySet = GetPolicies();
            SignatureTestTarget target = new SignatureTestTarget();
            IInterceptingProxy proxy = interceptor.CreateProxy(typeof(SignatureTestTarget), target);

            PipelineManager manager = new PipelineManager();
            foreach (MethodImplementationInfo method in interceptor.GetInterceptableMethods(typeof(SignatureTestTarget), typeof(SignatureTestTarget)))
            {
                HandlerPipeline pipeline = new HandlerPipeline(
                    policySet.GetHandlersFor(method, container));
                manager.SetPipeline(method.ImplementationMethodInfo, pipeline);
            }
            proxy.AddInterceptionBehavior(new PolicyInjectionBehavior(manager));

            return (SignatureTestTarget)proxy;
        }
コード例 #8
0
        public void OnClick(Window mainWindow, Instance instance)
        {
            if (instance != null)
            {
                var paths = instance.GetVisualStudioSolutionFiles().ToArray();
                if (paths.Length == 1)
                {
                    WindowHelper.OpenFile(paths.First());
                }
                else if (paths.Length == 0)
                {
                    var          version           = instance.Product.Version.SubstringEx(0, 3);
                    const string noThanks          = "No, thanks";
                    const string yesAspNetWebforms = "Yes, ASP.NET WebForms";
                    const string yesAspNetMvc      = "Yes, ASP.NET MVC";

                    var packageName = "Visual Studio " + AppSettings.AppToolsVisualStudioVersion.Value + " Website Project.zip";

                    var is66     = version == "6.6";
                    var is70     = version == "7.0";
                    var is7x     = version[0] == '7';
                    var is71plus = is7x && !is70;
                    var is8      = version[0] == '8';
                    if (is66 || is7x || is8)
                    {
                        var options = is71plus ? new[]
                        {
                            noThanks, yesAspNetMvc
                        } : new[]
                        {
                            noThanks, yesAspNetWebforms, yesAspNetMvc
                        };
                        var result = WindowHelper.AskForSelection("Choose Visual Studio Project Type", null,
                                                                  "There isn't any Visual Studio project in the instance's folder. \n\nWould you like us to create a new one?",
                                                                  options, mainWindow);
                        if (result == null || result == noThanks)
                        {
                            return;
                        }

                        if (result == yesAspNetMvc)
                        {
                            if (!this.EnsureMvcEnabled(mainWindow, instance, version))
                            {
                                return;
                            }

                            packageName = "Visual Studio " + AppSettings.AppToolsVisualStudioVersion.Value + " MVC" + (is71plus ? " 4" : string.Empty) + " Website Project.zip";
                        }
                    }

                    Product product = GetProduct(packageName);

                    if (product == null)
                    {
                        WindowHelper.HandleError("The " + packageName + " package cannot be found in either the .\\Packages folder", false, null, this);
                        return;
                    }

                    PipelineManager.StartPipeline("installmodules", new InstallModulesArgs(instance, new[]
                    {
                        product
                    }), isAsync: false);
                    var path = instance.GetVisualStudioSolutionFiles().FirstOrDefault();
                    Assert.IsTrue(!string.IsNullOrEmpty(path) && FileSystem.FileSystem.Local.File.Exists(path), "The Visual Studio files are missing");
                    WindowHelper.OpenFile(path);
                }
                else
                {
                    var rootPath     = instance.RootPath.ToLowerInvariant();
                    var virtualPaths = paths.Select(file => file.ToLowerInvariant().Replace(rootPath, string.Empty).TrimStart('\\'));
                    var path         = WindowHelper.AskForSelection("Open Visual Studio", null, "Select the project you need", virtualPaths, mainWindow, paths.First());
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }

                    WindowHelper.OpenFile(Path.Combine(rootPath, path));
                }
            }
        }
コード例 #9
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <summary>
        /// Builds the specified source file.
        /// </summary>
        /// <param name="sourceFile">
        /// The absolute path of the source file. The file format must be a supported 3D model file
        /// format.
        /// </param>
        /// <param name="importerName">The name of the content importer.</param>
        /// <param name="processorName">The name of the content processor.</param>
        /// <param name="processorParameters">The processor parameters.</param>
        /// <param name="errorMessage">The error message in case of failure.</param>
        /// <returns>
        /// <see langword="true"/> if the asset was successfully processed. <see langword="false"/>
        /// if an error has occurred, in which case the output window should contain useful
        /// information.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="sourceFile"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="sourceFile"/> is empty or is not an absolute (rooted) path.
        /// </exception>
        public bool Build(string sourceFile, string importerName, string processorName, OpaqueDataDictionary processorParameters, out string errorMessage)
        {
            if (sourceFile == null)
            {
                throw new ArgumentNullException(nameof(sourceFile));
            }
            if (sourceFile.Length == 0)
            {
                throw new ArgumentException("Source file path must not be empty.", nameof(sourceFile));
            }
            if (!Path.IsPathRooted(sourceFile))
            {
                throw new ArgumentException("Source file path must be an absolute (rooted) path.", nameof(sourceFile));
            }

            string executableFolder = ExecutableFolder;

            string outputFolder = OutputFolder;

            if (!Path.IsPathRooted(outputFolder))
            {
                outputFolder = Path.GetFullPath(Path.Combine(executableFolder, outputFolder));
            }

            string intermediateFolder = IntermediateFolder;

            if (!Path.IsPathRooted(intermediateFolder))
            {
                intermediateFolder = PathHelper.Normalize(Path.GetFullPath(Path.Combine(executableFolder, intermediateFolder)));
            }

            // No assets should lie outside the working folder because then some XNB are built
            // into parent folders.
            string workingFolder = Path.GetPathRoot(sourceFile);

            Directory.SetCurrentDirectory(workingFolder);

            var manager = new PipelineManager(workingFolder, outputFolder, intermediateFolder)
            {
                Logger            = _logger,
                RethrowExceptions = false,
                CompressContent   = false,
                Profile           = GraphicsProfile.HiDef,
                Platform          = TargetPlatform.Windows
            };

            // Add references to content pipeline assemblies.
            // All assemblies are expected to lie in the executable folder. Therefore, this project
            // references the content pipeline DLLs, so that they are automatically copied to the
            // executable folder.
            // TODO: Make a public property to allow user to set references.
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Animation.Content.Pipeline.dll")));
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Game.UI.Content.Pipeline.dll")));
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Geometry.Content.Pipeline.dll")));
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Graphics.Content.Pipeline.dll")));
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Mathematics.Content.Pipeline.dll")));

            // Add this assembly because it also contains model processors.
            manager.AddAssembly(Path.GetFullPath(Path.Combine(ExecutableFolder, "DigitalRune.Editor.Game.dll")));

            _logger.LogMessage("----- Begin MonoGame content pipeline -----");

            // Remove any previous build content to force a full rebuild.
            manager.CleanContent(sourceFile);

            try
            {
                manager.BuildContent(sourceFile, null, importerName, processorName, processorParameters);
                errorMessage = null;
                return(true);
            }
            catch (Exception exception)
            {
                _logger.LogMessage("Exception in MonoGame content pipeline:");
                _logger.LogWarning(null, null, exception.Message);
                _logger.LogMessage(exception.StackTrace);
                if (exception.Message.StartsWith("Value cannot be null.", StringComparison.OrdinalIgnoreCase))
                {
                    _logger.LogWarning(null, null, "This can happen if the FBX references a texture but the filename is null. Check the referenced texture file paths in a 3D modeling tool.");
                }

                errorMessage = exception.Message;
                return(false);
            }
            finally
            {
                _logger.LogMessage("----- End MonoGame content pipeline -----");
            }
        }
コード例 #10
0
ファイル: BuildContent.cs プロジェクト: zmyspc/MonoGame
        public void Build(out int successCount, out int errorCount)
        {
            var projectDirectory = Directory.GetCurrentDirectory();
            var outputPath       = Path.GetFullPath(Path.Combine(projectDirectory, OutputDir));
            var intermediatePath = Path.GetFullPath(Path.Combine(projectDirectory, IntermediateDir));

            _manager        = new PipelineManager(projectDirectory, outputPath, intermediatePath);
            _manager.Logger = new ConsoleLogger();

            // Feed all the assembly references to the pipeline manager
            // so it can resolve importers, processors, writers, and types.
            foreach (var r in References)
            {
                var assembly = r;
                if (!Path.IsPathRooted(assembly))
                {
                    assembly = Path.GetFullPath(Path.Combine(projectDirectory, assembly));
                }
                _manager.AddAssembly(assembly);
            }

            // Load the previously serialized list of built content.
            var contentFile     = Path.Combine(intermediatePath, PipelineBuildEvent.Extension);
            var previousContent = SourceFileCollection.Read(contentFile);

            // If the target changed in any way then we need to force
            // a fuull rebuild even under incremental builds.
            var targetChanged = previousContent.Config != Config ||
                                previousContent.Platform != Platform ||
                                previousContent.Profile != Profile;

            // First clean previously built content.
            foreach (var sourceFile in previousContent.SourceFiles)
            {
                var inContent           = _content.Any(e => string.Equals(e.SourceFile, sourceFile, StringComparison.InvariantCultureIgnoreCase));
                var cleanOldContent     = !inContent && !Incremental;
                var cleanRebuiltContent = inContent && (Rebuild || Clean);
                if (cleanRebuiltContent || cleanOldContent || targetChanged)
                {
                    _manager.CleanContent(sourceFile);
                }
            }

            var newContent = new SourceFileCollection
            {
                Profile  = _manager.Profile = Profile,
                Platform = _manager.Platform = Platform,
                Config   = _manager.Config = Config
            };

            errorCount   = 0;
            successCount = 0;

            foreach (var c in _content)
            {
                try
                {
                    _manager.BuildContent(c.SourceFile,
                                          null,
                                          c.Importer,
                                          c.Processor,
                                          c.ProcessorParams);

                    newContent.SourceFiles.Add(c.SourceFile);

                    ++successCount;
                }
                catch (PipelineException ex)
                {
                    Console.Error.WriteLine("{0}: error: {1}", c.SourceFile, ex.Message);
                    if (ex.InnerException != null)
                    {
                        Console.Error.Write(ex.InnerException.ToString());
                    }
                    ++errorCount;
                }
            }

            // If this is an incremental build we merge the list
            // of previous content with the new list.
            if (Incremental && !targetChanged)
            {
                newContent.Merge(previousContent);
            }

            // Delete the old file and write the new content
            // list if we have any to serialize.
            FileHelper.DeleteIfExists(contentFile);
            if (newContent.SourceFiles.Count > 0)
            {
                newContent.Write(contentFile);
            }
        }
コード例 #11
0
        protected override BuildResult Compile(MonoDevelop.Core.IProgressMonitor monitor, SolutionEntityItem item, BuildData buildData)
        {
#if DEBUG
            monitor.Log.WriteLine("MonoGame Extension Compile Called");
#endif
            try
            {
                var cfg  = buildData.Configuration as MonoGameContentProjectConfiguration;
                var proj = item as MonoGameContentProject;
                if (proj == null || cfg == null)
                {
                    monitor.Log.WriteLine("Compiling for Unknown MonoGame Project");
                    return(base.Compile(monitor, item, buildData));
                }
                monitor.Log.WriteLine("Detected {0} MonoGame Platform", cfg.MonoGamePlatform);
                var result  = new BuildResult();
                var manager = new PipelineManager(proj.BaseDirectory.FullPath,
                                                  Path.Combine(buildData.Configuration.OutputDirectory, cfg.MonoGamePlatform),
                                                  buildData.Configuration.IntermediateOutputDirectory);

                manager.Logger   = new MonitorBuilder(monitor, result);
                manager.Platform = (TargetPlatform)Enum.Parse(typeof(TargetPlatform), cfg.MonoGamePlatform);
                try {
                    foreach (var pr in proj.ParentSolution.GetAllProjects())
                    {
                        if (pr is DotNetAssemblyProject)
                        {
                            var dot = pr as DotNetAssemblyProject;
                            foreach (var r in dot.References)
                            {
                                if (r.Package.Name == "monogame-contentpipeline")
                                {
                                    var output = dot.GetOutputFileName(buildData.ConfigurationSelector).FullPath;
                                    monitor.Log.WriteLine("Adding {0} to Content Pipeline Assembly List", output);
                                    manager.AddAssembly(output);
                                    proj.Manager.AddAssembly(output);
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    result.AddWarning(string.Format("Problem processing Content Extensions {0}", ex.Message));
                }

                var dict = new Microsoft.Xna.Framework.Content.Pipeline.OpaqueDataDictionary();
                if (cfg != null)
                {
                    if (cfg.XnaCompressContent.ToLower() == "true")
                    {
                        // tell the manager to compress the output
                    }
                }
                foreach (var file in proj.Files)
                {
                    if (file.BuildAction == "Compile")
                    {
                        try
                        {
                            dict.Clear();
                            foreach (object key in file.ExtendedProperties.Keys)
                            {
                                string k = key as string;
                                if (k != null && k.StartsWith("ProcessorParameters_"))
                                {
                                    if (!dict.ContainsKey(k.Replace("ProcessorParameters_", String.Empty)))
                                    {
                                        dict.Add(k.Replace("ProcessorParameters_", String.Empty), file.ExtendedProperties[k]);
                                    }
                                    else
                                    {
                                        dict[k.Replace("ProcessorParameters_", String.Empty)] = file.ExtendedProperties[k];
                                    }
                                }
                            }

                            // check if the file has changed and rebuild if required.
                            manager.BuildContent(file.FilePath.FullPath,
                                                 null,
                                                 file.ExtendedProperties.Contains("Importer") ? (string)file.ExtendedProperties["Importer"] : null,
                                                 file.ExtendedProperties.Contains("Processor") ? (string)file.ExtendedProperties["Processor"] : null,
                                                 dict);
                        }
                        catch (Exception ex)
                        {
                            monitor.Log.WriteLine(ex.ToString());
                            result.AddError(ex.Message);
                        }
                    }
                }
                return(result);
            }
            finally
            {
#if DEBUG
                monitor.Log.WriteLine("MonoGame Extension Compile Ended");
#endif
            }
        }
コード例 #12
0
        public async Task shouldShowWhereBuildWasCancelled()
        {
            // Similar to "shouldCancelDuringBuild", but this time check to be sure that the build is cancelling at the right spot.
            var cancellationTestee = new PipelineManager();
            var canceller = new System.Threading.CancellationTokenSource();
            var progressReporter = new PipelineProgress(canceller.Cancel, 50, false);
            var expected = new List<StepBuildResults>()
            {
                StepBuildResults.Completed, StepBuildResults.Completed, StepBuildResults.Completed, StepBuildResults.Completed,
                StepBuildResults.Cancelled, StepBuildResults.Cancelled
            };
            
            var result = await cancellationTestee.BuildPipelineAsync(this.scheme, canceller.Token, progressReporter, new TestSubject());

            var actual = result.Select(r => r.Outcome).ToArray();

            Assert.IsTrue(expected.SequenceEqual(actual), TestingHelpers.DumpTestSequencesToText(expected, actual));
        }
コード例 #13
0
        public async Task CompileAsync(IAssetFsFile assetFile, IAssetDependencies assetDependencies, TargetPlatform platform, IWritableSerializedAsset output)
        {
            var tempPath = System.IO.Path.GetTempFileName();

            try
            {
                using (var stream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    using (var sourceStream = await assetFile.GetContentStream().ConfigureAwait(false))
                    {
                        await sourceStream.CopyToAsync(stream).ConfigureAwait(false);
                    }
                }

                var importer       = new TextureImporter();
                var monogameOutput = importer.Import(tempPath, new DummyContentImporterContext());

                var originalWidth  = monogameOutput.Faces[0][0].Width;
                var originalHeight = monogameOutput.Faces[0][0].Height;

                var nameComponents = assetFile.Name.Split('.');
                nameComponents[nameComponents.Length - 1] = "_FolderOptions";
                var folderOptionsFile = await assetDependencies.GetOptionalCompileTimeFileDependency(string.Join(".", nameComponents)).ConfigureAwait(false);

                string[] importFolderOptions = null;
                if (folderOptionsFile != null)
                {
                    using (var optionsReader = new StreamReader(await folderOptionsFile.GetContentStream().ConfigureAwait(false)))
                    {
                        importFolderOptions = optionsReader.ReadToEnd()
                                              .Trim()
                                              .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                                              .Select(x => x.Trim())
                                              .Where(x => !x.StartsWith("#"))
                                              .ToArray();
                    }
                }

                var optionsFile = await assetDependencies.GetOptionalCompileTimeFileDependency(assetFile.Name + ".Options").ConfigureAwait(false);

                string[] importOptions = null;
                if (optionsFile != null)
                {
                    using (var optionsReader = new StreamReader(await optionsFile.GetContentStream().ConfigureAwait(false)))
                    {
                        importOptions = optionsReader.ReadToEnd()
                                        .Trim()
                                        .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                                        .Select(x => x.Trim())
                                        .Where(x => !x.StartsWith("#"))
                                        .ToArray();
                    }
                }

                if (importOptions == null)
                {
                    importOptions = importFolderOptions;
                }
                if (importOptions == null)
                {
                    importOptions = new string[0];
                }

                var allowResizeToPowerOfTwo = !IsPowerOfTwo((ulong)originalWidth) || !IsPowerOfTwo((ulong)originalHeight);
                var allowMakeSquare         = originalWidth != originalHeight;

                var manager = new PipelineManager(
                    Environment.CurrentDirectory,
                    Environment.CurrentDirectory,
                    Environment.CurrentDirectory);
                TextureContent content = CompileTexture(assetFile, platform, monogameOutput, importOptions, allowResizeToPowerOfTwo, allowMakeSquare, manager);

                Console.WriteLine("Texture " + assetFile.Name + " resized " + originalWidth + "x" + originalHeight + " -> " + content.Faces[0][0].Width + "x" + content.Faces[0][0].Height);

                output.SetLoader <IAssetLoader <TextureAsset> >();
                output.SetPlatform(platform);
                output.SetByteArray("Data", CompileAndGetBytes(content));
                output.SetInt32("OriginalWidth", originalWidth);
                output.SetInt32("OriginalHeight", originalHeight);
            }
            finally
            {
                try
                {
                    File.Delete(tempPath);
                }
                catch
                {
                }
            }
        }
コード例 #14
0
ファイル: Setup.cs プロジェクト: ossyahya60/FN-Engine
 public static void ConfigurePipelineMG(Microsoft.Xna.Framework.Content.Pipeline.TargetPlatform targetPlatform = Microsoft.Xna.Framework.Content.Pipeline.TargetPlatform.DesktopGL)
 {
     PM          = new PipelineManager(SourceFilePath, OutputFilePath, IntermediateFilePath);
     PM.Platform = targetPlatform;
 }
コード例 #15
0
        private void SetPipeline(PipelineManager manager, object instance, string methodName, params ICallHandler[] handlers)
        {
            HandlerPipeline pipeline = new HandlerPipeline(handlers);
            MethodInfo targetMethod = instance.GetType().BaseType.GetMethod(methodName);
            IInterceptingProxy proxy = (IInterceptingProxy)instance;
            manager.SetPipeline(targetMethod, pipeline);

        }
コード例 #16
0
ファイル: AvatarFavMod.cs プロジェクト: Heorenmaru/AvatarFav
        private IEnumerator CheckAndWearAvatar()
        {
            //DebugUtils.PrintHierarchy(pageAvatar.avatar.transform, 0);
            PipelineManager avatarPipelineManager = pageAvatar.avatar.GetComponentInChildren <PipelineManager>();

            if (avatarPipelineManager == null) // Avoid avatars locking for builds <625
            {
                VRCModLogger.Log("[AvatarFav] Current avatar prefab name: " + pageAvatar.avatar.transform.GetChild(0).name);
                if (pageAvatar.avatar.transform.GetChild(0).name == "avatar_loading2(Clone)")
                {
                    VRCUiPopupManagerUtils.ShowPopup("Error", "Please wait for this avatar to finish loading before wearing it", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                }
                else
                {
                    baseChooseEvent.Invoke();
                }
            }
            else
            {
                bool copied = false;

                string avatarBlueprintID = avatarPipelineManager?.blueprintId ?? "";
                if (!avatarBlueprintID.Equals("") && !avatarBlueprintID.Equals(pageAvatar.avatar.apiAvatar.id))
                {
                    copied = true;
                }

                using (WWW avtrRequest = new WWW(API.GetApiUrl() + "avatars/" + (copied ? avatarBlueprintID : pageAvatar.avatar.apiAvatar.id) + "?apiKey=" + GetApiKey()))
                {
                    yield return(avtrRequest);

                    int rc = WebRequestsUtils.GetResponseCode(avtrRequest);
                    if (rc == 200)
                    {
                        try
                        {
                            string uuid = APIUser.CurrentUser?.id ?? "";
                            SerializableApiAvatar aa = JsonConvert.DeserializeObject <SerializableApiAvatar>(avtrRequest.text);
                            if (aa.releaseStatus.Equals("public") || aa.authorId.Equals(uuid))
                            {
                                baseChooseEvent.Invoke();
                            }
                            else
                            {
                                if (copied)
                                {
                                    VRCUiPopupManagerUtils.ShowPopup("Error", "Unable to put this avatar: This avatar is not the original one, and the one is not public anymore (private)", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                                }
                                else
                                {
                                    VRCUiPopupManagerUtils.ShowPopup("Error", "Unable to put this avatar: This avatar is not public anymore (private)", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            VRCModLogger.LogError(e.ToString());
                            VRCUiPopupManagerUtils.ShowPopup("Error", "Unable to put this avatar: Unable to parse API response", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                        }
                    }
                    else
                    {
                        if (copied)
                        {
                            VRCUiPopupManagerUtils.ShowPopup("Error", "Unable to put this avatar: This avatar is not the original one, and the one is not public anymore (deleted)", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                        }
                        else
                        {
                            VRCUiPopupManagerUtils.ShowPopup("Error", "Unable to put this avatar: This avatar is not public anymore (deleted)", "Close", () => VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup());
                        }
                    }
                }
            }
        }
コード例 #17
0
        public void shouldRebuildPipeline()
        {
            // Setup test object and states. (states are represented by the scheme objects)
            var rebuildingTestee = new PipelineManager(this.scheme);
            var nameOfShort = typeof(short).AssemblyQualifiedName;
            var nameOfInt = typeof(int).AssemblyQualifiedName;
            var nameOfTestSubj = typeof(TestSubject).AssemblyQualifiedName;
            var secondConfig =
                "{" + nameOfTestSubj + "; Add3; " + nameOfShort + "; " + nameOfShort + "; (0,2)}\n" +
                "{" + nameOfTestSubj + "; Square; " + nameOfShort + "; " + nameOfInt + "; (0,0)}\n" +
                "{" + nameOfTestSubj + "; Squareroot; " + nameOfInt + "; " + nameOfShort + "; (0,1)}\n" +
                "{" + nameOfTestSubj + "; Subtract3; " + nameOfShort + "; " + nameOfShort + "; (0,5)}\n";

            var secondScheme = PipelineScheme.Parse(secondConfig);
            var buildResults = rebuildingTestee.BuildPipeline(new TestSubject());

            foreach (var entry in buildResults)
            {
                Assert.IsTrue(entry.Outcome == StepBuildResults.Completed, "First build did not succeed\n" + buildResults.PrintContentsToString('\n'));
            }

            buildResults = rebuildingTestee.RebuildPipeline(secondScheme, new TestSubject());

            foreach (var entry in buildResults)
            {
                Assert.IsTrue(entry.Outcome == StepBuildResults.Completed, "Second build did not succeed\n" + buildResults.PrintContentsToString('\n'));
            }
        }
コード例 #18
0
        public override void Init(GraphicalConfiguration config, ID3D12Device *device)
        {
            bool z = new RgbaColor() == new RgbaColor();

            _pipelineManager = new PipelineManager(ComPtr <ID3D12Device> .CopyFromPointer(device));
            _allocator       = new GpuAllocator(ComPtr <ID3D12Device> .CopyFromPointer(device));

            var verticesDesc = new GpuResourceDesc(
                GpuResourceFormat.Buffer((ulong)sizeof(Vertex) * 3),
                GpuMemoryType.CpuWriteOptimized,
                D3D12_RESOURCE_STATE_GENERIC_READ,
                GpuAllocFlags.ForceAllocateComitted
                );

            //var triangleVertices = stackalloc Vertex[3] {
            //    new Vertex
            //    {
            //        Position = new Vector3(0.0f, 0.25f, 0.0f),
            //        Color = new Vector4(1.0f, 0.0f, 0.0f, 1.0f)
            //    },
            //    new Vertex
            //    {
            //        Position = new Vector3(0.25f, -0.25f, 0.0f),
            //        Color = new Vector4(0.0f, 1.0f, 0.0f, 1.0f)
            //    },
            //    new Vertex
            //    {
            //        Position = new Vector3(-0.25f, -0.25f, 0.0f),
            //        Color = new Vector4(0.0f, 0.0f, 1.0f, 1.0f)
            //    },
            //};

            var cubeVertices = stackalloc Vertex[8]
            {
                new Vertex(new Vector3(-0.5f, -0.5f, -0.5f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
                new Vertex(new Vector3(-0.5f, -0.5f, 0.5f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)),
                new Vertex(new Vector3(-0.5f, 0.5f, -0.5f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)),
                new Vertex(new Vector3(-0.5f, 0.5f, 0.5f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f)),
                new Vertex(new Vector3(0.5f, -0.5f, -0.5f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)),
                new Vertex(new Vector3(0.5f, -0.5f, 0.5f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f)),
                new Vertex(new Vector3(0.5f, 0.5f, -0.5f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f)),
                new Vertex(new Vector3(0.5f, 0.5f, 0.5f), new Vector4(1.0f, 1.0f, 1.0f, 1.0f))
            };

            var cubeIndices = stackalloc ushort[36]
            {
                0,
                2,
                1, // -x
                1,
                2,
                3,

                4,
                5,
                6, // +x
                5,
                7,
                6,

                0,
                1,
                5, // -y
                0,
                5,
                4,

                2,
                6,
                7, // +y
                2,
                7,
                3,

                0,
                4,
                6, // -z
                0,
                6,
                2,

                1,
                3,
                7, // +z
                1,
                7,
                5,
            };

            var vertices = _allocator.AllocateVertexBuffer <Vertex>(8, GpuMemoryType.CpuWriteOptimized, GpuAllocFlags.ForceAllocateComitted);
            var indices  = _allocator.AllocateIndexBuffer <ushort>(36, GpuMemoryType.CpuWriteOptimized, GpuAllocFlags.ForceAllocateComitted);

            vertices.Resource.Map(0);
            Unsafe.CopyBlock(vertices.Resource.CpuAddress, cubeVertices, (uint)sizeof(Vertex) * 8);
            vertices.Resource.Unmap(0);

            indices.Resource.Map(0);
            Unsafe.CopyBlock(indices.Resource.CpuAddress, cubeIndices, (uint)sizeof(ushort) * 36);
            indices.Resource.Unmap(0);

            _vertexBuffer = vertices;
            _indexBuffer  = indices;

            _rootSig = RootSignature.Create(device, default, default);
コード例 #19
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            if (!Clipboard.ContainsText())
            {
                return;
            }

            var item = context.SelectedItems.First() as ItemTreeViewItem;

            if (item == null)
            {
                return;
            }

            string text;

            try
            {
                text = Clipboard.GetText();
            }
            catch
            {
                return;
            }

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var items = GetItems(text);

            if (items == null)
            {
                return;
            }

            if (IsCopy)
            {
                var pipeline = PipelineManager.GetPipeline <DragCopyPipeline>();

                pipeline.KeyStates = DragDropKeyStates.None;
                pipeline.Target    = item;
                pipeline.Items     = items;
                pipeline.Position  = ControlDragAdornerPosition.Over;
                pipeline.Confirm   = false;

                pipeline.Start();
            }
            else
            {
                var pipeline = PipelineManager.GetPipeline <DragMovePipeline>();

                pipeline.KeyStates = DragDropKeyStates.None;
                pipeline.Target    = item;
                pipeline.Items     = items;
                pipeline.Position  = ControlDragAdornerPosition.Over;
                pipeline.Confirm   = false;

                pipeline.Start();

                Clipboard.Clear();
            }
        }
コード例 #20
0
ファイル: NavTileManager.cs プロジェクト: Zombach/Project-X
 /// <summary>
 /// Calculates a path through the pipeline using the specified input.
 /// It's an async operation since it can be done multithreaded if specified in the Pipeline tab.
 /// </summary>
 /// <param name="inInput">Data holder for all path find variables.</param>
 /// <returns>A task with a NavTilePath as output when the calculation is finished.</returns>
 public async Task <NavTilePath> GetPath(FindPathInput inInput)
 {
     return(await PipelineManager.GetPath(inInput));
 }
コード例 #21
0
        public void EventsAreIntercepted()
        {
            CallCountHandler fireHandler = new CallCountHandler();
            CallCountHandler addHandler = new CallCountHandler();

            VirtualMethodInterceptor interceptor = new VirtualMethodInterceptor();
            Assert.IsTrue(interceptor.CanIntercept(typeof(OverrideableProperies)));

            Type proxyType = interceptor.CreateProxyType(typeof(ClassWithEvent));
            ClassWithEvent instance = (ClassWithEvent)Activator.CreateInstance(proxyType);
            PipelineManager manager = new PipelineManager();
            ((IInterceptingProxy)instance).AddInterceptionBehavior(new PolicyInjectionBehavior(manager));
            SetPipeline(manager, instance, "add_MyEvent", addHandler);
            SetPipeline(manager, instance, "FireMyEvent", fireHandler);


            bool raised = false;
            instance.MyEvent += delegate { raised = true; };

            instance.FireMyEvent();
            instance.FireMyEvent();

            Assert.IsTrue(raised);

            Assert.AreEqual(2, fireHandler.CallCount);
            Assert.AreEqual(1, addHandler.CallCount);

        }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceInterceptor" /> with a pipeline manager.
 /// </summary>
 /// <param name="pipelineManager">The <see cref="PipelineManager" /> for the new instance.</param>
 /// <param name="container">Service container that can be used to resolve interceptors.</param>
 public ServiceInterceptor(PipelineManager pipelineManager, IServiceContainer container)
 {
     PipelineManager = pipelineManager;
     _container      = container;
 }
コード例 #23
0
        public void CanInterceptTypeWithNonDefaultCtor()
        {
            CallCountHandler h1 = new CallCountHandler();
            VirtualMethodInterceptor interceptor = new VirtualMethodInterceptor();
            Type proxyType = interceptor.CreateProxyType(typeof(ClassWithNonDefaultCtor));

            ClassWithNonDefaultCtor instance =
                (ClassWithNonDefaultCtor)Activator.CreateInstance(proxyType, "arg-value");

            PipelineManager manager = new PipelineManager();
            ((IInterceptingProxy)instance).AddInterceptionBehavior(new PolicyInjectionBehavior(manager));
            SetPipeline(manager, instance, "GetArg", h1);

            Assert.AreEqual("arg-value", instance.GetArg());

            Assert.AreEqual(1, h1.CallCount);
        }
コード例 #24
0
        public void shouldProcessDataChunk()
        {
            var expected = new short[] { 2, 3, 4, 5, 10 };
            var testee = new PipelineManager(this.scheme);
            testee.BuildPipeline(new TestSubject());

            try
            {
                testee.ExecuteOnCollection(expected);
            }
            catch (InvalidOperationException)
            {
                Assert.Fail("Methods missing from pipeline:\n" + testee.GetMetadataForMissingSteps().PrintContentsToString('\n'));
            }

            var actual = testee.GetResults<short>();

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
コード例 #25
0
        public bool Execute(InstallArgs args)
        {
            try
            {
                System.Console.WriteLine("SIM: Starting Install");

                string instanceRootDirectoryPath = args.InstanceDirectory + "\\" + args.InstanceName;


                Instance instance = InstanceManager.GetInstance(args.InstanceName);
                if (instance != null)
                {
                    Console.WriteLine("SIM: Warning! The instance with the same ({0}) name already exists",
                                      args.InstanceName);
                }

                // Next lets check the rootDirectoryPath folder for uniqueness
                if (Directory.Exists(instanceRootDirectoryPath))
                {
                    Console.WriteLine("SIM: Warning! The folder {0} already exists", instanceRootDirectoryPath);
                }

                Product product;
                string  repoFullPath = args.RepoDirectory + "\\" + args.RepoFile;

                var result = Product.TryParse(repoFullPath, out product);
                if (result == false)
                {
                    System.Console.WriteLine("SIM: Warning! Can't detect Sitecore-based product in {0} file", args.RepoFile);
                }

                var modules = new List <Product>();

                if (!string.IsNullOrEmpty(args.Modules))
                {
                    var modulesNames = args.Modules.Split('|');
                    foreach (var moduleName in modulesNames)
                    {
                        string  modulePath = args.RepoDirectory + "\\" + moduleName;
                        Product module;
                        Product.TryParse(modulePath, out module);

                        if (module != null)
                        {
                            modules.Add(module);
                        }
                    }
                }

                SIM.Pipelines.Install.InstallArgs installArgs = new SIM.Pipelines.Install.InstallArgs(
                    args.InstanceName,
                    args.InstanceName,
                    product,
                    instanceRootDirectoryPath,
                    new SqlConnectionStringBuilder(args.ConnectionString),
                    args.AppPoolIdentity,
                    args.AppPoolIdentity,
                    new FileInfo(args.LicencePath),
                    true,
                    false,
                    false,
                    modules);

                IPipelineController controller = new ConsoleController();

                // Lets start installation
                PipelineManager.Initialize();
                PipelineManager.StartPipeline(
                    "install",
                    installArgs,
                    controller,
                    false);

                System.Console.WriteLine("SIM: Finished Install");

                return(true);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Sitecore SIM install failed {0}", ex);
                return(false);
            }
        }
コード例 #26
0
        public void shouldNotCacheUnusedMethodsAtRebuildUsingBuild()
        {
            var testee = new PipelineManager(this.scheme);
            testee.BuildPipeline(new TestSubject());

            var nameOfShort = typeof(short).AssemblyQualifiedName;
            var nameOfInt = typeof(int).AssemblyQualifiedName;
            var nameOfTestSubj = typeof(TestSubject).AssemblyQualifiedName;
            var secondConfig =
                "{" + nameOfTestSubj + "; Add3; " + nameOfShort + "; " + nameOfShort + "; (0,2)}\n" +
                "{" + nameOfTestSubj + "; Square; " + nameOfShort + "; " + nameOfInt + "; (0,0)}\n" +
                "{" + nameOfTestSubj + "; Squareroot; " + nameOfInt + "; " + nameOfShort + "; (0,1)}\n" +
                "{" + nameOfTestSubj + "; Subtract3; " + nameOfShort + "; " + nameOfShort + "; (0,5)}\n";

            var secondScheme = PipelineScheme.Parse(secondConfig);

            testee.BuildPipeline(secondScheme, new TestSubject());

            var cacheCollection = testee.GetType().GetField("unusedSteps", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            var actualCollection = (Dictionary<StepMetadata, StepWrapper>)cacheCollection.GetValue(testee);

            Assert.IsTrue(actualCollection.IsNull() || actualCollection.Count == 0);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PolicyInjectionBehavior"/> with a pipeline manager.
 /// </summary>
 /// <param name="pipelineManager">The <see cref="PipelineManager"/> for the new instance.</param>
 public PolicyInjectionBehavior(PipelineManager pipelineManager)
 {
     _pipelineManager = pipelineManager;
 }
コード例 #28
0
 public InterfaceOneInterceptor(IInterfaceOne target)
 {
     this.target = target;
     pipelines   = new PipelineManager();
 }
コード例 #29
0
        public void Build(out int successCount, out int errorCount)
        {
            var projectDirectory = PathHelper.Normalize(Directory.GetCurrentDirectory());

            var outputPath = ReplaceSymbols(OutputDir);

            if (!Path.IsPathRooted(outputPath))
            {
                outputPath = PathHelper.Normalize(Path.GetFullPath(Path.Combine(projectDirectory, outputPath)));
            }

            var intermediatePath = ReplaceSymbols(IntermediateDir);

            if (!Path.IsPathRooted(intermediatePath))
            {
                intermediatePath = PathHelper.Normalize(Path.GetFullPath(Path.Combine(projectDirectory, intermediatePath)));
            }

            _manager                 = new PipelineManager(projectDirectory, outputPath, intermediatePath);
            _manager.Logger          = new ConsoleLogger();
            _manager.CompressContent = CompressContent;

            // If the intent is to debug build, break at the original location
            // of any exception, eg, within the actual importer/processor.
            if (LaunchDebugger)
            {
                _manager.RethrowExceptions = false;
            }

            // Feed all the assembly references to the pipeline manager
            // so it can resolve importers, processors, writers, and types.
            foreach (var r in References)
            {
                var assembly = r;
                if (!Path.IsPathRooted(assembly))
                {
                    assembly = Path.GetFullPath(Path.Combine(projectDirectory, assembly));
                }
                _manager.AddAssembly(assembly);
            }

            // Load the previously serialized list of built content.
            var contentFile     = Path.Combine(intermediatePath, PipelineBuildEvent.Extension);
            var previousContent = SourceFileCollection.Read(contentFile);

            // If the target changed in any way then we need to force
            // a fuull rebuild even under incremental builds.
            var targetChanged = previousContent.Config != Config ||
                                previousContent.Platform != Platform ||
                                previousContent.Profile != Profile;

            // First clean previously built content.
            foreach (var sourceFile in previousContent.SourceFiles)
            {
                var inContent           = _content.Any(e => string.Equals(e.SourceFile, sourceFile, StringComparison.InvariantCultureIgnoreCase));
                var cleanOldContent     = !inContent && !Incremental;
                var cleanRebuiltContent = inContent && (Rebuild || Clean);
                if (cleanRebuiltContent || cleanOldContent || targetChanged)
                {
                    _manager.CleanContent(sourceFile);
                }
            }

            var newContent = new SourceFileCollection
            {
                Profile  = _manager.Profile = Profile,
                Platform = _manager.Platform = Platform,
                Config   = _manager.Config = Config
            };

            errorCount   = 0;
            successCount = 0;

            // Before building the content, register all files to be built. (Necessary to
            // correctly resolve external references.)
            foreach (var c in _content)
            {
                try
                {
                    _manager.RegisterContent(c.SourceFile, null, c.Importer, c.Processor, c.ProcessorParams);
                }
                catch
                {
                    // Ignore exception. Exception will be handled below.
                }
            }

            foreach (var c in _content)
            {
                try
                {
                    _manager.BuildContent(c.SourceFile,
                                          null,
                                          c.Importer,
                                          c.Processor,
                                          c.ProcessorParams);

                    newContent.SourceFiles.Add(c.SourceFile);

                    ++successCount;
                }
                catch (InvalidContentException ex)
                {
                    var message = string.Empty;
                    if (ex.ContentIdentity != null && !string.IsNullOrEmpty(ex.ContentIdentity.SourceFilename))
                    {
                        message = ex.ContentIdentity.SourceFilename;
                        if (!string.IsNullOrEmpty(ex.ContentIdentity.FragmentIdentifier))
                        {
                            message += "(" + ex.ContentIdentity.FragmentIdentifier + ")";
                        }
                        message += ": ";
                    }
                    message += ex.Message;
                    Console.WriteLine(message);
                    ++errorCount;
                }
                catch (PipelineException ex)
                {
                    Console.Error.WriteLine("{0}: error: {1}", c.SourceFile, ex.Message);
                    if (ex.InnerException != null)
                    {
                        Console.Error.WriteLine(ex.InnerException.ToString());
                    }
                    ++errorCount;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("{0}: error: {1}", c.SourceFile, ex.Message);
                    if (ex.InnerException != null)
                    {
                        Console.Error.WriteLine(ex.InnerException.ToString());
                    }
                    ++errorCount;
                }
            }

            // If this is an incremental build we merge the list
            // of previous content with the new list.
            if (Incremental && !targetChanged)
            {
                newContent.Merge(previousContent);
            }

            // Delete the old file and write the new content
            // list if we have any to serialize.
            FileHelper.DeleteIfExists(contentFile);
            if (newContent.SourceFiles.Count > 0)
            {
                newContent.Write(contentFile);
            }

            // Process copy items (files that bypass the content pipeline)
            foreach (var c in _copyItems)
            {
                try
                {
                    // Figure out an asset name relative to the project directory,
                    // retaining the file extension.
                    // Note that replacing a sub-path like this requires consistent
                    // directory separator characters.
                    var relativeName = c.Replace(projectDirectory, string.Empty)
                                       .TrimStart(Path.DirectorySeparatorChar)
                                       .TrimStart(Path.AltDirectorySeparatorChar);
                    var dest = Path.Combine(outputPath, relativeName);

                    // Only copy if the source file is newer than the destination.
                    // We may want to provide an option for overriding this, but for
                    // nearly all cases this is the desired behavior.
                    if (File.Exists(dest))
                    {
                        var srcTime = File.GetLastWriteTimeUtc(c);
                        var dstTime = File.GetLastWriteTimeUtc(dest);
                        if (srcTime <= dstTime)
                        {
                            Console.WriteLine("Skipping {0}", c);
                            continue;
                        }
                    }

                    // Create the destination directory if it doesn't already exist.
                    var destPath = Path.GetDirectoryName(dest);
                    if (!Directory.Exists(destPath))
                    {
                        Directory.CreateDirectory(destPath);
                    }

                    File.Copy(c, dest, true);

                    // Destination file should not be read-only even if original was.
                    var fileAttr = File.GetAttributes(dest);
                    fileAttr = fileAttr & (~FileAttributes.ReadOnly);
                    File.SetAttributes(dest, fileAttr);

                    ++successCount;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("{0}: error: {1}", c, ex.Message);
                    if (ex.InnerException != null)
                    {
                        Console.Error.WriteLine(ex.InnerException.ToString());
                    }

                    ++errorCount;
                }
            }
        }
コード例 #30
0
        private static TextureContent CompileTexture(IAssetFsFile assetFile, TargetPlatform platform, TextureContent monogameOutput, string[] importOptions, bool allowResizeToPowerOfTwo, bool allowMakeSquare, PipelineManager manager)
        {
            var dictionary = new OpaqueDataDictionary();

            dictionary["GenerateMipmaps"]    = importOptions.Contains("GenerateMipmaps");
            dictionary["ResizeToPowerOfTwo"] = allowResizeToPowerOfTwo && !importOptions.Contains("NoResizeToPowerOfTwo");
            dictionary["MakeSquare"]         = allowMakeSquare && !importOptions.Contains("MakeSquare");
            dictionary["TextureFormat"]      = importOptions.Contains("NoCompress") ? TextureProcessorOutputFormat.Color : TextureProcessorOutputFormat.Compressed;
            var            processor = manager.CreateProcessor("TextureProcessor", dictionary);
            var            context   = new DummyContentProcessorContext(TargetPlatformCast.ToMonoGamePlatform(platform));
            TextureContent content;

            try
            {
                content = (TextureContent)processor.Process(monogameOutput, context);
            }
            catch (AccessViolationException)
            {
                // Sometimes the nvtt compressor crashes on some textures.  Workaround by turning off compression
                // in this case.
                Console.WriteLine("WARNING: Disabling texture compression on " + assetFile.Name + " due to nvtt bugs");
                dictionary["TextureFormat"] = TextureProcessorOutputFormat.Color;
                processor = manager.CreateProcessor("TextureProcessor", dictionary);
                context   = new DummyContentProcessorContext(TargetPlatformCast.ToMonoGamePlatform(platform));
                content   = (TextureContent)processor.Process(monogameOutput, context);
            }

            return(content);
        }
コード例 #31
0
        private void ApplyPolicies(IInterceptor interceptor, IInterceptingProxy proxy, object target, PolicySet policies)
        {
            PipelineManager manager = new PipelineManager();

            foreach (MethodImplementationInfo method in interceptor.GetInterceptableMethods(target.GetType(), target.GetType()))
            {
                HandlerPipeline pipeline = new HandlerPipeline(policies.GetHandlersFor(method, container));
                manager.SetPipeline(method.ImplementationMethodInfo, pipeline);
            }

            proxy.AddInterceptionBehavior(new PolicyInjectionBehavior(manager));
        }
コード例 #32
0
        public void shouldProcessDataPiece()
        {
            var expected = (short)2;
            var testee = new PipelineManager(this.scheme);
            testee.BuildPipeline(new TestSubject());

            try
            {
                testee.ExecuteOnData(expected);
            }
            catch (InvalidOperationException)
            {
                Assert.Fail("Methods missing from pipeline:\n" + testee.GetMetadataForMissingSteps().PrintContentsToString('\n'));
            }

            var actual = testee.GetResults<short>();

            Assert.IsTrue(expected.Equals(actual[0]));
        }