private static void Main(string[] args) { if (args.Length > 0) { var dataOptions = new OptionSet { { "environment=", s => _environmentName = s } }; dataOptions.Parse(args); } var configurationBuilder = new ConfigurationBuilder() .SetBasePath(_baseDirectory ?? Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", true, true) .AddJsonFile($"appsettings.{_environmentName}.json", true) .AddJsonFile("appsettings.local.json", true); IConfigurationRoot configuration = configurationBuilder.Build(); var builder = new DbContextOptionsBuilder() .UseNpgsql(configuration["DbConnection"], x => x.MigrationsAssembly("DbMigrator")); var modelStore = new ModelStore(); var context = new CustomEfDbContext(modelStore, builder.Options); var provider = new EfDataProvider(context); var generator = new DataGenerator(provider, _environmentName); generator.GenAsync().GetAwaiter().GetResult(); }
public void InputCorrect() { StreamReader s = new StreamReader(@"D:\MFF\ZS_2019\c#_repos\Nezarka\NezarkaTests\bin\Debug\netcoreapp3.0\Ins\Databaze.txt"); ModelStore store = ModelStore.LoadFrom(s); Assert.IsNotNull(store); }
public void FlawedLenghtOfLIne() { StreamReader s = new StreamReader(@"D:\MFF\ZS_2019\c#_repos\Nezarka\NezarkaTests\bin\Debug\netcoreapp3.0\Ins\FlawedLenghtOfLine.txt"); ModelStore store = ModelStore.LoadFrom(s); Assert.IsNull(store); }
/// <summary> /// Constructor for the <see cref="CsType"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="wellKnownType">The well known type from the language if it is well known.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="isGeneric">Flag that determines if the type is generic.</param> /// <param name="hasStrongTypesInGenerics">Flag that determines if the generics are strong types or placeholders.</param> /// <param name="genericParameters">Generic parameters assigned to the type.</param> /// <param name="genericTypes">The type definitions for the generic implementation.</param> /// <param name="name">The name of the type.</param> /// <param name="ns">The namespace the type belongs to.</param> /// <param name="isWellKnownType">Is the type one of the well known types for the language.</param> /// <param name="valueTypeDefaultValue">The default value if the type is a value type.</param> /// <param name="isValueType">Flag that determines if it is a value type.</param> /// <param name="supportsDisposable">Flag that determines if the type implements <see cref="IDisposable"/> interface.</param> /// <param name="isInterface">Flag that determines if the type is an interface definition.</param> /// <param name="isStructure">Flag that determines if the type is a structure definition.</param> /// <param name="isClass">Flag that determines if the type is a class definition.</param> /// <param name="isArray">Flag that determines if the type is also an array.</param> /// <param name="arrayDimensions">The dimensions assigned to the array.</param> /// <param name="isGenericPlaceHolder">Flag that determines if the type is a generic place holder definition.</param> /// <param name="isEnum">Flag that determines if the type is an enumeration.</param> /// <param name="isDelegate">Flag that determines if the type is a delegate definition.</param> /// <param name="isTuple">Flag that determines if the type is a tuple.</param> /// <param name="tupleTypes">The type information for each part of the tuple.</param> protected CsType(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, bool isGeneric, bool hasStrongTypesInGenerics, IReadOnlyList <CsGenericParameter> genericParameters, IReadOnlyList <CsType> genericTypes, string name, string ns, bool isWellKnownType, string valueTypeDefaultValue, bool isValueType, bool supportsDisposable, bool isInterface, bool isStructure, bool isClass, bool isArray, IReadOnlyList <int> arrayDimensions, bool isGenericPlaceHolder, bool isEnum, bool isDelegate, bool isTuple, IReadOnlyList <CsTupleTypeParameter> tupleTypes, CsKnownLanguageType wellKnownType, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Type, sourceDocument, modelStore, modelErrors) { _isGeneric = isGeneric; _hasStrongTypesInGenerics = hasStrongTypesInGenerics; _genericParameters = genericParameters ?? ImmutableList <CsGenericParameter> .Empty; _genericTypes = genericTypes ?? ImmutableList <CsType> .Empty; _name = name; _ns = ns; _isWellKnownType = isWellKnownType; _valueTypeDefaultValue = valueTypeDefaultValue; _isValueType = isValueType; _supportsDisposable = supportsDisposable; _isInterface = isInterface; _isStructure = isStructure; _isClass = isClass; _isArray = isArray; _arrayDimensions = arrayDimensions ?? ImmutableList <int> .Empty; _isGenericPlaceHolder = isGenericPlaceHolder; _isEnum = isEnum; _isDelegate = isDelegate; _isTuple = isTuple; _tupleTypes = tupleTypes ?? ImmutableList <CsTupleTypeParameter> .Empty; _wellKnownType = wellKnownType; }
/// <summary> /// 导出应用模型包 /// </summary> internal static async Task <AppPackage> Export(string appName) { //判断权限 if (!(RuntimeContext.Current.CurrentSession is IDeveloperSession developerSession)) { throw new Exception("Must login as a Developer"); } var desighHub = developerSession.GetDesignHub(); if (desighHub == null) { throw new Exception("Cannot get DesignContext"); } var appNode = desighHub.DesignTree.FindApplicationNodeByName(appName); if (appNode == null) { throw new Exception($"Can't find application: {appName}"); } //注意目前导出的是最近发布的版本,跟当前设计时版本无关 var pkg = new AppPackage(); await ModelStore.LoadToAppPackage(appNode.Model.Id, appName, pkg); //开始解析应用所使用的存储信息 ParseDataStores(desighHub, pkg); //TODO:考虑sys包忽略特定模型(即不允许导出) return(pkg); }
public void SaveProductPhoto(int productId, string photoname, byte[] photo) { _context.BeginTransaction(); var productPhoto = new ModelStore <ProductPhoto>() .TrackChanges(ChangeTrackingStrategy.PropertyState); productPhoto.Add(new ProductPhoto() { ProductPhotoID = productId, LargePhotoFileName = photoname, LargePhoto = photo }); var result = productPhoto.SaveChanges(_context); if (result.InsertedCount == 1) { var productPhotoID = productPhoto.FirstOrDefault().ProductPhotoID; var pordProdPhoto = new ModelStore <ProductProductPhoto>() .TrackChanges(ChangeTrackingStrategy.PropertyState); pordProdPhoto.Add(new ProductProductPhoto() { ProductID = productId, ProductPhotoID = productPhotoID, Primary = 1 }); pordProdPhoto.SaveChanges(_context); } _context.Commit(); }
public static void Add(int custId, int bookId, ModelStore modelStore) { Book bookToAdd = modelStore.GetBook(bookId); if (bookToAdd == null) { ViewInvalidRequest.Render(); return; } ShoppingCart cart = modelStore.GetCustomer(custId).ShoppingCart; ShoppingCartItem item = cart.GetItem(bookId); if (item == null) { cart.Items.Add(new ShoppingCartItem { BookId = bookId, Count = 1 }); } else { item.Count += 1; } ViewShoppingCart.Render(custId, modelStore); }
/// <summary> /// Constructor for the <see cref="CsMethod"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="parameters">The parameters assigned to the method.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="attributes">List of the attributes assigned to this model.</param> /// <param name="sourceFiles">List of the fully qualified paths to the source code files this member is defined in.</param> /// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param> /// <param name="documentation">The xml documentation assigned to the model.</param> /// <param name="lookupPath">The fully qualified model lookup path for this model.</param> /// <param name="name">The name of the model.</param> /// <param name="parentPath">THe fully qualified lookup path for the parent model to this one.</param> /// <param name="security">The security scope assigned to this model.</param> /// <param name="isGeneric">Flag that determines if the method is a generic definition.</param> /// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param> /// <param name="genericParameters">Generic parameters assigned to the method.</param> /// <param name="genericTypes">Target types for the generic parameters assigned to the method.</param> /// <param name="hasParameters">Flag that determines if the method had parameters.</param> /// <param name="isAbstract">Flag that determines if the model is abstract.</param> /// <param name="isVirtual">Flag that determines if the model is virtual.</param> /// <param name="isSealed">Flag that determines if the model is sealed.</param> /// <param name="isOverride">Flag that determines if the model is overridden.</param> /// <param name="isStatic">Flag that determines if the model is static.</param> /// <param name="isVoid">Flag that determines if the return type is void. </param> /// <param name="isAsync">Flag that determines if the method has the async keyword assigned.</param> /// <param name="isExtension">Flag that determines if the method is an extension method.</param> /// <param name="methodType">The type of method that was implemented.</param> /// <param name="returnType">The type definition for the return type.</param> protected CsMethod(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, IReadOnlyList <CsAttribute> attributes, IReadOnlyList <string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath, string name, string parentPath, CsSecurity security, bool isGeneric, bool hasStrongTypesInGenerics, IReadOnlyList <CsGenericParameter> genericParameters, IReadOnlyList <CsType> genericTypes, bool hasParameters, bool isAbstract, bool isVirtual, bool isSealed, bool isOverride, bool isStatic, bool isVoid, bool isAsync, bool isExtension, CsMethodType methodType, CsType returnType, IReadOnlyList <CsParameter> parameters, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Method, attributes, sourceFiles, hasDocumentation, documentation, lookupPath, name, parentPath, security, CsMemberType.Method, sourceDocument, modelStore, modelErrors) { _isGeneric = isGeneric; _hasStrongTypesInGenerics = hasStrongTypesInGenerics; _genericParameters = genericParameters ?? ImmutableList <CsGenericParameter> .Empty; _genericTypes = genericTypes ?? ImmutableList <CsType> .Empty; _hasParameters = hasParameters; _isAbstract = isAbstract; _isVirtual = isVirtual; _isSealed = isSealed; _isOverride = isOverride; _isStatic = isStatic; _isVoid = isVoid; _isAsync = isAsync; _isExtension = isExtension; _methodType = methodType; _returnType = returnType; _parameters = parameters ?? ImmutableList <CsParameter> .Empty; }
/// <summary> /// Constructor for the <see cref="CsContainer"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="modelType">The type of code model created.</param> /// <param name="members">The members assigned to this container.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="attributes">List of the attributes assigned to this model.</param> /// <param name="isGeneric">Flag that determines if the container is a generic definition.</param> /// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param> /// <param name="genericParameters">Generic parameters assigned to the container.</param> /// <param name="genericTypes">Target types for the generic parameters assigned to the container.</param> /// <param name="sourceFiles">List of the fully qualified paths to the source code files this model is defined in.</param> /// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param> /// <param name="documentation">The xml documentation assigned to the model.</param> /// <param name="lookupPath">The fully qualified model lookup path for this model.</param> /// <param name="name">The name of the model.</param> /// <param name="ns">The namespace the container belongs to.</param> /// <param name="parentPath">The fully qualified lookup path for the parent model to this one.</param> /// <param name="containerType">The type of container this model represents.</param> /// <param name="security">The security scope assigned to this model.</param> /// <param name="inheritedInterfaces">The interfaces that are inherited by this container.</param> protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, CsModelType modelType, IReadOnlyList <CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics, IReadOnlyList <CsGenericParameter> genericParameters, IReadOnlyList <CsType> genericTypes, IReadOnlyList <string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath, string name, string ns, string parentPath, CsContainerType containerType, CsSecurity security, IReadOnlyList <CsInterface> inheritedInterfaces, IReadOnlyList <CsMember> members, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, modelType, sourceDocument, modelStore, modelErrors) { _attributes = attributes ?? ImmutableList <CsAttribute> .Empty; _isGeneric = isGeneric; _hasStrongTypesInGenerics = hasStrongTypesInGenerics; _genericParameters = genericParameters ?? ImmutableList <CsGenericParameter> .Empty; _genericTypes = genericTypes ?? ImmutableList <CsType> .Empty; _sourceFiles = sourceFiles ?? ImmutableList <string> .Empty; _hasDocumentation = hasDocumentation; _documentation = documentation; _lookupPath = lookupPath; _name = name; _ns = ns; _parentPath = parentPath; _containerType = containerType; _security = security; _inheritedInterfaces = inheritedInterfaces ?? ImmutableList <CsInterface> .Empty; _members = members ?? ImmutableList <CsMember> .Empty; }
public static void Render(int custId, ModelStore modelStore) { Customer customer = modelStore.GetCustomer(custId); Console.WriteLine("<!DOCTYPE html>"); Console.WriteLine("<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">"); Console.WriteLine("<head>"); Console.WriteLine(" <meta charset=\"utf-8\" />"); Console.WriteLine(" <title>Nezarka.net: Online Shopping for Books</title>"); Console.WriteLine("</head>"); Console.WriteLine("<body>"); Console.WriteLine(" <style type=\"text/css\">"); Console.WriteLine(" table, th, td {"); Console.WriteLine(" border: 1px solid black;"); Console.WriteLine(" border-collapse: collapse;"); Console.WriteLine(" }"); Console.WriteLine(" table {"); Console.WriteLine(" margin-bottom: 10px;"); Console.WriteLine(" }"); Console.WriteLine(" pre {"); Console.WriteLine(" line-height: 70%;"); Console.WriteLine(" }"); Console.WriteLine(" </style>"); Console.WriteLine(" <h1><pre> v,<br />Nezarka.NET: Online Shopping for Books</pre></h1>"); Console.WriteLine(" " + customer.FirstName + ", here is your menu:"); Console.WriteLine(" <table>"); Console.WriteLine(" <tr>"); Console.WriteLine(" <td><a href=\"/Books\">Books</a></td>"); Console.WriteLine(" <td><a href=\"/ShoppingCart\">Cart ("+ customer.ShoppingCart.Items.Count.ToString() + ")</a></td>"); Console.WriteLine(" </tr>"); Console.WriteLine(" </table>"); }
/// <summary> /// 签出指定节点 /// </summary> internal static async Task <CheckoutResult> CheckoutAsync(List <CheckoutInfo> checkoutInfos) { if (checkoutInfos == null || checkoutInfos.Count == 0) { return(null); } //尝试向存储插入签出信息 var model = await RuntimeContext.Current.GetModelAsync <EntityModel>(Consts.SYS_CHECKOUT_MODEL_ID); #if FUTURE var txn = await Transaction.BeginAsync(); #else using var conn = await SqlStore.Default.OpenConnectionAsync(); using var txn = conn.BeginTransaction(); #endif try { for (int i = 0; i < checkoutInfos.Count; i++) { var info = checkoutInfos[i]; var obj = new Entity(model); obj.SetByte(Consts.CHECKOUT_NODETYPE_ID, (byte)info.NodeType); obj.SetString(Consts.CHECKOUT_TARGETID_ID, info.TargetID); obj.SetGuid(Consts.CHECKOUT_DEVELOPERID_ID, info.DeveloperOuid); obj.SetString(Consts.CHECKOUT_DEVELOPERNAME_ID, info.DeveloperName); obj.SetInt32(Consts.CHECKOUT_VERSION_ID, (int)info.Version); #if FUTURE await EntityStore.InsertEntityAsync(obj, txn); await txn.CommitAsync(); #else await SqlStore.Default.InsertAsync(obj, txn); txn.Commit(); #endif } } catch (Exception) { txn.Rollback(); return(new CheckoutResult(false)); } //检查签出单个模型时,存储有无新版本 CheckoutResult result = new CheckoutResult(true); if (checkoutInfos[0].IsSingleModel) { var storedModel = await ModelStore.LoadModelAsync(ulong.Parse(checkoutInfos[0].TargetID)); if (storedModel.Version != checkoutInfos[0].Version) { result.ModelWithNewVersion = storedModel; } } return(result); }
public IModelStore <TModel> Retrieve <TModel>(params object[] keyValue) where TModel : class, new() { var modelStore = new ModelStore <TModel>(); modelStore.Retrieve(_context, keyValue); return(modelStore); }
public override void TearDown() { ModelStore.Commit(); base.TearDown(); File.Delete(tmpDb); tmpDb = null; }
public Game() { Window = new Window(new Vector2(1280, 680), "HenHen"); Inputs = CreateInputs(); ScreenStack = new ScreenStack(); textureStore = new TextureStore(); modelStore = new ModelStore(); SpriteText.DefaultFont = LoadFont("Resources/Fonts/OpenSans-SemiBold.ttf"); SetTextureFilter(SpriteText.DefaultFont.texture, Raylib_cs.TextureFilter.TEXTURE_FILTER_TRILINEAR); }
/// <summary> /// Constructor for the <see cref="CsModel"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="modelType">The type of code model created.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> protected CsModel(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, CsModelType modelType, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) { _isLoaded = isLoaded; _hasErrors = hasErrors; _loadedFromSource = loadedFromSource; _language = language; _sourceDocument = sourceDocument; _modelType = modelType; ModelStore = modelStore; LocalModelErrors = modelErrors ?? ImmutableList <ModelLoadException> .Empty; }
public IModelStore <SubCategorySalesReport> RetrieveSubCategorySalesReport(params object[] salesmonth) { var OrderReportMonth1 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[1]); var OrderReportMonth2 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[2]); var OrderReportMonth3 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[3]); var OrderReportMonth4 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[4]); var OrderReportMonth5 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[5]); var OrderReportMonth6 = Retrieve <SubCategorySalesReport_D>(salesmonth[0], salesmonth[6]); var modelStore = new ModelStore <SubCategorySalesReport>(); var subCategorySalesReport = new SubCategorySalesReport(); if (OrderReportMonth1.Count > 0) { subCategorySalesReport.Name = OrderReportMonth1.GetValue <string>(0, "SubcategoryName"); subCategorySalesReport.SalesqtyMonth1 = OrderReportMonth1.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth1 = OrderReportMonth1.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } if (OrderReportMonth2.Count > 0) { subCategorySalesReport.SalesqtyMonth2 = OrderReportMonth2.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth2 = OrderReportMonth2.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } if (OrderReportMonth3.Count > 0) { subCategorySalesReport.SalesqtyMonth3 = OrderReportMonth3.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth3 = OrderReportMonth3.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } if (OrderReportMonth4.Count > 0) { subCategorySalesReport.SalesqtyMonth4 = OrderReportMonth4.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth4 = OrderReportMonth4.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } if (OrderReportMonth5.Count > 0) { subCategorySalesReport.SalesqtyMonth5 = OrderReportMonth5.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth5 = OrderReportMonth5.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } if (OrderReportMonth6.Count > 0) { subCategorySalesReport.SalesqtyMonth6 = OrderReportMonth6.GetValue <int?>(0, "TotalSalesqty") ?? 0; subCategorySalesReport.SalesRoomMonth6 = OrderReportMonth6.GetValue <decimal?>(0, "TotalSaleroom") ?? 0; } modelStore.Add(subCategorySalesReport); return(modelStore); }
/// <summary> /// Constructor for the <see cref="CsAttribute"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="type">The target type of the attribute.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="sourceFiles">The list of source files the attribute is defined in.</param> /// <param name="hasParameters">Flag that determines if the attribute has parameters.</param> /// <param name="parentPath">The fully qualified lookup path to the parent model for this attribute.</param> /// <param name="parameters">The list of parameters assigned to the attribute.</param> protected CsAttribute(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, IReadOnlyList <string> sourceFiles, bool hasParameters, string parentPath, IReadOnlyList <CsAttributeParameter> parameters, CsType type, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Attribute, sourceDocument, modelStore, modelErrors) { _sourceFiles = sourceFiles ?? ImmutableList <string> .Empty; _hasParameters = hasParameters; _parentPath = parentPath; _parameters = parameters ?? ImmutableList <CsAttributeParameter> .Empty; _type = type; }
/// <summary> /// Constructor for the <see cref="CsUsingStatement"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="parentPath">Fully qualified lookup path for the parent model to this model.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="lookupPath">Fully qualified path for the model to be stored in the model store.</param> /// <param name="referenceNamespace">The full namespace being referenced.</param> /// <param name="hasAlias">Flag that determines if the namespace is referenced by a alias name.</param> /// <param name="alias">The alias name for the referenced namespace. this will be null when <see cref="HasAlias"/> is false</param> protected CsUsingStatement(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, string lookupPath, string referenceNamespace, bool hasAlias, string alias, string parentPath, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Using, sourceDocument, modelStore, modelErrors) { _lookupPath = lookupPath; _referenceNamespace = referenceNamespace; _hasAlias = hasAlias; _alias = alias; _parentPath = parentPath; }
public static MobileNet GetMobileNetV2(float multiplier, bool pretrained = false, Context ctx = null, string root = "", int classes = 1000, string prefix = null, ParameterDict @params = null) { var net = new MobileNet(multiplier, classes, prefix, @params); if (pretrained) { net.LoadParameters(ModelStore.GetModelFile($"mobilenetv2_{multiplier}"), ctx); } return(net); }
private static async Task ImportApp(DesignHub ctx, AppPackage pkg) { //TODO:暂重用更新逻辑简单实现 //先创建应用,必须添加到设计树内,因保存实体模型时获取表名需要用到 var appRootNode = ctx.DesignTree.AppRootNode; var appNode = new ApplicationNode(ctx.DesignTree, pkg.Application); appRootNode.Nodes.Add(appNode); await ModelStore.CreateApplicationAsync(pkg.Application); await UpdateApp(ctx, pkg, pkg.Application); }
public void GeneralTests() { StreamWriter sw = new StreamWriter(@"TestFiles\Outs\NezarkaTest.html"); StreamReader Reader = new StreamReader(@"TestFiles\NezarkaTest.in"); ModelStore store = ModelStore.LoadFrom(Reader); Controler.ReadAdnDoRequests(Reader, sw, store); sw.Close(); Reader.Close(); bool b = Utils.FileDiff(@"TestFiles\Outs\NezarkaTest.html", @"TestFiles\NezarkaTest.out"); Assert.IsTrue(b); }
/// <summary> /// Constructor for the <see cref="CsStructure"/> /// </summary> /// <param name="isLoaded">Flag that determines if the model was loaded.</param> /// <param name="hasErrors">Flag that determine if errors were found creating the model.</param> /// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param> /// <param name="language">The target language the model was generated from.</param> /// <param name="members">The members assigned to this container.</param> /// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param> /// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param> /// <param name="modelErrors">Optional the error that occured while creating the model.</param> /// <param name="attributes">List of the attributes assigned to this model.</param> /// <param name="isGeneric">Flag that determines if the container is a generic definition.</param> /// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param> /// <param name="genericParameters">Generic parameters assigned to the container.</param> /// <param name="genericTypes">Target types for the generic parameters assigned to the container.</param> /// <param name="sourceFiles">List of the fully qualified paths to the source code files this model is defined in.</param> /// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param> /// <param name="documentation">The xml documentation assigned to the model.</param> /// <param name="lookupPath">The fully qualified model lookup path for this model.</param> /// <param name="name">The name of the model.</param> /// <param name="ns">The namespace the container belongs to.</param> /// <param name="parentPath">The fully qualified lookup path for the parent model to this one.</param> /// <param name="security">The security scope assigned to this model.</param> /// <param name="inheritedInterfaces">The interfaces that are inherited by this container.</param> protected CsStructure(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, IReadOnlyList <CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics, IReadOnlyList <CsGenericParameter> genericParameters, IReadOnlyList <CsType> genericTypes, IReadOnlyList <string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath, string name, string ns, string parentPath, CsSecurity security, IReadOnlyList <CsInterface> inheritedInterfaces, IReadOnlyList <CsMember> members, string sourceDocument = null, ModelStore <ICsModel> modelStore = null, IReadOnlyList <ModelLoadException> modelErrors = null) : base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Structure, attributes, isGeneric, hasStrongTypesInGenerics, genericParameters, genericTypes, sourceFiles, hasDocumentation, documentation, lookupPath, name, ns, parentPath, CsContainerType.Structure, security, inheritedInterfaces, members, sourceDocument, modelStore, modelErrors) { //Intentionally blank }
public void AddBook_IncreaseCount() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); Customer c = model.GetCustomer(2); Book b = model.GetBook(1); control.AddBook(c, b); Assert.AreEqual(model.GetCustomer(2).ShoppingCart.Items.Find(itm => itm.BookId == b.Id).Count, 4); }
public void RemoveBook_DeleteBook() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); Customer c = model.GetCustomer(2); Book b = model.GetBook(5); control.RemoveBook(c, b); Assert.AreEqual(model.GetCustomer(2).ShoppingCart.Items.Find(itm => itm.BookId == b.Id), null); }
public static AlexNet GetAlexNet(bool pretrained = false, Context ctx = null, string root = "") { var net = new AlexNet(); if (ctx == null) { ctx = Context.CurrentContext; } if (pretrained) { net.LoadParameters(ModelStore.GetModelFile("alexnet", root), ctx); } return(net); }
public void ProcessCommand_HTTPIsTooShort() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); try { control.ProcessCommand("GET 1 http://www.nezarka.net/"); Assert.Fail("Expected exception was not thrown."); } catch (Exception ex) { Assert.AreEqual("HTTP address is too short.", ex.Message); } }
public void ProcessCommand_HTTPBooksDetailNotFound() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); try { control.ProcessCommand("GET 1 http://www.nezarka.net/Books/Detail/6"); Assert.Fail("Expected exception was not thrown."); } catch (Exception ex) { Assert.AreEqual("Book Detail not found.", ex.Message); } }
public void ProcessCommand_HTTPShoppingCartIsWrong() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); try { control.ProcessCommand("GET 4 http://www.nezarka.net/ShoppingCart/1"); Assert.Fail("Expected exception was not thrown."); } catch (Exception ex) { Assert.AreEqual("ShoppingCart HTTP address is wrong.", ex.Message); } }
public void ProcessCommand_NotGet() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); try { control.ProcessCommand("POST 1 http://www.nezarka.net/Books"); Assert.Fail("Expected exception was not thrown."); } catch (Exception ex) { Assert.AreEqual("Not a GET request.", ex.Message); } }
public void ProcessCommand_IncorrectDomain() { StringWriter output = new StringWriter(); ModelStore model = ModelMockup(); Viewer view = new Viewer(output); Controller control = new Controller(model, view); try { control.ProcessCommand("GET 1 http://www.nezarka.net1/Books"); Assert.Fail("Expected exception was not thrown."); } catch (Exception ex) { Assert.AreEqual("Wrong domain.", ex.Message); } }