public void dump_descriptor(PhotoshopTypeLibrary.IActionDescriptor desc1, int indent) { string indent_text = " "; int num_items; desc1.GetCount(out num_items); log.WriteLine("Descriptor ({0} items)", num_items); for (int i = 0; i < num_items; i++) { int child_key; int child_type; desc1.GetKey(i, out child_key); desc1.GetType(child_key, out child_type); string indent_str = " ";///commoncs.libstring.Multiply(indent_text, indent + 1); log.Write(indent_str); log.Write("[{0}] ", i.ToString()); log.WriteLine(" ( {0} ) ", IDToStr(child_type)); log.Write(indent_str + "-"); if (child_type == (int)PSConstants.phTypeObject) { PhotoshopTypeLibrary.IActionDescriptor child_desc; int child_class_id; desc1.GetObject(child_key, out child_class_id, out child_desc); string sss = string.Format(" ( {0} ) ( {1} ) ", IDToStr(child_key), IDToStr(child_class_id)); log.WriteLine(sss); dump_descriptor(child_desc, indent + 1); } else if (child_type == (int)PSConstants.phTypeObjectReference) { log.WriteLine("<handled type>"); } else if (child_type == (int)PSConstants.phTypeText) { log.WriteLine("<handled type>"); } else if (child_type == (int)PSConstants.phTypeBoolean) { log.WriteLine("<handled type>"); } else if (child_type == (int)PSConstants.phTypeEnumerated) { log.WriteLine("<handled type>"); } else if (child_type == (int)PSConstants.phTypeType) { log.WriteLine("<handled type>"); } else if (child_type == (int)PSConstants.phTypePath) { log.WriteLine("<handled type>"); } else { log.WriteLine("<unhandled type>"); } } }
public Object get_value_from_descriptor(PhotoshopTypeLibrary.IActionDescriptor desc, int prop_id) { /// ///<summary> /// /// Given a descriptor and a propid, will return an Object containing /// the value /// /// If there is no prop_id, then returns null /// /// Workitem: this should really return an exception if the property doesn't /// exist or it should return an additional error code. /// ///</summary> /// if (!desc_has_key(desc, prop_id)) { // If the descriptor does not contain the key, return null return(null); } // Stores the object being returned Object o = null; // Determine the type of the object int type = 0; type = get_type_from_descriptor(desc, prop_id); if (type == (int)PSConstants.phTypeChar) { string v; desc.GetString(prop_id, out v); o = (string)v; } else if (type == (int)PSConstants.phTypeInteger) { int v; desc.GetInteger(prop_id, out v); o = v; } else if (type == (int)PSConstants.phTypeFloat) { double v; desc.GetDouble(prop_id, out v); o = v; } else if (type == (int)PSConstants.phTypeBoolean) { int v; desc.GetBoolean(prop_id, out v); o = v; } else if (type == (int)PSConstants.phTypeUnitFloat) { // WORKITEM: Return an array instead int unit_id; double v; desc.GetUnitDouble(prop_id, out unit_id, out v); o = v; } else if (type == (int)PSConstants.phTypeEnumerated) { // WORKITEM: Return an array instead int enum_type; int enum_value; desc.GetEnumerated(prop_id, out enum_type, out enum_value); o = enum_value; } else if (type == (int)PSConstants.phTypeObject) { // WORKITEM: Return an array instead int class_id; PhotoshopTypeLibrary.IActionDescriptor v; desc.GetObject(prop_id, out class_id, out v); o = v; } else if (type == (int)PSConstants.phTypePath) { string v; desc.GetPath(prop_id, out v); o = v; } else { string type_name = GetNameFromTypeID(type); string msg = "Unsupported type " + type_name; var e = new PhotoshoProxyError(msg); throw (e); } return(o); }