/// <summary> /// Creates sample user token /// </summary> /// <param name="context">context</param> /// <param name="userId">user identifier</param> /// <returns>sample user token</returns> public SampleUserToken CreateUserToken(Context context, int userId) { if (context == null) throw new MemoryPointerIsNullException("context"); return new SampleUserToken(userId, utcTimeProviderResolver.GetService(context).GetCurrentUTCTime()); }
/// <summary> /// Gets another sample type structured data /// </summary> /// <param name="context">context</param> /// <returns>another sample type structured data</returns> public UITree GetAnotherTypeStructuredData(Context context) { var setProvider = this.setProviderResolver.GetService(context); var structureProvider = this.structureProviderResolver.GetService(context); var descriptorTree = structureProvider.GetAnotherTypeDescriptorTree(context); return UITree.Create<string, AnotherType>(descriptorTree, name => setProvider.GetAnotherTypeInstanceByName(context, name)); }
/// <summary> /// Gets user token /// </summary> /// <param name="context">context</param> /// <param name="userTokenRequest">user token request</param> /// <returns>user token</returns> public UserToken GetUserToken(Context context, UserTokenRequest userTokenRequest) { var request = userTokenRequest as UserTokenRequestWithCredentials; Debug.Assert(request != null, "request != null"); var userToken = LoadUserToken(context, request.TenantName, request.AccountName, request.Password); return userToken; }
private UserToken LoadUserToken(Context context, string tenantName, string accountName, string password) { // TODO: implement this function var sampleUserTokenFactory = this.sampleUserTokenFactoryResolver.GetService(context); var result = sampleUserTokenFactory.CreateUserToken(context, 100); return result; }
/// <summary> /// Lists sample type instances /// </summary> /// <param name="context">context</param> /// <returns>list of sample type instances</returns> public List<SampleType> ListSampleTypes(Context context) { var setProvider = this.setProviderResolver.GetService(context); var structureProvider = this.structureProviderResolver.GetService(context); var descriptorsTree = structureProvider.GetSampleTypeDescriptorTree(context); var entityRootsTree = UITree .Create<string, SampleType>(descriptorsTree, name => setProvider.GetSampleTypeInstanceByName(context, name)) .GetEntityRootsTree(); return entityRootsTree.Roots.Select(root => ((EntityTreeNode<SampleType>)root).Entity).ToList(); }
/// <summary> /// Gets user data by user token /// </summary> /// <param name="context">context</param> /// <param name="userToken">user token</param> /// <returns>user data</returns> public UserData GetUserData(Context context, UserToken userToken) { int userId = 0; if (!(userToken is AnonymousUserToken)) { var token = userToken as SampleUserToken; Debug.Assert(token != null, "token != null"); userId = token.UserId; } return this.userData[userId]; }
/// <summary> /// Updates meeting /// </summary> /// <param name="context">context</param> /// <param name="userId">user identifier</param> /// <param name="meetingId">meeting identifier</param> /// <param name="updateData">meeting update data</param> public void UpdateMeeting(Context context, int userId, int meetingId, MeetingUpdateData updateData) { if (updateData == null) throw new MemoryPointerIsNullException("updateData"); // TODO: user user id to check write access to the meeting // TODO: implement this method properly (the following implementation is just a hack) this.meetings.Remove(meetingId); var newMeetingInitData = new MeetingInitData() { Id = meetingId, Name = updateData.Name, StartTime = updateData.StartTime, EndTime = updateData.EndTime, DelegateProviderResolver = this.delegateProviderResolver, AttendeeProviderResolver = this.attendeeProviderResolver, }; this.meetings.Add(meetingId, new Meeting(newMeetingInitData)); }
/// <summary> /// Gets exception for the case when argument is null /// </summary> /// <param name="context">context</param> /// <returns>exception instance</returns> public EntityException<SampleType, TestError> GetTestErrorException(Context context) { var testErrorFactory = testErrorFactoryResolver.GetService(context); return new EntityException<SampleType, TestError>(context, this, testErrorFactory.CreateInfoEntity()); }
/// <summary> /// Gets sample type instance by name /// </summary> /// <param name="context">context</param> /// <param name="name">name</param> /// <returns>sample type instance</returns> public SampleType GetSampleTypeInstanceByName(Context context, string name) { SampleType result; this.sampleTypes.TryGetValue(name, out result); return result; }
/// <summary> /// Gets HTML-encoded transformed string with regard to the specified context /// </summary> /// <param name="context">context</param> /// <param name="rawString">raw string</param> /// <returns>HTML-encoded string</returns> public static string GetHtmlEncodedTransformedString(Context context, string rawString) { return GetHtmlEncodedString(GetTransformedString(context, rawString)); }
/// <summary> /// Gets transformed string /// </summary> /// <param name="context">context</param> /// <param name="rawString">raw string</param> /// <returns>transformed string</returns> public static string Transform(Context context, string rawString) { return rawString != null ? rawString.Replace('s', '$') : null; }
/// <summary> /// Loads output string by key with regard to the specified context /// </summary> /// <param name="context">context</param> /// <param name="key">output string key</param> /// <returns>output string</returns> protected override string LoadOutputString(Context context, string key) { return this.resourceManager.GetString(key, context.GetCurrentUICulture()); }
/// <summary> /// Gets transformed string with regard to the specified context /// </summary> /// <param name="context">context</param> /// <param name="rawString">raw string</param> /// <returns>transformed string</returns> public static string GetTransformedString(Context context, string rawString) { return TransformedStrings.Transform(context, rawString); }
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public override string GetObjectDescription(Context context) { return string.Format("Name={0};", this.Name); }
/// <summary> /// Gets current user token /// </summary> /// <param name="context">context</param> /// <returns>user token</returns> public UserToken GetCurrentUserToken(Context context) { // TODO: read token data from cookie, possibly using IAuthCookiePropertiesProvider return new SampleUserToken(100, DateTime.UtcNow); }
/// <summary> /// Gets delegate /// </summary> /// <param name="context">context</param> /// <param name="delegateId">delegate identifier</param> /// <returns>delegate</returns> public Delegate GetDelegate(Context context, int delegateId) { return this.delegates[delegateId]; }
/// <summary> /// Gets yet another sample type instance by name /// </summary> /// <param name="context">context</param> /// <param name="name">name</param> /// <returns>yet another sample type instance</returns> public YetAnotherType GetYetAnotherTypeInstanceByName(Context context, string name) { YetAnotherType result; this.yetAnotherTypes.TryGetValue(name, out result); return result; }
/// <summary> /// Gets attendee delegate /// </summary> /// <param name="context">context</param> public Delegate GetDelegate(Context context) { return this.delegateProvider.GetDelegate(context, this.DelegateId); }
/// <summary> /// Gets sample type instances /// </summary> /// <param name="context">context</param> /// <returns>sample type instances</returns> public IEnumerable<SampleType> GetSampleTypeInstances(Context context) { return this.sampleTypes.Values; }
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public override string GetObjectDescription(Context context) { return string.Format("Id={0}; DelegateId={1}; State={2}", this.Id, this.DelegateId, this.State); }
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public abstract string GetObjectDescription(Context context);
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public override string GetObjectDescription(Context context) { return Surname + "(" + Id + "," + UserId + ")"; }
/// <summary> /// Gets description of the item /// </summary> /// <param name="context">context</param> /// <returns>description</returns> public string GetDescription(Context context) { return this.description; }
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public override string GetObjectDescription(Context context) { return string.Format("Name='{0}'; Description='{1}'", this.Name, this.Description); }
/// <summary> /// Gets yet another sample type instances /// </summary> /// <param name="context">context</param> /// <returns>yet another sample type instances</returns> public IEnumerable<YetAnotherType> GetYetAnotherTypeInstances(Context context) { return this.yetAnotherTypes.Values; }
/// <summary> /// Gets description of the item /// </summary> /// <param name="context">context</param> /// <returns>description</returns> public string GetDescription(Context context) { return this.resourceManager.GetString(resourceKey, context.GetCurrentUICulture()); }
/// <summary> /// Lists attendees of specified meeting /// </summary> /// <param name="context">context</param> /// <param name="meetingId">meeting identifier</param> /// <returns>attendee instances</returns> public IEnumerable<Attendee> ListMeetingAttendees(Context context, int meetingId) { return this.attendees[meetingId]; }
/// <summary> /// Gets description of the item /// </summary> /// <param name="context">context</param> /// <returns>description</returns> public string GetDescription(Context context) { return this.descriptionProvider.GetDescription(context); }
/// <summary> /// Gets yet another sample type descriptor tree /// </summary> /// <param name="context">context</param> /// <returns>yet another sample type descriptors tree</returns> public IUITree GetYetAnotherTypeDescriptorTree(Context context) { return this.yetAnotherTypeConfigCollection; }
/// <summary> /// Gets string description of an object with regard to the specified context /// </summary> /// <param name="context">context</param> /// <returns>string representation</returns> public override string GetObjectDescription(Context context) { return GetDescription(context); }