private static CK_ATTRIBUTE[] getAssignedAttributes(P11Object obj) { PropertyInfo[] props = obj.GetType().GetProperties(); List <CK_ATTRIBUTE> attrs = new List <CK_ATTRIBUTE>(); for (int i = 0; i < props.Length; i++) { P11Attribute val = props[i].GetValue(obj, null) as P11Attribute; if (val != null && val.IsAssigned) { attrs.Add(val.CK_ATTRIBUTE); } } return(attrs.ToArray()); }