/// <summary> /// Returns a options set according to the object type /// </summary> /// <param name="objectType"></param> /// <returns></returns> /// <remarks> /// Not all objectType must have a custom OptionsObj descendant, but if it has OptionsObj descendants must have the /// OptionsXXXXX signature, where XXXX is the name of the object type as <see cref="ObjectType"/> If there is not a descendant /// a generic OptionsObj is created. /// </remarks> public static OptionsObj OptionsObjFactory(string name, ObjectType objectType) { try { Type t = Type.GetType("AccessIO.Options" + objectType.ToString(), true, true); OptionsObj opt = (OptionsObj)Activator.CreateInstance(t); opt.Name = name; return(opt); } catch (TypeLoadException) { OptionsObj opt = new OptionsObj(); opt.Name = name; return(opt); } }
/// <summary> /// Constructor /// </summary> /// <param name="name">Full name of the file containing the object definition</param> /// <param name="objectType">object type clasification</param> public ObjectOptions(string name, ObjectType objectType) { Name = name; ObjectType = objectType; Options = OptionsObj.OptionsObjFactory(name, objectType); }