Пример #1
0
        void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog)
        {
            object valTempFolder     = null,
                   valTargetFolder   = null,
                   valFieldDelimiter = null,
                   valNameSpace      = null;

            try
            {
                propertyBag.Read("TempFolder", out valTempFolder, 0);
                propertyBag.Read("TargetFolder", out valTargetFolder, 0);
                propertyBag.Read("FieldDelimiter", out valFieldDelimiter, 0);
                propertyBag.Read("NameSpace", out valNameSpace, 0);
            }
            catch (ArgumentException argEx)
            {
                // throw argEx;
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error reading propertybag: " + ex.Message);
            }
            if (valTempFolder != null)
            {
                TempFolder = (string)valTempFolder;
            }
            else
            {
                TempFolder = "";
            }

            if (valTargetFolder != null)
            {
                TargetFolder = (string)valTargetFolder;
            }
            else
            {
                TargetFolder = "";
            }

            if (valFieldDelimiter != null)
            {
                FieldDelimiter = (string)valFieldDelimiter;
            }
            else
            {
                FieldDelimiter = "";
            }

            if (valNameSpace != null)
            {
                NameSpace = (string)valNameSpace;
            }
            else
            {
                NameSpace = "";
            }
        }
Пример #2
0
    private static bool GetFriendlyName(IMoniker mon, ref string devname, ref string devpath)
    {
        object       bagObj = null;
        IPropertyBag bag    = null;

        try
        {
            Guid bagId = typeof(IPropertyBag).GUID;
            mon.BindToStorage(null, null, ref bagId, out bagObj);
            bag = (IPropertyBag)bagObj;
            object val = "";
            int    hr  = bag.Read("Description", ref val, IntPtr.Zero);
            if (hr != 0)
            {
                hr = bag.Read("FriendlyName", ref val, IntPtr.Zero);
            }
            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            devname = val as string;
            if ((devname == null) || (devname.Length < 1))
            {
                throw new NotImplementedException("Device FriendlyName");
            }
            val = "";
            hr  = bag.Read("DevicePath", ref val, IntPtr.Zero);
            if (hr != 0)
            {
                Marshal.ThrowExceptionForHR(hr);
            }
            devpath = val as string;
            if ((devpath == null) || (devpath.Length < 1))
            {
                throw new NotImplementedException("Device Path");
            }
            return(true);
        }
        catch (Exception)
        {
            return(false);
        }
        finally
        {
            bag = null;
            if (bagObj != null)
            {
                Marshal.ReleaseComObject(bagObj);
            }
            bagObj = null;
        }
    }
Пример #3
0
        /// <summary>
        /// Get the FriendlyName for a moniker
        /// </summary>
        /// <returns>String or null on error</returns>
        public static string GetFriendlyName(IMoniker m_Mon)
        {
            IPropertyBag bag    = null;
            string       ret    = null;
            object       bagObj = null;
            object       val    = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                m_Mon.BindToStorage(null, null, ref bagId, out bagObj);

                bag = (IPropertyBag)bagObj;

                int hr = bag.Read("FriendlyName", out val, null);
                DsError.ThrowExceptionForHR(hr);

                ret = val as string;
            }
            catch
            {
                ret = null;
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }

            return(ret);
        }
Пример #4
0
        private void DisplayDebugInformation(IMoniker moniker, Guid filterClsid)
        {
            IPropertyBag propertyBag = null;

            try
            {
                string registryPath   = string.Format(@"HKEY_CLASSES_ROOT\CLSID\{0}\InprocServer32", filterClsid.ToString("B"));
                string filterLocation = (string)Registry.GetValue(registryPath, string.Empty, string.Empty);

                object o;
                Guid   IID_IPropertyBag = typeof(IPropertyBag).GUID;

                moniker.BindToStorage(null, null, ref IID_IPropertyBag, out o);
                propertyBag = (IPropertyBag)o;

                int hr = propertyBag.Read("FriendlyName", out o, null);
                Marshal.ThrowExceptionForHR(hr);

                string friendlyName = o.ToString();

                Debug.WriteLine(string.Format("Localtion: {0}\r\nFriendly Name: {1}", filterLocation, friendlyName));
            }
            catch { }
            finally
            {
                if (propertyBag != null)
                {
                    Marshal.ReleaseComObject(propertyBag);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Get friendly name of the device
        /// </summary>
        /// <param name="monikers"></param>
        /// <param name="displayName"></param>
        /// <returns></returns>
        private string GetFriendlyName(IMoniker moniker)
        {
            int    hr          = 0;
            string displayName = string.Empty;
            ///Get selected device name
            object       bagObj          = null;
            object       propValue       = null;
            IPropertyBag monikerProperty = null;

            Guid propertyBagGuid = typeof(IPropertyBag).GUID;

            moniker.BindToStorage(null, null, ref propertyBagGuid, out bagObj);
            monikerProperty = (IPropertyBag)bagObj;
            hr = monikerProperty.Read("FriendlyName", out propValue, null);

            displayName = propValue as string;
            if (hr != 0 || string.IsNullOrEmpty(displayName))
            {
                displayName = "Unknown";
            }

            if (bagObj != null)
            {
                Marshal.ReleaseComObject(bagObj);
            }

            return(displayName);
        }
Пример #6
0
        public string getProperty(string sProperty)
        {
            object       ppvObj      = (object)null;
            IPropertyBag propertyBag = (IPropertyBag)null;
            string       str         = (string)null;
            Guid         guid        = typeof(IPropertyBag).GUID;

            try
            {
                this.m_Moniker.BindToStorage((IBindCtx)null, (IMoniker)null, ref guid, out ppvObj);
                propertyBag = (IPropertyBag)ppvObj;
                object       pVar;
                ErrorHandler errorHandler = (ErrorHandler)propertyBag.Read(sProperty, out pVar, (IErrorLog)null);
                str = (string)pVar;
            }
            catch (Exception ex)
            {
                Logger.Error("Exception in fetch Property.  {0} Err :", (object)sProperty, (object)ex.ToString());
            }
            finally
            {
                if (propertyBag != null)
                {
                    Marshal.ReleaseComObject((object)propertyBag);
                }
            }
            return(str);
        }
 /// <summary>
 /// Reads the property value from the property bag into a value of type T.
 /// If the conversion cannot be performed, a default value will be returned.
 /// </summary>
 /// <typeparam name="T">Type to which the string value will be converted to.</typeparam>
 /// <param name="propertyBag">Property bag.</param>
 /// <param name="propertyName">Name of property.</param>
 /// <param name="defaultValue">Optional default value returned if the conversion cannot be performed.</param>
 /// <returns>Value of the property.</returns>
 public static T Read <T>(this IPropertyBag propertyBag, string propertyName, T defaultValue = default(T))
 {
     if (propertyBag == null)
     {
         throw new ArgumentNullException("propertyBag");
     }
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new ArgumentNullException("propertyName");
     }
     try
     {
         object value = propertyBag.Read(propertyName);
         if (value != null)
         {
             if (typeof(T).IsEnum == true)
             {
                 return((T)Enum.Parse(typeof(T), value.ToString()));
             }
             else
             {
                 return((T)Convert.ChangeType(value, typeof(T)));
             }
         }
         return(defaultValue);
     }
     catch (ArgumentException)
     {
         // return default value, if property cannot be read
         return(defaultValue);
     }
 }
 public override void Update(IPropertyBag config, IPropertyBag bizTalkConfig, IPropertyBag handlerPropertyBag)
 {
     lock (this)
     {
         if (this.taskController.State != State.Running)
         {
             if (config != null)
             {
                 lock (this)
                 {
                     object property = null;
                     config.Read("AdapterConfig", out property, 0);
                     if (property != null)
                     {
                         XmlDocument document = new XmlDocument();
                         document.LoadXml((string)property);
                         this.adapterConfiguration.Load(document);
                     }
                     this.taskController.Schedule = this.adapterConfiguration.Schedule;
                     transportProxy.SetErrorInfo(new ScheduledException(string.Format("\r\n{0}:  scheduled activation changed to  {1}", this.adapterConfiguration.Name, this.adapterConfiguration.Schedule.GetNextActivationTime())));
                 }
             }
         }
     }
 }
Пример #9
0
        // Token: 0x06000280 RID: 640 RVA: 0x000128C8 File Offset: 0x00010AC8
        private static string GetFriendlyName(UCOMIMoniker mon)
        {
            object obj = null;
            string result;

            try
            {
                Guid guid = typeof(IPropertyBag).GUID;
                mon.BindToStorage(null, null, ref guid, out obj);
                IPropertyBag propertyBag = (IPropertyBag)obj;
                object       obj2        = "";
                int          num         = propertyBag.Read("FriendlyName", ref obj2, IntPtr.Zero);
                string       text        = obj2 as string;
                result = text;
            }
            catch (Exception ex)
            {
                result = null;
            }
            finally
            {
                if (obj != null)
                {
                    Marshal.ReleaseComObject(RuntimeHelpers.GetObjectValue(obj));
                }
                obj = null;
            }
            return(result);
        }
        public static T ReadPropertyBag <T>(IPropertyBag pb, string propName, T oldValue)
        {
            try
            {
                object val;
                pb.Read(propName, out val, 0);

                if (val == null)
                {
                    return(oldValue);
                }

                return(val is T ? (T)val : default(T));
            }
            catch (ArgumentException)
            {
                return(default(T));
            }
            catch (InvalidCastException)
            {
                return(default(T));
            }
            catch (Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }
Пример #11
0
        /// <summary> Retrieve the human-readable name of the filter </summary>
        protected string getName(IMoniker moniker)
        {
            object       bagObj = null;
            IPropertyBag bag    = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag)bagObj;
                object val = "";
                int    hr  = bag.Read("FriendlyName", ref val, IntPtr.Zero);
                //if( hr != 0 )
                //	Marshal.ThrowExceptionForHR( hr );
                string ret = val as string;
                if ((ret == null) || (ret.Length < 1))
                {
                    throw new NotImplementedException("Device FriendlyName");
                }
                return(ret);
            }
            catch (Exception)
            {
                return("");
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                }
                bagObj = null;
            }
        }
Пример #12
0
        private string GetName(IMoniker moniker)
        {
            object       bagObject = null;
            IPropertyBag bag       = null;

            try
            {
                var bagId = typeof(IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObject);
                bag = (IPropertyBag)bagObject;
                object value   = string.Empty;
                int    hresult = bag.Read("FriendlyName", ref value, IntPtr.Zero);
                if (hresult != 0)
                {
                    Marshal.ThrowExceptionForHR(hresult);
                }
                string returnValue = (string)value;
                if ((returnValue == null) || (returnValue.Length < 1))
                {
                    throw new ApplicationException();
                }
                return(returnValue);
            }
            catch (Exception) { return(string.Empty); }
            finally
            {
                bag = null;
                if (bagObject != null)
                {
                    Marshal.ReleaseComObject(bagObject); bagObject = null;
                }
            }
        }
        /// <summary>
        /// Reads the property.
        /// </summary>
        /// <param name="propertyBag">The property bag.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="defaultValue">The default value.</param>
        /// <returns></returns>
        /// <exception cref="System.ApplicationException"></exception>
        protected virtual object LoadProperty(IPropertyBag propertyBag, string propertyName, object defaultValue)
        {
            Guard.NotNull(propertyBag, "propertyBag");
            Guard.NotNull(propertyName, "propertyName");
            Guard.NotNull(defaultValue, "defaultValue");

            object value = defaultValue;

            try
            {
                propertyBag.Read(propertyName, out value, 0);

                if (value == null)
                {
                    value = defaultValue;
                }
            }
            catch (ArgumentException)
            {
                value = defaultValue;
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }

            return(value);
        }
        public int Load(IPropertyBag pPropBag, [In, MarshalAs(UnmanagedType.Interface)] object pErrorLog)
        {
            object stratExampleType = "Example3dNav";
            int    retval           = pPropBag.Read("StratExampleType", ref stratExampleType, pErrorLog);

            return(retval);
        }
Пример #15
0
        /// <summary>
        /// Get the Guid for a moniker
        /// </summary>
        /// <returns>String or null on error</returns>
        public static Guid GetMonikerGuid(IMoniker m_Mon)
        {
            IPropertyBag bag    = null;
            Guid         ret    = Guid.Empty;
            object       bagObj = null;
            object       val    = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                m_Mon.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag)bagObj;

                int hr = bag.Read("clsid", out val, null);
                DsError.ThrowExceptionForHR(hr);

                ret = new Guid(val as string);
            }
            catch
            {
                ret = Guid.Empty;
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }

            return(ret);
        }
Пример #16
0
        internal string ReadString(IPropertyBag propertyBag, string propertyName)
        {
            string value = null;

            try
            {
                if (propertyBag != null)
                {
                    object obj = null;
                    try
                    {
                        propertyBag.Read(propertyName, out obj, 0);
                    }
                    catch (Exception)
                    {
                        // If the read failed then we will be returning null.
                    }
                    if (obj != null)
                    {
                        value = (string)obj;
                    }
                }
            }
            catch (Exception ex)
            {
                Exception exception = new Exception("Error reading property '" + propertyName + "' from property bag.", ex);
                WriteTrace(exception.ToString());
                throw exception;
            }
            return(value);
        }
Пример #17
0
        private string GetFriendlyName()
        {
            IPropertyBag bag    = null;
            string       str    = null;
            object       ppvObj = null;
            object       pVar   = null;

            try
            {
                Guid gUID = typeof(IPropertyBag).GUID;
                this.m_Mon.BindToStorage(null, null, ref gUID, out ppvObj);
                bag = (IPropertyBag)ppvObj;
                DsError.ThrowExceptionForHR(bag.Read("FriendlyName", out pVar, null));
                str = pVar as string;
            }
            catch
            {
                str = null;
            }
            finally
            {
                bag = null;
                if (ppvObj != null)
                {
                    Marshal.ReleaseComObject(ppvObj);
                    ppvObj = null;
                }
            }
            return(str);
        }
Пример #18
0
        /// <summary>
        /// Get a specific PropertyBag value from a moniker
        /// </summary>
        /// <param name="sPropName">The name of the value to retrieve</param>
        /// <returns>String or null on error</returns>
        public string GetPropBagValue(string sPropName)
        {
            IPropertyBag bag    = null;
            string       ret    = null;
            object       bagObj = null;
            object       val    = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                _moniker.BindToStorage(null, null, ref bagId, out bagObj);

                bag = (IPropertyBag)bagObj;

                int hr = bag.Read(sPropName, out val, null);
                DsError.ThrowExceptionForHR(hr);

                ret = val as string;
            }
            catch
            {
                ret = null;
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    DsUtils.ReleaseComObject(bagObj);
                    bagObj = null;
                }
            }

            return(ret);
        }
Пример #19
0
        public int Load(IPropertyBag pPropBag, object pErrorLog)
        {
            object val = null;

            pPropBag.Read("CustomProperty", ref val, IntPtr.Zero);
            Write("CustomProperty", ref val);
            return(0);
        }
Пример #20
0
        /// <summary> Retrieve the human-readable name of the filter </summary>
        protected string getName(IMoniker moniker)
        {
            object       bagObj = null;
            IPropertyBag bag    = null;

            try
            {
                Guid bagId = typeof(IPropertyBag).GUID;
                moniker.BindToStorage(null, null, ref bagId, out bagObj);
                bag = (IPropertyBag)bagObj;
                object val = "";
                int    hr  = bag.Read("FriendlyName", out val, null);
                if (hr != 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
                string ret = val as string;
                if ((ret == null) || (ret.Length < 1))
                {
                    throw new NotImplementedException("Device FriendlyName");
                }

                hr = bag.Read("CLSID", out val, null);
                if (hr == 0)
                {
                    CLSID = new Guid(val.ToString());
                }

                return(ret);
            }
            catch (Exception)
            {
                return("");
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    DirectShowUtil.ReleaseComObject(bagObj);
                }
                bagObj = null;

                _nameResolved = true;
            }
        }
Пример #21
0
        static public List <FilterProps> GetFiltersFromEnum(IEnumMoniker emon, Guid cg)
        {
            List <FilterProps> list = new List <FilterProps>();

            if (emon != null)
            {
                IMoniker[] mon = new IMoniker[1];
                while (0 == emon.Next(1, mon, IntPtr.Zero))
                {
                    object bagObj        = null;
                    Guid   propertyBagId = typeof(IPropertyBag).GUID;
                    mon[0].BindToStorage(null, null, ref propertyBagId, out bagObj);
                    IPropertyBag bag = (IPropertyBag)bagObj;
                    object       nameObj;
                    bag.Read("FriendlyName", out nameObj, null);
                    string name = nameObj as string;

                    string dispname;
                    mon[0].GetDisplayName(null, null, out dispname);
                    bag.Read("CLSID", out nameObj, null);
                    string clsid = nameObj as string;
                    if (clsid == null && dispname.Contains(":dmo:"))
                    {
                        int st = dispname.IndexOf('{');
                        int ed = dispname.IndexOf('}');
                        if (st >= 0 && ed >= 0)
                        {
                            clsid = dispname.Substring(st, ed - st + 1);
                        }
                    }
                    if (clsid != null && !friendlyNames.ContainsKey(clsid))
                    {
                        friendlyNames.Add(clsid, name);
                    }

                    FilterProps fp = new FilterProps(name, dispname, clsid, Graph.GuidToString(cg));
                    list.Add(fp);

                    Marshal.ReleaseComObject(bagObj);
                    Marshal.ReleaseComObject(mon[0]);
                }
            }
            return(list);
        }
        /// <summary>
        /// 获取 所有摄像头,返回 List<CameraDevice>
        /// </summary>
        /// <returns></returns>
        public List <CameraDevice> GetCameraDeviceList()
        {
            List <CameraDevice> cameras = new List <CameraDevice>();
            Object         bagObj       = null;
            object         comObj       = null;
            ICreateDevEnum enumDev      = null;
            IEnumMoniker   enumMon      = null;

            IMoniker[]   moniker = new IMoniker[100];
            IPropertyBag bag     = null;

            try
            {
                // Get the system device enumerator
                Type srvType = Type.GetTypeFromCLSID(SystemDeviceEnum);
                // create device enumerator
                comObj  = Activator.CreateInstance(srvType);
                enumDev = (ICreateDevEnum)comObj;
                // Create an enumerator to find filters of specified category
                enumDev.CreateClassEnumerator(VideoInputDevice, out enumMon, 0);
                Guid bagId = typeof(IPropertyBag).GUID;
                int  i     = 0;

                while (enumMon.Next(1, moniker, IntPtr.Zero) == 0)
                {
                    CameraDevice cam = new CameraDevice();
                    // get property bag of the moniker
                    moniker[0].BindToStorage(null, null, ref bagId, out bagObj);
                    bag = (IPropertyBag)bagObj;
                    // read FriendlyName
                    object val = "";
                    bag.Read("FriendlyName", ref val, IntPtr.Zero);

                    cam.Index = i++;
                    cam.Title = (string)val;
                    cameras.Add(cam);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
                enumDev = null;
                enumMon = null;
                moniker = null;
            }

            return(cameras);
        }
 private string TryReadString(string property, IPropertyBag pBag)
 {
     try
     {
         object cs;
         pBag.Read(property, out cs, null, 0, null);
         return(cs.ToString());
     }
     catch { return(null); }
 }
Пример #24
0
        void TestReadWrite()
        {
            int    hr;
            object o  = "moo";
            object o2 = "zoo";
            object o3 = "goo";

            IErrorLog iel = new MyErrorLog() as IErrorLog;

            hr = m_ipb.Write("name", ref o);
            DsError.ThrowExceptionForHR(hr);

            hr = m_ipb.Read("name", out o2, null);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert((string)o2 == (string)o, "Read/Write");

            hr = m_ipb.Read("name", out o3, iel);
            DsError.ThrowExceptionForHR(hr);
        }
 private bool TryReadBool(string property, IPropertyBag pBag, bool defaultValue = false)
 {
     try
     {
         object cs;
         pBag.Read(property, out cs, null, 0, null);
         bool val;
         bool.TryParse(cs.ToString(), out val);
         return(val);
     }
     catch { return(defaultValue); }
 }
Пример #26
0
        private void ListVideoDevices(ComboBox xcombobox)
        {
            Object         bagObj  = null;
            object         comObj  = null;
            ICreateDevEnum enumDev = null;
            IEnumMoniker   enumMon = null;

            IMoniker[]   moniker = new IMoniker[100];
            IPropertyBag bag     = null;

            try
            {
                // Get the system device enumerator
                Type srvType = Type.GetTypeFromCLSID(SystemDeviceEnum);
                // create device enumerator
                comObj  = Activator.CreateInstance(srvType);
                enumDev = (ICreateDevEnum)comObj;
                // Create an enumerator to find filters of specified category
                enumDev.CreateClassEnumerator(VideoInputDevice, out enumMon, 0);
                Guid bagId = typeof(IPropertyBag).GUID;
                while (enumMon.Next(1, moniker, IntPtr.Zero) == 0)
                {
                    // get property bag of the moniker
                    moniker[0].BindToStorage(null, null, ref bagId, out bagObj);
                    bag = (IPropertyBag)bagObj;
                    // read FriendlyName
                    object val = "";
                    bag.Read("FriendlyName", ref val, IntPtr.Zero);
                    //list in box
                    xcombobox.Items.Add((string)val);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                bag = null;
                if (bagObj != null)
                {
                    Marshal.ReleaseComObject(bagObj);
                    bagObj = null;
                }
                enumDev = null;
                enumMon = null;
                moniker = null;
            }
            if (xcombobox.Items.Count > 0)
            {
                xcombobox.SelectedIndex = 0;
            }
        }
        object ReadProperty(IPropertyBag propertyBag, string key)
        {
            object val = null;

            try
            {
                propertyBag.Read(key, out val, 0);
            }
            catch
            {
            }
            return(val);
        }
Пример #28
0
 public static object ReadProperty(IPropertyBag pb, string name)
 {
     try
     {
         object val;
         pb.Read(name, out val, 0);
         return(val ?? string.Empty);
     }
     catch
     {
         return(null);
     }
 }
Пример #29
0
        /// <summary>
        /// Reads property value from property bag
        /// </summary>
        /// <param name="pb">Property bag</param>
        /// <param name="propName">Name of property</param>
        /// <returns>Value of the property</returns>
        private object ReadProperty(IPropertyBag propertyBag, String propName)
        {
            object val = null;

            try
            {
                propertyBag.Read(propName, out val, 0);
            }
            catch
            {
            }
            return(val);
        }
Пример #30
0
 protected static object ReadPropertyBag(IPropertyBag propertyBag, string propName)
 {
     object val = null;
     try
     {
         propertyBag.Read(propName, out val, 0);
     }
     catch (System.ArgumentException)
     {
         return val;
     }
     return val;
 }
Пример #31
0
        public int ReadSolutionProps([In] IVsHierarchy pHierarchy, [In] string pszProjectName,
                                     [In] string pszProjectMk, [In] string pszKey, [In] int fPreLoad,
                                     [In] IPropertyBag pPropBag)
        {
            object solutionConfigurationLocation;

            pPropBag.Read(SolutionConfigurationLocationProperty, out solutionConfigurationLocation, null, 0, null);

            _solutionConfigurationPath = Path.Combine(Path.GetDirectoryName(_dte2.Solution.FullName), (string)solutionConfigurationLocation);

            _usingSolutionOptions = true;

            return(VSConstants.S_OK);
        }
        // Various useful helper functions
        public static XmlDocument ExtractConfigDomImpl(IPropertyBag pConfig, bool required)
        {
            object obj = null;
            pConfig.Read("AdapterConfig", out obj, 0);
            if (!required && null == obj)
                return null;
            if (null == obj)
                throw new NoAdapterConfig();

            XmlDocument configDom = new XmlDocument();

            string adapterConfig = (string)obj;
            configDom.LoadXml(adapterConfig);

            return configDom;
        }
 /// <summary>
 /// Reads property value from property bag
 /// </summary>
 /// <param name="pb">Property bag</param>
 /// <param name="propName">Name of property</param>
 /// <returns>Value of the property</returns>
 public static object ReadPropertyBag(IPropertyBag pb, string propName)
 {
     object val = null;
     try
     {
         pb.Read(propName, out val, 0);
     }
     catch (ArgumentException)
     {
         return val;
     }
     catch (Exception e)
     {
         throw new ApplicationException(e.Message);
     }
     return val;
 }
 /// <summary>
 /// Reads property value from property bag.
 /// </summary>
 /// <param name="propertyBag">Property bag.</param>
 /// <param name="propertyName">Name of property.</param>
 /// <returns>Value of the property.</returns>
 private object ReadPropertyBag(IPropertyBag propertyBag, string propertyName)
 {
     object val = null;
     try
     {
         propertyBag.Read(propertyName, out val, 0);
     }
     catch (ArgumentException)
     {
         return val;
     }
     //catch (Exception ex)
     //{
     //    ExceptionHelper.HandleException(Resources.T4TemplaterPipelineComponentName, ex);
     //    TraceHelper.WriteLineIf(traceEnabled, ex.Message, EventLogEntryType.Error);
     //    throw; ;
     //}
     return val;
 }
 private bool TryReadBool(string property, IPropertyBag pBag, bool defaultValue = false)
 {
     try
     {
         object cs;
         pBag.Read(property, out cs, null, 0, null);
         bool val;
         bool.TryParse(cs.ToString(), out val);
         return val;
     }
     catch { return defaultValue; }
 }
 private string TryReadString(string property, IPropertyBag pBag)
 {
     try
     {
         object cs;
         pBag.Read(property, out cs, null, 0, null);
         return cs.ToString();
     }
     catch { return null; }
 }