private static TModel Create <TModel>() where TModel : UploadModelBase, new() { SelectListItem CreateItem(TimeSpan timespan) => new SelectListItem { Value = (DateTime.UtcNow + timespan).ToString("O"), Text = timespan.Humanize() }; SelectListItem CreateMonthItem(int month) => new SelectListItem { Value = CultureInfo.CurrentCulture.Calendar.AddMonths(DateTime.UtcNow, month).ToString("O"), Text = $"{month} months" }; TModel uploadModel = new TModel { FileIdentifier = FileIdentifier.CreateNew(), Expiration = DateTime.UtcNow.AddDays(7), AvailableExpiration = new[] { CreateItem(TimeSpan.FromHours(1)), CreateItem(TimeSpan.FromHours(4)), CreateItem(TimeSpan.FromHours(8)), CreateItem(TimeSpan.FromDays(1)), CreateItem(TimeSpan.FromDays(2)), CreateItem(TimeSpan.FromDays(7)), CreateMonthItem(1), CreateMonthItem(2), CreateMonthItem(3), CreateMonthItem(6), CreateItem(TimeSpan.FromDays(CultureInfo.CurrentCulture.Calendar.GetDaysInYear(DateTime.UtcNow.Year))), } }; return(uploadModel); }
private string GetModelDir <TModel>() where TModel : new() { var model = new TModel(); string filename = SaveDir + @"\" + model.GetType().Name + @"\"; return(filename); }
public TModel Resolve <TModel>() where TModel : IModel { IModel model = GetModelByType <TModel>(); TModel typedModel = (TModel)model; return(typedModel); }
public async Task <DeviceInfoModel> GetDeviceInfo(AccessPolicyModel accessPolicyModel, string deviceId, string access_token) { RequestDeviceModel requestDeviceModel = new RequestDeviceModel { apiVersion = "2018-08-30-preview", authorizationPolicyKey = accessPolicyModel.SharedAccessKey, authorizationPolicyName = accessPolicyModel.SharedAccessKeyName, hostName = accessPolicyModel.HostName, requestPath = string.Format("/devices/{0}", deviceId) }; string url = "https://main.iothub.ext.azure.cn/api/dataPlane/get"; var request = new HttpRequestMessage(HttpMethod.Post, url); var client = this._clientFactory.CreateClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token); string requestbody = JsonConvert.SerializeObject(requestDeviceModel); request.Content = new StringContent(requestbody, UnicodeEncoding.UTF8, "application/json"); var response = await client.SendAsync(request); string result = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { TModel <DeviceInfoModel> job = JsonConvert.DeserializeObject <TModel <DeviceInfoModel> >(result); return(job.body); } else { return(null); } }
/// <summary> /// Creates the T model. /// </summary> /// <param name="tMName">Name of the t Model.</param> /// <param name="tMDescription">The t Model description.</param> /// <returns></returns> public static TModel CreateTModel(string tMName, string tMDescription) { TModel tModel = new TModel(tMName); tModel.Descriptions.Add(tMDescription); return(tModel); }
internal void RemoveInstance(TModel instance) { foreach (var index in base.Values) { index.RemoveInstance(instance); } }
protected ChangeResult(TModel model, TPropertiesEnum properties, bool success, string errorMessage) { Model = model; Property = properties; Success = success; ErrorMessage = errorMessage; }
private IQueryable <ArtistVM> FetchAndPopulateAll() { return(TModel .Include(artist => artist.AlbumArtist) .ThenInclude(aa => aa.Album) .Select(artist => populateArtist(artist))); }
/// <summary> /// Gets the base model. /// </summary> /// <typeparam name="TModel">The type of the model.</typeparam> /// <returns>base model</returns> protected virtual TModel GetBaseModel <TModel>() where TModel : IVmOpenApiServiceBase, new() { var model = new TModel { Id = this.Id, SourceId = this.SourceId, Type = this.Type, FundingType = this.FundingType, ServiceChargeType = this.ServiceChargeType, ServiceNames = this.ServiceNames, AreaType = this.AreaType, ServiceDescriptions = this.ServiceDescriptions, Legislation = this.Legislation, Languages = this.Languages, Keywords = this.Keywords, ServiceCoverageType = this.ServiceCoverageType, Requirements = this.Requirements, ServiceVouchersInUse = this.ServiceVouchersInUse, ServiceVouchers = this.ServiceVouchers, PublishingStatus = this.PublishingStatus, AvailableLanguages = this.AvailableLanguages, }; return(model); }
public static void WriteDataToText() { using (StreamWriter writer = new StreamWriter(filePath)) { //header writer.Write("PartitionKey|RowKey|Timestamp|Id|"); writer.WriteLine(); do { TModel entity = null; //Read and remove entity from queue entitiesQueue.TryDequeue(out entity); if (entity != null) { //Write data to text file writer.Write("\"" + entity.PartitionKey + "\"|\"" + entity.RowKey + "\"|" + entity.Timestamp + "|" + entity.Id); writer.WriteLine(); } else { //If all the entities are read out from the table and now there is no entities in the queue, we will break this loop and exit current thread. if (ReadTableFinished) { break; } } }while (true); writer.Dispose(); } }
public TBetterCubeTraverse(TModel model) { R = model.R; LevelBorders = new List <TBorders>(); for (int y = 0; y < R; ++y) { TBorders thisLevelBorders = new TBorders(); for (int x = 0; x < R; ++x) { for (int z = 0; z < R; ++z) { if (model[x, y, z] > 0) { MaxY = Math.Max(MaxY, y); thisLevelBorders.MinX = Math.Min(thisLevelBorders.MinX, x); thisLevelBorders.MaxX = Math.Max(thisLevelBorders.MaxX, x); thisLevelBorders.MinZ = Math.Min(thisLevelBorders.MinZ, z); thisLevelBorders.MaxZ = Math.Max(thisLevelBorders.MaxZ, z); } } } LevelBorders.Add(thisLevelBorders); } }
public void Finalize(TModel model, Range rangeZ) { if (model[Position.X + 1, Position.Y, Position.Z] > 0) { var toFill = new Coord(Position.X + 1, Position.Y, Position.Z); if (!FinalCoords.Contains(toFill)) { CurrentCommand = new Fill(1, 0, 0); FinalCoords.Add(toFill); return; } } var nextZ = Position.Z + FinalDirection; if (nextZ < 0 || nextZ > rangeZ.Max) { if (Position.X == 0) { CurrentCommand = null; } else { Move(Position.X - 1, Position.Y, Position.Z); FinalDirection = -FinalDirection; } return; } Move(Position.X, Position.Y, nextZ); }
public void Insert(TModel instance) { foreach (var index in base.Values) { index.Set(instance); } }
/// <summary> /// Converts to version. /// </summary> /// <typeparam name="TModel">The type of the model.</typeparam> /// <returns>converted model</returns> protected TModel ConvertToDeliveryAddressVersionIn <TModel>() where TModel : IV7VmOpenApiAddressDeliveryIn, new() { var vm = new TModel() { Id = this.Id, }; if (this.StreetAddress?.Count > 0) { vm.SubType = AddressTypeEnum.Street.ToString(); vm.StreetAddress = new VmOpenApiAddressStreetIn() { Street = this.StreetAddress, StreetNumber = this.StreetNumber, PostalCode = this.PostalCode, Municipality = this.Municipality, AdditionalInformation = this.AdditionalInformations }; } else { vm.SubType = AddressTypeEnum.PostOfficeBox.ToString(); vm.PostOfficeBoxAddress = new VmOpenApiAddressPostOfficeBoxIn() { PostOfficeBox = PostOfficeBox, PostalCode = this.PostalCode, Municipality = this.Municipality, AdditionalInformation = this.AdditionalInformations, }; } return(vm); }
public Dictionary <string, string> GetModelList(Dictionary <string, List <Columns> > dict) { Dictionary <string, string> result = new Dictionary <string, string>(); foreach (var tablename in dict.Keys) { List <Columns> columns = dict[tablename]; TModel model = new TModel() { ClassName = GetCSharpNameFromSqlName(tablename), Columns = columns, PkColumns = columns.Where(p => p.PK).ToList(), OtherColumns = columns.Where(p => !p.PK).ToList(), ModelSpaceName = "Mx", Namespace = baseClassNamespaces + ".Model", TableName = tablename, ShareNamespace = "MXWater", JsonName = GetJsonNameFromSqlName(tablename), }; string content = model.TransformText(); result.Add(model.ClassName, content); } return(result); }
public TState(TModel model, bool enableValidation = false) { Model = model; EnableValidation = enableValidation; Matrix = new int[Model.R, Model.R, Model.R]; var bot = new TBot { Bid = 1, Coord = { X = 0, Y = 0, Z = 0 } }; for (var i = 2; i <= 40; ++i) { bot.Seeds.Add(i); } Bots.Add(bot); Energy = 0; Harmonics = EHarmonics.Low; }
private IQueryable <SeriesVM> FetchAndPopulateAll() { return(TModel .Include(series => series.Albums) .ThenInclude(album => album.AlbumArtist) .ThenInclude(aa => aa.Artist) .Select(series => populateSeries(series))); }
/// <summary> /// Creates the T model. /// </summary> /// <param name="tMName">Name of the t Model.</param> /// <param name="tMDescription">The t Model description.</param> /// <param name="tMKeyedRefence">The t Model keyed refence.</param> /// <returns></returns> public static TModel CreateTModel(string tMName, string tMDescription, KeyedReference tMKeyedRefence) { TModel tModel = new TModel(tMName); tModel.Descriptions.Add(tMDescription); tModel.CategoryBag.KeyedReferences.Add(tMKeyedRefence); return(tModel); }
public static TModel New <TModel>() where TModel : DbEntity, new() { var model = new TModel(); model.ConfigureAsNew(); return(model); }
List <ICommand> IStrategy.MakeTrace(TModel src, TModel dst) { var traceFile = $"{tracesDir}/{dst.Name}.nbt"; return(File.Exists(traceFile) ? TraceReader.Read(traceFile) : new List <ICommand>()); }
/// <summary> /// 把请求信息根据名称自动封装进TModel类型中,并返回该类型对象 /// </summary> /// <typeparam name="TModel"></typeparam> /// <returns></returns> public TModel GetModel <TModel>() { TModel model = NFinal.Model.ModelHelper.GetModel <TModel>(this.parameters); System.Diagnostics.Debug.WriteLine(parameters.ToString()); System.Diagnostics.Debug.WriteLine(model); return(model); }
protected abstract IMachine GetMachineDesign(TModel mode, TContext context) { // Do some de-serialisation. return(new PrimaryAssemblyMachine(primarySysName, sysSerial, secondarySysName, primaryAssemblyLocation)); }
public void Create(TModel model) { using (var context = new MyContext()) { context.Set <TModel>().Attach(model); context.SaveChanges(); } }
/// <summary> /// Выполняет привязку аргументов к свойствам модели. /// </summary> /// <typeparam name="TModel">Тип модели, содержащей привязываемые свойства.</typeparam> /// <returns>Возвращает объект с установленными значениями свойств.</returns> TModel Bind <TModel>() where TModel : new() { var model = new TModel(); var metadatas = MetadataProvider.ReadMetadata(typeof(TModel)); BindUsingMetadata(model, metadatas); return(model); }
public FlatItemInfo(TModel item, Func <TModel, long> idProvider, Func <TModel, TModelWrapper> wrapper) { ViewType = ItemViewType; Item = item; Section = null; Id = idProvider(item); WrappedItem = wrapper(item); WrappedSection = default(TModelCollectionWrapper); }
}//сделано public void LoadModelInfo(TModel CurrModel) { if (CurrModel == null) { return; } textBoxModelName.Text = CurrModel.ModelName; textBoxModelURL.Text = CurrModel.ModelURL; }//сделано
public TModel CreateModel <TModel, TPrimary>() where TModel : IVHModel <TModel, TPrimary>, new() where TPrimary : IVHEntity { // All TModel (e.g. CommonPersonModel) must have valid constructor (TPrimary primaryEntity) as Activator expectation TModel result = (TModel)Activator.CreateInstance(typeof(TModel), new object[] { this }); return(result); }
public void BuildFromStat <TModel>() where TModel : NGramModelBase, new() { var stat = new TextStatistician($"{PATH_BASE}stat.csv"); var model = new TModel(); model.FromStatistician(stat); model.Save(); }
public void RemoveSeparatorIfLast(TModel model) { int count = modelAdapter.GetItemCount(model); if (count > 0 && modelAdapter.IsSeparatorAt(model, count - 1)) { modelAdapter.RemoveAt(model, count - 1); } }
public override void Process(long LSN) { // // Process change record hide by deleting the specified tModel. // TModel tModel = new TModel(TModelKey); tModel.Hide(); }
/// <summary> /// Publica ontologie cu numele si URL-ul specificat in campurile corespunzatoare (daca nu exista deja). /// </summary> private void performPublish() { String ontologyName = txbOntologyName.Text.Trim(); String ontologyURL = txbOntologyURL.Text.Trim(); if (ontologyName == String.Empty || ontologyURL == String.Empty) { MessageBox.Show("All values must be set", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { FindTModel findTModel = new FindTModel(ontologyName); // uuid:a035a07c-f362-44dd-8f95-e2b134bf43b4 == uddi-org:general_keywords key KeyedReference categoryOntology = new KeyedReference("uuid:a035a07c-f362-44dd-8f95-e2b134bf43b4", "ontology", "QoS"); findTModel.CategoryBag.Add(categoryOntology); findTModel.FindQualifiers.Add(FindQualifier.ExactNameMatch); TModelList tModelList = findTModel.Send(uddiConnection); if (0 == tModelList.TModelInfos.Count) { TModel ontologyTModel = new TModel(ontologyName); ontologyTModel.CategoryBag.Add(categoryOntology); ontologyTModel.OverviewDoc.OverviewUrl = ontologyURL; SaveTModel saveOntologyTModel = new SaveTModel(ontologyTModel); saveOntologyTModel.Send(uddiConnection); MessageBox.Show("Publish successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ontology already exists"); } } catch (UddiException e) { MessageBox.Show("Uddi error: "+ e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e){ MessageBox.Show("General exception: " + e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } }