public override DbParameter GetOutputParameter(IPropertyDescription property) { return(new SqlParameter(property.Name, GetMySqlDbType(property.TypeName)) { Direction = ParameterDirection.Output }); }
private void PopulateSystemProperties() { IPropertyDescriptionList propertyDescriptionList = null; IPropertyDescription propertyDescription = null; Guid guid = new Guid(ShellIIDGuid.IPropertyDescriptionList); try { int hr = PropertySystemNativeMethods.PSEnumeratePropertyDescriptions(PropertySystemNativeMethods.PropDescEnumFilter.PDEF_ALL, ref guid, out propertyDescriptionList); if (hr >= 0) { uint count; propertyDescriptionList.GetCount(out count); guid = new Guid(ShellIIDGuid.IPropertyDescription); Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); for (uint i = 0; i < count; i++) { propertyDescriptionList.GetAt(i, ref guid, out propertyDescription); var spd = new ShellPropertyDescription(propertyDescription); propDescs.Add(spd); propDescDict.Add(spd.CanonicalName, spd); } } } finally { if (propertyDescriptionList != null) { Marshal.ReleaseComObject(propertyDescriptionList); } } }
static void InitRow(DataRow Row, IPropertyDescription propDesc) { IPropertyDescriptionSearchInfo searchInfo; uint flags = propDesc.GetPropertyType(); Row["Type"] = TypeFlagToString(flags); flags = propDesc.GetTypeFlags(PropDescTypeFlags.PDTF_MASK_ALL); bool multiValued = (flags & (uint)PropDescTypeFlags.PDTF_MULTIPLEVALUES) != 0; Row["MultipleValues"] = (multiValued ? "True" : ""); bool isViewable = (flags & (uint)PropDescTypeFlags.PDTF_ISVIEWABLE) != 0; Row["IsViewable"] = (isViewable ? "True" : ""); bool isQueryable = (flags & (uint)PropDescTypeFlags.PDTF_ISVIEWABLE) != 0; Row["IsViewable"] = (isViewable ? "True" : ""); // TODO: fix this - we're not able to get a IPDSI interface from our prop desc if (propDesc is IPropertyDescriptionSearchInfo) { searchInfo = (IPropertyDescriptionSearchInfo)propDesc; flags = (uint)searchInfo.GetSearchInfoFlags(); bool isColumn = (flags & (uint)PROPDESC_SEARCHINFO_FLAGS.PDSIF_ISCOLUMN) != 0; Row["IsColumn"] = (isColumn ? "True" : ""); Marshal.ReleaseComObject(searchInfo); } }
private static void EmitForPropertyDescription(TypeBuilder typeBuilder, IPropertyDescription property, ILGenerator ctorIl, int index, Type targetType) { var field = typeBuilder.DefineField(property.Name, targetType, FieldAttributes.Private); EmitProperty(typeBuilder, property.Name, field, targetType); EmitConstructorFieldInit(ctorIl, index, field); }
/// <summary>Initializes a new instance of the <see cref="PropertyDescription"/> class.</summary> /// <param name="propkey">A valid <see cref="PROPERTYKEY"/>.</param> public PropertyDescription(PROPERTYKEY propkey) { key = propkey; if (PSGetPropertyDescription(propkey, typeof(IPropertyDescription).GUID, out var ppv).Succeeded) { iDesc = (IPropertyDescription)ppv; } }
/// <summary> /// Releases the COM pointer maintained for and by this instance /// </summary> public void Dispose() { if (_propDescription != null) { Marshal.FinalReleaseComObject(_propDescription); _propDescription = null; } }
protected override void EmitBeginWriteProperty(ILGenerator gen, IPropertyDescription property) { // XmlWriter.WriteEndElement() gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Ldstr, XmlSerializer.PropertyElementName); gen.Emit(OpCodes.Callvirt, XmlWriterWriteStartElement); gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Ldstr, XmlSerializer.NameAttributeName); gen.Emit(OpCodes.Ldstr, property.Name); gen.Emit(OpCodes.Callvirt, XmlWriterWriteAttributeString); }
static public IPropertyDescription <TOwner> DeclareOwner <TOwner>(this IPropertyDescription _this) where TOwner : class { if (_this is IPropertyDescription <TOwner> ) { return((IPropertyDescription <TOwner>)_this); } else { Throw.IfNot(_this.AccessingType.Extends <TOwner>()); return(new PropertyDescription <TOwner>(_this.ValueType, _this.ShortName)); } }
private IPropertyDescription getPropertyDescriptionByName(IPropertyDescriptionList oPropDescs, string pName) { IEnumerator itr = oPropDescs.GetEnumerator(); while (itr.MoveNext()) { IPropertyDescription pds = (IPropertyDescription)itr.Current; if (pds.Name == pName) { return(pds); } } return(null); }
/// <summary> /// Release all resources used by <see cref="ShellPropertyDescription" />, /// and optionally releases managed resources. /// </summary> /// <param name="disposing"> /// <c>true</c> to release both managed and unmanaged resources. /// <c>false</c> to release only unmanaged resources. /// </param> protected virtual void Dispose(bool disposing) { if (!this.disposed) { // Release unmanaged resources. if (this.propertyDescriptionNative != null) { Marshal.ReleaseComObject(this.propertyDescriptionNative); this.propertyDescriptionNative = null; } this.disposed = true; } }
private void CreateProperty(IPropertyDescription propertyDescription) { var property = _typeBuilder.DefineProperty(propertyDescription.Name, PropertyAttributes.None, propertyDescription.PropertyType.Type, new Type[0]); if (propertyDescription.GetMethod != null) { } if (propertyDescription.SetMethod != null) { } }
/// <summary> /// Gets a <see cref="PropertyDescription"/> for the property represented by a canonical name. /// </summary> /// <param name="CanonicalName">The canonical name of the property for which the <see cref="PropertyDescription"/> is requested</param> /// <example>new PropertyDescription("System.Title")</example> public PropertyDescription(string CanonicalName) { HRESULT hr = PSGetPropertyDescriptionByName(CanonicalName, IID.IPropertyDescription, out IntPtr ppv); if (hr.Failed) { throw hr.GetException(); } try { _propDescription = (IPropertyDescription)Marshal.GetUniqueObjectForIUnknown(ppv); } finally { Marshal.Release(ppv); } }
/// <summary> /// Gets a <see cref="PropertyDescription"/> for the specified <see cref="PropertyKey"/> /// </summary> /// <param name="key">The <see cref="PropertyKey"/> for which the <see cref="PropertyDescription"/> is required /// </param> public PropertyDescription(PropertyKey key) { HRESULT hr = PSGetPropertyDescription(key.MarshalledPointer, IID.IPropertyDescription, out IntPtr ppv); if (hr.Failed) { throw hr.GetException(); } try { _propDescription = (IPropertyDescription)Marshal.GetUniqueObjectForIUnknown(ppv); } finally { Marshal.Release(ppv); } }
public sxPropertyDefinition(IPropertyTemplate pt) { m_def = null; m_desc = null; m_temp = pt; m_id = m_temp.Id.ToString(); m_displayName = m_temp.DisplayName; m_name = m_temp.SymbolicName; m_cardinality = m_temp.Cardinality; m_choiceList = m_temp.ChoiceList; m_typeID = m_temp.DataType; m_hidden = m_temp.IsHidden; m_required = m_temp.IsValueRequired; }
public void GetTextAssociation_QuickTip() { string value = ShellMethods.AssocQueryString(AssociationFlags.None, AssociationString.QuickTip, ".txt", null); value.Should().Be("prop:System.ItemTypeText;System.Size;System.DateModified"); IPropertyDescriptionList list = ShellMethods.GetPropertyDescriptionListFromString(value); list.GetCount().Should().Be(3); IPropertyDescription desc = list.GetAt(0, new Guid(InterfaceIds.IID_IPropertyDescription)); desc.GetCanonicalName().Should().Be("System.ItemTypeText"); desc = list.GetAt(1, new Guid(InterfaceIds.IID_IPropertyDescription)); desc.GetCanonicalName().Should().Be("System.Size"); desc = list.GetAt(2, new Guid(InterfaceIds.IID_IPropertyDescription)); desc.GetCanonicalName().Should().Be("System.DateModified"); }
private static IEnumerable <IPropertyDescription> _LinkDescriptionsRec(IPropertyDescription previous, IEnumerable <MemberExpression> rest) { if (!rest.Any()) { yield break; } var expr = rest.First(); var firstFromRest = new PropertyDescription(previous.ValueType, expr.Type, expr.Member.Name); yield return(firstFromRest); foreach (var iNode in _LinkDescriptionsRec(firstFromRest, rest.Skip(1))) { yield return(iNode); } }
private void PopulatePropertyList(List <PropertyConfig> propertyList, PropertySystemNativeMethods.PropDescEnumFilter filter) { propertyList.Clear(); IPropertyDescriptionList propertyDescriptionList = null; IPropertyDescription propertyDescription = null; Guid guid = new Guid(ShellIIDGuid.IPropertyDescriptionList); try { var hr = PropertySystemNativeMethods.PSEnumeratePropertyDescriptions( filter, ref guid, out propertyDescriptionList); if (hr >= 0) { propertyDescriptionList.GetCount(out uint count); guid = new Guid(ShellIIDGuid.IPropertyDescription); for (uint i = 0; i < count; i++) { propertyDescriptionList.GetAt(i, ref guid, out propertyDescription); if (propertyDescription != null) { var shellProperty = new ShellPropertyDescription(propertyDescription); var pc = new PropertyConfig(shellProperty); shellProperty.Dispose(); // Releases propertyDescription propertyDescription = null; GetInstalledProperty(pc, true); // Add search and alias info propertyList.Add(pc); DictInstalledProperties.Add(pc.CanonicalName, pc); } } } } finally { if (propertyDescriptionList != null) { Marshal.ReleaseComObject(propertyDescriptionList); } if (propertyDescription != null) { Marshal.ReleaseComObject(propertyDescription); } } }
/// <summary> /// Release the native objects /// </summary> /// <param name="disposing">Indicates that this is being called from Dispose(), rather than the finalizer.</param> protected virtual void Dispose(bool disposing) { if (this.nativePropertyDescription != null) { Marshal.ReleaseComObject(this.nativePropertyDescription); this.nativePropertyDescription = null; } if (disposing) { // and the managed ones this.canonicalName = null; this.displayName = null; this.editInvitation = null; this.defaultColumWidth = null; this.valueType = null; this.propertyEnumTypes = null; } }
/// <summary> /// Release the native objects /// </summary> /// <param name="disposing">Indicates that this is being called from Dispose(), rather than the finalizer.</param> public void Dispose(bool disposing) { if (nativePropertyDescription != null) { Marshal.ReleaseComObject(nativePropertyDescription); nativePropertyDescription = null; } if (disposing) { // and the managed ones canonicalName = null; displayName = null; editInvitation = null; defaultColumWidth = null; valueType = null; propertyEnumTypes = null; } }
public static DataTable GetPropertyDefinitions() { DataTable dt = CreateTable(); Guid riid; IPropertyDescriptionList propList = null; IPropertyDescription propDesc = null; try { riid = new Guid(IIDStrings.IPropertyDescriptionList); int hr = PSEnumeratePropertyDescriptions(0, // PDEF_ALL, ref riid, out propList); if (hr < 0) { throw (new ApplicationException(string.Format("PSEnumeratePropertyDescriptions returned: {0}", hr))); } uint numProps = propList.GetCount(); riid = new Guid(IIDStrings.IPropertyDescription); for (int i = 0; i < numProps; i++) { // Iterates through each item in the description list propDesc = propList.GetAt((uint)i, ref riid); string propName = propDesc.GetCanonicalName(); DataRow dr = dt.Rows.Add(propName); InitRow(dr, propDesc); Marshal.ReleaseComObject(propDesc); } } finally { Marshal.ReleaseComObject(propList); Marshal.ReleaseComObject(propDesc); } return(dt); }
protected override void EmitBeginReadProperty(ILGenerator gen, IPropertyDescription property) { var correctField = gen.DefineLabel(); var actualElementName = gen.DeclareLocal(typeof(string)); // If reader.Name == FieldElementName goto correctField gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Callvirt, XmlReaderGetName); gen.Emit(OpCodes.Stloc, actualElementName); gen.Emit(OpCodes.Ldloc, actualElementName); gen.Emit(OpCodes.Ldstr, XmlSerializer.FieldElementName); gen.Emit(OpCodes.Call, StringEquals); gen.Emit(OpCodes.Brtrue_S, correctField); // throw new XmlParseException EmitThrowXmlParseException(gen, actualElementName); gen.MarkLabel(correctField); gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Ldstr, property.Name); gen.Emit(OpCodes.Callvirt, XmlReaderMoveToAttributeByName); gen.Emit(OpCodes.Pop); }
public static IEnumerable <string> GetPropertyDefinitions() { Guid riid; IPropertyDescriptionList propList = null; IPropertyDescription propDesc = null; try { riid = new Guid(IIDStrings.IPropertyDescriptionList); int hr = PSEnumeratePropertyDescriptions(0, // PDEF_ALL, ref riid, out propList); if (hr < 0) { throw (new ApplicationException(string.Format("PSEnumeratePropertyDescriptions returned: {0}", hr))); } uint numProps = propList.GetCount(); riid = new Guid(IIDStrings.IPropertyDescription); for (int i = 0; i < numProps; i++) { // Iterates through each item in the description list propDesc = propList.GetAt((uint)i, ref riid); yield return(propDesc.GetCanonicalName()); } } finally { Marshal.ReleaseComObject(propList); Marshal.ReleaseComObject(propDesc); } }
public void PopulateSystemProperties() { IPropertyDescriptionList propertyDescriptionList = null; IPropertyDescription propertyDescription = null; Guid guid = new Guid(ShellIIDGuid.IPropertyDescriptionList); try { int hr = PropertySystemNativeMethods.PSEnumeratePropertyDescriptions(PropertySystemNativeMethods.PropDescEnumFilter.PDEF_ALL, ref guid, out propertyDescriptionList); if (hr >= 0) { uint count; propertyDescriptionList.GetCount(out count); guid = new Guid(ShellIIDGuid.IPropertyDescription); Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); for (uint i = 0; i < count; i++) { propertyDescriptionList.GetAt(i, ref guid, out propertyDescription); string propName; propertyDescription.GetCanonicalName(out propName); List <string> names = null; string[] parts = propName.Split('.'); if (parts.Count() == 2) { // System.Foo if (!dict.TryGetValue(parts[0], out names)) { names = new List <string>(); dict.Add(parts[0], names); } names.Add(parts[1]); } else if (parts.Count() == 3) { // System.Bar.Baz if (!dict.TryGetValue(parts[1], out names)) { names = new List <string>(); dict.Add(parts[1], names); } names.Add(parts[2]); } // If we ever need it: // ShellPropertyDescription desc = new ShellPropertyDescription(propertyDescription); if (propertyDescription != null) { Marshal.ReleaseComObject(propertyDescription); propertyDescription = null; } } // build tree foreach (string cat in dict.Keys) { TreeItem main = new TreeItem(cat, PropType.Group); foreach (string name in dict[cat]) { main.AddChild(new TreeItem(name, PropType.Normal)); } if (cat == "System") { AllProperties.Insert(0, main); } else if (cat == "PropGroup") { foreach (TreeItem ti in main.Children) { GroupProperties.Add(ti.Name); } } else { AllProperties.Add(main); } } } } finally { if (propertyDescriptionList != null) { Marshal.ReleaseComObject(propertyDescriptionList); } if (propertyDescription != null) { Marshal.ReleaseComObject(propertyDescription); } } }
public PropertyDescriptionChain(IPropertyDescription <TOwner> firstNode, IReadOnlyList <IPropertyDescription> otherNodes) { this.FirstNode = firstNode; this.Nodes = ListFrom.Elements(firstNode).Concat(otherNodes).ToList(); }
/// <summary> /// Release the native objects /// </summary> /// <param name="disposing">Indicates that this is being called from Dispose(), rather than the finalizer.</param> protected virtual void Dispose(bool disposing) { if (nativePropertyDescription != null) { Marshal.ReleaseComObject(nativePropertyDescription); nativePropertyDescription = null; } if (disposing) { // and the managed ones canonicalName = null; displayName = null; editInvitation = null; defaultColumWidth = null; valueType = null; propertyEnumTypes = null; } }
/// <summary>Initializes a new instance of the <see cref="PropertyDescription"/> class.</summary> /// <param name="propertyDescription">The property description.</param> protected internal PropertyDescription(IPropertyDescription propertyDescription) { iDesc = propertyDescription; key = iDesc.GetPropertyKey(); }
public abstract DbParameter GetOutputParameter(IPropertyDescription property);
internal ShellPropertyDescription(IPropertyDescription nativePropertyDescription) { this.nativePropertyDescription = nativePropertyDescription; this.nativePropertyDescription.GetPropertyKey(out this.propertyKey); }
internal static extern HRESULT PSGetPropertyDescription( ref PROPERTYKEY propkey, ref Guid riid, [Out][MarshalAs(UnmanagedType.Interface)] out IPropertyDescription ppv);
/// <summary>Initializes a new instance of the <see cref="PropertyDescription"/> class.</summary> /// <param name="propertyDescription">The property description.</param> /// <param name="pkey">The associated property key.</param> protected internal PropertyDescription(IPropertyDescription propertyDescription, PROPERTYKEY?pkey = null) { iDesc = propertyDescription; key = pkey ?? iDesc.GetPropertyKey(); }
static public IPropertyDescriptionChain <TOwner> Add <TOwner>(this IPropertyDescriptionChain <TOwner> _this, IPropertyDescription propertyDescription) where TOwner : class { return(new PropertyDescriptionChain <TOwner>(_this.FirstNode, _this.Nodes.Skip(1).Add(propertyDescription).ToList())); }
internal static extern HResult PSGetPropertyDescription( ref PropertyKey propkey, ref Guid riid, [Out, MarshalAs(UnmanagedType.Interface)] out IPropertyDescription ppv );