public static void Dump(this TypeInfoCollection target) { Console.WriteLine("Structures:"); foreach (TypeInfo type in target.Structures) { type.DumpName(1); type.DumpAncestor(2); type.DumpDescendants(2); } Console.WriteLine("Entities:"); foreach (TypeInfo type in target.Entities) { type.DumpName(1); type.DumpAncestor(2); type.DumpDescendants(2); type.DumpInterfaces(2); } Console.WriteLine("Interfaces:"); foreach (TypeInfo type in target.Interfaces) { type.DumpName(1); type.DumpInterfaces(2); type.DumpDescendants(2); type.DumpImplementors(2); } }
private Dictionary <TypeInfo, int> InitReferencesOfTypesDictionary(TypeInfoCollection allTypes) { var referencesOfTypeDictionary = new Dictionary <TypeInfo, int>(); var entityTypes = allTypes.Where(el => el.IsEntity && !el.IsInterface && !el.IsStructure && !el.IsSystem && !el.IsAuxiliary); foreach (var type in entityTypes) { referencesOfTypeDictionary.Add(type, 0); } return(referencesOfTypeDictionary); }
/// <summary> /// Handles the Click event of the btnReset control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void btnReset_Click(object sender, System.Windows.RoutedEventArgs e) { txtDescription.Text = string.Empty; txtHourCount.Text = "0"; try { var projectItem = timeSheetDetail.ProjectList.Where(project => project.Id == DefaultId).FirstOrDefault(); ProjectListPicker.SelectedItem = projectItem; featureList = new TypeInfoCollection { new TypeInfo { Id = -1, Name = "Feature" } }; FeatureListPicker.ItemsSource = featureList; ToggleFeatureControl(featureList.Count > 1); var workCategoryItem = timeSheetDetail.WorkCategories.Where(workCategory => workCategory.Id == DefaultId).FirstOrDefault(); WorkCategoryListPicker.SelectedItem = workCategoryItem; } catch (Exception ex) { } }
private async void ProjectListPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (NetworkInterface.GetIsNetworkAvailable()) { if (ProjectListPicker.SelectedItem != null && timeSheetDetail != null) { var project = ProjectListPicker.SelectedItem as ProjectDetail; var projectDetailValue = project.Id; if (!string.IsNullOrEmpty(projectDetailValue.ToString()) && projectDetailValue >= 0) { featureList = await timesheetRepository.RetrieveFeatures(projectDetailValue, null, ApplicationData.User.UserId, ApplicationData.User.Token); var defaultFeature = new TypeInfo { Id = -1, Name = "Feature" }; featureList.Insert(0, defaultFeature); FeatureListPicker.ItemsSource = new List<TypeInfo>(featureList); ToggleFeatureControl(featureList.Count > 1); if (isActivityStart) { var selectedFeature = featureList.Where(feature => feature.Id == timeSheetDetail.LastTaskDetail.FeatureId).FirstOrDefault(); FeatureListPicker.SelectedItem = selectedFeature != null ? selectedFeature : defaultFeature; isActivityStart = false; progressMask.Hide(); } } } } }
/// <summary> /// Handles the ItemSelected event of the spnProject control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AdapterView.ItemSelectedEventArgs"/> instance containing the event data.</param> private async void spnProject_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { if (!IfNetworkAvailable()) { return; } var spnProj = sender as Spinner; if (spnProj != null && timeSheetDetail != null) { var projectDetailValue = timeSheetDetail.ProjectList[(int)spnProj.SelectedItemId].Id; if (!string.IsNullOrEmpty(projectDetailValue.ToString()) && projectDetailValue >= 0) { featureList = await timesheetRepository.RetrieveFeatures(projectDetailValue, null, ApplicationData.User.Token); featureList.Add(new TypeInfo { Id = -1, Name = "Feature" }); var featureListAdapter = new CustomArrayAdapter<TypeInfo>(this, Android.Resource.Layout.SimpleSpinnerItem, featureList); spnFeature.Adapter = featureListAdapter; toggleFeatureControl(featureList.Count > 1); if (isActivityStart) { var selectedFeature = featureList.Where(feature => feature.Id == timeSheetDetail.LastTaskDetail.FeatureId).FirstOrDefault(); spnFeature.SetSelection(((CustomArrayAdapter<TypeInfo>)spnFeature.Adapter).GetPosition(selectedFeature)); isActivityStart = false; } else { if (featureList.Count > 1) { spnFeature.SetSelection(((CustomArrayAdapter<TypeInfo>)spnFeature.Adapter).Count); } } } } if (progressDialog != null && progressDialog.IsShowing) { progressDialog.Dismiss(); } }
/// <summary> /// Clears the control. /// </summary> private void ClearControl() { txtDescription.Text = string.Empty; txtHourCount.Text = "0"; try { spnProject.SetSelection(((CustomArrayAdapter<ProjectDetail>)spnProject.Adapter).Count); featureList = new TypeInfoCollection { new TypeInfo { Id = -1, Name = "Feature" } }; var featureListAdapter = new CustomArrayAdapter<TypeInfo>(this, Android.Resource.Layout.SimpleSpinnerItem, featureList); spnFeature.Adapter = featureListAdapter; toggleFeatureControl(featureList.Count > 1); spnWorkCategory.SetSelection(((CustomArrayAdapter<TypeInfo>)spnWorkCategory.Adapter).Count); } catch (Exception ex) { } }
public HttpResponseMessage RetrieveTimesheetFeatureList(string projectId, string userId) { int? developerId = string.IsNullOrWhiteSpace(userId) ? null : (int?)Convert.ToInt32(userId, CultureInfo.CurrentCulture); var features = this.lookupService.RetrieveProjectFeatures(Convert.ToInt32(projectId, CultureInfo.CurrentCulture), developerId); var featureList = new TypeInfoCollection(); if (features != null) { features.Sort(); foreach (LookupItem item in features) { featureList.Add(new TypeInfo { Id = item.ID, Name = item.Name }); } return Request.CreateResponse(HttpStatusCode.OK, featureList); } return Request.CreateResponse(HttpStatusCode.BadRequest); }
private static void VerifyModel(Domain domain) { TypeInfoCollection types = domain.Model.Types; Assert.AreEqual(types.FindAncestor(types[typeof(Person)]), null); Assert.AreEqual(types.FindAncestor(types[typeof(Book)]), null); Assert.AreEqual(types.FindAncestor(types[typeof(BookReview)]), null); Assert.AreEqual(types.FindAncestor(types[typeof(Author)]), types[typeof(Person)]); Assert.AreEqual(types[typeof(Person)].GetAncestor(), null); Assert.AreEqual(types[typeof(Book)].GetAncestor(), null); Assert.AreEqual(types[typeof(BookReview)].GetAncestor(), null); Assert.AreEqual(types[typeof(Author)].GetAncestor(), types[typeof(Person)]); ICollection <TypeInfo> collection = types.Structures; Assert.IsTrue(collection.Count > 0); foreach (TypeInfo item in collection) { Assert.IsTrue(item.IsStructure); Assert.IsFalse(item.IsInterface); Assert.IsFalse(item.IsEntity); } collection = types.Interfaces; Assert.IsFalse(collection.Count > 0); foreach (TypeInfo item in collection) { Assert.IsTrue(item.IsInterface); Assert.IsFalse(item.IsStructure); Assert.IsFalse(item.IsEntity); } collection = types.Entities; Assert.IsTrue(collection.Count > 0); foreach (TypeInfo item in collection) { Assert.IsTrue(item.IsEntity); Assert.IsFalse(item.IsInterface); Assert.IsFalse(item.IsStructure); } #region IdentityCard TypeInfo typeInfo = domain.Model.Types[typeof(IdentityCard)]; // Fields Assert.IsNotNull(typeInfo.Fields["FirstName"]); Assert.AreEqual("FirstName", typeInfo.Fields["FirstName"].Name); Assert.AreEqual(64, typeInfo.Fields["FirstName"].Length); Assert.IsTrue(typeInfo.Fields["FirstName"].IsDeclared); Assert.IsFalse(typeInfo.Fields["FirstName"].IsInherited); Assert.IsNotNull(typeInfo.Fields["SecondName"]); Assert.AreEqual("SecondName", typeInfo.Fields["SecondName"].Name); Assert.AreEqual(64, typeInfo.Fields["SecondName"].Length); Assert.IsTrue(typeInfo.Fields["SecondName"].IsDeclared); Assert.IsFalse(typeInfo.Fields["SecondName"].IsInherited); Assert.IsNotNull(typeInfo.Fields["LastName"]); Assert.AreEqual("LastName", typeInfo.Fields["LastName"].Name); Assert.AreEqual(64, typeInfo.Fields["LastName"].Length); Assert.IsTrue(typeInfo.Fields["LastName"].IsDeclared); Assert.IsFalse(typeInfo.Fields["LastName"].IsInherited); #endregion #region Passport typeInfo = domain.Model.Types[typeof(Passport)]; // Fields Assert.IsNotNull(typeInfo.Fields["Number"]); Assert.AreEqual("Number", typeInfo.Fields["Number"].Name); Assert.IsTrue(typeInfo.Fields["Number"].IsDeclared); Assert.IsFalse(typeInfo.Fields["Number"].IsInherited); Assert.IsFalse(typeInfo.Fields["Number"].IsStructure); Assert.IsFalse(typeInfo.Fields["Number"].IsEntity); Assert.IsFalse(typeInfo.Fields["Number"].IsEntitySet); Assert.IsNotNull(typeInfo.Fields["Card"]); Assert.AreEqual("Card", typeInfo.Fields["Card"].Name); Assert.IsTrue(typeInfo.Fields["Card"].IsStructure); Assert.IsFalse(typeInfo.Fields["Card"].IsEntity); Assert.IsFalse(typeInfo.Fields["Card"].IsEntitySet); Assert.AreEqual(3, typeInfo.Fields["Card"].Fields.Count); Assert.IsTrue(typeInfo.Fields["Card"].IsDeclared); Assert.IsFalse(typeInfo.Fields["Card"].IsInherited); Assert.IsNotNull(typeInfo.Columns["Card.FirstName"]); Assert.AreEqual("Card.FirstName", typeInfo.Columns["Card.FirstName"].Name); Assert.AreEqual(64, typeInfo.Columns["Card.FirstName"].Length); Assert.IsNotNull(typeInfo.Columns["Card.SecondName"]); Assert.AreEqual("Card.SecondName", typeInfo.Columns["Card.SecondName"].Name); Assert.AreEqual(64, typeInfo.Columns["Card.SecondName"].Length); Assert.IsNotNull(typeInfo.Columns["Card.LastName"]); Assert.AreEqual("Card.LastName", typeInfo.Columns["Card.LastName"].Name); Assert.AreEqual(64, typeInfo.Columns["Card.LastName"].Length); #endregion #region Person typeInfo = domain.Model.Types[typeof(Person)]; Assert.IsNotNull(typeInfo); Assert.IsNotNull(domain.Model.Types["Person"]); Assert.AreEqual(typeInfo, domain.Model.Types["Person"]); Assert.AreEqual("Person", typeInfo.Name); // Fields Assert.IsNotNull(typeInfo.Fields["Passport"]); Assert.AreEqual("Passport", typeInfo.Fields["Passport"].Name); Assert.IsTrue(typeInfo.Fields["Passport"].IsStructure); Assert.IsFalse(typeInfo.Fields["Passport"].IsEntity); Assert.IsFalse(typeInfo.Fields["Passport"].IsEntitySet); // Assert.AreEqual(typeInfo.Fields["Passport"].Columns.Count, 4); Assert.IsNotNull(typeInfo.Fields["Reviews"]); Assert.AreEqual("Reviews", typeInfo.Fields["Reviews"].Name); Assert.IsFalse(typeInfo.Fields["Reviews"].IsStructure); Assert.IsFalse(typeInfo.Fields["Reviews"].IsEntity); Assert.IsTrue(typeInfo.Fields["Reviews"].IsEntitySet); // KeyColumns Assert.IsNotNull(typeInfo.Columns["Passport.Number"]); Assert.AreEqual("Passport.Number", typeInfo.Columns["Passport.Number"].Name); // Assert.AreEqual(person.Fields["Passport"].Indexes[0], person.Key); Assert.IsNotNull(typeInfo.Columns["Passport.Card.FirstName"]); Assert.AreEqual("Passport.Card.FirstName", typeInfo.Columns["Passport.Card.FirstName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.FirstName"].Length); Assert.IsNotNull(typeInfo.Columns["Passport.Card.SecondName"]); Assert.AreEqual("Passport.Card.SecondName", typeInfo.Columns["Passport.Card.SecondName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.SecondName"].Length); Assert.IsNotNull(typeInfo.Columns["Passport.Card.LastName"]); Assert.AreEqual("Passport.Card.LastName", typeInfo.Columns["Passport.Card.LastName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.LastName"].Length); // Indexes if (IsSingleTable(typeInfo) || IsConcreteTable(typeInfo)) { Assert.AreEqual(2, typeInfo.Indexes.Count); } else { Assert.AreEqual(1, typeInfo.Indexes.Count); } Assert.IsNotNull(typeInfo.Indexes["PK_Person"]); Assert.IsTrue(typeInfo.Indexes["PK_Person"].IsPrimary); Assert.IsTrue(typeInfo.Indexes["PK_Person"].IsUnique); Assert.AreEqual(typeInfo.Hierarchy.Key.TupleDescriptor.Count, typeInfo.Indexes["PK_Person"].KeyColumns.Count); Assert.AreEqual(typeInfo.Columns["PassportNumber"], typeInfo.Indexes["PK_Person"].KeyColumns[0].Key); #endregion #region Author typeInfo = domain.Model.Types[typeof(Author)]; Assert.IsNotNull(typeInfo); Assert.IsNotNull(domain.Model.Types["Author"]); Assert.AreEqual(typeInfo, domain.Model.Types["Author"]); Assert.AreEqual("Author", typeInfo.Name); // Fields Assert.IsNotNull(typeInfo.Fields["Passport"]); Assert.AreEqual("Passport", typeInfo.Fields["Passport"].Name); Assert.IsTrue(typeInfo.Fields["Passport"].IsStructure); Assert.IsTrue(typeInfo.Fields["Passport"].IsInherited); Assert.AreEqual(5, typeInfo.Fields["Passport"].Fields.Count); Assert.IsNotNull(typeInfo.Fields["PenName"]); Assert.AreEqual(true, typeInfo.Fields["PenName"].IsNullable); Assert.AreEqual("PenName", typeInfo.Fields["PenName"].Name); Assert.AreEqual(64, typeInfo.Fields["PenName"].Length); Assert.IsNotNull(typeInfo.Fields["Books"]); Assert.AreEqual(true, typeInfo.Fields["Books"].IsNullable); Assert.AreEqual("Books", typeInfo.Fields["Books"].Name); Assert.AreEqual(2, typeInfo.Fields.Find(FieldAttributes.Declared).Count); Assert.AreEqual(9, typeInfo.Fields.Find(FieldAttributes.Inherited).Count); // KeyColumns Assert.IsNotNull(typeInfo.Columns["PassportNumber"]); Assert.AreEqual("PassportNumber", typeInfo.Columns["PassportNumber"].Name); // Assert.AreEqual(person.Fields["Passport"].Indexes[0], person.Key); Assert.IsNotNull(typeInfo.Columns["Passport.Card.FirstName"]); Assert.AreEqual("Passport.Card.FirstName", typeInfo.Columns["Passport.Card.FirstName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.FirstName"].Length); Assert.IsNotNull(typeInfo.Columns["Passport.Card.SecondName"]); Assert.AreEqual("Passport.Card.SecondName", typeInfo.Columns["Passport.Card.SecondName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.SecondName"].Length); Assert.IsNotNull(typeInfo.Columns["Passport.Card.LastName"]); Assert.AreEqual("Passport.Card.LastName", typeInfo.Columns["Passport.Card.LastName"].Name); Assert.AreEqual(64, typeInfo.Columns["Passport.Card.LastName"].Length); Assert.IsNotNull(typeInfo.Columns["PenName"]); Assert.AreEqual(true, typeInfo.Columns["PenName"].IsNullable); Assert.AreEqual("PenName", typeInfo.Columns["PenName"].Name); Assert.AreEqual(64, typeInfo.Columns["PenName"].Length); Assert.IsFalse(typeInfo.Columns.Contains("Reviews")); // Indexes if (!IsSingleTable(typeInfo)) { if (IsConcreteTable(typeInfo)) { Assert.AreEqual(2, typeInfo.Indexes.Count); } else { Assert.AreEqual(3, typeInfo.Indexes.Count); } Assert.IsNotNull(typeInfo.Indexes["Author.IX_PENNAME"]); Assert.IsNotNull(typeInfo.Indexes[0]); Assert.AreEqual(typeInfo.Indexes[0], typeInfo.Indexes["Author.IX_PENNAME"]); Assert.AreEqual(1, typeInfo.Indexes[0].KeyColumns.Count); Assert.IsNotNull(typeInfo.Indexes[0].KeyColumns[0]); Assert.AreEqual(typeInfo.Columns["PenName"], typeInfo.Indexes[0].KeyColumns[0].Key); } #endregion #region Book typeInfo = domain.Model.Types[typeof(Book)]; Assert.IsNotNull(typeInfo); Assert.IsNotNull(domain.Model.Types["Book"]); Assert.AreEqual(typeInfo, domain.Model.Types["Book"]); Assert.AreEqual(typeInfo.Name, "Book"); // Fields Assert.IsNotNull(typeInfo.Fields["Isbn"]); Assert.AreEqual(typeInfo.Fields["Isbn"].Name, "Isbn"); Assert.AreEqual(typeInfo.Fields["Isbn"].Length, 32); // Assert.AreEqual(book.Fields["Isbn"].Indexes[0], book.Key); Assert.IsNotNull(typeInfo.Fields["Title"]); Assert.AreEqual(typeInfo.Fields["Title"].Name, "Title"); Assert.AreEqual(typeInfo.Fields["Title"].Length, 128); Assert.IsNotNull(typeInfo.Fields["Author"]); Assert.AreEqual(typeInfo.Fields["Author"].Name, "Author"); Assert.IsFalse(typeInfo.Fields["Author"].IsStructure); Assert.IsTrue(typeInfo.Fields["Author"].IsEntity); Assert.IsFalse(typeInfo.Fields["Author"].IsEntitySet); Assert.AreEqual(OnRemoveAction.Deny, typeInfo.Fields["Author"].Associations.Last().OnTargetRemove); // Indexes Assert.AreEqual(6, typeInfo.Indexes.Count); Assert.IsNotNull(typeInfo.Indexes["PK_Book"]); Assert.IsTrue(typeInfo.Indexes["PK_Book"].IsPrimary); Assert.IsTrue(typeInfo.Indexes["PK_Book"].IsUnique); Assert.AreEqual(typeInfo.Hierarchy.Key.TupleDescriptor.Count, typeInfo.Indexes["PK_Book"].KeyColumns.Count); Assert.AreEqual("Isbn", typeInfo.Indexes["PK_Book"].KeyColumns[0].Key.Name); Assert.AreEqual(Direction.Positive, typeInfo.Indexes["PK_Book"].KeyColumns[0].Value); Assert.IsNotNull(typeInfo.Indexes["Book.FK_Author"]); Assert.IsFalse(typeInfo.Indexes["Book.FK_Author"].IsPrimary); Assert.IsFalse(typeInfo.Indexes["Book.FK_Author"].IsUnique); Assert.AreEqual(domain.Model.Types[typeof(Author)].Hierarchy.Key.TupleDescriptor.Count, typeInfo.Indexes["Book.FK_Author"].KeyColumns.Count); Assert.AreEqual("BookAuthor", typeInfo.Indexes["Book.FK_Author"].KeyColumns[0].Key.Name); Assert.AreEqual(Direction.Positive, typeInfo.Indexes["Book.FK_Author"].KeyColumns[0].Value); Assert.IsNotNull(typeInfo.Indexes["Book.IX_Title"]); Assert.IsFalse(typeInfo.Indexes["Book.IX_Title"].IsPrimary); Assert.IsFalse(typeInfo.Indexes["Book.IX_Title"].IsUnique); Assert.AreEqual(1, typeInfo.Indexes["Book.IX_Title"].KeyColumns.Count); Assert.AreEqual("Title", typeInfo.Indexes["Book.IX_Title"].KeyColumns[0].Key.Name); Assert.AreEqual(Direction.Positive, typeInfo.Indexes["Book.IX_Title"].KeyColumns[0].Value); #endregion #region BookReview typeInfo = domain.Model.Types[typeof(BookReview)]; Assert.IsNotNull(typeInfo); Assert.IsNotNull(domain.Model.Types["BookReview"]); Assert.AreEqual(typeInfo, domain.Model.Types["BookReview"]); Assert.AreEqual("BookReview", typeInfo.Name); // Fields Assert.IsNotNull(typeInfo.Fields["Book"]); Assert.AreEqual("Book", typeInfo.Fields["Book"].Name); Assert.AreEqual(OnRemoveAction.Cascade, typeInfo.Fields["Book"].Associations.Last().OnTargetRemove); Assert.IsNotNull(typeInfo.Fields["Reviewer"]); Assert.AreEqual("Reviewer", typeInfo.Fields["Reviewer"].Name); Assert.AreEqual(OnRemoveAction.Clear, typeInfo.Fields["Reviewer"].Associations.Last().OnTargetRemove); Assert.IsNotNull(typeInfo.Fields["Text"]); Assert.AreEqual("Text", typeInfo.Fields["Text"].Name); Assert.AreEqual(4096, typeInfo.Fields["Text"].Length); // Indexes Assert.AreEqual(6, typeInfo.Indexes.Count); Assert.IsNotNull(typeInfo.Indexes["PK_BookReview"]); Assert.IsTrue(typeInfo.Indexes["PK_BookReview"].IsPrimary); Assert.IsTrue(typeInfo.Indexes["PK_BookReview"].IsUnique); Assert.AreEqual(typeInfo.Hierarchy.Key.TupleDescriptor.Count, typeInfo.Indexes["PK_BookReview"].KeyColumns.Count); Assert.AreEqual("Book", typeInfo.Indexes["PK_BookReview"].KeyColumns[0].Key.Name); Assert.AreEqual(Direction.Positive, typeInfo.Indexes["PK_BookReview"].KeyColumns[0].Value); // Assert.AreEqual("Reviewer.PassportNumber", typeInfo.Indexes["PK_BookReview"].KeyColumns[1].Key.Name); // Assert.AreEqual(Direction.Positive, typeInfo.Indexes["PK_BookReview"].KeyColumns[1].Value); #endregion }