CatenaLogic.Windows.Presentation.WebcamPlayer.FilterInfo.GetName C# (CSharp) Method

GetName() private static method

Gets the name of a specific moniker
private static GetName ( IMoniker moniker ) : string
moniker IMoniker Moniker object to get the name of
return string
        private static string GetName(IMoniker moniker)
        {
            // Declare variables
            Object bagObj = null;
            IPropertyBag bag = null;

            try
            {
                // Bind the moniker to storage
                Guid bagId = typeof (IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag) bagObj;

                // Try to retrieve the friendly name
                object val = "";
                int hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }

                // Convert to string & validate
                string result = (string) val;
                if (string.IsNullOrEmpty(result))
                {
                    throw new ApplicationException();
                }

                // Return result
                return result;
            }
            catch (Exception)
            {
                // Return empty string
                return string.Empty;
            }
            finally
            {
                // Clean up
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }
        }

Same methods

FilterInfo::GetName ( string monikerString ) : string