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


C# Logger.Flush方法代码示例

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


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

示例1: Execute

    public bool Execute()
    {
        var message = string.Format("Costura.EmbedTask v{0} Executing (Change MessageImportance to get more or less info)", version);
        var buildMessageEventArgs = new BuildMessageEventArgs(message, "", "EmbedTask", Microsoft.Build.Framework.MessageImportance.High);
        BuildEngine.LogMessageEvent(buildMessageEventArgs);

        var stopwatch = Stopwatch.StartNew();

        try
        {
            logger = new Logger
                {
                    BuildEngine = BuildEngine,
                };
            logger.Initialise(MessageImportance);
            Inner();
        }
        catch (Exception exception)
        {
            HandleException(exception);
        }
        finally
        {
            stopwatch.Stop();
            logger.Flush();
            BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tFinished ({0}ms)", stopwatch.ElapsedMilliseconds), "", "Costura.EmbedTask", Microsoft.Build.Framework.MessageImportance.High));
        }
        return !logger.ErrorHasBeenRaised;
    }
开发者ID:MartinDemberger,项目名称:Costura,代码行数:29,代码来源:InnerTask.cs

示例2: Generate

            /**
             * Generates the system prefab from the configuration
             * @return System prefab object
             **/
            public PSystem Generate()
            {
                // Dictionary of bodies generated
                Dictionary<string, Body> bodies = new Dictionary<string, Body> ();

                // Retrieve the root config node
                ConfigNode rootConfig = GameDatabase.Instance.GetConfigs (rootNodeName) [0].config;

                if (rootConfig.HasValue("Epoch"))
                    double.TryParse(rootConfig.GetValue("Epoch"), out Templates.instance.epoch);

                if(rootConfig.HasValue("useOnDemand"))
                    bool.TryParse(rootConfig.GetValue("useOnDemand"), out OnDemand.OnDemandStorage.useOnDemand);
                if (rootConfig.HasValue("onDemandLoadOnMissing"))
                    bool.TryParse(rootConfig.GetValue("onDemandLoadOnMissing"), out OnDemand.OnDemandStorage.onDemandLoadOnMissing);
                if (rootConfig.HasValue("onDemandLogOnMissing"))
                    bool.TryParse(rootConfig.GetValue("onDemandLogOnMissing"), out OnDemand.OnDemandStorage.onDemandLogOnMissing);
                if (rootConfig.HasValue("onDemandForceCollect"))
                    bool.TryParse(rootConfig.GetValue("onDemandForceCollect"), out OnDemand.OnDemandStorage.onDemandForceCollect);

                if (rootConfig.HasNode("Finalize"))
                    foreach (ConfigNode n in rootConfig.GetNode("Finalize").GetNodes(bodyNodeName))
                        if (n.HasValue("name"))
                            Templates.instance.finalizeBodies.Add(n.GetValue("name"));

                // Stage 1 - Load all of the bodies
                foreach (ConfigNode bodyNode in rootConfig.GetNodes(bodyNodeName))
                {
                    // Create a logger for this body
                    Logger bodyLogger = new Logger (bodyNode.GetValue ("name") + ".Body");
                    bodyLogger.SetAsActive ();

                    // Attempt to create the body
                    try
                    {
                        Body body = Parser.CreateObjectFromConfigNode<Body> (bodyNode);
                        bodies.Add (body.name, body);
                        Logger.Default.Log ("[Kopernicus]: Configuration.Loader: Loaded Body: " + body.name);
                    }
                    catch (Exception e)
                    {
                        bodyLogger.LogException (e);
                        Logger.Default.Log ("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue ("name"));
                    }

                    // Restore default logger
                    bodyLogger.Flush ();
                    Logger.Default.SetAsActive ();
                }

                // Stage 2 - create a new planetary system object
                GameObject gameObject = new GameObject ("Kopernicus");
                gameObject.transform.parent = Utility.Deactivator;
                PSystem system = gameObject.AddComponent<PSystem> ();

                // Set the planetary system defaults (pulled from PSystemManager.Instance.systemPrefab)
                system.systemName          = "Kopernicus";
                system.systemTimeScale     = 1.0;
                system.systemScale         = 1.0;
                system.mainToolbarSelected = 2;   // initial value in stock systemPrefab. Unknown significance.

                // Stage 3 - Glue all the orbits together in the defined pattern
                foreach (KeyValuePair<string, Body> body in bodies)
                {
                    // If this body is in orbit around another body
                    if(body.Value.referenceBody != null)
                    {
                        // Get the Body object for the reference body
                        Body parent = null;
                        if(!bodies.TryGetValue(body.Value.referenceBody, out parent))
                        {
                            throw new Exception("\"" + body.Value.referenceBody + "\" not found.");
                        }

                        // Setup the orbit of the body
                        parent.generatedBody.children.Add(body.Value.generatedBody);
                        body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
                        body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
                    }

                    // Parent the generated body to the PSystem
                    body.Value.generatedBody.transform.parent = system.transform;
                }

                // Stage 4 - elect root body
                system.rootBody = bodies.First(p => p.Value.referenceBody == null).Value.generatedBody;

                // Stage 4.5, get the new Menu-body / Home body
                if (rootConfig.HasValue("mainMenuBody"))
                {
                    Templates.menuBody = rootConfig.GetValue("mainMenuBody");
                }
                else
                {
                    Templates.menuBody = Utility.FindHomeBody(system.rootBody).name;
                }
//.........这里部分代码省略.........
开发者ID:KillAshley,项目名称:Kopernicus,代码行数:101,代码来源:Loader.cs

示例3: foreach

            // Generates the system prefab from the configuration
            void IParserEventSubscriber.PostApply(ConfigNode node)
            {
                // Dictionary of bodies generated
                Dictionary<string, Body> bodies = new Dictionary<string, Body>();

                // Load all of the bodies
                foreach (ConfigNode bodyNode in node.GetNodes(bodyNodeName))
                {
                    // Create a logger for this body
                    Logger bodyLogger = new Logger(bodyNode.GetValue("name") + ".Body");
                    bodyLogger.SetAsActive();

                    // Attempt to create the body
                    try
                    {
                        currentBody = new Body();
                        Parser.LoadObjectFromConfigurationNode(currentBody, bodyNode);
                        bodies.Add(currentBody.name, currentBody);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Body: " + currentBody.name);
                    }
                    catch (Exception e)
                    {
                        bodyLogger.LogException(e);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Body: " + bodyNode.GetValue("name"));
                    }

                    // Restore default logger
                    bodyLogger.Flush ();
                    Logger.Default.SetAsActive ();
                }

                // Load all of the asteroids
                foreach (ConfigNode asteroidNode in node.GetNodes(asteroidNodeName))
                {
                    // Create a logger for this asteroid
                    Logger logger = new Logger(asteroidNode.GetValue("name") + ".Asteroid");
                    logger.SetAsActive();

                    // Attempt to create the Asteroid
                    try
                    {
                        Asteroid asteroid = Parser.CreateObjectFromConfigNode<Asteroid>(asteroidNode);
                        DiscoverableObjects.asteroids.Add(asteroid);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Loaded Asteroid: " + asteroid.name);
                    }
                    catch (Exception e)
                    {
                        logger.LogException(e);
                        Logger.Default.Log("[Kopernicus]: Configuration.Loader: Failed to load Asteroid: " + asteroidNode.GetValue("name"));
                    }

                    // Restore default logger
                    logger.Flush();
                    Logger.Default.SetAsActive();
                }

                // Glue all the orbits together in the defined pattern
                foreach (KeyValuePair<string, Body> body in bodies)
                {
                    // If this body is in orbit around another body
                    if(body.Value.orbit != null)
                    {
                        // Get the Body object for the reference body
                        Body parent = null;
                        if(!bodies.TryGetValue(body.Value.orbit.referenceBody, out parent))
                        {
                            throw new Exception("\"" + body.Value.orbit.referenceBody + "\" not found.");
                        }

                        // Setup the orbit of the body
                        parent.generatedBody.children.Add(body.Value.generatedBody);
                        body.Value.generatedBody.orbitDriver.referenceBody = parent.generatedBody.celestialBody;
                        body.Value.generatedBody.orbitDriver.orbit.referenceBody = parent.generatedBody.celestialBody;
                    }

                    // Parent the generated body to the PSystem
                    body.Value.generatedBody.transform.parent = systemPrefab.transform;
                }

                // Elect root body
                systemPrefab.rootBody = bodies.First(p => p.Value.orbit == null).Value.generatedBody;

                // Sort by distance from parent (discover how this effects local bodies)
                RecursivelySortBodies (systemPrefab.rootBody);

                // Fix doubled flightGlobals
                List<int> numbers = new List<int>() { 0 };
                int index = bodies.Sum(b => b.Value.generatedBody.flightGlobalsIndex);
                PatchFGI(ref numbers, ref index, systemPrefab.rootBody);

                // Main Menu bodies
                if (randomMainMenuBodies.Any())
                    Templates.menuBody = randomMainMenuBodies[new System.Random().Next(0, randomMainMenuBodies.Count)];
            }
开发者ID:FrancoisHarvey,项目名称:Kopernicus,代码行数:95,代码来源:Loader.cs

示例4: Execute

        public override bool Execute()
        {
            BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("NotifyPropertyWeaver (version {0}) Executing (Change MessageImportance to get more or less info)", GetType().Assembly.GetName().Version), "", "NotifyPropertyWeaver", Microsoft.Build.Framework.MessageImportance.High));

            var lastVersionMessage = "Version 2.1 will be the last version of NotifyPropertyWeaver. No more updates will be published. Please move over to Fody and the PropertyChanged addin.";

            BuildEngine.LogWarningEvent(new BuildWarningEventArgs("","","",0,0,0,0,lastVersionMessage, "", "NotifyPropertyWeaver"));

            var stopwatch = Stopwatch.StartNew();

            try
            {
                logger = new Logger
                             {
                                 SenderName = "NotifyPropertyWeaver",
                                 BuildEngine = BuildEngine,
                             };
                logger.Initialise(MessageImportance);
                Inner();
            }
            catch (Exception exception)
            {
                HandleException(exception);
            }
            finally
            {
                stopwatch.Stop();
                logger.Flush();
                BuildEngine.LogMessageEvent(new BuildMessageEventArgs(string.Format("\tFinished ({0}ms)", stopwatch.ElapsedMilliseconds), "", "NotifyPropertyWeaver", Microsoft.Build.Framework.MessageImportance.High));
            }
            return !logger.ErrorHasBeenRaised;
        }
开发者ID:marcuswhit,项目名称:NotifyPropertyWeaver,代码行数:32,代码来源:WeavingTask.cs


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