/// <summary> /// Create a <see cref="Unity.UnityContainer"/> with the given parent container. /// </summary> /// <param name="parent">The parent <see cref="Unity.UnityContainer"/>. The current object /// will apply its own settings first, and then check the parent for additional ones.</param> private UnityContainer(UnityContainer parent) { // Validate input Debug.Assert(null != parent, nameof(parent)); Debug.Assert(null != parent._root, nameof(parent._root)); // Register with parent _parent = parent; _root = parent._root; _parent.LifetimeContainer.Add(this); // Defaults and policies LifetimeContainer = new LifetimeContainer(this); ModeFlags = parent._root.ModeFlags; Defaults = _root.Defaults; Context = new ContainerContext(this); // Dynamic Members Register = InitAndAdd; // Validators ValidateType = _root.ValidateType; ValidateTypes = _root.ValidateTypes; DependencyResolvePipeline = _root.DependencyResolvePipeline; }
public static bool RegisterDevice(UsagePage usagePage, UsageId usageId, ModeFlags flags, IntPtr target) { var device = new RawInputDevice { UsagePage = (ushort)usagePage, Usage = (ushort)usageId, Flags = (uint)flags, Target = target }; return(RegisterDevice(device)); }
/// <summary> /// Create a <see cref="Unity.UnityContainer"/> with the given parent container. /// </summary> /// <param name="parent">The parent <see cref="Unity.UnityContainer"/>. The current object /// will apply its own settings first, and then check the parent for additional ones.</param> private UnityContainer(UnityContainer parent) { // Validate input Debug.Assert(null != parent); Debug.Assert(null != parent._root); // Register with parent _parent = parent; _root = parent._root; _parent.LifetimeContainer.Add(this); // Defaults and policies LifetimeContainer = new LifetimeContainer(this); ExecutionMode = parent._root.ExecutionMode; Defaults = _root.Defaults; Context = new ContainerContext(this); // Dynamic Members Register = InitAndAdd; // Validators ValidateType = _root.ValidateType; ValidateTypes = _root.ValidateTypes; DependencyResolvePipeline = _root.DependencyResolvePipeline; ///////////////////////////////////////////////////////////// // Build Mode var build = _root.ExecutionMode.BuildMode(); PipelineFromRegistration = build switch { ModeFlags.Activated => PipelineFromRegistrationActivated, ModeFlags.Compiled => PipelineFromRegistrationCompiled, _ => (FromRegistration)PipelineFromRegistrationOptimized }; PipelineFromUnregisteredType = build switch { ModeFlags.Activated => PipelineFromUnregisteredTypeActivated, ModeFlags.Compiled => PipelineFromUnregisteredTypeCompiled, _ => (FromUnregistered)PipelineFromUnregisteredTypeOptimized }; PipelineFromOpenGeneric = build switch { ModeFlags.Activated => PipelineFromOpenGenericActivated, ModeFlags.Compiled => PipelineFromOpenGenericCompiled, _ => (FromOpenGeneric)PipelineFromOpenGenericOptimized }; }
public FileAttributes(FileType fileType, ModeFlags protectionMode, UInt32 hardLinks, UInt32 ownerUid, UInt32 gid, UInt64 fileSize, UInt64 diskSize, UInt32 specialData1, UInt32 specialData2, UInt64 fileSystemID, UInt64 fileID, Time lastAccessTime, Time lastModifyTime, Time lastAttributeModifyTime) { this.fileType = fileType; this.protectionMode = protectionMode; this.hardLinks = hardLinks; this.ownerUid = ownerUid; this.gid = gid; this.fileSize = fileSize; this.diskSize = diskSize; this.specialData1 = specialData1; this.specialData2 = specialData2; this.fileSystemID = fileSystemID; this.fileID = fileID; this.lastAccessTime = lastAccessTime; this.lastModifyTime = lastModifyTime; this.lastAttributeModifyTime = lastAttributeModifyTime; }
public static String FormatFlags( ModeFlags fmd, DrawFlags fdr, EGFlags feg, HiFlags fBlackHi, HiFlags fWhiteHi, LoFlags flo) { if (fmd == 0 && fdr == 0 && feg == 0 && fBlackHi == 0 && fWhiteHi == 0 && flo == 0) { return("None"); } var sBlackHi = FormatFlags(fBlackHi); var sWhiteHi = FormatFlags(fWhiteHi); var sBlackHiLabelled = IsNullOrEmpty(sBlackHi) ? Empty : $"Black[{sBlackHi}]"; var sWhiteHiLabelled = IsNullOrEmpty(sWhiteHi) ? Empty : $"White[{sWhiteHi}]"; const Int32 nCapacity = 4; var sFlags = new List <String>(nCapacity) .AddNotEmpty(FormatFlags(fmd)) .AddNotEmpty(FormatFlags(fdr)) .AddNotEmpty(FormatFlags(feg)) .AddNotEmpty(sBlackHiLabelled) .AddNotEmpty(sWhiteHiLabelled) .AddNotEmpty(FormatFlags(flo)); return(Join(sSpace, sFlags)); }
/// <summary> /// Create a default <see cref="UnityContainer"/>. /// </summary> public UnityContainer(ModeFlags mode = ModeFlags.Optimized) { if (!mode.IsValid()) { throw new ArgumentException("'Activated' and 'Diagnostic' flags are mutually exclusive."); } ///////////////////////////////////////////////////////////// // Initialize Root _root = this; ExecutionMode = mode; LifetimeContainer = new LifetimeContainer(this); Register = AddOrReplace; //Built-In Registrations // Defaults Defaults = new DefaultPolicies(this); // IUnityContainer, IUnityContainerAsync var container = new ExplicitRegistration(this, null, typeof(UnityContainer), new ContainerLifetimeManager()) { Pipeline = (ref PipelineContext c) => c.Container }; Debug.Assert(null != container.LifetimeManager); // Create Registries _metadata = new Metadata(); _registry = new Registry(Defaults); _registry.Set(typeof(IUnityContainer), null, container); // TODO: Remove redundancy _registry.Set(typeof(IUnityContainerAsync), null, container); _registry.Set(typeof(IUnityContainer), null, container.LifetimeManager.Pipeline); _registry.Set(typeof(IUnityContainerAsync), null, container.LifetimeManager.Pipeline); ///////////////////////////////////////////////////////////// // Built-In Features var func = new PolicySet(this); _registry.Set(typeof(Func <>), func); func.Set(typeof(LifetimeManager), new PerResolveLifetimeManager()); func.Set(typeof(TypeFactoryDelegate), FuncResolver.Factory); // Func<> Factory _registry.Set(typeof(Lazy <>), new PolicySet(this, typeof(TypeFactoryDelegate), LazyResolver.Factory)); // Lazy<> _registry.Set(typeof(IEnumerable <>), new PolicySet(this, typeof(TypeFactoryDelegate), EnumerableResolver.Factory)); // Enumerable _registry.Set(typeof(IRegex <>), new PolicySet(this, typeof(TypeFactoryDelegate), RegExResolver.Factory)); // Regular Expression Enumerable ///////////////////////////////////////////////////////////// // Pipelines var typeFactory = new TypeFactoryPipeline(); var lifetime = new LifetimePipeline(); // Mode of operation if (ExecutionMode.IsDiagnostic()) { ///////////////////////////////////////////////////////////// // Setup Diagnostic mode var diagnostic = new DiagnosticPipeline(); // Create Context Context = new ContainerContext(this, new StagedStrategyChain <Pipeline, Stage> // Type Build Pipeline { { diagnostic, Stage.Diagnostic }, { typeFactory, Stage.Factory }, { new MappingDiagnostic(), Stage.TypeMapping }, { new ConstructorDiagnostic(this), Stage.Creation }, { new FieldDiagnostic(this), Stage.Fields }, { new PropertyDiagnostic(this), Stage.Properties }, { new MethodDiagnostic(this), Stage.Methods } }, new StagedStrategyChain <Pipeline, Stage> // Factory Resolve Pipeline { { diagnostic, Stage.Diagnostic }, { new FactoryPipeline(), Stage.Factory } }, new StagedStrategyChain <Pipeline, Stage> // Instance Resolve Pipeline { { diagnostic, Stage.Diagnostic }, { typeFactory, Stage.Factory } }); // Build process DependencyResolvePipeline = ValidatingDependencyResolvePipeline; // Validators ValidateType = DiagnosticValidateType; ValidateTypes = DiagnosticValidateTypes; CreateErrorMessage = CreateDiagnosticMessage; } else { // Create Context Context = new ContainerContext(this, new StagedStrategyChain <Pipeline, Stage> // Type Build Pipeline { { lifetime, Stage.Lifetime }, { typeFactory, Stage.Factory }, { new MappingPipeline(), Stage.TypeMapping }, { new ConstructorPipeline(this), Stage.Creation }, { new FieldPipeline(this), Stage.Fields }, { new PropertyPipeline(this), Stage.Properties }, { new MethodPipeline(this), Stage.Methods } }, new StagedStrategyChain <Pipeline, Stage> // Factory Resolve Pipeline { { lifetime, Stage.Lifetime }, { new FactoryPipeline(), Stage.Factory } }, new StagedStrategyChain <Pipeline, Stage> // Instance Resolve Pipeline { { typeFactory, Stage.Factory } }); } ///////////////////////////////////////////////////////////// // Build Mode var build = _root.ExecutionMode.BuildMode(); PipelineFromRegistration = build switch { ModeFlags.Activated => PipelineFromRegistrationActivated, ModeFlags.Compiled => PipelineFromRegistrationCompiled, _ => (FromRegistration)PipelineFromRegistrationOptimized }; PipelineFromUnregisteredType = build switch { ModeFlags.Activated => PipelineFromUnregisteredTypeActivated, ModeFlags.Compiled => PipelineFromUnregisteredTypeCompiled, _ => (FromUnregistered)PipelineFromUnregisteredTypeOptimized }; PipelineFromOpenGeneric = build switch { ModeFlags.Activated => PipelineFromOpenGenericActivated, ModeFlags.Compiled => PipelineFromOpenGenericCompiled, _ => (FromOpenGeneric)PipelineFromOpenGenericOptimized }; }
public bool HasFlag(ModeFlags flag) => (Flags & flag) != 0;
public static bool IsCompiled(this ModeFlags mode) => 0 != ((int)mode & (int)ModeFlags.Compiled);
public static bool IsActivated(this ModeFlags mode) => 0 != ((int)mode & (int)ModeFlags.Activated);
public static bool IsDiagnostic(this ModeFlags mode) => 0 != ((int)mode & (int)ModeFlags.Diagnostic);
public static String FormatFlags(ModeFlags fmd) { var en = mdFlags.Where(f => (f & fmd) != 0); return(Join(sSpace, en)); }
public Boolean RefreshFileAttributes(IPermissions permissions) { Boolean attributesChanged = false; if (fileInfo == null) { attributesChanged = true; fileInfo = new System.IO.FileInfo(localPathAndName); } else { fileInfo.Refresh(); } // // Update file attributes // ModeFlags newPermissions = permissions.GetPermissions(this); if (newPermissions != fileAttributes.protectionMode) { attributesChanged = true; fileAttributes.protectionMode = newPermissions; } fileAttributes.hardLinks = (fileType == FileType.Directory) ? 2U : 1U; fileAttributes.ownerUid = 0; fileAttributes.gid = 0; if (fileType == FileType.Regular) { UInt64 newFileSize = (UInt64)fileInfo.Length; if (fileAttributes.fileSize != newFileSize) { attributesChanged = true; fileAttributes.fileSize = newFileSize; } fileAttributes.diskSize = fileAttributes.fileSize; } fileAttributes.specialData1 = 0; fileAttributes.specialData2 = 0; { DateTime lastAccessDateTime = fileInfo.LastAccessTime; UInt32 newLastAccessTimeSeconds = lastAccessDateTime.ToUniversalTime().ToUnixTime(); if (fileAttributes.lastAccessTime.seconds != newLastAccessTimeSeconds) { attributesChanged = true; fileAttributes.lastAccessTime.seconds = newLastAccessTimeSeconds; } } { DateTime lastModifyTime = fileInfo.LastWriteTime; UInt32 newLastModifyTimeSeconds = lastModifyTime.ToUniversalTime().ToUnixTime(); if (fileAttributes.lastModifyTime.seconds != newLastModifyTimeSeconds) { attributesChanged = true; fileAttributes.lastModifyTime.seconds = newLastModifyTimeSeconds; } } if (attributesChanged) { fileAttributes.lastAttributeModifyTime.seconds = (fileAttributes.lastAccessTime.seconds > fileAttributes.lastModifyTime.seconds) ? fileAttributes.lastAccessTime.seconds : fileAttributes.lastModifyTime.seconds; } return(attributesChanged); }
static void Main(String[] args) { #if WindowsCE try { #endif NfsServerLog.stopwatchTicksBase = Stopwatch.GetTimestamp(); NfsServerProgramOptions options = new NfsServerProgramOptions(); List <String> nonOptionArguments = options.Parse(args); if (nonOptionArguments.Count < 2) { options.ErrorAndUsage("Expected at least 2 non-option arguments but got '{0}'", nonOptionArguments.Count); return; } if (nonOptionArguments.Count % 2 == 1) { options.ErrorAndUsage("Expected an even number of non-option arguments but got {0}", nonOptionArguments.Count); } // // RootShareDirectory[] rootShareDirectories = new RootShareDirectory[nonOptionArguments.Count / 2]; for (int i = 0; i < rootShareDirectories.Length; i++) { String localSharePath = nonOptionArguments[2 * i]; String remoteShareName = nonOptionArguments[2 * i + 1]; rootShareDirectories[i] = new RootShareDirectory(localSharePath, remoteShareName); } // // Options not exposed via command line yet // Int32 mountListenPort = 59733; Int32 backlog = 4; UInt32 readSizeMax = 65536; UInt32 suggestedReadSizeMultiple = 4096; // // Listen IP Address // IPAddress listenIPAddress = options.listenIPAddress.ArgValue; // // Debug Server // IPEndPoint debugServerEndPoint = !options.debugListenPort.set ? null : new IPEndPoint(listenIPAddress, options.debugListenPort.ArgValue); // // Npc Server // IPEndPoint npcServerEndPoint = !options.npcListenPort.set ? null : new IPEndPoint(listenIPAddress, options.npcListenPort.ArgValue); // // Logging Options // #if WindowsCE JediTimer.printJediTimerPrefix = options.jediTimer.set; #endif if (options.performanceLog.set) { if (options.performanceLog.ArgValue.Equals("internal", StringComparison.CurrentCultureIgnoreCase)) { NfsServerLog.performanceLog = new InternalPerformanceLog(); if (!options.debugListenPort.set) { options.ErrorAndUsage("Invalid option combination: you cannot set '-i internal' unless you also set -d <port>"); return; } } else { try { FileStream fileStream = new FileStream(options.performanceLog.ArgValue, FileMode.Create, FileAccess.ReadWrite, FileShare.Read); NfsServerLog.performanceLog = new WriterPerformanceLog(fileStream); } catch (Exception e) { Console.WriteLine("Failed to create performance log file '{0}'", options.performanceLog.ArgValue); throw e; } } } TextWriter selectServerEventsLog = null; if (options.logLevel.ArgValue != LogLevel.None) { TextWriter logWriter; if (options.logFile.set) { logWriter = new StreamWriter(new FileStream(options.logFile.ArgValue, FileMode.Create, FileAccess.Write, FileShare.Read)); } else { logWriter = Console.Out; } NfsServerLog.sharedFileSystemLogger = (options.logLevel.ArgValue >= LogLevel.Info) ? logWriter : null; NfsServerLog.rpcCallLogger = (options.logLevel.ArgValue >= LogLevel.Info) ? logWriter : null; NfsServerLog.warningLogger = (options.logLevel.ArgValue >= LogLevel.Warning) ? logWriter : null; NfsServerLog.npcEventsLogger = (options.logLevel.ArgValue >= LogLevel.Info) ? logWriter : null; RpcPerformanceLog.rpcMessageSerializationLogger = (options.logLevel.ArgValue >= LogLevel.Info) ? logWriter : null; selectServerEventsLog = (options.logLevel.ArgValue >= LogLevel.All) ? logWriter : null; } // // Permissions // ModeFlags defaultDirectoryPermissions = ModeFlags.OtherExecute | ModeFlags.OtherWrite | ModeFlags.OtherRead | ModeFlags.GroupExecute | ModeFlags.GroupWrite | ModeFlags.GroupRead | ModeFlags.OwnerExecute | ModeFlags.OwnerWrite | ModeFlags.OwnerRead; /*ModeFlags.SaveSwappedText | ModeFlags.SetUidOnExec | ModeFlags.SetGidOnExec;*/ ModeFlags defaultFilePermissions = ModeFlags.OtherExecute | ModeFlags.OtherWrite | ModeFlags.OtherRead | ModeFlags.GroupExecute | ModeFlags.GroupWrite | ModeFlags.GroupRead | ModeFlags.OwnerExecute | ModeFlags.OwnerWrite | ModeFlags.OwnerRead; /*ModeFlags.SaveSwappedText | ModeFlags.SetUidOnExec | ModeFlags.SetGidOnExec;*/ IPermissions permissions = new ConstantPermissions(defaultDirectoryPermissions, defaultFilePermissions); IFileIDsAndHandlesDictionary fileIDDictionary = new FreeStackFileIDDictionary(512, 512, 4096, 1024); SharedFileSystem sharedFileSystem = new SharedFileSystem(fileIDDictionary, permissions, rootShareDirectories); new RpcServicesManager().Run( selectServerEventsLog, debugServerEndPoint, npcServerEndPoint, listenIPAddress, backlog, sharedFileSystem, Ports.PortMap, mountListenPort, Ports.Nfs, readSizeMax, suggestedReadSizeMultiple); #if WindowsCE } catch (Exception e) { Console.WriteLine(e.ToString()); } #endif }
public static bool IsLegacy(this ModeFlags mode) => 0 != ((int)mode & (int)ModeFlags.Legacy);
internal static extern SharedMemorySafeHandle SharedMemoryOpen(string name, OpenFlags openFlags, ModeFlags mode);
internal static extern SemaphoreSafeHandle SemaphoreOpen(string name, OpenFlags openFlags, ModeFlags mode, int value);
public ConstantPermissions(ModeFlags defaultDirectoryPermissions, ModeFlags defaultFilePermissions) { this.defaultDirectoryPermissions = defaultDirectoryPermissions; this.defaultFilePermissions = defaultFilePermissions; }
/// <summary> /// Create a default <see cref="UnityContainer"/>. /// </summary> public UnityContainer(ModeFlags mode = ModeFlags.Optimized) { if (!mode.IsValid()) { throw new ArgumentException("'Activated' and 'Diagnostic' flags are mutually exclusive."); } ///////////////////////////////////////////////////////////// // Initialize Root _root = this; // Defaults and policies ModeFlags = mode; Defaults = new DefaultPolicies(this); LifetimeContainer = new LifetimeContainer(this); Register = AddOrReplace; // Create Registry and set Factory strategy _metadata = new Registry <int[]>(); _registry = new Registry <IPolicySet>(Defaults); ///////////////////////////////////////////////////////////// //Built-In Registrations // IUnityContainer, IUnityContainerAsync var container = new ImplicitRegistration(this, null) { Pipeline = (ref BuilderContext c) => c.Async ? (object)Task.FromResult <object>(c.Container) : c.Container }; _registry.Set(typeof(IUnityContainer), null, container); _registry.Set(typeof(IUnityContainerAsync), null, container); // Built-In Features var func = new PolicySet(this); _registry.Set(typeof(Func <>), func); func.Set(typeof(LifetimeManager), new PerResolveLifetimeManager()); func.Set(typeof(TypeFactoryDelegate), FuncResolver.Factory); // Func<> Factory _registry.Set(typeof(Lazy <>), new PolicySet(this, typeof(TypeFactoryDelegate), LazyResolver.Factory)); // Lazy<> _registry.Set(typeof(IEnumerable <>), new PolicySet(this, typeof(TypeFactoryDelegate), EnumerableResolver.Factory)); // Enumerable _registry.Set(typeof(IRegex <>), new PolicySet(this, typeof(TypeFactoryDelegate), RegExResolver.Factory)); // Regular Expression Enumerable ///////////////////////////////////////////////////////////// // Pipelines var factory = new FactoryPipeline(); var lifetime = new LifetimePipeline(); // Mode of operation if (ModeFlags.IsOptimized()) { ///////////////////////////////////////////////////////////// // Setup Optimized mode // Create Context Context = new ContainerContext(this, new StagedStrategyChain <Pipeline, Stage> // Type Build Pipeline { { lifetime, Stage.Lifetime }, { factory, Stage.Factory }, { new MappingPipeline(), Stage.TypeMapping }, { new ConstructorPipeline(this), Stage.Creation }, { new FieldPipeline(this), Stage.Fields }, { new PropertyPipeline(this), Stage.Properties }, { new MethodPipeline(this), Stage.Methods } }, new StagedStrategyChain <Pipeline, Stage> // Factory Resolve Pipeline { { lifetime, Stage.Lifetime }, { factory, Stage.Factory } }, new StagedStrategyChain <Pipeline, Stage> // Instance Resolve Pipeline { { lifetime, Stage.Lifetime }, }); } else { ///////////////////////////////////////////////////////////// // Setup Diagnostic mode var diagnostic = new DiagnosticPipeline(); // Create Context Context = new ContainerContext(this, new StagedStrategyChain <Pipeline, Stage> // Type Build Pipeline { { diagnostic, Stage.Diagnostic }, { lifetime, Stage.Lifetime }, { factory, Stage.Factory }, { new MappingDiagnostic(), Stage.TypeMapping }, { new ConstructorDiagnostic(this), Stage.Creation }, { new FieldDiagnostic(this), Stage.Fields }, { new PropertyDiagnostic(this), Stage.Properties }, { new MethodDiagnostic(this), Stage.Methods } }, new StagedStrategyChain <Pipeline, Stage> // Factory Resolve Pipeline { { diagnostic, Stage.Diagnostic }, { lifetime, Stage.Lifetime }, { factory, Stage.Factory } }, new StagedStrategyChain <Pipeline, Stage> // Instance Resolve Pipeline { { diagnostic, Stage.Diagnostic }, { lifetime, Stage.Lifetime }, }); // Build process DependencyResolvePipeline = ValidatingDependencyResolvePipeline; // Validators ValidateType = DiagnosticValidateType; ValidateTypes = DiagnosticValidateTypes; CreateMessage = CreateDiagnosticMessage; } }
private IObjectContainer Register(Type from, Type to, Object instance, String typeName, ModeFlags mode, Object id, Int32 priority /*, Boolean singleton = false*/) { if (from == null) { throw new ArgumentNullException("from"); } // 名称不能是null,否则字典里面会报错 if (id == null) { id = String.Empty; } var dic = Find(from, true); IObjectMap old = null; Map map = null; if (dic.TryGetValue(id, out old) || dic.TryGetValue(id + "", out old)) { map = old as Map; if (map != null) { // 优先级太小不能覆盖 if (priority <= map.Priority) { return(this); } map.TypeName = typeName; map.Mode = mode; map.ImplementType = to; map.Instance = instance; //map.Singleton = instance != null || singleton; if (OnRegistering != null) { OnRegistering(this, new EventArgs <Type, IObjectMap>(from, map)); } if (OnRegistered != null) { OnRegistered(this, new EventArgs <Type, IObjectMap>(from, map)); } return(this); } else { dic.Remove(id); } } map = new Map(); map.Identity = id; map.TypeName = typeName; map.Mode = mode; map.Priority = priority; if (to != null) { map.ImplementType = to; } if (instance != null) { map.Instance = instance; } //map.Singleton = instance != null || singleton; if (!dic.ContainsKey(id)) { if (OnRegistering != null) { OnRegistering(this, new EventArgs <Type, IObjectMap>(from, map)); } dic.Add(id, map); if (OnRegistered != null) { OnRegistered(this, new EventArgs <Type, IObjectMap>(from, map)); } } return(this); }
static Map GetConfig(String str) { // 如果不含=,表示整个str就是类型Type if (!str.Contains("=")) { return new Map() { TypeName = str } } ; var dic = str.SplitAsDictionary(); if (dic == null || dic.Count < 1) { if (!str.IsNullOrWhiteSpace()) { return new Map { TypeName = str } } ; return(null); } var map = new Map(); foreach (var item in dic) { switch (item.Key.ToLower()) { case "name": map.Identity = item.Value; break; case "type": map.TypeName = item.Value; break; case "singleton": //map.Singleton = item.Value.EqualIgnoreCase("true") || item.Value == "1"; break; case "priority": Int32 n = 0; if (Int32.TryParse(item.Value, out n)) { map.Priority = n; } break; case "mode": map.Mode = ModeFlags.None; //// 默认覆盖 //map.Mode |= ModeFlags.Overwrite; String[] ss = item.Value.Split(new Char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < ss.Length; i++) { try { ModeFlags mf = (ModeFlags)Enum.Parse(typeof(ModeFlags), ss[i], true); map.Mode |= mf; } catch { } } break; default: break; } } return(map); }
public static bool IsValid(this ModeFlags mode) => ((int)ModeFlags.Activated | (int)ModeFlags.Compiled) != ((int)mode & ((int)ModeFlags.Activated | (int)ModeFlags.Compiled));
public static ModeFlags BuildMode(this ModeFlags mode) => (ModeFlags)((int)mode & ((int)ModeFlags.Activated | (int)ModeFlags.Compiled));
public static bool IsOptimized(this ModeFlags mode) => 0 == ((int)mode & (int)ModeFlags.Diagnostic);