/// <summary> /// Create specific or generic Oid. /// </summary> /// <param name="className"></param> /// <param name="values"></param> /// <param name="types"></param> /// <returns></returns> public static Oid Create(string className, IList <object> values, IList <ModelType> types) { // Specific Oid. Oid lOid = Create(className); if (lOid != null) { if ((types != null) && (types.Count > 0)) { ModelType[] ltypes = new ModelType[types.Count]; types.CopyTo(ltypes, 0); lOid.CreateTypes(ltypes); if ((values != null) && (values.Count > 0)) { object[] lvalues = new object[values.Count]; values.CopyTo(lvalues, 0); lOid.SetValues(lvalues); } } } else { // Generic Oid. lOid = new GenericOID(className, values, types); } return(lOid); }
/// <summary> /// Create specific or generic Oid. /// </summary> /// <param name="className"></param> /// <param name="fields"></param> /// <returns></returns> public static Oid Create(string className, IList <KeyValuePair <ModelType, object> > fields) { // Specific Oid. Oid lOid = Create(className); // Generic Oid. if (lOid == null) { lOid = new GenericOID(className); } if (lOid != null) { if ((fields != null) && (fields.Count > 0)) { lOid.Fields.Clear(); foreach (KeyValuePair <ModelType, object> lField in fields) { IOidField loidfield = FieldList.CreateField(string.Empty, lField.Key); loidfield.Value = lField.Value; lOid.Fields.Add(loidfield); } } } return(lOid); }
/// <summary> /// Create Oid object specific. If className Oid object don't exist, return GenericOid object. /// </summary> /// <param name="className">Class Name.</param> /// <returns>Oid Object.</returns> private static Oid Create(string className, bool specific) { Oid lResult = null; Type lType = GetOidType(className); if (lType != null) { lResult = Activator.CreateInstance(lType) as Oid; } else { if (!specific) { lResult = new GenericOID(className); } } return(lResult); }