コード例 #1
0
ファイル: Parser.cs プロジェクト: nive20/NoSQLPOCOGenerator
        /// <summary>
        /// Convert Fetched Data to List format.
        /// </summary>
        /// <param name="nmspcenameName"></param>
        /// <param name="columnFamilyName"></param>
        /// <param name="keyDataType"></param>
        /// <param name="columnsAndDataType"></param>
        /// <param name="isCqlScript"></param>
        /// <returns>Returns List</returns>
        public static PocoObjectListForExport ConvertGeneratedMetaDataToListFormat(string nmspcenameName,string columnFamilyName,string keyDataType,
            Dictionary<string,string> columnsAndDataType, bool isCqlScript)
        {
            _initializeMappings = new Mapper();
            _initializeMappings.InitializeDataTypeMappings();

            var pocoChildList = new List<PocoListofObjects>();
            var exportPocoItem = new PocoObjectListForExport
            {
                ClassName = columnFamilyName,
                NamespaceName = String.IsNullOrEmpty(nmspcenameName) ? KeyspaceName : nmspcenameName
            };

               foreach (var columnName in columnsAndDataType.Keys)
            {
                var pocoChildItem = new PocoListofObjects
                {
                    ColumnFamilyName = columnName,
                    Type =
                        isCqlScript
                            ? _initializeMappings.DataTypes[String.Concat(columnsAndDataType[columnName], "type")]
                            : _initializeMappings.DataTypes[columnsAndDataType[columnName]]
                };
                pocoChildList.Add(pocoChildItem);
            }
            exportPocoItem.PocoListObjects = pocoChildList;
            return exportPocoItem;
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: nive20/NoSQLPOCOGenerator
        /// <summary>
        /// This function converts Metadata to List.
        /// </summary>
        /// <param name="columnsAndDataType"></param>
        /// <returns>Returns Metadata List</returns>
        public static List<PocoListofObjects> PocoObjectListMetadata(Dictionary<string,string> columnsAndDataType)
        {
            if (columnsAndDataType == null) throw new ArgumentNullException("columnsAndDataType");

            _initializeMappings = new Mapper();
            _initializeMappings.InitializeDataTypeMappings();
            var pocoChildList = new List<PocoListofObjects>();
            foreach (var columnData in columnsAndDataType)
            {
                var pocoChildItem = new PocoListofObjects {ColumnFamilyName = columnData.Key};
                //string type = initializeMappings.DataTypes.Where(kvp => kvp.Value.ToLower() == columnData.Value.ToLower()).Select(kvp => kvp.Key).FirstOrDefault();
                var type = _initializeMappings.DataTypes.Where(kvp => String.Equals(kvp.Value, columnData.Value, StringComparison.CurrentCultureIgnoreCase))
                    .Select(kvp => kvp.Key).FirstOrDefault();
                if (type != null) pocoChildItem.Type = type.Remove(type.IndexOf("type", StringComparison.Ordinal));
                pocoChildList.Add(pocoChildItem);
            }
            return pocoChildList;
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: nive20/NoSQLPOCOGenerator
        /// <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;
        }