Exemplo n.º 1
0
        void DoViewport(InterfaceModel mdl)
        {
            if (drawable == null)
            {
                return;
            }
            var szX = (int)ImGui.GetColumnWidth() - 5;
            var szY = (int)ImGui.GetWindowContentRegionMax().Y - (int)ImGui.GetCursorPosY() - 5;

            BindViewport(szX, szY);
            //Do drawing
            var rectangle = new Rectangle(5, 5, rtX - 10, rtY - 10);

            mainWindow.Renderer2D.Start(rtX, rtY);
            mainWindow.Renderer2D.FillRectangle(rectangle, Color4.CornflowerBlue);
            mainWindow.Renderer2D.Finish();
            var transform = Matrix4x4.CreateScale(mdl.XScale, mdl.YScale, 1) *
                            Matrix4x4.CreateTranslation(mdl.X, mdl.Y, 0);
            var mcam = new MatrixCamera(Matrix4x4.Identity);

            mcam.CreateTransform(rtX, rtY, rectangle);

            drawable.Update(mcam, TimeSpan.FromSeconds(mainWindow.TotalTime), context.ResourceManager);
            mainWindow.RenderState.Cull             = false;
            mainWindow.RenderState.ScissorEnabled   = true;
            mainWindow.RenderState.ScissorRectangle = rectangle;
            drawable.DrawImmediate(mainWindow.RenderState, context.ResourceManager, transform, ref Lighting.Empty);
            mainWindow.RenderState.ScissorEnabled = false;
            mainWindow.RenderState.Cull           = true;
            DrawViewport();
        }
Exemplo n.º 2
0
 public async Task GenerateInterfaceFile(InterfaceModel @interface, DirectoryInfo di)
 {
     using (var sw = File.CreateText(Path.Combine(di.FullName, $"{@interface.Name}.cs")))
     {
         await sw.WriteAsync(_interfaceGenerator.Generate(@interface));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///		Interpreta un interface
        /// </summary>
        protected void ParseInterface(SyntaxNode node, LanguageStructModel parent, INamedTypeSymbol symbol)
        {
            InterfaceModel interfaceDef = parent.Items.CreateInterface(parent);

            // Asigna las propiedades básicas
            ParseNamedTypeSymbol(interfaceDef, node, symbol);
        }
Exemplo n.º 4
0
        public myResponse UpLoad(int SN)
        {
            myResponse res = new myResponse();

            InterfaceModel model = this.infterfaceDAL.Get <InterfaceModel>(SN);

            InterfaceModel dbInter = new InterfaceModel();

            dbInter.SerializeType = model.SerializeType;
            dbInter.Method        = model.Method;
            dbInter.IsTransaction = model.IsTransaction;
            dbInter.ExecuteType   = model.ExecuteType;

            //步骤
            dbInter.Steps = this.flowStepDAL.Query(SN);

            string url = model.Url;

            if (this.routeDict.ContainsKey(url))
            {
                this.routeDict[url] = dbInter;
            }
            else
            {
                this.routeDict.Add(url, dbInter);
            }
            return(res);
        }
Exemplo n.º 5
0
        public IActionResult Add(int FKSN, int SN)
        {
            List <string> list = this.config.GetSection("ExecuteType").Get <List <string> >();

            ViewData.Add("ExecuteType", list); //执行集合类型

            //参数类型
            List <string> DataType = this.config.GetSection("DataType").Get <List <string> >();

            ViewData.Add("DataType", DataType);

            //序列化格式
            List <string> stList = this.config.GetSection("SerializeType").Get <List <string> >();

            ViewData.Add("SerializeType", stList);

            //数据库类型
            List <string> dataBaseType = this.config.GetSection("DataBaseType").Get <List <string> >();

            ViewData.Add("DataBaseType", dataBaseType);

            InterfaceModel model = new InterfaceModel();

            model.SN   = SN;
            model.FKSN = FKSN;
            if (SN > 0)
            {
                model = this.infterfaceDAL.Get <InterfaceModel>(SN);
            }

            ViewData.Add("FullPath", this.infterfaceDAL.FullPath(FKSN)); //虚拟路径全称
            return(View(model));
        }
        public CodeOutput GenerateInterface()
        {
            var filename = Settings.DbContextInterfaceName + Settings.FileExtension;

            if (!CanWriteInterface())
            {
                FileManagementService.DeleteFile(filename);
                return(null);
            }

            var data = new InterfaceModel
            {
                interfaceModifier             = Settings.DbContextInterfaceModifiers ?? "public partial",
                DbContextInterfaceName        = Settings.DbContextInterfaceName,
                DbContextInterfaceBaseClasses = Settings.DbContextInterfaceBaseClasses,
                DbContextName = Settings.DbContextName,
                tables        = _tables.Where(x => x.DbSetModifier == "public").ToList(),
                AdditionalContextInterfaceItems = Settings.AdditionalContextInterfaceItems.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList(),
                addSaveChanges           = !Settings.UseInheritedBaseInterfaceFunctions,
                storedProcs              = _storedProcs,
                hasStoredProcs           = _hasStoredProcs,
                tableValuedFunctions     = _tableValuedFunctions,
                scalarValuedFunctions    = _scalarValuedFunctions,
                hasTableValuedFunctions  = _hasTableValuedFunctions && _filter.IncludeTableValuedFunctions,
                hasScalarValuedFunctions = _hasScalarValuedFunctions && _filter.IncludeScalarValuedFunctions,
            };

            var co = new CodeOutput(string.Empty, filename, "Database context interface", _globalUsings);

            co.AddUsings(_template.DatabaseContextInterfaceUsings(data));
            co.AddCode(Template.Transform(_template.DatabaseContextInterface(), data));

            return(co);
        }
Exemplo n.º 7
0
        public List <InterfaceModel> All(string title, string url, int fksn)
        {
            List <InterfaceModel> list = new List <InterfaceModel>();

            try
            {
                string strSql = "select * from api_interface where FKSN=" + fksn.ToString()
                                + " and title like '%" + title + "%'"
                                + " and url like '%" + url + "%'";
                DataTable dt = db.FillTable(strSql);

                foreach (DataRow dataRow in dt.Rows)
                {
                    InterfaceModel info = new InterfaceModel();
                    base.CreateModel(info, dataRow);
                    list.Add(info);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("DbCommand->api_interface=>Insert(s) 出错\r\n" + ex.Message);
                throw ex;
            }
            return(list);
        }
Exemplo n.º 8
0
        public List <InterfaceModel> All(string title, string url, int fksn)
        {
            List <InterfaceModel> list = new List <InterfaceModel>();

            string strSql = "with temp as( select * from api_folder where SN =" + fksn.ToString();

            strSql += " union all ";
            strSql += "select b.* from temp a inner join api_folder b on b.[ParentSN] = a.SN ) ";
            strSql += "select b.* from api_interface b inner join temp c on c.SN = b.FKSN";
            strSql += " and title like '%" + title + "%'";
            strSql += " and url like '%" + url + "%'";

            //所以数据
            if (fksn == 0)
            {
                strSql = "select * from api_interface where title like '%" + title + "%'" + " and url like '%" + url + "%'";
            }

            DataTable dt = db.FillTable(strSql);

            foreach (DataRow dataRow in dt.Rows)
            {
                InterfaceModel info = base.CreateModel <InterfaceModel>(dataRow);
                list.Add(info);
            }

            return(list);
        }
Exemplo n.º 9
0
        /// <summary>
        ///		Interpreta un interface
        /// </summary>
        protected void ParseInterface(SyntaxNode objNode, LanguageStructModel objParent, INamedTypeSymbol objSymbol)
        {
            InterfaceModel objInterface = objParent.Items.CreateInterface(objParent);

            // Asigna las propiedades básicas
            ParseNamedTypeSymbol(objInterface, objNode, objSymbol);
        }
Exemplo n.º 10
0
        public override List <string> DatabaseContextInterfaceUsings(InterfaceModel data)
        {
            var usings = new List <string>
            {
                "System",
                "System.Data",
                "System.Threading.Tasks",
                "System.Threading"
            };

            if (Settings.IncludeCodeGeneratedAttribute)
            {
                usings.Add("System.CodeDom.Compiler");
            }

            if (data.tables.Any() || data.hasStoredProcs)
            {
                usings.Add("Microsoft.EntityFrameworkCore");
                usings.Add("Microsoft.EntityFrameworkCore.Infrastructure");
                usings.Add("System.Linq");
            }

            if (data.hasStoredProcs)
            {
                usings.Add("System.Collections.Generic");
            }

            if (!Settings.UseInheritedBaseInterfaceFunctions)
            {
                usings.Add("System.Collections.Generic");
            }

            return(usings);
        }
Exemplo n.º 11
0
        /// <summary>
        ///		Interpreta un interface
        /// </summary>
        private void ParseInterface(SyntaxNode objNode, LanguageStructModel objParent)
        {
            InterfaceModel   objInterface = objParent.Items.CreateInterface(objParent);
            INamedTypeSymbol objSymbol    = objTreeSemantic.GetDeclaredSymbol(objNode as InterfaceDeclarationSyntax);

            // Asigna las propiedades básicas
            ParseNamedTypeSymbol(objInterface, objNode, objSymbol);
        }
Exemplo n.º 12
0
        /// <summary>
        ///		Obtiene el MLNode de un interface
        /// </summary>
        private void GetMLInterface(MLNode objMLRoot, DocumentFileModel objDocument)
        {
            InterfaceModel objInterface = objDocument.LanguageStruct as InterfaceModel;

            if (objInterface != null)
            {
                AddTablesComplexParts(objMLRoot, objDocument);
            }
        }
Exemplo n.º 13
0
 public int Delete(List <int> ids)
 {
     foreach (int sn in ids)
     {
         Models.InterfaceModel model = new InterfaceModel();
         model.SN = sn;
         int result = this.infterfaceDAL.Delete(model);
     }
     return(1);
 }
Exemplo n.º 14
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     _interfaceModel      = new InterfaceModel(_screenSize, GameWorld.Instance, this);
     _interfaceController = new InterfaceController(_interfaceModel, this, _isometricEngine);
     _interfaceView       = new InterfaceView(_interfaceModel, _isometricEngine);
     _spriteBatch         = new SpriteBatch(GraphicsDevice);
     _isometricEngine.LoadContent(Content);
     _interfaceView.LoadContent(Content);
     GameWorld.Instance.LoadGameDescription(Content);
     GameWorld.Instance.LoadTestWorld();
 }
Exemplo n.º 15
0
        private void UpdateListenAddresses(InterfaceModel model)
        {
            if (!model.Checked && model.UnknownInterface)
            {
                Interfaces.Remove(model);
            }

            StringCollection addressList = new StringCollection();

            addressList.AddRange(Interfaces.Where(m => m.Checked).Select(m => m.Address.ToString()).ToArray());
            Settings.Default.ListenAddressesCustom = addressList;
        }
Exemplo n.º 16
0
 private static void RenameInterfacePropertyInBaseClasses(InterfaceModel interfaceModel, ReferenceTypeModel implementationClass,
                                                          PropertyModel interfaceProperty, string newName)
 {
     foreach (var interfaceModelImplementationClass in interfaceModel.AllDerivedReferenceTypes().Where(c =>
                                                                                                       c != implementationClass))
     {
         foreach (var propertyModel in interfaceModelImplementationClass.Properties.Where(p =>
                                                                                          p.Name == interfaceProperty.Name))
         {
             propertyModel.Name = newName;
         }
     }
 }
Exemplo n.º 17
0
 public InterfaceModel Save(InterfaceModel model)
 {
     if (model.SN > 0)
     {
         this.infterfaceDAL.Update(model);
     }
     else
     {
         int SN = this.infterfaceDAL.Insert(model);
         model.SN = SN;
     }
     return(model);
 }
Exemplo n.º 18
0
        public async Task Invoke(HttpContext context)
        {
            this.context = context;
            string path = context.Request.Path.ToString();

            switch (path)
            {
            case "/CS":
                await this.WriteAsync("欢迎浏览ApiDoc");

                return;

            case "/CSDB":
                return;

            case "/vir":
                var    segment         = new PathString("~".Substring(1));
                var    applicationPath = context.Request.PathBase;
                string virpath         = applicationPath.Add(segment).Value;
                await this.WriteAsync(virpath);

                return;
            }

            if (this.routeDict.ContainsKey(path))
            {
                InterfaceModel response = this.routeDict[path];
                Dictionary <string, object> paramList = null;    //接口参数
                string msg;
                bool   bOK = this.CheckDataBase(response, out paramList, out msg);
                if (!bOK)     //如果验证失败
                {
                    await this.InvokeException(msg);
                }
                else
                {
                    if (response.IsJms)
                    {
                        await this.InvokeJms(context, paramList);
                    }
                    else
                    {
                        await InvokeDB(context, paramList);
                    }
                }
            }
            else
            {
                await next(context);
            }
        }
Exemplo n.º 19
0
        public InterfaceModel Save(InterfaceModel model)
        {
            int            SN       = model.SN;
            InterfaceModel modelOld = null;

            if (model.SN > 0)
            {
                modelOld = this.infterfaceDAL.Get <InterfaceModel>(model.SN);
                this.infterfaceDAL.Update(model);
            }
            else
            {
                SN       = this.infterfaceDAL.Insert(model);
                model.SN = SN;
            }

            //更新路由
            string url = model.Url;

            if (!model.IsStop)
            {
                if (modelOld != null && url != modelOld.Url)
                {
                    //删除以前的接口
                    if (this.routeDict.ContainsKey(modelOld.Url))
                    {
                        this.routeDict.Remove(url);
                    }
                }

                InterfaceModel dbInter = this.interfaceBLL.GetInterfaceModel(SN);
                if (this.routeDict.ContainsKey(url))
                {
                    this.routeDict[url] = dbInter;
                }
                else
                {
                    this.routeDict.Add(url, dbInter);
                }
            }
            if (model.IsStop)
            {
                if (this.routeDict.ContainsKey(url))
                {
                    this.routeDict.Remove(url);
                }
            }

            return(model);
        }
Exemplo n.º 20
0
        public List <InterfaceModel> Query(bool isStop)
        {
            List <InterfaceModel> list = new List <InterfaceModel>();
            string    vStop            = isStop ? "1" : "0";
            string    strSql           = "select * from " + base.tableName + " where isStop = " + vStop;
            DataTable dt = db.FillTable(strSql);

            foreach (DataRow dataRow in dt.Rows)
            {
                InterfaceModel info = base.CreateModel <InterfaceModel>(dataRow);
                list.Add(info);
            }

            return(list);
        }
Exemplo n.º 21
0
        public List <InterfaceModel> All()
        {
            List <InterfaceModel> list = new List <InterfaceModel>();

            string    strSql = "select * from " + base.tableName;
            DataTable dt     = db.FillTable(strSql);

            foreach (DataRow dataRow in dt.Rows)
            {
                InterfaceModel info = base.CreateModel <InterfaceModel>(dataRow);
                list.Add(info);
            }

            return(list);
        }
Exemplo n.º 22
0
        public void ShouldWriteInterface()
        {
            // Interfaces
            InterfaceModel myInterfaceModel = new InterfaceModel("MyInterfaceModel");

            myInterfaceModel.Properties.Add(new Property(BuiltInDataType.Int, "Prop1"));
            myInterfaceModel.Properties.Add(new Property(BuiltInDataType.String, "Prop2"));

            myInterfaceModel.Methods.Add(new Method(BuiltInDataType.Void, "Method1"));

            string result = myInterfaceModel.ToString() + Util.NewLine;

            string text = GetInterfaceText();

            Debug.WriteLine(result);
            Assert.Equal(result, text);
        }
        public LoginRadiusCustomInterface(string apikey)
        {
            if (Extensions.IsGuid(apikey))
            {
                string url = string.Format("https://devhub.loginradius.com/getinterfaceinfo/{0}", apikey);

                WebClient webclient = new WebClient();

                string interfaceresponse = webclient.DownloadString(url);

                interfacemodel = (InterfaceModel)Newtonsoft.Json.JsonConvert.DeserializeObject(interfaceresponse, typeof(InterfaceModel));
            }
            else
            {
                throw new Exception("Invalid Api key please use valid Guid format api key");
            }
        }
Exemplo n.º 24
0
        //验证数据库类型
        private bool CheckDataBase(InterfaceModel response, out Dictionary <string, object> dict, out string msg)
        {
            msg  = "";
            dict = new Dictionary <string, object>();

            if (response.DataType == "" || response.DataType == null)
            {
                msg = "没有配置数据库类型";
                return(false);
            }

            if (response.DataType != "SqlServer" && response.DataType != "Oracle" && response.DataType != "MySql")
            {
                msg = "不支持数据库类型:" + response.DataType;
                return(false);
            }

            string method = response.Method.ToLower();

            if (method != "post" && method != "get")
            {
                msg = "此平台只支持post,get";
                return(false);
            }

            //参数验证
            string auth;  //参数规则

            //从Request中获取参数集合
            dict = this.CreateDict(method, out auth);
            auth = auth.ToLower();
            if (response.Auth != auth)
            {
                msg = "接收参数[" + response.Auth + "]与规则[" + auth + "]不匹配";
                return(false);
            }

            //步骤
            if (response.Steps.Count == 0)
            {
                msg = response.Url + "没有任何步骤,请维护";
                return(false);
            }

            return(true);
        }
Exemplo n.º 25
0
        public LoginRadiusCustomInterface(string apikey)
        {
            if (Extensions.IsGuid(apikey))
            {
                string url = string.Format("https://devhub.loginradius.com/getinterfaceinfo/{0}", apikey);

                WebClient webclient = new WebClient();

                string interfaceresponse = webclient.DownloadString(url);

                interfacemodel = (InterfaceModel)Newtonsoft.Json.JsonConvert.DeserializeObject(interfaceresponse, typeof(InterfaceModel));
            }
            else
            {
                throw new Exception("Invalid Api key please use valid Guid format api key");
            }
        }
Exemplo n.º 26
0
        public IActionResult Add(int FKSN, int SN)
        {
            List <string> list = new List <string>();

            list.Add("Int");
            list.Add("Scalar");
            list.Add("DataSet");

            ViewData.Add("ExecuteType", list); //执行集合类型

            InterfaceModel model = new InterfaceModel();

            model.SN   = SN;
            model.FKSN = FKSN;
            if (SN > 0)
            {
                model = (InterfaceModel)this.infterfaceDAL.Get(model);
            }
            return(View(model));
        }
Exemplo n.º 27
0
        private TypeModel CreateTypeModel(Uri source, XmlSchemaGroup group, NamespaceModel namespaceModel, XmlQualifiedName qualifiedName, List <DocumentationModel> docs)
        {
            var name = "I" + _configuration.NamingProvider.GroupTypeNameFromQualifiedName(qualifiedName);

            if (namespaceModel != null)
            {
                name = namespaceModel.GetUniqueTypeName(name);
            }

            var interfaceModel = new InterfaceModel(_configuration)
            {
                Name          = name,
                Namespace     = namespaceModel,
                XmlSchemaName = qualifiedName
            };

            interfaceModel.Documentation.AddRange(docs);

            if (namespaceModel != null)
            {
                namespaceModel.Types[name] = interfaceModel;
            }

            if (!qualifiedName.IsEmpty)
            {
                var key = BuildKey(group, qualifiedName);
                Types[key] = interfaceModel;
            }

            var particle   = group.Particle;
            var items      = GetElements(particle);
            var properties = CreatePropertiesForElements(source, interfaceModel, particle, items.Where(i => !(i.XmlParticle is XmlSchemaGroupRef)));

            interfaceModel.Properties.AddRange(properties);
            var interfaces = items.Select(i => i.XmlParticle).OfType <XmlSchemaGroupRef>()
                             .Select(i => (InterfaceModel)CreateTypeModel(CodeUtilities.CreateUri(i.SourceUri), Groups[i.RefName], i.RefName));

            interfaceModel.AddInterfaces(interfaces);

            return(interfaceModel);
        }
Exemplo n.º 28
0
        public InterfaceModel GetInterfaceModel(int SN)
        {
            InterfaceModel model = this.infterfaceDAL.Get <InterfaceModel>(SN);

            model.Steps = this.flowStepDAL.QueryOfParam(model.SN);

            //接口参数
            string auth = "";

            foreach (ParamModel param in this.paramDAL.Query(model.SN))
            {
                if (auth != "")
                {
                    auth += "_";
                }
                auth += param.ParamName;
            }
            auth       = auth.ToLower();
            model.Auth = auth;
            return(model);
        }
Exemplo n.º 29
0
        private TypeModel CreateTypeModel(Uri source, XmlSchemaAttributeGroup attributeGroup, NamespaceModel namespaceModel, XmlQualifiedName qualifiedName, List <DocumentationModel> docs)
        {
            var name = "I" + _configuration.NamingProvider.AttributeGroupTypeNameFromQualifiedName(qualifiedName);

            if (namespaceModel != null)
            {
                name = namespaceModel.GetUniqueTypeName(name);
            }

            var interfaceModel = new InterfaceModel(_configuration)
            {
                Name          = name,
                Namespace     = namespaceModel,
                XmlSchemaName = qualifiedName
            };

            interfaceModel.Documentation.AddRange(docs);

            if (namespaceModel != null)
            {
                namespaceModel.Types[name] = interfaceModel;
            }

            if (!qualifiedName.IsEmpty)
            {
                var key = BuildKey(attributeGroup, qualifiedName);
                Types[key] = interfaceModel;
            }

            var items      = attributeGroup.Attributes;
            var properties = CreatePropertiesForAttributes(source, interfaceModel, items.OfType <XmlSchemaAttribute>());

            interfaceModel.Properties.AddRange(properties);
            var interfaces = items.OfType <XmlSchemaAttributeGroupRef>()
                             .Select(a => (InterfaceModel)CreateTypeModel(CodeUtilities.CreateUri(a.SourceUri), AttributeGroups[a.RefName], a.RefName));

            interfaceModel.AddInterfaces(interfaces);

            return(interfaceModel);
        }
Exemplo n.º 30
0
        public int UpdateStop(int SN, bool bStop)
        {
            InterfaceModel model = this.infterfaceDAL.Get <InterfaceModel>(SN);

            model.IsStop = bStop;
            if (model.SN > 0)
            {
                this.infterfaceDAL.Update(model);
            }
            else
            {
                SN       = this.infterfaceDAL.Insert(model);
                model.SN = SN;
            }

            //更新路由
            string url = model.Url;

            if (model.IsStop)
            {
                if (this.routeDict.ContainsKey(url))
                {
                    this.routeDict.Remove(url);
                }
            }
            else //启用
            {
                InterfaceModel dbInter = this.interfaceBLL.GetInterfaceModel(SN);
                if (this.routeDict.ContainsKey(url))
                {
                    this.routeDict[url] = dbInter;
                }
                else
                {
                    this.routeDict.Add(url, dbInter);
                }
            }

            return(model.SN);
        }
Exemplo n.º 31
0
        public List <InterfaceModel> All()
        {
            List <InterfaceModel> list = new List <InterfaceModel>();

            try
            {
                string    strSql = "select * from api_interface";
                DataTable dt     = db.FillTable(strSql);
                foreach (DataRow dataRow in dt.Rows)
                {
                    InterfaceModel info = new InterfaceModel();
                    base.CreateModel(info, dataRow);
                    list.Add(info);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("DbCommand->api_interface=>Insert(s) 出错\r\n" + ex.Message);
                throw ex;
            }
            return(list);
        }