Beispiel #1
0
        private Task AddNewTabWithLogger()
        {
            // create unique target name
            var    taskNumber = _RandomTaskCounter++;
            string targetName = $"task{taskNumber}";
            // create a unique logger
            var loggerName = $"MyFoo.Logger.{taskNumber}";
            var logger     = LogManager.GetLogger(loggerName);

            // create new CacheTarget
            CacheTarget target = new CacheTarget
            {
                Name = targetName
            };

            // get config // https://stackoverflow.com/a/3603571/6229375
            var config = LogManager.Configuration;

            // add target
            config.AddTarget(targetName, target);

            // create a logging rule for the new logger
            LoggingRule loggingRule = new LoggingRule(loggerName, LogLevel.Trace, target);

            // add the logger to the existing configuration
            config.LoggingRules.Add(loggingRule);

            // reassign config back to NLog
            LogManager.Configuration = config;

            // create a new NLogViewer Control with the unique logger target name
            NLogViewer nLogViewer = new NLogViewer
            {
                TargetName = targetName,
            };

            // add it to the tab control
            var tabItem = new TabItem {
                Header = $"Task {taskNumber}", Content = nLogViewer
            };

            TabControl1.Items.Add(tabItem);
            TabControl1.SelectedItem = tabItem;

            // create task which produces some output
            var task = new Task(async() =>
            {
                while (true)
                {
                    logger.Info($"Hello from task nr. {taskNumber}. It's {DateTime.Now.ToLongTimeString()}");
                    await Task.Delay(1000);
                }
            });

            return(task);
        }
Beispiel #2
0
        public static BuildTarget? BuildTargetForCacheTarget(CacheTarget? option)
        {
            switch (option)
            {
                case CacheTarget.Android:
                    return BuildTarget.Android;
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && (UNITY_4_2 || UNITY_4_3)
			case LocalCache.Shared.CacheTarget.BlackBerry:
				return BuildTarget.BB10;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3
                case CacheTarget.BlackBerry:
                    return BuildTarget.BlackBerry;
#endif
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
			case LocalCache.Shared.CacheTarget.Flash:
				return BuildTarget.FlashPlayer;
#endif
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 // UNITY 4.6-
                case CacheTarget.iOS:
                    return BuildTarget.iPhone;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && (UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6)
                case CacheTarget.Metro:
                    return BuildTarget.MetroPlayer;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && (UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3)
			case LocalCache.Shared.CacheTarget.NaCl:
				return BuildTarget.NaCl;
#endif
                case CacheTarget.PS3:
                    return BuildTarget.PS3;
                case CacheTarget.Standalone:
                    switch (Preferences.DefaultStandaloneBuildTargetOption)
                    {
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1
                        case 0:
                            return BuildTarget.StandaloneWindows;
                        case 1:
                            return BuildTarget.StandaloneWindows64;
                        case 2:
                            return BuildTarget.StandaloneOSXIntel;
                        case 3:
                            return BuildTarget.StandaloneOSXIntel64;
                        case 4:
                            return BuildTarget.StandaloneOSXUniversal;
                        case 5:
                            return BuildTarget.StandaloneLinux;
                        case 6:
                            return BuildTarget.StandaloneLinux64;
                        case 7:
                            return BuildTarget.StandaloneLinuxUniversal;
#elif !UNITY_3_4 && !UNITY_3_5
                        case 0:
                            return BuildTarget.StandaloneWindows;
                        case 1:
                            return BuildTarget.StandaloneWindows64;
                        case 2:
                            return BuildTarget.StandaloneOSXIntel;
                        case 3:
                            return BuildTarget.StandaloneLinux;
                        case 4:
                            return BuildTarget.StandaloneLinux64;
                        case 5:
                            return BuildTarget.StandaloneLinuxUniversal;
#else
                        case 0:
                            return BuildTarget.StandaloneWindows;
                        case 1:
                            return BuildTarget.StandaloneWindows64;
                        case 2:
                            return BuildTarget.StandaloneOSXIntel;
#endif
                        default:
                            return BuildTarget.StandaloneWindows;
                    }
                case CacheTarget.WebPlayer:
                    switch (Preferences.DefaultWebPlayerBuildTargetOption)
                    {
                        case 0:
                            return BuildTarget.WebPlayer;
                        case 1:
                            return BuildTarget.WebPlayerStreamed;
                        default:
                            return BuildTarget.WebPlayer;
                    }
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3
			case LocalCache.Shared.CacheTarget.Wii:
				return BuildTarget.Wii;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1
                case CacheTarget.WP8:
                    return BuildTarget.WP8Player;
#endif
                case CacheTarget.X360:
                    return BuildTarget.XBOX360;
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3
                case CacheTarget.PS4:
                    return BuildTarget.PS4;
                case CacheTarget.VITA:
                    return BuildTarget.PSP2;
                case CacheTarget.PSM:
                    return BuildTarget.PSM;
                case CacheTarget.XBONE:
                    return BuildTarget.XboxOne;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 && !UNITY_4_6 // UNITY 5.0+
                case CacheTarget.iOS:
                    return BuildTarget.iOS;
                case CacheTarget.Metro:
                    return BuildTarget.WSAPlayer;
                case CacheTarget.WebGL:
                    return BuildTarget.WebGL;
#endif
                default:
                    return null;
            }
        }
Beispiel #3
0
        public static BuildTargetGroup? BuildTargetGroupForCacheTarget(CacheTarget? option)
        {
            switch (option)
            {
                case CacheTarget.Android:
                    return BuildTargetGroup.Android;
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && (UNITY_4_2 || UNITY_4_3)
			case LocalCache.Shared.CacheTarget.BlackBerry:
				return BuildTargetGroup.BB10;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3
                case CacheTarget.BlackBerry:
                    return BuildTargetGroup.BlackBerry;
#endif
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
			case LocalCache.Shared.CacheTarget.Flash:
				return BuildTargetGroup.FlashPlayer;
#endif
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9 // UNITY 4.6-
                case CacheTarget.iOS:
                    return BuildTargetGroup.iPhone;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && (UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6)
                case CacheTarget.Metro:
                    return BuildTargetGroup.Metro;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && (UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3)
			case LocalCache.Shared.CacheTarget.NaCl:
				return BuildTargetGroup.NaCl;
#endif
                case CacheTarget.PS3:
                    return BuildTargetGroup.PS3;
                case CacheTarget.Standalone:
                    return BuildTargetGroup.Standalone;
                case CacheTarget.WebPlayer:
                    return BuildTargetGroup.WebPlayer;
#if UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3
			case LocalCache.Shared.CacheTarget.Wii:
				return BuildTargetGroup.Wii;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1
                case CacheTarget.WP8:
                    return BuildTargetGroup.WP8;
#endif
                case CacheTarget.X360:
                    return BuildTargetGroup.XBOX360;
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3
                case CacheTarget.PS4:
                    return BuildTargetGroup.PS4;
                case CacheTarget.VITA:
                    return BuildTargetGroup.PSP2;
                case CacheTarget.PSM:
                    return BuildTargetGroup.PSM;
                case CacheTarget.XBONE:
                    return BuildTargetGroup.XboxOne;
#endif
#if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 && !UNITY_4_2 && !UNITY_4_3 && !UNITY_4_5 && !UNITY_4_6 // UNITY 5.0+
                case CacheTarget.iOS:
                    return BuildTargetGroup.iOS;
                case CacheTarget.Metro:
                    return BuildTargetGroup.WSA;
                case CacheTarget.WebGL:
                    return BuildTargetGroup.WebGL;
#endif
                default:
                    return null;
            }
        }
Beispiel #4
0
 /// <summary>
 /// 构找函数
 /// </summary>
 /// <param name="target">执行缓存的操作类型</param>
 /// <param name="prefix">缓存key前缀</param>
 public CacheAttribute(CacheTarget target, params string[] prefix)
 {
     prefixs = prefix;
 }