Пример #1
0
        public IProcessController Compose(string cfg, LogLevel logLevel = LogLevel.Info, Dictionary <string, string> parameters = null, string placeHolderStyle = "@()")
        {
            var logger    = new TraceLogger(logLevel);
            var container = ConfigurationContainer.Create(cfg, logger, parameters, placeHolderStyle);

            Process = parameters == null?container.Resolve <Process>(new NamedParameter("cfg", cfg)) : container.Resolve <Process>(new NamedParameter("cfg", cfg), new NamedParameter("parameters", parameters));

            if (Process.Errors().Any())
            {
                foreach (var error in Process.Errors())
                {
                    Trace.WriteLine(error);
                }
                throw new Exception("Configuration Error(s)");
            }

            if (Process.Warnings().Any())
            {
                foreach (var warning in Process.Warnings())
                {
                    Trace.WriteLine(warning);
                }
            }

            return(DefaultContainer.Create(Process, logger, placeHolderStyle).Resolve <IProcessController>(new NamedParameter("cfg", cfg)));
        }
Пример #2
0
        /// <summary>
        /// 编辑图文消息
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public DocPic EditDocPic(DocPicEditReqeust info)
        {
            ValiDatas.valiData(info);
            ValiCode(info.Code, info.Id);
            using (var db = new DefaultContainer()) {
                var row = db.Db_BaseDocSet.OfType <Db_DocPic>().Single(p => p.Id == this.Id);
                row.Caption  = info.Caption;
                row.Code     = info.Code;
                row.Content  = info.Content;
                row.Descript = info.Descript;

                //删除原来的分类
                db.Database.ExecuteSqlCommand("delete from Db_BaseDocTreeSet where Db_BaseDocId=@docId", new SqlParameter("@docId", this.Id));
                //新增分类
                if (info.TreeIds != null)
                {
                    if (info.TreeIds.Count > 0)
                    {
                        List <Db_BaseDocTree> dbTrees = new List <Db_BaseDocTree>();
                        foreach (var item in info.TreeIds)
                        {
                            dbTrees.Add(new Db_BaseDocTree()
                            {
                                Id           = Guid.NewGuid().ToString(),
                                Db_BaseDocId = this.Id,
                                TreeId       = item
                            });
                        }
                        db.Db_BaseDocTreeSet.AddRange(dbTrees);
                    }
                }
                db.SaveChanges();
                return(new DocPic(row));
            }
        }
Пример #3
0
        public void Execute(Process process)
        {
            var logger = _logger ?? new NLogPipelineLogger(SlugifyTransform.Slugify(Cfg));

            if (process.OutputIsConsole())
            {
                logger.SuppressConsole();
            }

            if (_checkMemory)
            {
                CheckMemory(process, logger);
            }

            using (var scope = DefaultContainer.Create(process, logger, Options.PlaceHolderStyle)) {
                try {
                    scope.Resolve <IProcessController>().Execute();
                } catch (Exception ex) {
                    var context = scope.Resolve <IContext>();
                    context.Error(ex.Message);
                    context.Logger.Clear();

                    new LibaryVersionChecker(context).Check();
                }
            }
        }
Пример #4
0
        /// <inheritdoc />
        public string UpdateTimeEntry(string json)
        {
            var timeEntryRepository = DefaultContainer.FethInstance <ITimeEntryRepository>();
            var entry = json.SerializeObject <TimeEntry>();

            return(ExecuteActionInTry(timeEntryRepository.Update, entry));
        }
Пример #5
0
        /// <summary>
        /// 新增/编辑
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public static List <WorkFlowRole> Edit(List <WorkFlowRole> rows)
        {
            List <WorkFlowRole> result = new List <WorkFlowRole>();

            foreach (var item in rows)
            {
                ValiDatas.valiData(item);
            }
            using (var db = new DefaultContainer()) {
                foreach (var item in rows)
                {
                    if (string.IsNullOrEmpty(item.Id))
                    {
                        Db_WorkFlowRole dbRole = new Db_WorkFlowRole()
                        {
                            CreatedOn = DateTime.Now,
                            Descript  = string.IsNullOrEmpty(item.Descript) ? null : item.Descript,
                            Id        = Guid.NewGuid().ToString(),
                            RoleName  = item.RoleName
                        };
                        db.Db_WorkFlowRoleSet.Add(dbRole);
                        result.Add(new WorkFlowRole(dbRole));
                    }
                    else
                    {
                        var row = db.Db_WorkFlowRoleSet.Single(p => p.Id == item.Id);
                        row.RoleName = item.RoleName;
                        row.Descript = item.Descript;
                        result.Add(new WorkFlowRole(row));
                    }
                }
                db.SaveChanges();
            }
            return(result);
        }
Пример #6
0
 public void BindingInterfaceToExistingInstance_ShouldUseSpecifiedObject()
 {
     container = new DefaultContainer(new BindingInterfaceAndExistingInstanceConfiguration());
     var emptyInterfaceInstance = container.getInstance<EmptyInterface>();
     Assert.That(emptyInterfaceInstance, Is.Not.Null);
     Assert.That(emptyInterfaceInstance, Is.SameAs(exampleInstance));
 }
Пример #7
0
        public IProcessController Compose(string cfg, LogLevel logLevel = LogLevel.Info, Dictionary <string, string> parameters = null)
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule(new RootModule(@"Shorthand.xml"));
            var container = builder.Build();

            Process = parameters == null?container.Resolve <Process>(new NamedParameter("cfg", cfg)) : container.Resolve <Process>(new NamedParameter("cfg", cfg), new NamedParameter("parameters", parameters));

            if (Process.Errors().Any())
            {
                foreach (var error in Process.Errors())
                {
                    Trace.WriteLine(error);
                }
                throw new Exception("Configuration Error(s)");
            }

            if (Process.Warnings().Any())
            {
                foreach (var warning in Process.Warnings())
                {
                    Trace.WriteLine(warning);
                }
            }

            return(DefaultContainer.Create(Process, new TraceLogger(logLevel)).Resolve <IProcessController>(new NamedParameter("cfg", cfg)));
        }
        static async Task PostTemperatureDatas(DefaultContainer container, Random random)
        {
            const int startNumberOfTemperaturePoints = 168;
            const int endNumberOfTemperaturePoints   = 176;
            double    timeForCalculate;

            for (int i = startNumberOfTemperaturePoints; i <= endNumberOfTemperaturePoints; i++)
            {
                var newTemperatureData = new Original_TemperatureTable()
                {
                    PointsNumberId = i,
                    Time           = DateTime.Now,
                };
                timeForCalculate = Convert.ToDouble(newTemperatureData.Time.Hour) + Convert.ToDouble(newTemperatureData.Time.Minute) / 60;
                if (newTemperatureData.PointsNumberId == 168)
                {
                    newTemperatureData.Temperature = Math.Round((0.0006688963 * Math.Pow(timeForCalculate, 4) - 0.0348599334 * Math.Pow(timeForCalculate, 3) + 0.5121538687 * Math.Pow(timeForCalculate, 2) - 1.3478253362 * timeForCalculate + 23.4826210826 + random.Next(-2, 2)), 2);
                }
                else
                {
                    newTemperatureData.Temperature = Math.Round((-0.0000161352 * Math.Pow(timeForCalculate, 6) + 0.0013666675 * Math.Pow(timeForCalculate, 5) - 0.0419269504 * Math.Pow(timeForCalculate, 4) + 0.5518862571 * Math.Pow(timeForCalculate, 3) - 2.8402782982 * Math.Pow(timeForCalculate, 2) + 5.1969544638 * timeForCalculate + 11.6605128245 + random.Next(-2, 5)), 2);
                }
                await AddOriginal_TemperatureTableEntity(container, newTemperatureData);
            }
        }
Пример #9
0
        /// <summary>
        /// 检索系统异常日志
        /// </summary>
        /// <param name="condtion"></param>
        /// <returns></returns>
        public static BaseResponseList <ExceptionLog> searchList(ExceptionLogSearchRequest condtion)
        {
            BaseResponseList <ExceptionLog> result = new BaseResponseList <ExceptionLog>();
            DateTime?endDate = null;

            if (condtion.endDate != null)
            {
                endDate = DateTime.Parse(string.Format("{0} 23:59:59", condtion.endDate.Value.Date.ToString("yyyy-MM-dd")));
            }
            DateTime?beginDate = null;

            if (condtion.beginDate != null)
            {
                beginDate = condtion.beginDate.Value.Date;
            }
            using (var db = new DefaultContainer()) {
                var rows = (from c in db.Db_BaseLogSet.OfType <Db_ExceptionLog>()
                            where (1 == 1) &&
                            (string.IsNullOrEmpty(condtion.code) ? true : c.code == condtion.code) &&
                            (beginDate == null ? true : c.createdOn >= beginDate) &&
                            (endDate == null ? true : c.createdOn <= endDate)
                            select c);
                result.total = rows.Count();
                if (result.total > 0 && condtion.getRows)
                {
                    rows = rows.OrderByDescending(p => p.createdOn);
                    if (condtion.page > 0)
                    {
                        rows = rows.Skip(condtion.getSkip()).Take(condtion.pageSize);
                    }
                    result.rows = rows.AsEnumerable().Select(p => new ExceptionLog(p)).ToList();
                }
            }
            return(result);
        }
Пример #10
0
        static async Task GetByBatchOperation()
        {
            DefaultContainer context = new DefaultContainer(new Uri("https://services.odata.org/V4/(S(uvf1y321yx031rnxmcbqmlxw))/TripPinServiceRW/"));
            var peopleQuery          = context.People;
            var airlinesQuery        = context.Airlines;

            var batchResponse = await context.ExecuteBatchAsync(peopleQuery, airlinesQuery);

            Console.WriteLine("GET BY USING EXECUTING A BATCH AS ASYNC:");

            foreach (var r in batchResponse)
            {
                var people = r as QueryOperationResponse <Person>;
                if (people != null)
                {
                    Console.WriteLine("GET BY USING EXECUTING A BATCH AS ASYNC - PEOPLE ENTITY:");
                    foreach (Person p in people)
                    {
                        Console.WriteLine(p.UserName);
                    }
                }

                var airlines = r as QueryOperationResponse <Airline>;
                if (airlines != null)
                {
                    Console.WriteLine("GET BY USING EXECUTING A BATCH AS ASYNC - AIRLINE ENTITY:");
                    foreach (var airline in airlines)
                    {
                        Console.WriteLine(airline.Name);
                    }
                }
            }
            Console.WriteLine("------------------------------------------");
        }
        static async Task PostHumidityDatas(DefaultContainer container, Random random)
        {
            const int startNumberOfHumidityPoints = 159;
            const int endNumberOfHumidityPoints   = 167;
            double    timeForCalculate;

            for (int i = startNumberOfHumidityPoints; i <= endNumberOfHumidityPoints; i++)
            {
                var newHumidityData = new Original_HumidityTable()
                {
                    PointsNumberId = i,
                    Time           = DateTime.Now,
                };
                timeForCalculate = Convert.ToDouble(newHumidityData.Time.Hour) + Convert.ToDouble(newHumidityData.Time.Minute) / 60;

                if (newHumidityData.PointsNumberId == 159)
                {
                    newHumidityData.Humidity = Math.Round((-0.0000078423 * Math.Pow(timeForCalculate, 6) + 0.0002969528 * Math.Pow(timeForCalculate, 5) - 0.0003479320 * Math.Pow(timeForCalculate, 4) - 0.0882313919 * Math.Pow(timeForCalculate, 3) + 0.9074929115 * Math.Pow(timeForCalculate, 2) - 2.7612024709 * timeForCalculate + 94.4810448062 + random.Next(-5, 5)), 2);
                }
                else
                {
                    newHumidityData.Humidity = Math.Round((0.0000003604 * Math.Pow(timeForCalculate, 6) - 0.0000414864 * Math.Pow(timeForCalculate, 5) + 0.0021461937 * Math.Pow(timeForCalculate, 4) - 0.0521791190 * Math.Pow(timeForCalculate, 3) + 0.5739883341 * Math.Pow(timeForCalculate, 2) - 2.1637451666 * timeForCalculate + 42.5826680075 + random.Next(-5, 5)), 2);
                }
                await AddOriginal_HumidityTableEntity(container, newHumidityData);
            }
        }
Пример #12
0
        public bool CreateContainer(int index, int weight, TypeContainer type)
        {
            if (weight > 30 || weight < 4)
            {
                Program.PrintError("The Weight of The Container cant be more than 30 and less than 4");
                return(false);
            }

            if (type == TypeContainer.Default_Container)
            {
                var newContainer = new DefaultContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.Cooled_Container)
            {
                var newContainer = new CooledContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.Valuable_Container)
            {
                var newContainer = new ValuableContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.RefrigeratedValuable_Container)
            {
                var newContainer = new ValuableCooledContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }

            return(false);
        }
Пример #13
0
        /*[Fact, Asynchronous] */ // Activate this after solving error handling
        public async Task BatchSequencingTestFailsWithMultiPartMixed()
        {
            DefaultContainer context = this.CreateWrappedContext <DefaultContainer>().Context;
            Customer         c1      = new Customer {
                CustomerId = 1, Name = "customerOne"
            };
            Customer c2 = new Customer {
                CustomerId = 2, Name = "customerTwo"
            };

            context.AddToCustomer(c1);
            context.AddToCustomer(c2);
            await context.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset);

            c1.Name = "customerOne updated name";
            c2.Name = "customerTwo updated name";

            context.UpdateObject(c1);
            context.UpdateObject(c2, c1);

            Task response() => context.SaveChangesAsync(SaveChangesOptions.BatchWithIndependentOperations);

            var exception = await Assert.ThrowsAsync <ODataException>(response);

            Assert.Contains("The dependsOn Id in request is not matching any of the request Id and atomic group Id seen so far", exception.Message);

            this.EnqueueTestComplete();
        }
        public void Setup()
        {
            Container = new DefaultContainer();
            Container.SetupForTests();

            new SchemaExport(Container.Resolve <Configuration>()).Create(true, true);
        }
Пример #15
0
        /// <inheritdoc />
        public string PostProjects(string json)
        {
            var repo     = DefaultContainer.FethInstance <IProjectRepository>();
            var projects = json.SerializeObjectCollection <Project>();

            return(ExecuteActionInTry(repo.CreateMany, projects));
        }
Пример #16
0
    public async Task <HttpStatusCode> ConfirmAliveAsync(int processId, DateTime now, ControllableProcessStatus status)
    {
        using (_SimpleLogger.BeginScope(SimpleLoggingScopeId.Create(nameof(ConfirmAliveAsync)))) {
            var methodNamesFromStack = _MethodNamesFromStackFramesExtractor.ExtractMethodNamesFromStackFrames();
            _SimpleLogger.LogInformationWithCallStack($"Confirm that process with id={processId} is alive", methodNamesFromStack);
            var context       = new DefaultContainer(new Uri(BaseUrl));
            var processExists = await ProcessExists(context, processId);

            if (processExists.Inconclusive)
            {
                _SimpleLogger.LogInformationWithCallStack($"Could not determine if process with id={processId} exists", methodNamesFromStack);
                return(HttpStatusCode.InternalServerError);
            }

            if (!processExists.YesNo)
            {
                _SimpleLogger.LogInformationWithCallStack($"No process exists with id={processId}", methodNamesFromStack);
                return(HttpStatusCode.NotFound);
            }

            _SimpleLogger.LogInformationWithCallStack($"Update process with id={processId}", methodNamesFromStack);
            var controllableProcess = await context.ControllableProcesses.ByKey(processId).GetValueAsync();

            controllableProcess.ConfirmedAt = now;
            controllableProcess.Status      = status;
            context.UpdateObject(controllableProcess);
            var response = await context.SaveChangesAsync(SaveChangesOptions.None);

            var statusCode = response.Select(r => (HttpStatusCode)r.StatusCode).FirstOrDefault();
            return(statusCode);
        }
    }
Пример #17
0
        public async Task JsonBatchSequencingSingeChangeSetTest()
        {
            DefaultContainer context = this.CreateWrappedContext <DefaultContainer>().Context;
            Customer         c1      = new Customer {
                CustomerId = 1, Name = "customerOne"
            };
            Customer c2 = new Customer {
                CustomerId = 2, Name = "customerTwo"
            };
            Customer c3 = new Customer {
                CustomerId = 3, Name = "customerThree"
            };

            context.AddToCustomer(c1);
            context.AddToCustomer(c2);
            context.AddToCustomer(c3);
            await context.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset);

            c1.Name = "customerOne updated name";
            c2.Name = "customerTwo updated name";

            context.UpdateObject(c1);
            context.UpdateObject(c2, c1);
            context.DeleteObject(c3, c2);

            var response = await context.SaveChangesAsync(SaveChangesOptions.BatchWithSingleChangeset | SaveChangesOptions.UseJsonBatch);

            Assert.Equal(204, (response.First() as ChangeOperationResponse).StatusCode);

            this.EnqueueTestComplete();
        }
Пример #18
0
    private async Task <bool> ProcessTaskExists(DefaultContainer context, Guid taskId)
    {
        var query = (DataServiceQuery <ControllableProcessTask>)context.ControllableProcessTasks.Where(p => p.Id == taskId || p.Id == Guid.NewGuid()); // Hack, hack, hack
        var controllableProcessTasks = await query.ExecuteAsync();

        return(controllableProcessTasks.Any());
    }
Пример #19
0
 public void BindingInterfaceToImplementation_ShouldUseSpecifiedImplementationClass()
 {
     container = new DefaultContainer(new BindingInterfaceAndImplementationConfiguration());
     var emptyInterfaceInstance = container.getInstance<EmptyInterface>();
     Assert.That(emptyInterfaceInstance, Is.Not.Null);
     Assert.That(emptyInterfaceInstance, Is.InstanceOf<DerievedFromEmptyInterface>());
 }
Пример #20
0
        /// <summary>
        /// 批量添加基础工单信息
        /// </summary>
        /// <param name="remarks"></param>
        /// <returns></returns>
        public static List <BaseWorkOrder> CreateBaseWorkOrders(List <string> remarks)
        {
            List <BaseWorkOrder> result = new List <BaseWorkOrder>();

            using (var db = new DefaultContainer()) {
                List <Db_BaseWorkOrder> dbRows = new List <Db_BaseWorkOrder>();
                foreach (var item in remarks)
                {
                    var newRow = new Db_BaseWorkOrder()
                    {
                        CreatedOn = DateTime.Now,
                        Id        = Guid.NewGuid().ToString(),
                        OrderType = (byte)WorkOrderType.无类型.GetHashCode(),
                        Remark    = item
                    };
                    dbRows.Add(newRow);
                    result.Add(new BaseWorkOrder(newRow));
                }
                if (dbRows.Count > 0)
                {
                    db.Db_BaseWorkOrderSet.AddRange(dbRows);
                    db.SaveChanges();
                }
            }
            return(result);
        }
Пример #21
0
        static void Main(string[] args)
        {
            var context = new DefaultContainer(new Uri("http://services.odata.org/v4/(S(lqbvtwide0ngdev54adgc0lu))/TripPinServiceRW/"));

            var people = context.People.Expand(p => p.Trips).Execute();

            foreach (var person in people)
            {
                Console.WriteLine($"{person.FirstName} {person.LastName}");
                foreach (var trip in person.Trips)
                {
                    Console.WriteLine($"\t{trip.Name} {trip.Budget}");
                }
            }

            Console.ReadLine();

            Console.WriteLine("--- More complex query ---");
            var petersOrTrippers = from person in context.People
                                   //where person.FirstName == "Scott"
                                   where person.FirstName.EndsWith("Scott")
                                   //|| person.Trips.Count == 2 // Can't do this some error around $count being a single value
                                   || person.Trips.Any(t => t.Budget > 3000)
                                   select person;

            foreach (var person in petersOrTrippers)
            {
                Console.WriteLine($"{person.FirstName} {person.LastName}");
            }

            Console.ReadLine();
        }
Пример #22
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="container"></param>
 /// <param name="interceptor">设置远程拦截器</param>
 public WindsorContainer(IWindsorContainer container, Type interceptor)
 {
     this._default   = new DefaultContainer();
     this._container = container;
     this._container.Register(Component.For <RemoteServiceInterceptor>().ImplementedBy(interceptor));
     this._container.Register(Component.For <RemovedInterceptor>());
 }
Пример #23
0
        /// <inheritdoc />
        public string GetProjectsByCompany(int id)
        {
            var projectDetailRepository = DefaultContainer.FethInstance <IProjectDetailRepository>();

            return(ExecuteGenericFuncInTry <ProjectDetail>(projectDetailRepository.Where, detail => detail.CompanyId == id,
                                                           JSON.ToJSON));
        }
Пример #24
0
        /// <summary>
        /// 创建容器
        /// </summary>
        /// <param name="configs">依赖配置</param>
        /// <returns></returns>
        public static IContainer CreateContainer(params IConfig[] configs)
        {
            var container = new DefaultContainer();

            container.Register(null, builder => builder.EnableAop(), configs);
            return(container);
        }
Пример #25
0
        public void A()
        {
            const string xml = @"
    <add name='TestProcess'>
      <parameters>
        <add name='humanized' value='camelCase' t='replace(lC,l-c).upper()' />
        <add name='replaced' value='TestEnvironment' t='replace(Test,Production).trimEnd(s).append(s)' />
      </parameters>
      <entities>
      </entities>
    </add>";

            var logger = new TraceLogger(LogLevel.Debug);

            using (var outer = ConfigurationContainer.Create(xml, logger)) {
                var process = outer.Resolve <Process>();
                using (var inner = DefaultContainer.Create(process, logger, "@()")) {
                    inner.Resolve <IProcessController>().Execute();

                    var parmeters = process.GetActiveParameters();
                    Assert.AreEqual("CAMEL-CASE", parmeters.First().Value);
                    Assert.AreEqual("ProductionEnvironments", parmeters.Skip(1).First().Value);
                }
            }
        }
Пример #26
0
        static void Main(string[] args)
        {
            var logger  = new ConsoleLogger();
            var options = new Options();

            if (Parser.Default.ParseArguments(args, options))
            {
                try
                {
                    var indexer    = new DefaultIndexer();
                    var json       = File.ReadAllText(options.BatchPath);
                    var jobs       = JsonConvert.DeserializeObject <Job[]>(json);
                    var container  = new DefaultContainer(indexer, logger, null);
                    var staticSite = new StaticSite(container);
                    var publish    = staticSite.PublishAsync <Metadata>(jobs);

                    Task.WaitAll(publish);
                }
                catch (Exception e)
                {
                    logger.Log(string.Format("Error during publish '{0}'", e.InnerException.Message));
                }
            }
            else
            {
                logger.Log("Unable to parse arguments");
            }
        }
Пример #27
0
        /// <summary>
        /// 验证用户名和密码是否正确
        /// </summary>
        /// <param name="condtion"></param>
        /// <returns>验证通过返回后台用户对象 验证不通过直接抛出DataNotFundException异常</returns>
        public static UserManager checkLogin(UserManagerLoginRequest condtion)
        {
            ValiDatas.valiData(condtion);
            using (var db = new DefaultContainer()) {
                //判断数据库是否为空,如果为空则添加一个管理员用户
                var count = (from c in db.Db_BaseUserSet.OfType <Db_ManagerUser>()
                             select c.Id).Count();

                if (count == 0)
                {
                    return(UserManager.create(new UserManagerCreateRequest()
                    {
                        fullName = "管理员",
                        loginName = "admin",
                        roleNames = new string[] { "admin" }
                    }));
                }

                var row = db.Db_BaseUserSet.OfType <Db_ManagerUser>().SingleOrDefault(p =>
                                                                                      p.loginName == condtion.loginName &&
                                                                                      p.passWord.ToLower() == condtion.passWord.ToLower() &&
                                                                                      p.isDeleted == false
                                                                                      );
                if (row == null)
                {
                    throw new DataNotFundException("用户名或者密码错误");
                }
                if (row.isDisabled)
                {
                    throw new ValiDataException("已被禁用的用户无法登录");
                }
                return(new UserManager(row));
            }
        }
Пример #28
0
        /// <inheritdoc />
        public string PostTimeEntry(string json)
        {
            var repo   = DefaultContainer.FethInstance <ITimeEntryRepository>();
            var detail = json.SerializeObject <TimeEntry>();

            return(ExecuteFuncInTry(repo.Create, detail));
        }
Пример #29
0
        public void showFilters(object sender, EventArgs e)
        {
            string s       = FilterBy_SelectedIndexChanged();
            string text    = findTextBox();
            var    context = new DefaultContainer(new Uri("https://services.odata.org/V4/(S(y5tuj04bxbfsxzimbxbnauqg))/TripPinServiceRW/"));

            IEnumerable <Person> person = context.People.Execute();;

            switch (s)
            {
            case "UserName":
                person = context.People.Where(c => c.UserName.Equals(text));
                break;

            case "LastName":
                person = context.People.Where(c => c.LastName.Equals(text));
                break;

            case "FirstName":
                person = context.People.Where(c => c.FirstName.Equals(text));
                break;
            }
            GridViewPerson.DataSource = person;
            GridViewPerson.DataBind();
        }
Пример #30
0
        /// <summary>
        /// 创建容器
        /// </summary>
        /// <param name="configs">依赖配置</param>
        /// <returns></returns>
        public static Sand.Dependency.IContainer CreateContainer(params IConfig[] configs)
        {
            var container = new DefaultContainer();

            container.Register(null, null, configs);
            return(container);
        }
Пример #31
0
        public void BasicTest()
        {
            var dsc    = new DefaultContainer(new Uri("http://services.odata.org/V4/(S(ply0t0sqxoh4wooviq211x55))/TripPinServiceRW/"));
            var people = dsc.People;

            people.BeginExecute(ReadingPeople, people);
        }
Пример #32
0
        /// <inheritdoc />
        public Container Convert(ItemDTO value, object state)
        {
            var entity = new DefaultContainer();

            this.Merge(entity, value, state);
            return(entity);
        }
        static void Main()
        {
            var container = new DefaultContainer();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1(container));
        }
Пример #34
0
 public void BindingQualifierToImplementation_ShouldUseSpecifiedImplementationClass()
 {
     container = new DefaultContainer(new BindingQualifierConfiguration());
     var qualifierUsage = container.getInstance<QualifierUsageExample>();
     Assert.That(qualifierUsage, Is.Not.Null);
     Assert.That(qualifierUsage.Property, Is.Not.Null);
     Assert.That(qualifierUsage.Property, Is.InstanceOf<OtherInterfaceImplementation>());
 }
Пример #35
0
        private Login AddNewLoginForCustomer(DefaultContainer context, Customer customer, string loginKeyValue)
        {
            var newLogin = new Login { Username = loginKeyValue, };

            context.AddToLogin(newLogin);
            context.SetLink(newLogin, "Customer", customer);
            context.AddLink(customer, "Logins", newLogin);
            context.SaveChanges();

            return newLogin;
        }
        public void Removals_dont_cause_exceptions()
        {
            Assert.DoesNotThrow(() =>
            {
                var container = new DefaultContainer();

                container.Register<IFoo>(r => new Foo());
                Assert.IsTrue(container.Remove<IFoo>());
                Assert.IsFalse(container.Remove<IFoo>());

                container.Register<IFoo>("MyFoo", r=> new Foo());
                Assert.IsTrue(container.Remove<IFoo>("MyFoo"));
                Assert.IsFalse(container.Remove<IFoo>("VitaminFail"));
            });
        }
 public TypeWithPropertyAlreadySet()
 {
     Resolver = new DefaultContainer();
 }
 protected DependencyLifetimeManager(DefaultContainer resolver)
 {
     Resolver = resolver;
 }
 public SingletonLifetimeManager(DefaultContainer builder)
     : base(builder)
 {
 }
 public PerRequestLifetimeManager(DefaultContainer resolver)
     : base(resolver)
 {
 }
 public TransientLifetimeManager(DefaultContainer builder)
     : base(builder)
 {
 }