Ejemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////

        //
        // BUGFIX: *DEADLOCK* Prevent deadlocks here by using the TryLock
        //         pattern.
        //
        // NOTE: Used by the _Hosts.Default.WriteEngineInfo method.
        //
        public static void AddInfo(
            StringPairList list,
            DetailFlags detailFlags
            )
        {
            if (list == null)
            {
                return;
            }

            bool locked = false;

            try
            {
                TryLock(ref locked); /* TRANSACTIONAL */

                if (locked)
                {
                    bool           empty     = HostOps.HasEmptyContent(detailFlags);
                    StringPairList localList = new StringPairList();

                    if (empty || (isAvailable != null))
                    {
                        localList.Add("IsAvailable", (isAvailable != null) ?
                                      isAvailable.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || locked)
                    {
                        localList.Add("Locked", locked.ToString());
                    }

                    if (empty || disabled)
                    {
                        localList.Add("Disabled", disabled.ToString());
                    }

                    if (empty || strictPath)
                    {
                        localList.Add("StrictPath", strictPath.ToString());
                    }

                    if (empty || noReflection)
                    {
                        localList.Add("NoReflection", noReflection.ToString());
                    }

                    if (empty || (nativeModule != IntPtr.Zero))
                    {
                        localList.Add("NativeModule", nativeModule.ToString());
                    }

                    if (empty || (nativeFileName != null))
                    {
                        localList.Add("NativeFileName", (nativeFileName != null) ?
                                      nativeFileName : FormatOps.DisplayNull);
                    }

                    if (empty || ((nativeDelegates != null) && (nativeDelegates.Count > 0)))
                    {
                        localList.Add("NativeDelegates", (nativeDelegates != null) ?
                                      nativeDelegates.Count.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeGetVersion != null))
                    {
                        localList.Add("NativeGetVersion", (nativeGetVersion != null) ?
                                      nativeGetVersion.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeAllocateMemory != null))
                    {
                        localList.Add("NativeAllocateMemory", (nativeAllocateMemory != null) ?
                                      nativeAllocateMemory.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeFreeMemory != null))
                    {
                        localList.Add("NativeFreeMemory", (nativeFreeMemory != null) ?
                                      nativeFreeMemory.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeFreeElements != null))
                    {
                        localList.Add("NativeFreeElements", (nativeFreeElements != null) ?
                                      nativeFreeElements.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeSplitList != null))
                    {
                        localList.Add("NativeSplitList", (nativeSplitList != null) ?
                                      nativeSplitList.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (nativeJoinList != null))
                    {
                        localList.Add("NativeJoinList", (nativeJoinList != null) ?
                                      nativeJoinList.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || (version != null))
                    {
                        localList.Add("Version", (version != null) ?
                                      version : FormatOps.DisplayNull);
                    }

                    if (empty || (itemsFieldInfo != null))
                    {
                        localList.Add("ItemsFieldInfo", (itemsFieldInfo != null) ?
                                      itemsFieldInfo.ToString() : FormatOps.DisplayNull);
                    }

                    if (empty || Parser.UseNativeSplitList)
                    {
                        localList.Add("UseNativeSplitList",
                                      Parser.UseNativeSplitList.ToString());
                    }

                    if (empty || GenericOps <string> .UseNativeJoinList)
                    {
                        localList.Add("UseNativeJoinList",
                                      GenericOps <string> .UseNativeJoinList.ToString());
                    }

                    if (localList.Count > 0)
                    {
                        list.Add((IPair <string>)null);
                        list.Add("Native Utility");
                        list.Add((IPair <string>)null);
                        list.Add(localList);
                    }
                }
                else
                {
                    StringPairList localList = new StringPairList();

                    localList.Add(FormatOps.DisplayBusy);

                    if (localList.Count > 0)
                    {
                        list.Add((IPair <string>)null);
                        list.Add("Native Utility");
                        list.Add((IPair <string>)null);
                        list.Add(localList);
                    }
                }
            }
            finally
            {
                ExitLock(ref locked); /* TRANSACTIONAL */
            }
        }