public override SearchResult<TargetAttributeEntity> SearchTargetAttributes(string name, string version, string namedProtectionDomain, string targetObjectType, CustomContext context) { throw new NotSupportedException(); }
public override PolicySet FindPolicySet(string namedProtectionDomain, string policysetName, string policysetVersion, ICollection<SearchTarget> searchTargets, CustomContext context) { // it's expected to return new instance instead of one single shared one of PolicySet object // since the execution engine modifies it later // PolicySet class doesn't support perfect clone or XML serialization/de-serialization // so have to construct it from DataSet repeatitively return (PolicySet)miConstructPolicySet.Invoke(null, new object[] { dsPolicySet, context }); }
public static TValidator ResolveValidator <TChild, TValidator>(this CustomContext context) where TValidator : IValidator <TChild> { return(GetValidatorFactory(context).GetSpecificValidator <TValidator>()); }
public static IServiceProvider GetServiceProvider(this CustomContext context) { return(GetServiceProvider(context.ParentContext)); }
public static void Deserialize(TestCustomContext t, IBinaryReader reader, CustomContext context) { t.Value = context.ValueOverride; }
static void Main(string[] args) { char keychar = ' '; while (true) { Console.Write("\r\nEnter key character to count in names: "); keychar = Console.ReadKey().KeyChar; if (keychar.Equals('q')) { return; } try { // Load source XML into an XPathDocument object instance. XPathDocument xmldoc = new XPathDocument("Tasks.xml"); // Create an XPathNavigator from the XPathDocument. XPathNavigator nav = xmldoc.CreateNavigator(); //Create argument list and add the parameters. XsltArgumentList varList = new XsltArgumentList(); varList.AddParam("charToCount", string.Empty, keychar); // Create an instance of custom XsltContext object. // Pass in the XsltArgumentList object // in which the user-defined variable will be defined. CustomContext context = new CustomContext(new NameTable(), varList); // Add a namespace definition for the namespace prefix that qualifies the // user-defined function name in the query expression. context.AddNamespace("Extensions", "http://xpathExtensions"); // Create the XPath expression using extension function to select nodes // that contain 2 occurences of the character entered by user. XPathExpression xpath = XPathExpression.Compile( "/Tasks/Name[Extensions:CountChar(., $charToCount) = 2]"); xpath.SetContext(context); XPathNodeIterator iter = nav.Select(xpath); if (iter.Count.Equals(0)) { Console.WriteLine("\n\n\rNo results contain 2 instances of " + keychar.ToString()); } else { Console.WriteLine("\n\n\rResults that contain 2 instances of : " + keychar.ToString()); // Iterate over the selected nodes and output the // results filtered by extension function. while (iter.MoveNext()) { Console.WriteLine(iter.Current.Value); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
/// <summary> /// When performing validation the <see cref="ExecutionOptions.UserContext"/> instance /// will be added to <see cref="ValidationContext.RootContextData"/> with an key of "UserContext". /// During validation this instance can be retrieved from <see cref="CustomContext"/> using this method. /// </summary> public static T UserContext <T>(this CustomContext customContext) { Guard.AgainstNull(customContext, nameof(customContext)); return(customContext.ParentContext.UserContext <T>()); }
private void ProcessNCSError(Guid paymentId, out bool ErrorIsReceived, out string Message) { ErrorIsReceived = false; var getPaymentLog = _context.Payment.Find(paymentId); int retry = 50; int counter = -50; PaymentStatus paymentStatus = null; Message = string.Empty; do { //var all = Directory.GetFiles(@"C:\tosser\inout\in"); var all = Directory.GetFiles(@"C:\tosser\inout\err"); if (all.Any()) { foreach (string filename in all) { string readFile = System.IO.File.ReadAllText(filename); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(readFile); var transactionStatusDetails = xmlDoc.SelectNodes("TransactionResponse"); using (CustomContext cust = new CustomContext()) { foreach (XmlNode node in transactionStatusDetails) { if (readFile.Contains("PayExcise")) { paymentStatus = new PaymentStatus { CustomsCode = node["CustomsCode"].InnerText, CompanyCode = node["CompanyCode"].InnerText, AssessmentSerial = node["Asmt"]["AssessmentSerial"].InnerText, AssessmentNumber = node["Asmt"]["AssessmentNumber"].InnerText, Year = node["Asmt"]["SADYear"].InnerText, Status = node["TransactionStatus"].InnerText, Message = node["Info"]["Message"].InnerText, DateCreated = DateTime.Now, PaymentLogId = getPaymentLog.Id, ErrorCode = node["Info"]["Message"].Attributes["errorCode"].Value }; } else { paymentStatus = new PaymentStatus { CustomsCode = node["CustomsCode"].InnerText, DeclarantCode = node["DeclarantCode"].InnerText, AssessmentSerial = node["SadAsmt"]["SADAssessmentSerial"].InnerText, AssessmentNumber = node["SadAsmt"]["SADAssessmentNumber"].InnerText, Year = node["SadAsmt"]["SADYear"].InnerText, Status = node["TransactionStatus"].InnerText, Message = node["Info"]["Message"].InnerText, DateCreated = DateTime.Now, PaymentLogId = getPaymentLog.Id, ErrorCode = node["Info"]["Message"].Attributes["errorCode"].Value }; } cust.PaymentStatus.Add(paymentStatus); int saveOne = cust.SaveChanges(); if (saveOne == 1) { // await CreditTillAccount(getPaymentLog.Amount, _dutyConfig.SuspenseAccount, getPaymentLog.PaymentReference); counter = 0; ErrorIsReceived = counter == 0; cleaner.DeleteFile(@"C:\tosser\inout\err"); Message = paymentStatus.Message; Log.Information("Error received"); getPaymentLog.StatusId = (int)TransactionStatus.Completed; getPaymentLog.TransactionStatusId = (int)TransactionStatus.Pending; _context.Update(getPaymentLog); _context.SaveChangesAsync(); break; } } } } } counter = (counter == 0 ? counter : counter += 1); retry = counter; }while (retry != 0); }
private void Given_shared_value_is_5(CustomContext ctx) { ctx.Shared = 5; }
public static void AddNoContentError(this CustomContext context, string propertyName, string errorMessage) { AddHttpResponseError(context, "204", propertyName, errorMessage); }
public static void AddBadRequestError(this CustomContext context, string propertyName, string errorMessage) { AddHttpResponseError(context, "400", propertyName, errorMessage); }
private void ProcessIndex(XPathNavigator indexNode, CustomContext context, IDictionary <string, object> globalData) { MemoryIndexedDocumentSource memorySource = null; DatabaseIndexedDocumentSource databaseSource = null; // get the name of the index string name = indexNode.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(name)) { throw new BuildComponentException("Each index must have a unique name."); } // get the xpath for value nodes string valueXPath = indexNode.GetAttribute("value", String.Empty); if (String.IsNullOrEmpty(valueXPath)) { WriteMessage(MessageLevel.Error, "Each index element must have a value attribute containing an XPath that describes index entries."); } // get the xpath for keys (relative to value nodes) string keyXPath = indexNode.GetAttribute("key", String.Empty); if (String.IsNullOrEmpty(keyXPath)) { WriteMessage(MessageLevel.Error, "Each index element must have a key attribute containing an XPath (relative to the value XPath) that evaluates to the entry key."); } // get the cache size int cache = 10; string cacheValue = indexNode.GetAttribute("cache", String.Empty); if (!String.IsNullOrEmpty(cacheValue)) { cache = Convert.ToInt32(cacheValue); } // create the index memorySource = new MemoryIndexedDocumentSource(_component, keyXPath, valueXPath, context, cache); // search the data directories for entries XPathNodeIterator dataNodes = indexNode.Select("data"); foreach (XPathNavigator dataNode in dataNodes) { string baseValue = dataNode.GetAttribute("base", String.Empty); if (!String.IsNullOrEmpty(baseValue)) { baseValue = Environment.ExpandEnvironmentVariables(baseValue); } bool recurse = false; string recurseValue = dataNode.GetAttribute("recurse", String.Empty); if (!String.IsNullOrEmpty(recurseValue)) { recurse = Convert.ToBoolean(recurseValue); } bool warnOverride = true; string warningValue = dataNode.GetAttribute("warnOverride", String.Empty); if (!String.IsNullOrEmpty(warningValue)) { warnOverride = Convert.ToBoolean(warningValue); } // get the files string files = dataNode.GetAttribute("files", String.Empty); if (String.IsNullOrEmpty(files)) { WriteMessage(MessageLevel.Error, "Each data element must have a files attribute specifying which files to index."); } // if ((files == null) || (files.Length == 0)) throw new BuildComponentException("When instantiating a CopyFromDirectory component, you must specify a directory path using the files attribute."); files = Environment.ExpandEnvironmentVariables(files); WriteMessage(MessageLevel.Info, String.Format( "Searching for files that match '{0}'.", files)); memorySource.AddDocuments(baseValue, files, recurse, false, warnOverride); } WriteMessage(MessageLevel.Info, String.Format( "Indexed {0} elements in {1} files.", memorySource.Count, memorySource.DocumentCount)); globalData.Add(name, this); _documentSources[name] = new IndexedDocumentSources(_component, databaseSource, memorySource); }
private void ProcessCommentsIndex(XPathNavigator indexNode, CustomContext context, IDictionary <string, object> globalData) { MemoryIndexedDocumentSource memorySource = null; DatabaseIndexedDocumentSource databaseSource = null; // get the name of the index string name = indexNode.GetAttribute("name", String.Empty); if (String.IsNullOrEmpty(name)) { throw new BuildComponentException("Each index must have a unique name."); } // get the xpath for value nodes string valueXPath = indexNode.GetAttribute("value", String.Empty); if (String.IsNullOrEmpty(valueXPath)) { WriteMessage(MessageLevel.Error, "Each index element must have a value attribute containing an XPath that describes index entries."); } // get the xpath for keys (relative to value nodes) string keyXPath = indexNode.GetAttribute("key", String.Empty); if (String.IsNullOrEmpty(keyXPath)) { WriteMessage(MessageLevel.Error, "Each index element must have a key attribute containing an XPath (relative to the value XPath) that evaluates to the entry key."); } // get the cache size int cache = 10; string cacheValue = indexNode.GetAttribute("cache", String.Empty); if (!String.IsNullOrEmpty(cacheValue)) { cache = Convert.ToInt32(cacheValue); } HashSet <string> sourceDirs = new HashSet <string>( StringComparer.OrdinalIgnoreCase); // create the index memorySource = new MemoryIndexedDocumentSource(_component, keyXPath, valueXPath, context, cache); // Search for the persistent data sources for entries... XPathNodeIterator sourcesNodes = indexNode.Select("sources"); foreach (XPathNavigator sourcesNode in sourcesNodes) { DataSources dataSources = new DataSources(false, sourcesNode); if (dataSources.IsValid) { // Currently, database is supported for systems only... if (!dataSources.IsSystem && !dataSources.IsDatabase) { dataSources = null; } } else { dataSources = null; } if (dataSources != null && dataSources.Exists) { if (databaseSource == null) { databaseSource = new DatabaseIndexedDocumentSource( _component, keyXPath, valueXPath, context, cache, true); } if (!databaseSource.IsInitialized) { sourceDirs.UnionWith(dataSources.Sources); databaseSource.Initialize(dataSources.OutputDir, false); } else { DatabaseIndexedDocument document = new DatabaseIndexedDocument(true, false, dataSources.OutputDir); if (document.Exists) { sourceDirs.UnionWith(dataSources.Sources); databaseSource.AddDocument(document); } } } } // search the data directories for entries XPathNodeIterator dataNodes = indexNode.Select("data"); foreach (XPathNavigator dataNode in dataNodes) { string baseValue = dataNode.GetAttribute("base", String.Empty); if (!String.IsNullOrEmpty(baseValue)) { baseValue = Environment.ExpandEnvironmentVariables(baseValue); } bool isSystem = false; string systemValue = dataNode.GetAttribute("system", String.Empty); if (!String.IsNullOrEmpty(systemValue)) { isSystem = Convert.ToBoolean(systemValue); } bool recurse = false; string recurseValue = dataNode.GetAttribute("recurse", String.Empty); if (!String.IsNullOrEmpty(recurseValue)) { recurse = Convert.ToBoolean(recurseValue); } bool warnOverride = true; string warningValue = dataNode.GetAttribute("warnOverride", String.Empty); if (!String.IsNullOrEmpty(warningValue)) { warnOverride = Convert.ToBoolean(warningValue); } // get the files string files = dataNode.GetAttribute("files", String.Empty); if (String.IsNullOrEmpty(files)) { WriteMessage(MessageLevel.Error, "Each data element must have a files attribute specifying which files to index."); } // if ((files == null) || (files.Length == 0)) throw new BuildComponentException("When instantiating a CopyFromDirectory component, you must specify a directory path using the files attribute."); files = Environment.ExpandEnvironmentVariables(files); WriteMessage(MessageLevel.Info, String.Format( "Searching for files that match '{0}'.", files)); if (isSystem && sourceDirs.Count != 0 && Directory.Exists(baseValue)) { // For consistent, we make sure all directory paths // end with backslash... string sourceDir = String.Copy(baseValue); if (!sourceDir.EndsWith("\\")) { sourceDir += "\\"; } // If included already in the persistent sources, we // will not load it into memory... if (sourceDirs.Contains(sourceDir)) { continue; } } memorySource.AddDocuments(baseValue, files, recurse, true, warnOverride); } WriteMessage(MessageLevel.Info, String.Format( "Indexed {0} elements in {1} files.", memorySource.Count, memorySource.DocumentCount)); globalData.Add(name, this); _documentSources[name] = new IndexedDocumentSources(_component, databaseSource, memorySource); }
public BaseRepository(CustomContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
// { // "nameid": "admin", 帳號 // "jti": "2069aa29-d18f-4e1d-8893-8f910a2c656b", jwt的唯一身份標識,主要用來作為一次性token,從而迴避重放攻擊 // "ROle": "管理者", 角色 // "nbf": 1575292627, 定義在什麼時間之前,該jwt都是不可用的 // "exp": 1575294427, 到期時間 // "iat": 1575292627, 簽發時間 // "iss": "http://www.facebook.com", // "aud": "http://www.facebook.com" // } public async Task InvokeAsync(HttpContext context, CustomContext DBcontext) { //設定HttpRequest與HttpResponse var Request = context.Request; var Response = context.Response; //抓取路徑 string Path = Request.Path.Value; //抓取傳送方式,ex:GET、POST、DELETE、PUT string URLMethod = Request.Method; //抓取Token string Token = Request.Headers["Authorization"]; //加密金鑰 string secret = this._config["Jwt:Key"]; var hs256 = new HMACSHA256(Encoding.ASCII.GetBytes(secret)); //判斷路徑是否需要做Token驗證 if (RouteChecked(Path, URLMethod)) { //判斷Token是否存在 if (Token == "" || string.IsNullOrEmpty(Token)) { await BadResponse(Response); } else { try { //讀取Token的Header與PayLoad var jwtArr = Token.Split('.'); var Header = JsonConvert.DeserializeObject <Dictionary <string, object> >(Base64UrlEncoder.Decode(jwtArr[0])); var PayLoad = JsonConvert.DeserializeObject <Dictionary <string, object> >(Base64UrlEncoder.Decode(jwtArr[1])); Boolean success = true; success = success && string.Equals(jwtArr[2], Base64UrlEncoder.Encode(hs256.ComputeHash(Encoding.UTF8.GetBytes(string.Concat(jwtArr[0], ".", jwtArr[1]))))); //驗證Token安全金鑰的值是否正確 if (!success) { await BadResponse(Response); } else { //驗證Token是否過期 if (!TimeChecked(PayLoad["iat"].ToString(), PayLoad["exp"].ToString())) { await BadResponse(Response); } else { //驗證使用者是否存在 if (!await UserChecked(PayLoad["nameid"].ToString(), DBcontext)) { await BadResponse(Response); } // else // { // // string Role = PayLoad["Role"]..ToString(); // //驗證角色權限 // if (!await RolePermissionsChecked(PayLoad["Role"].ToString(), Path, URLMethod, DBcontext)) // await BadResponse(Response); // } } } } catch (Exception e) { context.Response.ContentType = "text/html; charset = utf-8"; context.Response.StatusCode = 401; await context.Response.WriteAsync("權限驗證失敗" + "\r\n" + e.ToString(), Encoding.GetEncoding("utf-8")); await Task.CompletedTask; return; } } } await this._next(context); }
public async Task <Boolean> PermissionsChecked(string Role, string FunctionNames, string Actions, CustomContext DBcontext) { var ROlePermissions = await DBcontext.role_permissions .Include(r => r.roles) .Include(p => p.permissions) .ThenInclude(permissions => permissions.function_names) .Include(p => p.permissions) .ThenInclude(permissions => permissions.actions) .Where(r => r.roles.role == Role && r.permissions.function_names.function_name == FunctionNames && r.permissions.actions.action == Actions) .ToListAsync(); if (ROlePermissions.Count() == 0) { return(false); } return(true); }
private void Step_checking_shared_value_eq_3(CustomContext ctx) { Assert.That(ctx.Shared, Is.EqualTo(3)); }
public static void AddNoContentError(this CustomContext context, string errorMessage) { AddNoContentError(context, null, errorMessage); }
public async Task <Boolean> RolePermissionsChecked(string Role, string Path, string URLMethod, CustomContext DBcontext) { string[] PathDetails = Path.Split("/"); string FunctionNames = ""; string Actions = ""; //確認Request路徑 #region 人事管理權限 // 10 if ((PathDetails[2] == "Permissions" && URLMethod == "GET") || (PathDetails[2] == "FunctionNames" && URLMethod == "GET") || (PathDetails[2] == "Actions" && URLMethod == "GET") || (PathDetails[2] == "Roles" && URLMethod == "GET") || (PathDetails[2] == "Users" && URLMethod == "GET")) { FunctionNames = "HRManage"; Actions = "查詢"; } // 5 if ((PathDetails[2] == "Permissions" && URLMethod == "POST") || (PathDetails[2] == "FunctionNames" && URLMethod == "POST") || (PathDetails[2] == "Actions" && URLMethod == "POST") || (PathDetails[2] == "Roles" && URLMethod == "POST") || (PathDetails[2] == "Users" && URLMethod == "POST")) { FunctionNames = "HRManage"; Actions = "新增"; } // 5 if ((PathDetails[2] == "Permissions" && URLMethod == "PUT") || (PathDetails[2] == "FunctionNames" && URLMethod == "PUT") || (PathDetails[2] == "Actions" && URLMethod == "PUT") || (PathDetails[2] == "Roles" && URLMethod == "PUT") || (PathDetails[2] == "Users" && URLMethod == "PUT")) { FunctionNames = "HRManage"; Actions = "修改"; } // 5 if ((PathDetails[2] == "Permissions" && URLMethod == "DELETE") || (PathDetails[2] == "FunctionNames" && URLMethod == "DELETE") || (PathDetails[2] == "Actions" && URLMethod == "DELETE") || (PathDetails[2] == "Roles" && URLMethod == "DELETE") || (PathDetails[2] == "Users" && URLMethod == "DELETE")) { FunctionNames = "HRManage"; Actions = "刪除"; } #endregion //確認角色權限是否存在 if (!await PermissionsChecked(Role, FunctionNames, Actions, DBcontext)) { return(false); } return(true); }
public FunctionNamesRepository(CustomContext context) : base(context) { }
private async Task BackupSettingsNotConflictWithIdleSchedule(UpdateBackupSettingsCommand command, CustomContext context, CancellationToken cancellationToken) { var account = await _context.Set <Account>() .Include(x => x.IdleSchedules) .FirstOrDefaultAsync(x => x.Id == command.AccountId, cancellationToken); if (account == null || account.IsDeleted) { context.AddFailure("Accounts not found"); return; } var idleSchedules = account.IdleSchedules; var backupTimes = command.Times; foreach (var idleSchedule in idleSchedules) { var from = idleSchedule.StopAt; var to = from.AddHours(idleSchedule.ResumeAfter); foreach (var backupTime in backupTimes) { if (backupTime <= to && backupTime >= from) { context.AddFailure(new ValidationFailure("backupTimes", "Backup time has conflict with idle schedule", backupTime)); } } } }
internal static ValidationResult ExecuteChild <TChild>(this CustomContext context, TChild instance, Type validatorType) { var childValidator = context.ResolveValidator <TChild>(validatorType); return(ExecuteChild(context, instance, childValidator)); }
public RolePermissionsRepository(CustomContext context) : base(context) { }
/// <summary> /// Добавляет ошибку в контекст, если существуют другие сборки с таким номером и суффиксом. /// </summary> /// <param name="existedBuilds">Список существующих билдлов.</param> /// <param name="context"><see cref="CustomContext"/>.</param> /// <returns><see cref="Task"/>.</returns> protected void AddExistBuildsValidationFailure(IEnumerable <BuildReadModel> existedBuilds, CustomContext context) { var errorMessage = "Builds already exists. Exists builds: " + existedBuilds .Select(x => x.ToString()) .JoinWith(";"); context.AddFailure(new ValidationFailure(typeof(TEvent).Name, errorMessage) { ErrorCode = ValidatorErrorCodes.ExistSameBuild }); }
public static void Serialize(TestCustomContext t, IBinaryWriter writer, CustomContext context) { writer.Write(context.ValueOverride); }
private void P7BMustBeURL(Command command, CustomContext customContext) { MustBeURL(command.CRLs, "CRL", customContext); }
public ActionsRepository(CustomContext context) : base(context) { }
private void CRLMustBeURL(Command command, CustomContext customContext) { MustBeURL(command.P7Bs, "P7B", customContext); }
public static IValidatorFactory GetValidatorFactory(this CustomContext context) { return(GetValidatorFactory(context.ParentContext)); }
//===================================================================== /// <summary> /// This is used to write the document to its destination file /// </summary> private void WriteDocuments() { foreach (var kv in documentList.GetConsumingEnumerable()) { var document = kv.Value; // Set the evaluation context CustomContext context = new CustomContext(); context["key"] = kv.Key; XPathExpression xpath = pathExpression.Clone(); xpath.SetContext(context); // Evaluate the path string path = document.CreateNavigator().Evaluate(xpath).ToString(); if (basePath != null) { path = Path.Combine(basePath, path); } string targetDirectory = Path.GetDirectoryName(path); if (!Directory.Exists(targetDirectory)) { Directory.CreateDirectory(targetDirectory); } if (writeXhtmlNamespace) { document.DocumentElement.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml"); document.LoadXml(document.OuterXml); } // Save the document try { // selectExpression determines which nodes get saved. If there is no selectExpression we simply // save the root node as before. If there is a selectExpression, we evaluate the XPath expression // and save the resulting node set. The select expression also enables the "literal-text" processing // instruction, which outputs its content as unescaped text. if (selectExpression == null) { using (XmlWriter writer = XmlWriter.Create(path, settings)) { document.Save(writer); } } else { // IMPLEMENTATION NOTE: The separate StreamWriter is used to maintain XML indenting. Without it // the XmlWriter won't honor our indent settings after plain text nodes have been written. using (StreamWriter output = File.CreateText(path)) { using (XmlWriter writer = XmlWriter.Create(output, settings)) { XPathExpression selectXPath = selectExpression.Clone(); selectXPath.SetContext(context); XPathNodeIterator ni = document.CreateNavigator().Select(selectExpression); while (ni.MoveNext()) { if (ni.Current.NodeType == XPathNodeType.ProcessingInstruction && ni.Current.Name.Equals("literal-text")) { writer.Flush(); output.Write(ni.Current.Value); } else { ni.Current.WriteSubtree(writer); } } } } } // Raise an event to indicate that a file was created this.OnComponentEvent(new FileCreatedEventArgs(path, true)); } catch (IOException e) { this.WriteMessage(kv.Key, MessageLevel.Error, "An access error occurred while attempting to " + "save to the file '{0}'. The error message is '{1}'", path, e.GetExceptionMessage()); } catch (XmlException e) { this.WriteMessage(kv.Key, MessageLevel.Error, "Invalid XML was written to the output " + "file '{0}'. The error message is '{1}'", path, e.GetExceptionMessage()); } } }
static int Main (string[] args) { // Load source XML into an XPathDocument object instance. XPathDocument xmldoc = new XPathDocument ("books.xml"); // Create an XPathNavigator from the XPathDocument. XPathNavigator nav = xmldoc.CreateNavigator (); // The user-defined functions in this sample implement equivalents of the frequently-used // Left(string,length) and Right(string,length) Visual Basic string functions. // Compile two XPath query expressions that use the user-defined XPath functions and a user-defined variable. // The compilation step only checks the query expression for correct tokenization. It does not // try to resolve or to verify the definition or validity of the function and the variable names // that are used in the query expression. XPathExpression expr1 = nav.Compile ("myFuncs:left(string(.),$length)"); XPathExpression expr2 = nav.Compile ("myFuncs:right(string(.),$length)"); // Create an instance of an XsltArgumentList object. XsltArgumentList varList = new XsltArgumentList (); // Add the user-defined variable to the XsltArgumentList object, // and then supply a value for it. varList.AddParam ("length", "", 5); // Create an instance of a custom XsltContext object. This object is used to // resolve the references to the user-defined XPath extension functions and the // user-defined variable at execution time. // Notice that in the Ctor, you also pass in the XsltArgumentList object // in which the user-defined variable is defined. CustomContext cntxt = new CustomContext (new NameTable (), varList); // Add a namespace definition for the ns prefix that qualifies the user-defined // function names in the expr1 and expr2 query expressions. cntxt.AddNamespace ("myFuncs", "http://myXPathExtensionFunctions"); // Associate the custom XsltContext object with the two XPathExpression objects // whose query expressions use the custom XPath functions and the custom variable. expr1.SetContext (cntxt); expr2.SetContext (cntxt); XPathNodeIterator iter = nav.Select ("/Books/Title"); if (iter.Count != 2) { Console.WriteLine ("#1"); return 1; } iter.MoveNext (); nav = iter.Current; if (nav.Value != "A Brief History of Time") { Console.WriteLine ("#2: " + nav.Value); return 1; } if (((string) (nav.Evaluate (expr1))) != "A Bri") { Console.WriteLine ("#3: " + nav.Evaluate (expr1)); return 1; } if (((string) (nav.Evaluate (expr2))) != " Time") { Console.WriteLine ("#4: " + nav.Evaluate (expr2)); return 1; } iter.MoveNext (); nav = iter.Current; if (nav.Value != "Principle Of Relativity") { Console.WriteLine ("#5: " + nav.Value); return 1; } if (((string) (nav.Evaluate (expr1))) != "Princ") { Console.WriteLine ("#6: " + nav.Evaluate (expr1)); return 1; } if (((string) (nav.Evaluate (expr2))) != "ivity") { Console.WriteLine ("#7: " + nav.Evaluate (expr2)); return 1; } return 0; }
protected override string ExecuteCore() { var policyFilterCondition = GetPolicyFilter(_flights); //匹配政策 List <MatchedPolicy> matchedPolicies = Service.PolicyMatch.PolicyMatchServcie.MatchBunk(policyFilterCondition, false, _pnr.Passengers.First().Type, 10).ToList(); List <MatchedPolicy> matchedSpeciafPolicies = null; if ((_policyType & PolicyType.Special) != PolicyType.Special && (_policyType & PolicyType.Team) != PolicyType.Team) { policyFilterCondition = GetPolicyFilter(_flights, PolicyType.Special); matchedSpeciafPolicies = Service.PolicyMatch.PolicyMatchServcie.MatchBunk(policyFilterCondition, false, _pnr.Passengers.First().Type, 10).ToList(); if (!matchedPolicies.Any() && !matchedSpeciafPolicies.Any()) { throw new InterfaceInvokeException("9", "没有找到相关政策"); } } if (!matchedPolicies.Any()) { throw new InterfaceInvokeException("9", "没有找到相关政策"); } StringBuilder str = new StringBuilder(); str.Append("<policies>"); PNRImport.GetPolicy(matchedPolicies, matchedSpeciafPolicies, str, _policyType, _flights, InterfaceSetting); #region //if ((_policyType & PolicyType.Special) != PolicyType.Special) //{ // var list = from item in matchedPolicies // let generalPolicy = item.OriginalPolicy as IGeneralPolicy // let regulation = item.OriginalPolicy as IHasRegulation // select new // { // Id = item.Id, // Type = item.PolicyType == PolicyType.BargainDefault ? (int)PolicyType.Bargain : item.PolicyType == PolicyType.NormalDefault ? (int)PolicyType.Normal : (int)item.PolicyType, // Fare = item.ParValue.TrimInvaidZero(), // Rebate = (item.Commission * 100).TrimInvaidZero(), // Commission = (item.ParValue - item.SettleAmount).TrimInvaidZero(), // Amount = item.SettleAmount, // Ticket = (int)(item.OriginalPolicy == null ? TicketType.BSP : item.OriginalPolicy.TicketType), // EI = ReplaceEnter((regulation == null ? getEI(_flights) : getProvision(regulation))), // OfficeNo = item.OriginalPolicy == null && item.NeedAUTH ? item.OfficeNumber : (item.OriginalPolicy != null && item.OriginalPolicy.NeedAUTH ? item.OriginalPolicy.OfficeCode : ""), // Condition = item.OriginalPolicy == null ? "" : item.OriginalPolicy.Condition, // Confirm = item.ConfirmResource, // ChangePNR = generalPolicy == null ? false : generalPolicy.ChangePNR, // EtdzTime = getTimeRange(item.WorkStart, item.WorkEnd), // RefundTime = getTimeRange(item.WorkStart, item.WorkEnd), // ScrapTime = getTimeRange(item.RefundStart, item.RefundEnd), // EtdzSpeed = item.Speed == null ? 0 : item.Speed.ETDZ / 60, // RefundSpeed = item.Speed == null ? 0 : item.Speed.Refund / 60 // }; // foreach (var item in list) // { // str.Append("<policy>"); // str.AppendFormat("<id>{0}</id>", item.Id); // str.AppendFormat("<type>{0}</type>", item.Type); // str.AppendFormat("<fare>{0}</fare>", item.Fare); // str.AppendFormat("<rebate>{0}</rebate>", item.Rebate); // str.AppendFormat("<commission>{0}</commission>", item.Commission); // str.AppendFormat("<amount>{0}</amount>", item.Amount); // str.AppendFormat("<ticket>{0}</ticket>", item.Ticket); // str.AppendFormat("<ei>{0}</ei>", item.EI); // //需要授权的office号才有,否则为空字符 // str.AppendFormat("<officeNo>{0}</officeNo>", item.OfficeNo); // str.AppendFormat("<condition>{0}</condition>", item.Condition); // str.AppendFormat("<confirm>{0}</confirm>", item.Confirm); // str.AppendFormat("<changePNR>{0}</changePNR>", item.ChangePNR ? 1 : 0); // str.AppendFormat("<etdzTime>{0}</etdzTime>", item.EtdzTime); // str.AppendFormat("<refundTime>{0}</refundTime>", item.RefundTime); // str.AppendFormat("<scrapTime>{0}</scrapTime>", item.ScrapTime); // str.AppendFormat("<etdzSpeed>{0}</etdzSpeed>", item.EtdzSpeed); // str.Append("</policy>"); // } // if ((_policyType & PolicyType.Team) != PolicyType.Team) // { // var queryList = from item in matchedSpeciafPolicies // where item != null && item.OriginalPolicy != null // let specialPolicy = item.OriginalPolicy as SpecialPolicyInfo // let specialPolicyInfo = SpecialProductService.Query(specialPolicy.Type) // select new // { // Id = item.Id, // Type = (int)item.PolicyType, // Fare = item.ParValue.TrimInvaidZero(), // Rebate = (item.Commission * 100).TrimInvaidZero(), // Commission = (item.ParValue - item.SettleAmount).TrimInvaidZero(), // Amount = item.SettleAmount, // Ticket = (int)(item.OriginalPolicy == null ? TicketType.BSP : item.OriginalPolicy.TicketType), // EI = ReplaceEnter(getProvision(item.OriginalPolicy as IHasRegulation)), // OfficeNo = item.OriginalPolicy == null && item.NeedAUTH ? item.OfficeNumber : (item.OriginalPolicy != null && item.OriginalPolicy.NeedAUTH ? item.OriginalPolicy.OfficeCode : ""), // Condition = item.OriginalPolicy == null ? "" : item.OriginalPolicy.Condition, // Confirm = item.ConfirmResource, // ChangePNR = "0", // EtdzTime = getTimeRange(item.WorkStart, item.WorkEnd), // RefundTime = getTimeRange(item.WorkStart, item.WorkEnd), // ScrapTime = getTimeRange(item.RefundStart, item.RefundEnd), // EtdzSpeed = item.Speed == null ? 0 : item.Speed.ETDZ / 60, // RefundSpeed = item.Speed == null ? 0 : item.Speed.Refund / 60 // }; // foreach (var item in queryList) // { // str.Append("<policy>"); // str.AppendFormat("<id>{0}</id>", item.Id); // str.AppendFormat("<type>{0}</type>", item.Type); // str.AppendFormat("<fare>{0}</fare>", item.Fare); // str.AppendFormat("<rebate>{0}</rebate>", item.Rebate); // str.AppendFormat("<commission>{0}</commission>", item.Commission); // str.AppendFormat("<amount>{0}</amount>", item.Amount); // str.AppendFormat("<ticket>{0}</ticket>", item.Ticket); // str.AppendFormat("<ei>{0}</ei>", item.EI); // //需要授权的office号才有,否则为空字符 // str.AppendFormat("<officeNo>{0}</officeNo>", item.OfficeNo); // str.AppendFormat("<condition>{0}</condition>", item.Condition); // str.AppendFormat("<confirm>{0}</confirm>", item.Confirm); // str.AppendFormat("<changePNR>{0}</changePNR>", item.ChangePNR); // str.AppendFormat("<etdzTime>{0}</etdzTime>", item.EtdzTime); // str.AppendFormat("<refundTime>{0}</refundTime>", item.RefundTime); // str.AppendFormat("<scrapTime>{0}</scrapTime>", item.ScrapTime); // str.AppendFormat("<etdzSpeed>{0}</etdzSpeed>", item.EtdzSpeed); // str.Append("</policy>"); // } // foreach (var item in matchedSpeciafPolicies) // { // if (!matchedPolicies.Contains(item)) // { // matchedPolicies.Add(item); // } // } // } //} //else //{ // var queryList = from item in matchedPolicies // let specialPolicy = item.OriginalPolicy as SpecialPolicyInfo // let specialPolicyInfo = SpecialProductService.Query(specialPolicy.Type) // where item != null && item.OriginalPolicy != null && !specialPolicy.ConfirmResource // select new // { // Id = item.Id, // Type = (int)item.PolicyType, // Fare = item.ParValue.TrimInvaidZero(), // Rebate = (item.Commission * 100).TrimInvaidZero(), // Commission = 0, // Amount = item.SettleAmount, // Ticket = (int)(item.OriginalPolicy == null ? TicketType.BSP : item.OriginalPolicy.TicketType), // EI = ReplaceEnter(getProvision(item.OriginalPolicy as IHasRegulation)), // OfficeNo = item.OriginalPolicy == null && item.NeedAUTH ? item.OfficeNumber : (item.OriginalPolicy != null && item.OriginalPolicy.NeedAUTH ? item.OriginalPolicy.OfficeCode : ""), // Condition = item.OriginalPolicy == null ? "" : item.OriginalPolicy.Condition, // Confirm = item.ConfirmResource, // ChangePNR = "0", // EtdzTime = getTimeRange(item.WorkStart, item.WorkEnd), // RefundTime = getTimeRange(item.WorkStart, item.WorkEnd), // ScrapTime = getTimeRange(item.RefundStart, item.RefundEnd), // EtdzSpeed = item.Speed == null ? 0 : item.Speed.ETDZ / 60, // RefundSpeed = item.Speed == null ? 0 : item.Speed.Refund / 60, // OrganizaPolicy = item.OriginalPolicy // }; // foreach (var item in queryList) // { // str.Append("<policy>"); // str.AppendFormat("<id>{0}</id>", item.Id); // str.AppendFormat("<type>{0}</type>", item.Type); // str.AppendFormat("<fare>{0}</fare>", item.Fare); // str.AppendFormat("<rebate>{0}</rebate>", item.Rebate); // str.AppendFormat("<commission>{0}</commission>", item.Commission); // str.AppendFormat("<amount>{0}</amount>", item.Amount); // str.AppendFormat("<ticket>{0}</ticket>", item.Ticket); // str.AppendFormat("<ei>{0}</ei>", item.EI); // //需要授权的office号才有,否则为空字符 // str.AppendFormat("<officeNo>{0}</officeNo>", item.OfficeNo); // str.AppendFormat("<condition>{0}</condition>", item.Condition); // str.AppendFormat("<confirm>{0}</confirm>", item.Confirm); // str.AppendFormat("<changePNR>{0}</changePNR>", item.ChangePNR); // str.AppendFormat("<etdzTime>{0}</etdzTime>", item.EtdzTime); // str.AppendFormat("<refundTime>{0}</refundTime>", item.RefundTime); // str.AppendFormat("<scrapTime>{0}</scrapTime>", item.ScrapTime); // str.AppendFormat("<etdzSpeed>{0}</etdzSpeed>", item.EtdzSpeed); // str.Append("</policy>"); // } //} #endregion str.Append("</policies>"); //将匹配出来的政策存入缓存中 CustomContext context = CustomContext.NewContext(); context[_pnr.PnrPair.BPNR + _pnr.PnrPair.PNR] = matchedPolicies; ContextCenter.Instance.Save(context); str.AppendFormat("<batchNo>{0}</batchNo>", context.Id + "1"); return(str.ToString()); }
//===================================================================== /// <inheritdoc /> public override void Initialize(XPathNavigator configuration) { // Get the context. This will contain namespaces that prefix the elements to find. context = new CustomContext(); XPathNodeIterator contextNodes = configuration.Select("context"); foreach(XPathNavigator cn in contextNodes) context.AddNamespace(cn.GetAttribute("prefix", String.Empty), cn.GetAttribute("name", String.Empty)); // Item keys are compared case-insensitively content = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); elements = new List<SharedContentElement>(); // Get the elements to be resolved XPathNodeIterator resolve_nodes = configuration.Select("replace"); foreach(XPathNavigator resolve_node in resolve_nodes) { // Get the XPath expression used to find the elements to replace string path = resolve_node.GetAttribute("elements", String.Empty); // If not defined, assume include and includeAttribute are to be replaced if(String.IsNullOrEmpty(path)) path = "//include | //includeAttribute"; try { XPathExpression path_expresion = XPathExpression.Compile(path, context); } catch(XPathException) { base.WriteMessage(MessageLevel.Error, "The elements expression '{0}' is not a valid XPath", path); } // Get the XPath expression used to get the item name to insert string item = resolve_node.GetAttribute("item", String.Empty); if(String.IsNullOrEmpty(item)) item = "string(@item)"; try { XPathExpression item_expression = XPathExpression.Compile(item, context); } catch(XPathException) { base.WriteMessage(MessageLevel.Error, "The item expression '{0}' is not a valid XPath", item); } // Get the XPath expression used to find parameter elements string parameters = resolve_node.GetAttribute("parameters", String.Empty); if(String.IsNullOrEmpty(parameters)) parameters = "parameter"; // Get the XPath expression used to get the attribute name for attribute items string attribute = resolve_node.GetAttribute("attribute", String.Empty); if(String.IsNullOrEmpty(attribute)) attribute = "string(@name)"; elements.Add(new SharedContentElement(path, item, parameters, attribute, context)); } // If not defined, assume include and includeAttribute are to be replaced using the default names if(elements.Count == 0) elements.Add(new SharedContentElement("//include | //includeAttribute", "string(@item)", "parameter", "string(@name)", context)); // Load the content item files XPathNodeIterator content_nodes = configuration.Select("content"); foreach(XPathNavigator content_node in content_nodes) { string sharedContentFiles = content_node.GetAttribute("file", String.Empty); if(String.IsNullOrEmpty(sharedContentFiles)) base.WriteMessage(MessageLevel.Error, "The content/@file attribute must specify a path."); this.ParseDocuments(sharedContentFiles); } base.WriteMessage(MessageLevel.Info, "Loaded {0} shared content items.", content.Count); }
void PaymentResponseFinder(PaymentLog PaymentLog, out bool ResponseReceived, out string Message, string assessmentType) { int retry = 50; PaymentStatus paymentStatus = null; ResponseReceived = false; Message = string.Empty; int counter = -50; string responsePath = assessmentType == "Excise" ? _dutyConfig.ExciseResponsePath : @"C:\tosser\inout\eresponse"; do { var all = Directory.GetFiles(responsePath); if (all.Any()) { foreach (string filename in all) { string readFile = System.IO.File.ReadAllText(filename); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(readFile); var transactionStatusDetails = xmlDoc.SelectNodes("TransactionResponse"); using (CustomContext cust = new CustomContext()) { foreach (XmlNode node in transactionStatusDetails) { if (readFile.Contains("PayExcise")) { paymentStatus = new PaymentStatus { CustomsCode = node["CustomsCode"].InnerText, CompanyCode = node["CompanyCode"].InnerText, AssessmentSerial = node["Asmt"]["AssessmentSerial"].InnerText, AssessmentNumber = node["Asmt"]["AssessmentNumber"].InnerText, Year = node["Asmt"]["SADYear"].InnerText, Status = node["TransactionStatus"].InnerText, Message = node["Info"]["Message"].InnerText, DateCreated = DateTime.Now, PaymentLogId = PaymentLog.Id }; } else { paymentStatus = new PaymentStatus { CustomsCode = node["CustomsCode"].InnerText, DeclarantCode = node["DeclarantCode"].InnerText, AssessmentSerial = node["SadAsmt"]["SADAssessmentSerial"].InnerText, AssessmentNumber = node["SadAsmt"]["SADAssessmentNumber"].InnerText, Year = node["SadAsmt"]["SADYear"].InnerText, Status = node["TransactionStatus"].InnerText, Message = node["Info"]["Message"].InnerText, DateCreated = DateTime.Now, PaymentLogId = PaymentLog.Id }; } cust.PaymentStatus.Add(paymentStatus); int saveOne = cust.SaveChanges(); if (saveOne == 1) { Task.Run(() => CreditTillAccount(PaymentLog.Amount, _dutyConfig.SuspenseAccount, PaymentLog.PaymentReference)); // retry = 0; counter = 0; ResponseReceived = (counter == 0); Message = paymentStatus.Message; cleaner.DeleteFile(assessmentType == "Excise" ? _dutyConfig.ExciseResponsePath : @"C:\tosser\inout\eresponse"); Log.Information("Updation transaction status"); PaymentLog.StatusId = (int)TransactionStatus.Completed; PaymentLog.TransactionStatusId = (int)TransactionStatus.Completed; _context.Update(PaymentLog); _context.SaveChanges(); //return Ok(new { Status = HttpStatusCode.OK, Message = $"Transaction completed: NCS Message - {paymentStatus?.Message}" }); } } } } } counter = (counter == 0 ? counter : counter += 1); retry = counter; }while (retry != 0); }
private void Then_shared_value_is_passed_to_second_step_and_still_match_5(CustomContext ctx) { Assert.That(ctx.Shared, Is.EqualTo(5)); }
public PaymentController(ICustomDutyClient client, DutyConfig dutyConfig, CustomContext context) { _client = client; _dutyConfig = dutyConfig; _context = context; }
//===================================================================== /// <inheritdoc /> public override void Initialize(XPathNavigator configuration) { MessageLevel level; bool isAttribute, ignoreCase; // Set up the context this.Context = new CustomContext(); XPathNodeIterator contextNodes = configuration.Select("context"); foreach(XPathNavigator contextNode in contextNodes) this.Context.AddNamespace(contextNode.GetAttribute("prefix", String.Empty), contextNode.GetAttribute("name", String.Empty)); // Set up the indices XPathNodeIterator indexNodes = configuration.Select("index"); foreach(XPathNavigator indexNode in indexNodes) { // Create the index IndexedCache index = this.CreateIndex(indexNode); #if DEBUG base.WriteMessage(MessageLevel.Diagnostic, "Loading {0} index", index.Name); DateTime startLoad = DateTime.Now; #endif // Search the data directories for entries XPathNodeIterator dataNodes = indexNode.Select("data"); foreach(XPathNavigator dataNode in dataNodes) index.AddDocuments(dataNode); // Getting the count from a database cache can be expensive so only report it if it will be seen if(base.BuildAssembler.VerbosityLevel == MessageLevel.Info) base.WriteMessage(MessageLevel.Info, "Indexed {0} elements", index.Count); #if DEBUG TimeSpan loadTime = (DateTime.Now - startLoad); base.WriteMessage(MessageLevel.Diagnostic, "Load time: {0} seconds", loadTime.TotalSeconds); #endif BuildComponentCore.Data.Add(index.Name, index); } // Get the copy commands XPathNodeIterator copyNodes = configuration.Select("copy"); foreach(XPathNavigator copyNode in copyNodes) { string sourceName = copyNode.GetAttribute("name", String.Empty); if(String.IsNullOrWhiteSpace(sourceName)) base.WriteMessage(MessageLevel.Error, "Each copy command must specify an index to copy from"); string keyXPath = copyNode.GetAttribute("key", String.Empty); if(String.IsNullOrWhiteSpace(keyXPath)) keyXPath = "string($key)"; string sourceXPath = copyNode.GetAttribute("source", String.Empty); if(String.IsNullOrWhiteSpace(sourceXPath)) base.WriteMessage(MessageLevel.Error, "When instantiating a CopyFromIndex component, you " + "must specify a source XPath format using the source attribute"); string targetXPath = copyNode.GetAttribute("target", String.Empty); if(String.IsNullOrWhiteSpace(targetXPath)) base.WriteMessage(MessageLevel.Error, "When instantiating a CopyFromIndex component, you " + "must specify a target XPath format using the target attribute"); isAttribute = ignoreCase = false; string boolValue = copyNode.GetAttribute("attribute", String.Empty); if(!String.IsNullOrWhiteSpace(boolValue) && !Boolean.TryParse(boolValue, out isAttribute)) base.WriteMessage(MessageLevel.Error, "The 'attribute' attribute value is not a valid Boolean"); boolValue = copyNode.GetAttribute("ignoreCase", String.Empty); if(!String.IsNullOrWhiteSpace(boolValue) && !Boolean.TryParse(boolValue, out ignoreCase)) base.WriteMessage(MessageLevel.Error, "The ignoreCase attribute value is not a valid Boolean"); IndexedCache index = (IndexedCache)BuildComponentCore.Data[sourceName]; CopyFromIndexCommand copyCommand = new CopyFromIndexCommand(this, index, keyXPath, sourceXPath, targetXPath, isAttribute, ignoreCase); string messageLevel = copyNode.GetAttribute("missing-entry", String.Empty); if(!String.IsNullOrWhiteSpace(messageLevel)) if(Enum.TryParse<MessageLevel>(messageLevel, true, out level)) copyCommand.MissingEntry = level; else base.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel); messageLevel = copyNode.GetAttribute("missing-source", String.Empty); if(!String.IsNullOrWhiteSpace(messageLevel)) if(Enum.TryParse<MessageLevel>(messageLevel, true, out level)) copyCommand.MissingSource = level; else base.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel); messageLevel = copyNode.GetAttribute("missing-target", String.Empty); if(!String.IsNullOrWhiteSpace(messageLevel)) if(Enum.TryParse<MessageLevel>(messageLevel, true, out level)) copyCommand.MissingTarget = level; else base.WriteMessage(MessageLevel.Error, "'{0}' is not a message level.", messageLevel); copyCommands.Add(copyCommand); } XPathNodeIterator componentNodes = configuration.Select("components/component"); foreach(XPathNavigator componentNode in componentNodes) { // Get the ID of the copy component string id = componentNode.GetAttribute("id", String.Empty); if(String.IsNullOrWhiteSpace(id)) base.WriteMessage(MessageLevel.Error, "Each copy component element must have an id attribute"); var copyComponentFactory = copyComponentFactories.FirstOrDefault(g => g.Metadata.Id == id); if(copyComponentFactory == null) base.WriteMessage(MessageLevel.Error, "A copy component with the ID '{0}' could not be found", id); try { var copyComponent = copyComponentFactory.Value.Create(this); copyComponent.Initialize(componentNode.Clone(), BuildComponentCore.Data); components.Add(copyComponent); } catch(Exception ex) { base.WriteMessage(MessageLevel.Error, "An error occurred while attempting to instantiate " + "the '{0}' copy component. The error message is: {1}{2}", id, ex.Message, ex.InnerException != null ? "\r\n" + ex.InnerException.Message : String.Empty); } } if(components.Count != 0) base.WriteMessage(MessageLevel.Info, "Loaded {0} copy components", components.Count); }
private static void CreateFailuresInContext(IEnumerable <ValidationErrorDetail> errs, CustomContext context) { foreach (var error in errs) { context.AddFailure(error.Field, error.ErrorMessage); } }