GetName() private method

private GetName ( Type enumType, Object value ) : String
enumType Type
value Object
return String
Example #1
0
 private static EnumAttribute GetAttribute(Enum enumConstant) {
     EnumAttribute attribute = Attribute.GetCustomAttribute(ForValue(enumConstant), typeof(EnumAttribute)) as EnumAttribute;
     if (attribute == null) {
         D.Warn(ErrorMessages.EnumNoAttribute.Inject(enumConstant.GetName(), typeof(EnumAttribute).Name));
     }
     return attribute;
 }
        private void CreateFileObserver(string path)
        {
            // FileObserverEvents.Create | FileObserverEvents.Delete | FileObserverEvents.MovedFrom | FileObserverEvents.MovedTo;
            const FileObserverEvents Mask = FileObserverEvents.Create | FileObserverEvents.Delete | FileObserverEvents.MovedFrom | FileObserverEvents.MovedTo | (FileObserverEvents)0x40000000;

            Console.WriteLine(Mask.ToString());
            fileObserver              = new FilePickerFileObserver(path, Mask);
            fileObserver.OnFileEvent += (events, s) =>
            {
                LogDebug(string.Format("FileObserver event received - {0}", events));
                if ((events & (FileObserverEvents)0x40000000) == (FileObserverEvents)0x40000000)
                {
                    Console.WriteLine("Folder event");
                }
                events &= FileObserverEvents.AllEvents;
                var eventName = Enum.GetName(typeof(FileObserverEvents), events);
                Console.WriteLine(eventName);
                if ((events & Mask) == events)
                {
                    if (Activity != null)
                    {
                        Activity.RunOnUiThread(RefreshFilesList);
                    }
                }
            };
        }
        private bool VerifyTraceMatch()
        {
            string[] arrTrace;
            string[] arrSparam;
            bool     bOk = true;

            try
            {
                for (int iChn = 0; iChn < _traceSetting.Length; iChn++)
                {
                    string tmpVar = _eqNa.GetTraceInfo(iChn + 1);
                    tmpVar = tmpVar.Replace("'", "").Replace("\n", "").Trim();
                    string[] tmp = tmpVar.Split(new char[] { ',' });

                    arrTrace  = new string[tmp.Length / 2];
                    arrSparam = new string[tmp.Length / 2];
                    for (int i = 0; i < tmp.Length; i++)
                    {
                        arrTrace[i / 2]  = tmp[i].Replace("Trc", "");
                        arrSparam[i / 2] = tmp[i + 1];
                        i++;
                    }

                    for (int i = 0; i < _traceSetting[iChn].TraceNumber.Length; i++)
                    {
                        try
                        {
                            if (_traceSetting[iChn].TraceNumber[i] == 0)
                            {
                                continue;
                            }
                            if ((arrTrace[i] != _traceSetting[iChn].TraceNumber[i].ToString()) |
                                (arrSparam[i] != Enum.GetName(typeof(naEnum.ESParametersDef), _traceSetting[iChn].SParamDefNumber[i])))
                            {
                                DisplayError(this.ToString(), "Possible S Parameter Mismatch",
                                             "S Parameter for Trace Number " + _traceSetting[iChn].TraceNumber[i].ToString() + " mismatch!!!");
                                bOk = false;
                            }
                        }
                        catch
                        {
                            DisplayError(this.ToString(), "Possible S Parameter Mismatch",
                                         "S Parameter for Trace Number " + _traceSetting[iChn].TraceNumber[i].ToString() + " mismatch!!!");
                            bOk = false;
                        }
                    }
                }
                return(bOk);
            }
            catch
            {
                DisplayError(this.ToString(), "Possible S Parameter Mismatch",
                             "TCF Trace Sheet Total Channel VS NA Total Channel mismatch!!!");
                return(false);
            }
        }
Example #4
0
        public static T GetEnumByInteger <T>(int Itgr)
            where T : struct
        {
            Type   enumType  = typeof(T);
            string enumValue = EN.GetName(enumType, Itgr);
            T      value;

            EN.TryParse(enumValue, out value);
            return(value);
        }
Example #5
0
        public static JAccessPoint Translate(AccessPoint thisAp)
        {
            WlanInterface        wlanInterface = thisAp.GetFieldValue <WlanInterface>("_interface");
            WlanAvailableNetwork network       = thisAp.GetFieldValue <WlanAvailableNetwork>("_network");
            JAccessPoint         customAp      = new JAccessPoint
            {
                //TODO: Figure out why this line is so damn costly (and maybe replace it with interface Guid)
                InterfaceName            = wlanInterface.InterfaceName,
                Name                     = thisAp.Name,
                SignalStrength           = (int)thisAp.SignalStrength,
                AuthAlgorithm            = Enum.GetName(typeof(Dot11AuthAlgorithm), network.dot11DefaultAuthAlgorithm),
                CipherAlgorithm          = Enum.GetName(typeof(Dot11CipherAlgorithm), network.dot11DefaultCipherAlgorithm),
                BssType                  = Enum.GetName(typeof(Dot11BssType), network.dot11BssType),
                Connectable              = network.networkConnectable,
                WlanNotConnectableReason = Enum.GetName(typeof(WlanReasonCode), network.wlanNotConnectableReason)
            };

            return(customAp);
        }
        private static Expression GetEnumConstantExpression(object value)
        {
            Type type = value.GetType();

            if (type.IsEnum)
            {
                return(new Expression()
                {
                    MemberExpression = new MemberExpression()
                    {
                        ObjectExpression = new Expression()
                        {
                            IdentifierExpression = new IdentifierExpression()
                            {
                                Name = type.Name
                            }
                        },
                        MemberName = SystemEnum.GetName(type, value)
                    }
                });
            }

            return(null);
        }
    /// <summary>
    /// Flushes all the pending debug messages for all existing <see cref="ID3D12Device"/> instances to the console/debugger.
    /// It also checks whether or not there are any error messages being logged that didn't result in an actual crash yet.
    /// </summary>
    /// <return>Whether or not there are any logged errors or warnings.</return>
    public static unsafe bool FlushAllID3D12InfoQueueMessagesAndCheckForErrorsOrWarnings()
    {
        bool hasErrorsOrWarnings = false;

        lock (DevicesCache)
        {
            StringBuilder builder = new(1024);

            foreach (var pair in D3D12InfoQueueMap)
            {
                GraphicsDevice   device = DevicesCache[pair.Key];
                ID3D12InfoQueue *queue  = pair.Value.Get();

                ulong messages = queue->GetNumStoredMessagesAllowedByRetrievalFilter();

                for (ulong i = 0; i < messages; i++)
                {
                    nuint length;

                    queue->GetMessage(i, null, &length);

                    D3D12_MESSAGE *message = (D3D12_MESSAGE *)NativeMemory.Alloc(length);

                    try
                    {
                        queue->GetMessage(i, message, &length);

                        builder.Clear();
                        builder.AppendLine($"[D3D12 message #{i} for \"{device}\" (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
                        builder.AppendLine($"[Category]: {Enum.GetName(message->Category)}");
                        builder.AppendLine($"[Severity]: {Enum.GetName(message->Severity)}");
                        builder.AppendLine($"[ID]: {Enum.GetName(message->ID)}");
                        builder.Append($"[Description]: \"{new string(message->pDescription)}\"");
                    }
                    finally
                    {
                        NativeMemory.Free(message);
                    }

                    if (message->Severity is D3D12_MESSAGE_SEVERITY_ERROR or D3D12_MESSAGE_SEVERITY_CORRUPTION or D3D12_MESSAGE_SEVERITY_WARNING)
                    {
                        hasErrorsOrWarnings = true;
                    }

                    Trace.WriteLine(builder);
                }

                queue->ClearStoredMessages();

                HRESULT result = device.D3D12Device->GetDeviceRemovedReason();

                if (result != S.S_OK)
                {
                    string message = (int)result switch
                    {
                        DXGI.DXGI_ERROR_DEVICE_HUNG => nameof(DXGI.DXGI_ERROR_DEVICE_HUNG),
                        DXGI.DXGI_ERROR_DEVICE_REMOVED => nameof(DXGI.DXGI_ERROR_DEVICE_REMOVED),
                        DXGI.DXGI_ERROR_DEVICE_RESET => nameof(DXGI.DXGI_ERROR_DEVICE_RESET),
                        DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR => nameof(DXGI.DXGI_ERROR_DRIVER_INTERNAL_ERROR),
                        DXGI.DXGI_ERROR_INVALID_CALL => nameof(DXGI.DXGI_ERROR_INVALID_CALL),
                        _ => ThrowHelper.ThrowArgumentOutOfRangeException <string>("Invalid GetDeviceRemovedReason HRESULT.")
                    };

                    builder.Clear();
                    builder.AppendLine($"[D3D12 device \"{device}\" removed (HW: {device.IsHardwareAccelerated}, UMA: {device.IsCacheCoherentUMA})]");
                    builder.AppendLine($"[Reason]: {message}");

                    hasErrorsOrWarnings = true;

                    Trace.WriteLine(builder);
                }
            }
        }

        return(hasErrorsOrWarnings);
    }
}
Example #8
0
 //============================================================
 // <T>获得枚举对象中值对应的名称。</T>
 //
 // @template T 枚举对象
 // @param value 值
 // @return 名称
 //============================================================
 public static string ToString <T>(object value)
 {
     return(SysEnum.GetName(typeof(T), value));
 }
Example #9
0
 //============================================================
 // <T>获得枚举对象中值对应的名称。</T>
 //
 // @param type 枚举对象
 // @param value 值
 // @return 名称
 //============================================================
 public static string ToString(Type type, object value)
 {
     return(SysEnum.GetName(type, value));
 }