/// <summary> /// This function creates List by Appending Metadata. /// </summary> /// <param name="parent"></param> /// <param name="pocoObjectsMetadataDetails"></param> /// <returns>Return List</returns> private static List<PocoObjectListForExport> AppendCSharpPocoClassMetadata(string parent, PocoObjectsMetadata pocoObjectsMetadataDetails) { var exportPocoList = new List<PocoObjectListForExport>(); _initializeMappings = new Mapper(); _initializeMappings.InitializeDataTypeMappings(); var listitem = new PocoObjectListForExport {ClassName = pocoObjectsMetadataDetails.ClassName}; foreach (var detail in pocoObjectsMetadataDetails.PropertyDetail) { listitem.NamespaceName = parent; listitem.PocoListObjects.Add(new PocoListofObjects { ColumnFamilyName = detail.Key, Type = _initializeMappings.DataTypes[detail.Value] }); } exportPocoList.Add(listitem); return exportPocoList; }
/// <summary> /// This function assign values to Metadata . /// </summary> /// <param name="pocoObjectsMetadataDetails"></param> /// <param name="child"></param> /// <param name="key"></param> /// <returns>Returns bool</returns> private static bool AssignColumnFamilyDefinitionsMetadata(ref PocoObjectsMetadata pocoObjectsMetadataDetails, ColumnFamilyName child, Dictionary<string, string> key) { // Fetch class name via columnfamily name pocoObjectsMetadataDetails.ClassName = child.Columnfamilyname; // fetch the key data type pocoObjectsMetadataDetails.Key = key; foreach (ColumnFamilyMetadata data in child.ChildMetadata) { pocoObjectsMetadataDetails.PropertyDetail.Add(data.ColumnName, data.Validator); } const bool isValidColumnFamily = true; return isValidColumnFamily; }
/// <summary> /// This function generate PocoObjects List /// </summary> /// <param name="parent"></param> /// <param name="child"></param> /// <param name="key"></param> /// <returns>Returns Final List</returns> internal static List<PocoObjectListForExport> GenratePocoObjects(string parent, ColumnFamilyName child, Dictionary<string, string> key) { var pocoList = new List<PocoObjectListForExport>(); var pocoObjectsMetadataDetails = new PocoObjectsMetadata { NamespaceName = parent, ClassName = child.Columnfamilyname, Key = key }; // Fetch Namespace name via keyspace name var isValidColumnFamily = AssignColumnFamilyDefinitionsMetadata(ref pocoObjectsMetadataDetails, child, key); if (!isValidColumnFamily) { return pocoList; } pocoList = AppendCSharpPocoClassMetadata(parent, pocoObjectsMetadataDetails); return pocoList; }