public void Md5_bit32(string data, string hex) { var function = MdFactory.Create(MdTypes.Md5Bit32); var hashVal = function.ComputeHash(data); hashVal.GetHexString(true).ShouldBe(hex); }
public T4Base(string templateFilePath, string connectionName = "MetaDataDB") { string directoryName = Path.GetDirectoryName(templateFilePath); string exeConfigFilename = Directory.GetFiles(directoryName, "*.config").FirstOrDefault <string>() ?? Directory.GetParent(directoryName).GetFiles("*.config").FirstOrDefault <FileInfo>().FullName; this._configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = exeConfigFilename }, ConfigurationUserLevel.None); AppSettingsSection appSettingsSection = (AppSettingsSection)this._configuration.GetSection("appSettings"); ConnectionStringsSection connectionStringsSection = (ConnectionStringsSection)this._configuration.GetSection("connectionStrings"); MdFactory.SetConnectionStr(connectionStringsSection.ConnectionStrings[connectionName].ConnectionString); string strSql = appSettingsSection.Settings[connectionName].Value; T4Base.MyDb = MdFactory.SetCurrentDbName(strSql, true); foreach (TableObject current in T4Base.MyDb.GetTableView()) { if (!T4Base.TableDecs.ContainsKey(current.name)) { T4Base.TableDecs.Add(current.name, current); } foreach (FieldObject current2 in current.Columns) { if (!T4Base.Decs.ContainsKey(current2.ColumnName)) { T4Base.Decs.Add(current2.ColumnName, current2); } } } }
public void Md6Bit255L64Test(string data, string hex) { var function = MdFactory.Create(o => { o.HashSizeInBits = 255; o.ModeControl = 64; }); var hashVal = function.ComputeHash(data); hashVal.GetHexString(true).ShouldBe(hex); }
public static TableInfoEntity GetTableInfo(string filePath, string dbName, string tableName) { string pathStr = Path.GetDirectoryName(filePath); string configPath = Directory.GetFiles(pathStr, "*.config").FirstOrDefault() ?? Directory.GetParent(pathStr).GetFiles("*.config").FirstOrDefault().FullName; var config = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = configPath }, ConfigurationUserLevel.None); string dbConnectStr = ((ConnectionStringsSection)config.GetSection("connectionStrings")).ConnectionStrings[dbName + "_connect"].ConnectionString; TableInfoEntity entity = new TableInfoEntity(); List <TableFieldInfo> fieldInfo = new List <TableFieldInfo>(); MdFactory.SetConnectionStr(dbConnectStr); Database MyDb = MdFactory.SetCurrentDbName("TCInterVacationCommon", true); Dictionary <string, FieldObject> Decs = new Dictionary <string, FieldObject>(); Dictionary <string, TableObject> TableDecs = new Dictionary <string, TableObject>(); foreach (TableObject table in MyDb.GetTableView()) { if (!table.name.Equals(tableName)) { continue; } foreach (FieldObject field in table.Columns) { fieldInfo.Add(new TableFieldInfo { FieldName = field.ColumnName, Remark = field.DeTextSimplified, IsKey = field.isPK, IsNull = field.isNull, DefaultValue = field.defaultVal, Type = field.DbTypeNameStr }); } entity.DatabaseName = dbName; entity.TableName = tableName; entity.FieldInfo = fieldInfo; } return(entity); }
static void Main(string[] args) { string[] commands; string list = ""; try { list = File.ReadAllText(RelativeToAbsolutePath("CreateDocumentScript.txt")); } catch (FileNotFoundException e) { Console.WriteLine("Input file not found (be sure CreateDocumentScript.txt is in the right directory: \"" + e.FileName + "\")."); System.Environment.Exit(1); } commands = list.Split('#'); // to be assigned below DocumentFactory.IDocument document = null; //DocumentFactory.IElement element = null; string factoryType = ""; // 'html' or 'markdown' string elementType = ""; // 'image','header','list','table' string props = ""; // string value of rest component except elementType foreach (var command in commands) { string strippedCommand = Regex.Replace(command, @"\t|\n|\r", ""); // this cleans up the text a bit string[] commandList = strippedCommand.Split(':'); switch (commandList[0]) { case "Document": string[] DocumentList = commandList[1].Split(';'); factoryType = DocumentList[0]; string fileName = DocumentList[1]; if (factoryType == "Html") { document = HtmlFactory.Get().CreateDocument(fileName); } else if (factoryType == "Markdown") { document = MdFactory.Get().CreateDocument(fileName); } else { throw new NotImplementedException(); } break; case "Element": //props = propsList[0]; elementType = commandList[1]; props = commandList[2]; if (factoryType == "Html") { document.AddElement(HtmlFactory.Get().CreateElement(elementType, props)); } else if (factoryType == "Markdown") { document.AddElement(MdFactory.Get().CreateElement(elementType, props)); } else { throw new NotImplementedException(); } break; case "Run": File.WriteAllText(RelativeToAbsolutePath(document.GetFilename()), document.Run()); break; default: break; } } }
public void SetDb(string dbName, bool refresh = false) { T4Base.MyDb = MdFactory.SetCurrentDbName(dbName, refresh); }