public bool IsAllowed(Nop nop) { Type t2 = nop.GetType(); foreach (Type t in _Types) if (t == t2) return true; return false; }
public static Instruction CreateInstance(string instruction) { Instruction instance; var parts = instruction.Split(' '); var op = parts[0]; var val = int.Parse(parts[1]); switch (op) { case "nop": instance = new Nop(); break; case "acc": instance = new Acc(val); break; case "jmp": instance = new Jmp(val); break; default: throw new ArgumentException($"Unknown operation {op}"); } return(instance); }
private void PrepareCategoryMapping(Nop.Plugin.Misc.MultipleParents.Models.CategoryModel model) { if (model == null) throw new ArgumentNullException("model"); model.NumberOfAvailableCategories = _categoryService.GetAllCategories(true).Count; }
public CategoryController(ICategoryService categoryService, IPermissionService permissionService, Nop.Admin.Controllers.CategoryController categoryController, ILocalizationService localizationService) { this._categoryService = categoryService as CategoryServiceExt; this._permissionService = permissionService; this._localizationService = localizationService; this._categoryController = categoryController; }
protected internal override Statement VisitNop(Nop inst) { var stmt = new EmptyStatement(); if (inst.Comment != null) { stmt.AddChild(new Comment(inst.Comment), Roles.Comment); } return(stmt); }
public bool IsAllowed(Nop nop) { Type t2 = nop.GetType(); foreach (Type t in _Types) { if (t == t2) { return(true); } } return(false); }
private async Task Demo02_Nop() { Console.WriteLine(nameof(Demo02_Nop)); var testfile = "test.jpg"; var source = GetSourcePath(testfile); var target = GetTargetFilename(source); var fileSource = new FileSource(source); var nop = new Nop(); var fileWriter = new FileWriter(target); fileSource.Connect(nop); nop.Connect(fileWriter); await fileSource.Start(); AssertFilesAreEqual(source, target); }
public void Test_Code() { var c0 = Operand; Assert.False(c0.opcode.IsValid()); Assert.AreEqual(null, c0.operand); Assert.AreEqual(null, c0.name); var c1 = Nop; Assert.AreEqual(OpCodes.Nop, c1.opcode); Assert.AreEqual(null, c1.operand); Assert.AreEqual(null, c1.name); var c2 = Nop["test"]; Assert.AreEqual(OpCodes.Nop, c2.opcode); Assert.AreEqual("test", c2.operand); Assert.AreEqual(null, c2.name); var c3 = Nop[name : "test"]; Assert.AreEqual(OpCodes.Nop, c3.opcode); Assert.AreEqual(null, c3.operand); Assert.AreEqual("test", c3.name); var c4 = Nop[typeof(void), "test2"]; Assert.AreEqual(OpCodes.Nop, c4.opcode); Assert.AreEqual(typeof(void), c4.operand); Assert.AreEqual("test2", c4.name); var c5 = Nop[123][name : "test"]; Assert.AreEqual(OpCodes.Nop, c5.opcode); Assert.AreEqual(123, c5.operand); Assert.AreEqual("test", c5.name); var label = new Label(); var c6 = Nop.WithLabels(label); Assert.AreEqual(1, c6.labels.Count); Assert.AreEqual(label, c6.labels[0]);
public int HealBootSeqAndGetAccumulatorOnSuccesfulExecution() { var jumpAndNopInstructions = _instructions.Where(i => i is Jmp || i is Nop).ToList(); foreach (var jumpOrNop in jumpAndNopInstructions) { var instructionSet = _instructions.ToList(); instructionSet.ForEach(i => i.Executed = false); var index = instructionSet.IndexOf(jumpOrNop); var acc = new Nop(); instructionSet[index] = acc; var executor = new Executor(instructionSet); var exited = executor.Run(); if (exited) { return(executor.Accumulator); } } throw new Exception("Couldn't heal boot sequence"); }
//This function actually creates the object associated with each Instruction by using a long switch statement. The object //created is polymorphed up to an IInstruction and then returned from the function to be stored in the encodedInstrs list. //Ugly? Very. Effective? Extremely. private IInstruction createObject(string comm, int valToUse, int currentInstruc) { IInstruction retVal = null; switch (comm) { case "exit": retVal = new Exit(valToUse) as IInstruction; break; case "swap": retVal = new Swap() as IInstruction; break; case "inpt": retVal = new Inpt() as IInstruction; break; case "nop": retVal = new Nop() as IInstruction; break; case "pop": retVal = new Pop() as IInstruction; break; case "add": retVal = new Add() as IInstruction; break; case "sub": retVal = new Sub() as IInstruction; break; case "mul": retVal = new Mul() as IInstruction; break; case "div": retVal = new Div() as IInstruction; break; case "rem": retVal = new Rem() as IInstruction; break; case "and": retVal = new And() as IInstruction; break; case "or": retVal = new Or() as IInstruction; break; case "xor": retVal = new Xor() as IInstruction; break; case "neg": retVal = new Neg() as IInstruction; break; case "not": retVal = new Not() as IInstruction; break; case "goto": retVal = new Goto(valToUse) as IInstruction; break; case "ifeq": retVal = new If1(0, valToUse, currentInstruc) as IInstruction; break; case "ifne": retVal = new If1(1, valToUse, currentInstruc) as IInstruction; break; case "iflt": retVal = new If1(2, valToUse, currentInstruc) as IInstruction; break; case "ifgt": retVal = new If1(3, valToUse, currentInstruc) as IInstruction; break; case "ifle": retVal = new If1(4, valToUse, currentInstruc) as IInstruction; break; case "ifge": retVal = new If1(5, valToUse, currentInstruc) as IInstruction; break; case "ifez": retVal = new If2(0, valToUse, currentInstruc) as IInstruction; break; case "ifnz": retVal = new If2(1, valToUse, currentInstruc) as IInstruction; break; case "ifmi": retVal = new If2(2, valToUse, currentInstruc) as IInstruction; break; case "ifpl": retVal = new If2(3, valToUse, currentInstruc) as IInstruction; break; case "dup": retVal = new Dup(valToUse) as IInstruction; break; case "print": retVal = new Print() as IInstruction; break; case "dump": retVal = new Dump() as IInstruction; break; case "push": retVal = new Push(valToUse) as IInstruction; break; } return(retVal); }
public override void VisitNop(Nop nop) { IL.Emit(OpCodes.Nop); }
public ProductsController(Nop.Services.Catalog.IProductService productService, IProductTemplateService productTemplateService, ICategoryService categoryService, IManufacturerService manufacturerService, ICustomerService customerService, IUrlRecordService urlRecordService, IWorkContext workContext, ILanguageService languageService, ILocalizationService localizationService, ILocalizedEntityService localizedEntityService, Nop.Services.Catalog.ISpecificationAttributeService specificationAttributeService, IPictureService pictureService, ITaxCategoryService taxCategoryService, IProductTagService productTagService, ICopyProductService copyProductService, IPdfService pdfService, IExportManager exportManager, IImportManager importManager, ICustomerActivityService customerActivityService, IPermissionService permissionService, IAclService aclService, IStoreService storeService, IOrderService orderService, IStoreMappingService storeMappingService, IMultitenantService vendorService, IShippingService shippingService, IShipmentService shipmentService, ICurrencyService currencyService, CurrencySettings currencySettings, IMeasureService measureService, MeasureSettings measureSettings, AdminAreaSettings adminAreaSettings, IDateTimeHelper dateTimeHelper, IDiscountService discountService, IProductAttributeService productAttributeService, IBackInStockSubscriptionService backInStockSubscriptionService, IShoppingCartService shoppingCartService, IProductAttributeFormatter productAttributeFormatter, IProductAttributeParser productAttributeParser, IDownloadService downloadService, IRepository<GroupDeal> groupDealRepo, IGenericAttributeService genericAttributeService, IGroupDealService groupDealService) { _categories = new System.Collections.Generic.List<DTOs.Category>(); this._productService = productService; this._productTemplateService = productTemplateService; this._categoryService = categoryService; this._manufacturerService = manufacturerService; this._customerService = customerService; this._urlRecordService = urlRecordService; this._workContext = workContext; this._languageService = languageService; this._localizationService = localizationService; this._localizedEntityService = localizedEntityService; this._specificationAttributeService = specificationAttributeService; this._pictureService = pictureService; this._taxCategoryService = taxCategoryService; this._productTagService = productTagService; this._copyProductService = copyProductService; this._pdfService = pdfService; this._exportManager = exportManager; this._importManager = importManager; this._customerActivityService = customerActivityService; this._permissionService = permissionService; this._aclService = aclService; this._storeService = storeService; this._orderService = orderService; this._storeMappingService = storeMappingService; this._vendorService = vendorService; this._shippingService = shippingService; this._shipmentService = shipmentService; this._currencyService = currencyService; this._currencySettings = currencySettings; this._measureService = measureService; this._measureSettings = measureSettings; this._adminAreaSettings = adminAreaSettings; this._dateTimeHelper = dateTimeHelper; this._discountService = discountService; this._productAttributeService = productAttributeService; this._backInStockSubscriptionService = backInStockSubscriptionService; this._shoppingCartService = shoppingCartService; this._productAttributeFormatter = productAttributeFormatter; this._productAttributeParser = productAttributeParser; this._downloadService = downloadService; this._groupDealRepo = groupDealRepo; this._genericAttributeService = genericAttributeService; this._groupDealService = groupDealService; }
public Mnemonic Get(ASTNode?node) { Mnemonic result = null; var symbol = node.Value.Symbol.Name; switch (symbol) { case "assigment": result = new Assigment(node, this); break; case "expression": result = new Expression(node, this); break; case "expression_arg": case "expression_sum": case "expression_mult": case "expression_cmp": case "expression_bracket": case "expression_bool": result = new ExpressionCommon(node, this); break; case "expression_prefix": result = new ExpressionPrefix(node, this); break; case "NUMBER": result = new ValueNumber(node); break; case "STRING": result = new ValueString(node); break; case "method_call": result = new MethodCall(node, this); break; case "emptyLine": result = new Nop(node); break; case "variable_name": result = new VariableName(node, this); break; case "if": result = new If(node, this); break; case "block_of_lopla": result = new Block(node, this); break; case "method": result = new MethodDeclaration(node, this); break; case "declare_table": result = new DeclareTable(node, this); break; case "var_value_table": result = new ValueTable(node, this); break; case "while": result = new While(node, this); break; case "return": result = new Return(node, this); break; default: AddError( new CompilationError($"{symbol} not handled by compiler. line: {node?.Position.Line}")); break; } return(result); }
public ActionResult ProductList(DataSourceRequest command, Nop.Plugin.Tameion.SelectAndSell.ViewModels.ProductListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) // return AccessDeniedView(); //a vendor should have access only to his products if (_workContext.CurrentVendor != null) { model.SearchVendorId = _workContext.CurrentVendor.Id; } var categoryIds = new List<int> { model.SearchCategoryId }; //include subcategories if (model.SearchIncludeSubCategories && model.SearchCategoryId > 0) categoryIds.AddRange(GetChildCategoryIds(model.SearchCategoryId)); //0 - all (according to "ShowHidden" parameter) //1 - published only //2 - unpublished only bool? overridePublished = null; if (model.SearchPublishedId == 1) overridePublished = true; else if (model.SearchPublishedId == 2) overridePublished = false; var products = _productService.SearchProducts( categoryIds: categoryIds, manufacturerId: model.SearchManufacturerId, storeId: model.SearchStoreId, vendorId: model.SearchVendorId, warehouseId: model.SearchWarehouseId, productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null, keywords: model.SearchProductName, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true, overridePublished: overridePublished ); var gridModel = new DataSourceResult(); gridModel.Data = products.Select(x => { var productModel = x.ToModel(); //little hack here: //ensure that product full descriptions are not returned //otherwise, we can get the following error if products have too long descriptions: //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. " //also it improves performance productModel.FullDescription = ""; //picture var defaultProductPicture = _pictureService.GetPicturesByProductId(x.Id, 1).FirstOrDefault(); productModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true); //product type productModel.ProductTypeName = x.ProductType.GetLocalizedEnum(_localizationService, _workContext); //friendly stock qantity //if a simple product AND "manage inventory" is "Track inventory", then display if (x.ProductType == ProductType.SimpleProduct && x.ManageInventoryMethod == ManageInventoryMethod.ManageStock) productModel.StockQuantityStr = x.GetTotalStockQuantity().ToString(); return productModel; }); gridModel.Total = products.TotalCount; return Json(gridModel); }
public ActionResult Resources(int languageId, DataSourceRequest command, Nop.Web.Framework.Kendoui.Filter filter = null, IEnumerable<Sort> sort = null) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageLanguages)) return AccessDeniedView(); var language = _languageService.GetLanguageById(languageId); var resources = _localizationService .GetAllResourceValues(languageId) .OrderBy(x => x.Key) .Select(x => new LanguageResourceModel { LanguageId = languageId, LanguageName = language.Name, Id = x.Value.Key, Name = x.Key, Value = x.Value.Value, }) .AsQueryable() .Filter(filter) .Sort(sort); var gridModel = new DataSourceResult { Data = resources.PagedForCommand(command), Total = resources.Count() }; return Json(gridModel); }
public ActionResult Edit(Nop.Admin.Models.Catalog.CategoryModel model, bool continueEditing) { return _categoryController.Edit(model, continueEditing); }
public ActionResult Create(Nop.Admin.Models.Catalog.CategoryModel model, bool continueEditing) { var result = _categoryController.Create(model, continueEditing); int newCategoryId = _categoryService.GetAllCategories(true) .Where(c => c.Name == model.Name) .Select(c => c.Id).OrderByDescending(i => i) .FirstOrDefault(); if (newCategoryId > 0) { // add default category category mapping (root) _categoryService.InsertCategoryCategory( new CategoryCategory() { ParentCategoryId = null, ChildCategoryId = newCategoryId, DisplayOrder = 0 } ); } return result; }
public ActionResult Configure(Nop.Plugin.Misc.AUConsignor.Domain.AUConfigurationRecord model) { if (!ModelState.IsValid) return Configure(); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var AUConsignorSettings = _settings.LoadSetting<Nop.Plugin.Misc.AUConsignor.Domain.AUConsignorSettings>(storeScope); //save settings AUConsignorSettings.AllowStoreProductInquiries = model.AllowStoreProductInquiries; // AUConsignorSettings.StoreIsAuctionSite = model.StoreIsAuctionSite; *DEPRECATE* AUConsignorSettings.StoreTypeId = model.StoreTypeId; //purchaseOrderPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage; //purchaseOrderPaymentSettings.ShippableProductRequired = model.ShippableProductRequired; /* We do not clear cache after each setting update. * This behavior can increase performance because cached settings will not be cleared * and loaded from database after each update */ if (model.AllowStoreProductInquiries_OverrideForStore || storeScope == 0) _settings.SaveSetting(AUConsignorSettings, x => x.AllowStoreProductInquiries, storeScope, false); else if (storeScope > 0) _settings.DeleteSetting(AUConsignorSettings, x => x.AllowStoreProductInquiries, storeScope); // *DEPRECATE* //if (model.StoreIsAuctionSite_OverrideForStore || storeScope == 0) // _settings.SaveSetting(AUConsignorSettings, x => x.StoreIsAuctionSite, storeScope, false); //else if (storeScope > 0) // _settings.DeleteSetting(AUConsignorSettings, x => x.StoreIsAuctionSite, storeScope); if (model.StoreTypeId_OverrideForStore || storeScope == 0) _settings.SaveSetting(AUConsignorSettings, x => x.StoreTypeId, storeScope, false); else if (storeScope > 0) _settings.DeleteSetting(AUConsignorSettings, x => x.StoreTypeId, storeScope); //if (model.AdditionalFeePercentage_OverrideForStore || storeScope == 0) // _settingService.SaveSetting(purchaseOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope, false); //else if (storeScope > 0) // _settingService.DeleteSetting(purchaseOrderPaymentSettings, x => x.AdditionalFeePercentage, storeScope); //if (model.ShippableProductRequired_OverrideForStore || storeScope == 0) // _settingService.SaveSetting(purchaseOrderPaymentSettings, x => x.ShippableProductRequired, storeScope, false); //else if (storeScope > 0) // _settingService.DeleteSetting(purchaseOrderPaymentSettings, x => x.ShippableProductRequired, storeScope); //now clear settings cache _settings.ClearCache(); SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved")); return Configure(); }
public ActionResult GoToSku(Nop.Plugin.Tameion.SelectAndSell.ViewModels.ProductListModel model) { string sku = model.GoDirectlyToSku; //try to load a product entity var product = _productService.GetProductBySku(sku); //if not found, then try to load a product attribute combination if (product == null) { var combination = _productAttributeService.GetProductAttributeCombinationBySku(sku); if (combination != null) { product = combination.Product; } } if (product != null) return RedirectToAction("Edit", "Product", new { id = product.Id }); //not found return List(); }
public ActionResult ProductList(DataSourceRequest command, Nop.Admin.Models.Catalog.ProductListModel model) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) // return AccessDeniedView(); //a vendor should have access only to his products if (_workContext.CurrentVendor != null) { model.SearchVendorId = _workContext.CurrentVendor.Id; } var categoryIds = new List<int> { model.SearchCategoryId }; //include subcategories if (model.SearchIncludeSubCategories && model.SearchCategoryId > 0) categoryIds.AddRange(GetChildCategoryIds(model.SearchCategoryId)); //0 - all (according to "ShowHidden" parameter) //1 - published only //2 - unpublished only bool? overridePublished = null; if (model.SearchPublishedId == 1) overridePublished = true; else if (model.SearchPublishedId == 2) overridePublished = false; var products = _productService.SearchProducts( categoryIds: categoryIds, manufacturerId: model.SearchManufacturerId, storeId: model.SearchStoreId, //vendorId: model.SearchVendorId, warehouseId: model.SearchWarehouseId, productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null, keywords: model.SearchProductName, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true, overridePublished: overridePublished ); var gridModel = new DataSourceResult(); gridModel.Data = products.Select(x => { var productModel = new ModelsMapper().CreateMap<Product, ProducttModel>(x); //little hack here: //ensure that product full descriptions are not returned //otherwise, we can get the following error if products have too long descriptions: //"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property. " //also it improves performance var myStore = x.getStores().SingleOrDefault(s => s.Id == _workContext.CurrentVendor.getStore().Id); if (productModel.LimitedToStores && myStore != null) { productModel.AddToMyStore = true; } else { productModel.AddToMyStore = false; } //picture var defaultProductPicture = _pictureService.GetPicturesByProductId(x.Id, 1).FirstOrDefault(); productModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true); //product type productModel.ProductTypeName = x.ProductType.GetLocalizedEnum(_localizationService, _workContext); return productModel; }); gridModel.Total = products.TotalCount; return Json(gridModel); }
public bool IsAllowed(Nop nop) { return _Type.IsAssignableFrom(nop.GetType()); }
protected Object(Nop nop) { }
Stmt ParseStmt(bool in_dec = false) { Sequence result = new Sequence(); Stmt stmt = new Nop(); bool breaked = false; if (Index == Tokens.Count) { // Already got EOF? throw new RPExeption(20, App.Current.TryFindResource("x_nexpend").ToString(), Line, Column); } while (Index < Tokens.Count && !breaked) { switch (Config.In(Tokens[Index]).Name) { case "Forward": Index++; var stmtForward = new Forward(); stmtForward.Expression = ParseExpr(); stmt = stmtForward; break; case "Backward": Index++; var stmtBackward = new Backward(); stmtBackward.Expression = ParseExpr(); stmt = stmtBackward; break; case "Right": Index++; var stmtRight = new Right(); stmtRight.Expression = ParseExpr(); stmt = stmtRight; break; case "Left": Index++; var stmtLeft = new Left(); stmtLeft.Expression = ParseExpr(); stmt = stmtLeft; break; case "PenUp": Index++; stmt = new PenUp(); break; case "PenDown": Index++; stmt = new PenDown(); break; case "Home": Index++; stmt = new Home(); break; case "Clear": Index++; stmt = new Clear(); break; case "DeclareFunction": if (in_dec) { // Are we already declarating a function? throw new RPExeption(21, App.Current.TryFindResource("x_cdfif").ToString(), Line, Column); } var stmtDeclareFunction = new DeclareFunction(); // Read function name Index++; if (Index < Tokens.Count && Tokens[Index].isStr) { stmtDeclareFunction.Identity = (string)Tokens[Index]; } else { throw new RPExeption(22, App.Current.TryFindResource("x_expfn").ToString(), Line, Column); } // Read parameters if any Index++; while (Index + 1 < Tokens.Count && Tokens[Index].Equals(Scanner.ValueOf) && Tokens[Index + 1].isStr) { stmtDeclareFunction.Parameters.Add((string)Tokens[Index + 1]); Index += 2; } if (Index == Tokens.Count) { throw new RPExeption(23, App.Current.TryFindResource("x_expfb").ToString(), Line, Column); } // Add function to the functions list FuncDef.Add(stmtDeclareFunction.Identity, stmtDeclareFunction); // Parse body stmtDeclareFunction.Body = ParseStmt(true); // End of function if (Index == Tokens.Count || Tokens[Index].isStr && Config.Primitives.ContainsKey((string)Tokens[Index]) && Config.Primitives[(string)Tokens[Index]] == "End") { throw new RPExeption(24, App.Current.TryFindResource("x_expendttd").ToString(), Line, Column); } Index++; stmt = stmtDeclareFunction; break; case "Output": Index++; var stmtOutput = new Output(); stmtOutput.Expression = ParseExpr(); stmt = stmtOutput; break; case "Stop": Index++; stmt = new Stop(); break; case "IfElse": var stmtIfElse = new IfElse(); // Parse the condition Index++; stmtIfElse.Condition = ParseExpr(); // Parse the true branch if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtIfElse.True = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } // Parse the false branch if any Index++; if (Index < Tokens.Count && Tokens[Index].Equals(Scanner.BodyStart)) { Index++; stmtIfElse.False = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Contains.Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; } else { stmtIfElse.False = new Nop(); } stmt = stmtIfElse; break; case "Loop": var stmtLoop = new Loop(); // Parse expression Index++; stmtLoop.Repeat = ParseExpr(); // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtLoop.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtLoop; break; case "While": var stmtWhile = new While(); Index++; if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(30, App.Current.TryFindResource("x_expzbtce").ToString(), Line, Column); } Index++; stmtWhile.Condition = ParseExpr(); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(31, App.Current.TryFindResource("x_expzatce").ToString(), Line, Column); } Index++; // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtWhile.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtWhile; break; case "Forever": var stmtForever = new Forever(); Index++; // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtForever.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtForever; break; case "Print": Index++; var stmtPrint = new Print(); stmtPrint.Text = ParseExpr(); stmt = stmtPrint; break; case "DeclareVariable": var stmtDeclareVariable = new DeclareVariable(); Index += 2; if (Index < Tokens.Count && Tokens[Index - 1].Equals(Scanner.AsIs)) { stmtDeclareVariable.Identity = (string)Tokens[Index]; } else { throw new RPExeption(27, App.Current.TryFindResource("x_expvarname").ToString(), Line, Column); } // Do the math Index++; stmtDeclareVariable.Expression = ParseExpr(); stmt = stmtDeclareVariable; break; default: if (Tokens[Index].isStr) { if (Tokens[Index].Equals("language")) { Index++; Config.Load(); Index++; continue; } else if (Tokens[Index].Equals(Scanner.BodyEnd)) { breaked = true; continue; } else if (Tokens[Index].Equals(Config.Primitives["End"])) { if (!in_dec) throw new RPExeption(23, App.Current.TryFindResource("x_expfb").ToString(), Line, Column); else breaked = true; continue; } else if (!FuncDef.ContainsKey((string)Tokens[Index])) { throw new RPExeption(28, App.Current.TryFindResource("x_unknid").ToString() + (string)Tokens[Index] + "'", Line, Column); } else { var stmtCallFunction = new CallFunction(); stmtCallFunction.Identity = (string)Tokens[Index]; var P = FuncDef[(string)Tokens[Index]].Parameters.Count; int i = 0; Index++; while (Index < Tokens.Count && i < P) { stmtCallFunction.Parameters.Add(ParseExpr()); i++; } if (Index == Tokens.Count && i < P) { throw new RPExeption(29, App.Current.TryFindResource("x_fparnm").ToString(), Line, Column); } stmt = stmtCallFunction; } } else { throw new RPExeption(99, App.Current.TryFindResource("x_unkncomm").ToString(), Line, Column); } break; } result.Statements.Add(stmt); } return result; }
public ActionResult AllSettings(DataSourceRequest command, Nop.Web.Framework.Kendoui.Filter filter = null, IEnumerable<Sort> sort = null) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings)) return AccessDeniedView(); var settings = _settingService .GetAllSettings() .Select(x => { string storeName; if (x.StoreId == 0) { storeName = _localizationService.GetResource("Admin.Configuration.Settings.AllSettings.Fields.StoreName.AllStores"); } else { var store = _storeService.GetStoreById(x.StoreId); storeName = store != null ? store.Name : "Unknown"; } var settingModel = new SettingModel { Id = x.Id, Name = x.Name, Value = x.Value, Store = storeName, StoreId = x.StoreId }; return settingModel; }) .AsQueryable() .Filter(filter) .Sort(sort); var gridModel = new DataSourceResult { Data = settings.PagedForCommand(command).ToList(), Total = settings.Count() }; return Json(gridModel); }
public ActionResult CategoryCategoryInsert(GridCommand command, Nop.Plugin.Misc.MultipleParents.Models.CategoryModel.CategoryCategoryModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) return AccessDeniedView(); int parentCategoryId = 0; if (!String.IsNullOrEmpty(model.Category) && Int32.TryParse(model.Category, out parentCategoryId)) { var categoryCategory = new CategoryCategory() { ChildCategoryId = model.ChildCategoryId, DisplayOrder = model.DisplayOrder1 }; //use Category property (not CategoryId) because appropriate property is stored in it categoryCategory.ParentCategoryId = parentCategoryId; if (categoryCategory.ParentCategoryId == 0) categoryCategory.ParentCategoryId = null; _categoryService.InsertCategoryCategory(categoryCategory); } return CategoryCategoryList(command, model.ChildCategoryId); }
public bool IsAllowed(Nop nop) { return(_Type.IsAssignableFrom(nop.GetType())); }
public ActionResult CategoryCategoryUpdate(GridCommand command, Nop.Plugin.Misc.MultipleParents.Models.CategoryModel.CategoryCategoryModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog)) return AccessDeniedView(); var categoryCategory = _categoryService.GetCategoryCategoryById(model.Id); if (categoryCategory == null) throw new ArgumentException("No category category mapping found with the specified id"); //use Category property (not CategoryId) because appropriate property is stored in it categoryCategory.ParentCategoryId = Int32.Parse(model.Category); if (categoryCategory.ParentCategoryId == 0) categoryCategory.ParentCategoryId = null; categoryCategory.DisplayOrder = model.DisplayOrder1; _categoryService.UpdateCategoryCategory(categoryCategory); return CategoryCategoryList(command, categoryCategory.ChildCategoryId); }
public InvoicesController(IOrderService orderService, IOrderReportService orderReportService, IOrderProcessingService orderProcessingService, IPriceCalculationService priceCalculationService, IDateTimeHelper dateTimeHelper, IPriceFormatter priceFormatter, IDiscountService discountService, ILocalizationService localizationService, IWorkContext workContext, ICurrencyService currencyService, IEncryptionService encryptionService, IPaymentService paymentService, IMeasureService measureService, IPdfService pdfService, IAddressService addressService, ICountryService countryService, IStateProvinceService stateProvinceService, Nop.Services.Catalog.IProductService productService, IExportManager exportManager, IPermissionService permissionService, IWorkflowMessageService workflowMessageService, ICategoryService categoryService, IManufacturerService manufacturerService, IProductAttributeService productAttributeService, IProductAttributeParser productAttributeParser, IProductAttributeFormatter productAttributeFormatter, IShoppingCartService shoppingCartService, IGiftCardService giftCardService, IDownloadService downloadService, IShipmentService shipmentService, IShippingService shippingService, IStoreService storeService, IVendorService vendorService, IAddressAttributeParser addressAttributeParser, IAddressAttributeService addressAttributeService, IAddressAttributeFormatter addressAttributeFormatter, IAffiliateService affiliateService, IPictureService pictureService, CurrencySettings currencySettings, TaxSettings taxSettings, MeasureSettings measureSettings, AddressSettings addressSettings, ShippingSettings shippingSettings, IInvoiceService invoiceService, IGenericAttributeService genericAttributeService, IProductTemplateService productTemplateService, IStoreContext storeContext, ISettingService settingService, IGroupDealService groupDealService) { this._orderService = orderService; this._orderReportService = orderReportService; this._orderProcessingService = orderProcessingService; this._priceCalculationService = priceCalculationService; this._dateTimeHelper = dateTimeHelper; this._priceFormatter = priceFormatter; this._discountService = discountService; this._localizationService = localizationService; this._workContext = workContext; this._currencyService = currencyService; this._encryptionService = encryptionService; this._paymentService = paymentService; this._measureService = measureService; this._pdfService = pdfService; this._addressService = addressService; this._countryService = countryService; this._stateProvinceService = stateProvinceService; this._productService = productService; this._exportManager = exportManager; this._permissionService = permissionService; this._workflowMessageService = workflowMessageService; this._categoryService = categoryService; this._manufacturerService = manufacturerService; this._productAttributeService = productAttributeService; this._productAttributeParser = productAttributeParser; this._productAttributeFormatter = productAttributeFormatter; this._shoppingCartService = shoppingCartService; this._giftCardService = giftCardService; this._downloadService = downloadService; this._shipmentService = shipmentService; this._shippingService = shippingService; this._storeService = storeService; this._vendorService = vendorService; this._addressAttributeParser = addressAttributeParser; this._addressAttributeService = addressAttributeService; this._addressAttributeFormatter = addressAttributeFormatter; this._affiliateService = affiliateService; this._pictureService = pictureService; this._currencySettings = currencySettings; this._taxSettings = taxSettings; this._measureSettings = measureSettings; this._addressSettings = addressSettings; this._shippingSettings = shippingSettings; this._invoiceService = invoiceService; this._genericAttributeService = genericAttributeService; this._productTemplateService = productTemplateService; this._storeContext = storeContext; this._settingService = settingService; this._groupDealService = groupDealService; }
Stmt ParseStmt(bool in_dec = false) { Sequence result = new Sequence(); Stmt stmt = new Nop(); bool breaked = false; if (Index == Tokens.Count) { // Already got EOF? throw new RPExeption(20, App.Current.TryFindResource("x_nexpend").ToString(), Line, Column); } while (Index < Tokens.Count && !breaked) { switch (Config.In(Tokens[Index]).Name) { case "Forward": Index++; var stmtForward = new Forward(); stmtForward.Expression = ParseExpr(); stmt = stmtForward; break; case "Backward": Index++; var stmtBackward = new Backward(); stmtBackward.Expression = ParseExpr(); stmt = stmtBackward; break; case "Right": Index++; var stmtRight = new Right(); stmtRight.Expression = ParseExpr(); stmt = stmtRight; break; case "Left": Index++; var stmtLeft = new Left(); stmtLeft.Expression = ParseExpr(); stmt = stmtLeft; break; case "PenUp": Index++; stmt = new PenUp(); break; case "PenDown": Index++; stmt = new PenDown(); break; case "Home": Index++; stmt = new Home(); break; case "Clear": Index++; stmt = new Clear(); break; case "DeclareFunction": if (in_dec) { // Are we already declarating a function? throw new RPExeption(21, App.Current.TryFindResource("x_cdfif").ToString(), Line, Column); } var stmtDeclareFunction = new DeclareFunction(); // Read function name Index++; if (Index < Tokens.Count && Tokens[Index].isStr) { stmtDeclareFunction.Identity = (string)Tokens[Index]; } else { throw new RPExeption(22, App.Current.TryFindResource("x_expfn").ToString(), Line, Column); } // Read parameters if any Index++; while (Index + 1 < Tokens.Count && Tokens[Index].Equals(Scanner.ValueOf) && Tokens[Index + 1].isStr) { stmtDeclareFunction.Parameters.Add((string)Tokens[Index + 1]); Index += 2; } if (Index == Tokens.Count) { throw new RPExeption(23, App.Current.TryFindResource("x_expfb").ToString(), Line, Column); } // Add function to the functions list FuncDef.Add(stmtDeclareFunction.Identity, stmtDeclareFunction); // Parse body stmtDeclareFunction.Body = ParseStmt(true); // End of function if (Index == Tokens.Count || Tokens[Index].isStr && Config.Primitives.ContainsKey((string)Tokens[Index]) && Config.Primitives[(string)Tokens[Index]] == "End") { throw new RPExeption(24, App.Current.TryFindResource("x_expendttd").ToString(), Line, Column); } Index++; stmt = stmtDeclareFunction; break; case "Output": Index++; var stmtOutput = new Output(); stmtOutput.Expression = ParseExpr(); stmt = stmtOutput; break; case "Stop": Index++; stmt = new Stop(); break; case "IfElse": var stmtIfElse = new IfElse(); // Parse the condition Index++; stmtIfElse.Condition = ParseExpr(); // Parse the true branch if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtIfElse.True = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } // Parse the false branch if any Index++; if (Index < Tokens.Count && Tokens[Index].Equals(Scanner.BodyStart)) { Index++; stmtIfElse.False = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Contains.Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; } else { stmtIfElse.False = new Nop(); } stmt = stmtIfElse; break; case "Loop": var stmtLoop = new Loop(); // Parse expression Index++; stmtLoop.Repeat = ParseExpr(); // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtLoop.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtLoop; break; case "While": var stmtWhile = new While(); Index++; if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(30, App.Current.TryFindResource("x_expzbtce").ToString(), Line, Column); } Index++; stmtWhile.Condition = ParseExpr(); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(31, App.Current.TryFindResource("x_expzatce").ToString(), Line, Column); } Index++; // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtWhile.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtWhile; break; case "Forever": var stmtForever = new Forever(); Index++; // Parse the body if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyStart)) { throw new RPExeption(25, App.Current.TryFindResource("x_expzbb").ToString(), Line, Column); } Index++; stmtForever.Body = ParseStmt(in_dec); if (Index == Tokens.Count || !Tokens[Index].Equals(Scanner.BodyEnd)) { throw new RPExeption(26, App.Current.TryFindResource("x_expzab").ToString(), Line, Column); } Index++; stmt = stmtForever; break; case "Print": Index++; var stmtPrint = new Print(); stmtPrint.Text = ParseExpr(); stmt = stmtPrint; break; case "DeclareVariable": var stmtDeclareVariable = new DeclareVariable(); Index += 2; if (Index < Tokens.Count && Tokens[Index - 1].Equals(Scanner.AsIs)) { stmtDeclareVariable.Identity = (string)Tokens[Index]; } else { throw new RPExeption(27, App.Current.TryFindResource("x_expvarname").ToString(), Line, Column); } // Do the math Index++; stmtDeclareVariable.Expression = ParseExpr(); stmt = stmtDeclareVariable; break; default: if (Tokens[Index].isStr) { if (Tokens[Index].Equals("language")) { Index++; Config.Load(); Index++; continue; } else if (Tokens[Index].Equals(Scanner.BodyEnd)) { breaked = true; continue; } else if (Tokens[Index].Equals(Config.Primitives["End"])) { if (!in_dec) { throw new RPExeption(23, App.Current.TryFindResource("x_expfb").ToString(), Line, Column); } else { breaked = true; } continue; } else if (!FuncDef.ContainsKey((string)Tokens[Index])) { throw new RPExeption(28, App.Current.TryFindResource("x_unknid").ToString() + (string)Tokens[Index] + "'", Line, Column); } else { var stmtCallFunction = new CallFunction(); stmtCallFunction.Identity = (string)Tokens[Index]; var P = FuncDef[(string)Tokens[Index]].Parameters.Count; int i = 0; Index++; while (Index < Tokens.Count && i < P) { stmtCallFunction.Parameters.Add(ParseExpr()); i++; } if (Index == Tokens.Count && i < P) { throw new RPExeption(29, App.Current.TryFindResource("x_fparnm").ToString(), Line, Column); } stmt = stmtCallFunction; } } else { throw new RPExeption(99, App.Current.TryFindResource("x_unkncomm").ToString(), Line, Column); } break; } result.Statements.Add(stmt); } return(result); }