public Library Get(IId id) { using (var db = new SQLiteConnection(_path)) { return(db.Get <SqlLibrary>(((SqlId)id).Id)); } }
/// <summary> /// Create a new acknowledgement. /// </summary> /// <param name="Result">The result of the operation.</param> /// <param name="Description">An optional description of the result code.</param> /// <param name="Warnings">Warnings or additional information.</param> /// <param name="Runtime">The runtime of the request.</param> private PushChargingStationDataResult(IId Id, IReceiveData IReceiveData, PushDataResultTypes Result, IEnumerable <PushSingleChargingStationDataResult> RejectedEVSEs = null, String Description = null, IEnumerable <Warning> Warnings = null, TimeSpan?Runtime = null) { this.Id = Id; this.IReceiveData = IReceiveData; this.Result = Result; this.RejectedEVSEs = RejectedEVSEs ?? new PushSingleChargingStationDataResult[0]; this.Description = Description.IsNotNullOrEmpty() ? Description.Trim() : null; this.Warnings = Warnings != null ? Warnings.Where(warning => warning.IsNotNullOrEmpty()) : new Warning[0]; this.Runtime = Runtime; }
public IId GetProperty(IId property) { if(!ContainsProperty(property)) throw new Exception(); int pVal = ((IntId)property).Value; return list[pVal]; }
public static bool RemoveById <T>(this ICollection <T> collection, IId objId) where T : IId { var item = collection.Single(x => x.Id == objId.Id); return(collection.Remove(item)); }
public void Setup() { _el = _Fac.CreateDummyCompoundElementBase(Guid.NewGuid()); _asISetPortMgrs = _el as ISetPortMgrs; _asIParentId = _el as IParentId; _asIIdGetter = _el; }
public User Get(IId id) { using (var db = new SQLiteConnection(_path)) { return(db.Get <SqlUser>(((SqlId)id).Id)); } }
private IId ParseId(XmlReader reader) { IId id = entityFactory.CreateId(); id.Deserialize(reader, null); return(id); }
public static IId GetFunctionCall(IId valueDictionary, IId callee, string name) { var ret = GetFunctionCall(valueDictionary, callee); Naming.GiveNameToIId(name, ret); return(ret); }
public static IId GetFunctionCall(IId valueDictionary, IId callee) { var ret = RefId.CreateRefId(); ret.SetProperty(parameterValues,valueDictionary); ret.SetProperty(functionCalled,callee); return ret; }
public int GetHashCode(IId <long> obj) { unchecked { return((int)obj.Id); } }
public static IId getCombinedFunctionDefinition(IId parameterSet, IId functionCallList) { var ret = RefId.CreateRefId(); ret.SetProperty(parameters, parameterSet); ret.SetProperty(subFunctionCalls, functionCallList); return ret; }
public Account Get(IId id) { using (var db = new SQLiteConnection(_path)) { return(db.Get <SqlAccount>(((SqlId)id).Id).ToAccount(_libraryManager, _userManager)); } }
public MatcherInfo FindMatcher(IId partitionId) { MatcherInfoResponse response = null; string path = string.Format("{0}/find/{1}", MatchersPath, partitionId.ToUrlSafe()); using (WebClient wc = new WebClient { BaseAddress = this.BaseAddress }) using (var responseStream = wc.OpenRead(path)) { var s = new XmlSerializer(typeof(MatcherInfoResponse)); response = (MatcherInfoResponse)s.Deserialize(responseStream); } if (response.Success) { return(response.Result); } else { logger.Error("Error while getting matcher address: {0}.", response.ErrorMessage); // TODO: throw an exception? return(null); } }
public static void AddNameSpaceChild(IId parentId, IId childId) { if(!parentId.ContainsProperty(nsChildren)) parentId.SetProperty(nsChildren,DfSet.CreateSet()); var set = parentId.GetProperty(nsChildren); DfSet.AddToSet(set,childId); }
public static IId getCombinedFunctionDefinition(IId parameterSet, IId functionCallList, string name) { var ret = getCombinedFunctionDefinition(parameterSet, functionCallList); Naming.GiveNameToIId(name, ret); return(ret); }
public bool ContainsProperty(IId property) { if(!(property is IntId)) return false; int pVal = ((IntId )property).Value; return pVal >= 0 && pVal < list.Count; }
public TBuilder SetId <T>(IId <T> id) { var clrId = id.ClrId; this.DomReadWriteResource.SetDomIdFromClrResourceId(this.ResourceType, clrId); return(this.Builder); }
private IQueryBuilder GetQueryBuilder(IId spaceId) { var builder = this.queryBuilderFactory.Create(); builder.FromBuilder.Append($"SPACE \"{spaceId}\", Types version"); return(builder); }
/// <summary> /// Create a new abstract authorize stop result. /// </summary> /// <param name="AuthorizatorId">The identification of the authorizing entity.</param> /// <param name="Result">The authorize start result type.</param> /// <param name="SessionId">The optional charging session identification, when the authorize start operation was successful.</param> /// /// <param name="ProviderId">An optional identification of the e-mobility provider.</param> /// <param name="Description">An optional description of the auth start result.</param> /// <param name="AdditionalInfo">An optional additional message.</param> /// <param name="Runtime">The runtime of the request.</param> protected AAuthStopResult(IId AuthorizatorId, T Result, ChargingSession_Id?SessionId = null, eMobilityProvider_Id?ProviderId = null, String Description = null, String AdditionalInfo = null, TimeSpan?Runtime = null) { #region Initial checks if (AuthorizatorId == null) { throw new ArgumentNullException(nameof(AuthorizatorId), "The given identification of the authorizator must not be null!"); } #endregion this.AuthorizatorId = AuthorizatorId; this.Result = Result; this.SessionId = SessionId; this.ProviderId = ProviderId ?? new eMobilityProvider_Id?(); this.Description = Description; this.AdditionalInfo = AdditionalInfo; this.Runtime = Runtime; }
public static PushRoamingNetworkAdminStatusResult Flatten(IId AuthId, ISendAdminStatus ISendAdminStatus, IEnumerable <PushRoamingNetworkAdminStatusResult> PushRoamingNetworkAdminStatusResults, TimeSpan Runtime) { #region Initial checks if (PushRoamingNetworkAdminStatusResults == null || !PushRoamingNetworkAdminStatusResults.Any()) { return(new PushRoamingNetworkAdminStatusResult(AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.Error, "!", new RoamingNetworkAdminStatusUpdate[0], new Warning[0], Runtime)); } #endregion var All = PushRoamingNetworkAdminStatusResults.ToArray(); var ResultOverview = All.GroupBy(_ => _.Result). ToDictionary(_ => _.Key, _ => new List <PushRoamingNetworkAdminStatusResult>(_)); var Descriptions = All.Where(_ => _ != null). SafeSelect(_ => _.Description). AggregateWith(Environment.NewLine); var RejectedRoamingNetworkAdminStatusUpdates = All.Where(_ => _ != null). SelectMany(_ => _.RejectedRoamingNetworkAdminStatusUpdates); var Warnings = All.Where(_ => _ != null). SelectMany(_ => _.Warnings); foreach (var result in ResultOverview) { if (ResultOverview[result.Key].Count == All.Length) { return(new PushRoamingNetworkAdminStatusResult(All[0].AuthId, ISendAdminStatus, result.Key, Descriptions, RejectedRoamingNetworkAdminStatusUpdates, Warnings, Runtime)); } } return(new PushRoamingNetworkAdminStatusResult(All[0].AuthId, ISendAdminStatus, PushRoamingNetworkAdminStatusResultTypes.Partial, Descriptions, RejectedRoamingNetworkAdminStatusUpdates, Warnings, Runtime)); }
public static void RemoveIfContainsById <T>(this ICollection <T> collection, IId objId) where T : IId { if (collection.ContainsById(objId)) { collection.RemoveById(objId); } }
/// <summary> /// 实体是否已经删除了 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static bool IsDeleted(IId obj) { if (obj == null || !(obj is IDelete)) { return(false); } return(((IDelete)obj).DeleteState); }
public static IId GetFunctionCall(IId valueDictionary, IId callee) { var ret = RefId.CreateRefId(); ret.SetProperty(parameterValues, valueDictionary); ret.SetProperty(functionCalled, callee); return(ret); }
public IId GetProperty(IId property) { if (!ContainsProperty(property)) { throw new Exception(); } return(BareParametersList); }
public IId GetProperty(IId property) { if (!set.Contains(property)) { throw new Exception(); } return(property); }
/// <summary> /// Gets entity at <paramref name="index"/> if exist, otherwise returns null. /// </summary> /// <typeparam name="TEntity">The type of the entity </typeparam> /// <param name="table">The SQL table <see cref="Table{TEntity}"/>.</param> /// <param name="index">The index.</param> /// <returns>An instance of <typeparamref name="TEntity"/> at <paramref name="index"/> if exist, otherwise null.</returns> public static TEntity GetAt <TEntity>(this Table <TEntity> table, int index) where TEntity : class, IId { //cast is not supported by linq to SQL. see revision 10753 IId _ret = table.Cast <IId>().Where <IId>(x => x.ID == index).FirstOrDefault <IId>(); return(_ret == null ? null : (TEntity)_ret); }
public dependDotAdapter(object ownerSender, IId IDinterface, ILine LineInterface) { if(ownerSender == null || IDinterface == null || LineInterface == null) throw new ArgumentNullException(); sender = ownerSender; parentID = IDinterface; line = LineInterface; }
public static void GiveNameToIId(string name, IId id) { if (!id.IsRefIId()) { throw new Exception("Can only give names to ref IIds"); } id.SetProperty(nameTag, StringId.CreateStringId(name)); }
public static IId getCombinedFunctionDefinition(IId parameterSet, IId functionCallList) { var ret = RefId.CreateRefId(); ret.SetProperty(parameters, parameterSet); ret.SetProperty(subFunctionCalls, functionCallList); return(ret); }
/// <summary> /// 删除的字段; /// </summary> /// <param name="delete"></param> /// <param name="user"></param> public static void SetDeleteState(IDelete delete, IId user) { if (!delete.DeleteState) { delete.DeleteState = true; delete.DeleteUserId = user?.Id; delete.DeleteDateTime = DateTime.Now; } }
private void OnCollisionEnter2D(Collision2D collision) { IId id = collision.gameObject.GetComponent <IId>(); if (id != null) { id.GetId(); } }
public TBuilder SetId <T>(IId <T> id) { Contract.Requires(id != null); var detail = InfrastructureErrorStrings.DocumentBuildExceptionDetailBuildResourceCollectionWithSingleObject .FormatWith(DomNodeType.Id, typeof(TResource).Name); throw new DocumentBuildException(detail); }
private void PopulateFields(int position) { var user = MainActivity.UserManager.Get(new SqlId(position + 1)); _id = user.Id; FindViewById <EditText>(Resource.Id.firstNameInput).Text = user.FirstName; FindViewById <EditText>(Resource.Id.lastNameInput).Text = user.LastName; }
public async Task ModifyAsync(Action <T> modifyLogic, IId <string> id) { await Policy .Handle <MongoWaitQueueFullException>() .WaitAndRetryForeverAsync(retryAttempt => TimeSpan.FromMilliseconds(Math.Pow(2, retryAttempt))) .ExecuteAsync(async() => { using (var session = dbContext.Database.Client.StartSession()) { try { await session.WithTransaction( async(s, ct) => { var entityCollection = session.Client.GetDatabase(mongoDbSettings.DatabaseName).GetCollection <T>(MongoUtils.GetCollectionName <T>()); var eventsCollection = session.Client.GetDatabase(mongoDbSettings.DatabaseName).GetCollection <EventWrapper>(MongoDefaultSettings.EventsDocumentName); ReplaceOneResult result; T foundAggregate; do { var filter = Builders <T> .Filter.Eq(MongoDefaultSettings.IdName, id.Value); foundAggregate = await GetFirstFromCollectionAsync(entityCollection, filter); var version = foundAggregate.Etag; foundAggregate.RegenerateEtag(); modifyLogic(foundAggregate); foundAggregate.CheckState(); filter = filter & Builders <T> .Filter.Eq(MongoDefaultSettings.EtagName, version); result = await entityCollection.ReplaceOneAsync(filter, foundAggregate, new ReplaceOptions { IsUpsert = false }); } while (result.ModifiedCount != 1); //events are saved after sucessfull transformation if (result.ModifiedCount == 1) { foreach (var @event in foundAggregate.GetEvents()) { var mongoEvent = new EventWrapper(Guid.NewGuid().ToString(), @event.GetType(), @event, foundAggregate.Id.Value); eventsCollection.InsertOne(mongoEvent); } } }); } catch (MongoWaitQueueFullException exception) { logger.LogError($"{Messages.NonTransientExceptionCaught} ${exception.Message}.", exception); throw; } } }); }
CommunicationTimeout(IId AuthorizatorId, IReceiveAuthorizeStartStop IReceiveAuthorizeStartStop, ChargingSession_Id?SessionId = null, TimeSpan?Runtime = null) => new AuthStopChargingPoolResult(AuthorizatorId, IReceiveAuthorizeStartStop, AuthStopChargingPoolResultType.CommunicationTimeout, SessionId, Runtime: Runtime);
private MatcherInfo FindMatcher(IId partitionId) { if (!this.partitionRouting.ContainsKey(partitionId)) { MatcherInfo mi = MatcherModule.Instance.CreatePartitionServiceClient().FindMatcher(partitionId); this.partitionRouting.TryAdd(partitionId, mi); } return(this.partitionRouting[partitionId]); }
public void Setup() { HttpApi.Register <IId>().ConfigureHttpApiConfig(c => { c.HttpHost = new Uri("http://localhost:8099/"); c.FormatOptions.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; }); _id = HttpApi.Resolve <IId>(); }
public static RefId CreateList(IId[] elements) { var list = RefId.CreateRefId(); var rawList = BareListId.CreateBareListId(); list.SetProperty(listId, rawList); for (int i = 0; i < elements.Length; i++) { rawList.SetProperty(IntId.CreateId(i),elements[i]); } return list; }
/// <summary> /// НАДО ТЕСТИРОВАТЬ! /// Класс участника связи, хранит информацию об участнике, а так же зависимость связи для него /// </summary> /// <param name="member">Идентификатор участника связи</param> /// <param name="dependType">Тип зависимости участника связи</param> /// <param name="delay">Значение задержки связи</param> /// <exception cref="NullReferenceException"></exception> /// <exception cref="objectAlreadyExistException"></exception> public linkMember(IId member, e_DependType dependType, double delay) { memberID = member; this.dependType = dependType; membersDaysDelta = 0; this._delay = delay; ddAdapter = new dependDotAdapter(memberID, memberID, (ILine)memberID); }
protected void init_slave(IId slaveID, ILine slaveLine) { slave = new linkMember(this, e_DependType.Slave); slave.init_member(slaveID, slaveLine, Hlp.GetDepenDot(limit, e_DependType.Slave)); slave.date = master.getObjectDependDotInfo().GetDate(); event_LimitChanged += slave.handler_limitTypeChanged; event_DelayChanged += slave.handler_delayChanged; master.getObjectDependDotInfo().event_DateChanged += slave.handler_dependDateChange; }
public ILMember GetInfoMember(IId member) { if (slave.memberID == member) return slave; else if (master.memberID == member) return master; else throw new ArgumentException("Wrong member ID"); }
public linkClass(IId MasterID, ILine MasterLine, IId SlaveID, ILine SlaveLine, e_TskLim limit) { if(!Enum.IsDefined(typeof(e_TskLim),limit)) throw new ArgumentNullException(); this.limit = limit; _ident = new Identity(e_Entity.Link); delay = 0; init_master(MasterID, MasterLine); Console.WriteLine("Master initialized"); init_slave(SlaveID, SlaveLine); Console.WriteLine("Slave initialized"); init_dependence(); Console.WriteLine("Dependence initialized"); }
protected void init_master(IId masterID, ILine masterLine) { master = new linkMember(this, e_DependType.Master); master.init_member(masterID, masterLine, Hlp.GetDepenDot(limit, e_DependType.Master)); event_LimitChanged += master.handler_limitTypeChanged; master.date = master.getObjectDependDotInfo().GetDate(); master.delay = 0; master.getObjectDependDotInfo().event_DateChanged += master.handler_dependDateChange; }
public ILMember GetInfoMember(IId member) { if (member.GetId() == master.GetMemberId().GetId()) return master; else if (member.GetId() == slave.GetMemberId().GetId()) return slave; return null; }
public simpleLMember(simpleLink parent, IId memberID, ILine lMember, e_DependType dependType) { depend = dependType; this.memberID = memberID; this.lMember = lMember; }
public bool ContainsProperty(IId property) { return values.ContainsKey(property); }
public simpleLink(IId idMaster, ILine lMaster, IId idSlave, ILine lSlave, e_TskLim limit) { id = new Identity(e_Entity.Link); this.limit = limit; master = new simpleLMember(this, idMaster, lMaster, e_DependType.Master); depend = new simpleDepend(lMaster, Hlp.GetPrecursor(limit)); slave = new simpleLMember(this, idSlave, lSlave, e_DependType.Slave); depend.sender = this; }
/// <summary> /// Метод получения ссылки на интерфейс класса информации о члене связи /// </summary> /// <param name="member">Идентификатор члена связи</param> /// <returns>Ссылка на интерфейс класса информации о члене связи</returns> public ILMember GetInfoMember(IId member) { if (member == _slave.memberID) return _slave; else if (member == _master.memberID) return _master; else return null; }
public IId GetProperty(IId property) { return values[property]; }
/// <summary> /// Метод инициализации управляющего члена связи (запускается вторым) /// </summary> /// <param name="masterID">Интерфейс идентификатора</param> /// <param name="masterLine">Интерфейс отрезка</param> protected void init_master(IId masterID, ILine masterLine) { //Запускать вторым из инитов _master.init_member(masterID, masterLine, dotDependMaster); event_LimitChanged += _master.handler_limitTypeChanged; aUnsuscribeMaster = () => { event_LimitChanged -= _master.handler_limitTypeChanged; aUnsuscribeMaster = () => { }; }; }
public void RemoveProperty(IId property) { values.Remove(property); }
/// <summary> /// Инициализирует класс зависимой точки <seealso cref="dependDotAdapter"/> /// </summary> /// <param name="memberID">Идентификатор участника связи</param> /// <param name="memberLine">Интерфейс <seealso cref="ILine"/> участника связи</param> /// <param name="dependDot">Зависимая точка подчиненного объекта</param> /// <exception cref="objectAlreadyExistException">Выбрасывает исключение если класс <seealso cref="dependDotAdapter"/> уже был инициализирован</exception> public void init_member(IId memberID, ILine memberLine, e_Dot dependDot) { if(ddAdapter != null) throw new objectAlreadyExistException(); this.memberID = memberID; ddAdapter = new dependDotAdapter(sender, memberID, memberLine); ddAdapter.event_DateChanged += handler_dependObjectDateChanged; ddAdapter.setDependDot(dependDot); }
public void SetProperty(IId property, IId value) { values[property] = value; }
/// <summary> /// Validate the given instance. /// </summary> /// <param name="toValidate">The given instance to validate.</param> /// <returns><c>true</c> if the given instance has an id that is the same as this <see cref="P:Id"/>; otherwise <c>false</c>.</returns> public bool Validate(IId toValidate) { return (toValidate != null && toValidate.Id == this.Id); }
/// <summary> /// Метод инициализации подчиненного члена связи (запускается третьим) /// </summary> /// <param name="slaveID">Интерфейс идентификатора</param> /// <param name="slaveLine">Интерфейс отрезка</param> protected void init_slave(IId slaveID, ILine slaveLine) { //Запускать третьим из инитов _slave.init_member(slaveID, slaveLine, dotDependSlave); _slave.date = _master.getObjectDependDotInfo().GetDate(); event_LimitChanged += _slave.handler_limitTypeChanged; event_DelayChanged += _slave.handler_delayChanged; _master.getObjectDependDotInfo().event_DateChanged += _slave.handler_dependDateChange; _slave.event_neighboursDeltaChanged += handler_deltaSlaveChange; aUnsuscribeSlave = () => { event_LimitChanged -= _slave.handler_limitTypeChanged; event_DelayChanged -= _slave.handler_delayChanged; _master.getObjectDependDotInfo().event_DateChanged -= _slave.handler_dependDateChange; _slave.event_neighboursDeltaChanged -= handler_deltaSlaveChange; aUnsuscribeSlave = () => { }; }; }
/// <summary> /// Gets the comment. /// </summary> /// <param name="user">The user.</param> /// <param name="saveView">The save view.</param> /// <param name="media">The media.</param> /// <returns></returns> private Comment GetComment(IId<int> user, CommentSaveView saveView, IMediaFiles media) { return new Comment { Text = saveView.Comments, MediaId = media.MediaId, CommentStatus = CommentStatus.Approved, Email = saveView.Email, Name = saveView.Name, SiteUrl = saveView.Website ?? string.Empty, CommentDate = DateTime.Now, Ip = HttpContext.Request.UserHostAddress, UserAgent = HttpContext.Request.UserAgent, UserId = user.Id }; }
public void Setup() { TestSupport.Core.Factory fac = new TestSupport.Core.Factory(); _el = fac.CreateDummyCommentBase(Guid.NewGuid()); _asIParentId = _el as IParentId; _asISetId = _el; _asIIdGetter = _el; _asISetParentId = _el as ISetParentId; }
private void AddIId(IId iid, string unique) { environment.NameToId.Add(unique, iid); environment.IdToName.Add(iid, unique); }
private async Task<Client.Common.Models.PlaylistItem> LoadModelImpl(IId model) { Client.Common.Models.PlaylistItem playlistItem = null; if (model != null) { await SubsonicService.GetSong(model.Id) .WithErrorHandler(this) .OnSuccess(result => playlistItem = CreatePlaylistItemFromSong(result)).Execute(); } return playlistItem; }
public void clear() { unsubscribe(); unsubscribe(); unsubscribe = null; sender = null; parentID = null; selectedDot = null; line = null; cleared = true; }