internal MainBranch GetLabBranchMenus(string labId, int take, int skip, double latitude, double longitude, long governId) { MainBranch labAndItsBranches = new MainBranch(); GeoCoordinate userGeoCoordinate = new GeoCoordinate(latitude, longitude); try { labAndItsBranches = checkUpContext.Laboratories.Where(w => w.FireBaseId == labId).AsEnumerable().Select(s => new MainBranch() { labHotline = s.hotline, labPhoto = s.image, branches = s.LabBranches.Where(w => (governId == 0 || w.governId == governId)).Skip(skip).Take(take).Select(c => new LabBranchMenu() { idFB = c.FireBaseId, govern = c.Govern1 != null ? c.Govern1.Name : string.Empty, address = MapToAddress(c.Address), rating = c.rating ?? 0, isAvailableFromHome = c.isAvailableFromHome ?? false, userGeoCoordinate = userGeoCoordinate, branchGeoCoordinate = new GeoCoordinate(c.Address.latitude ?? 0, c.Address.longitude ?? 0), }).OrderBy(o => o.distance).ToList() }).FirstOrDefault(); } catch (Exception ex) { labAndItsBranches = null; } return(labAndItsBranches); }
public OutputFormatBranch(MainBranch mainBranch) { this._mainBranch = mainBranch; // MainBranch populates this list for us... this._ormGenerators = new List <IORMGenerator>(); }
public ORMGeneratorSelectionControl(EnvDTE.ProjectItem projectItem, IServiceProvider serviceProvider) : this() { _projectItem = projectItem; _serviceProvider = serviceProvider; #if VISUALSTUDIO_10_0 ProjectRootElement project = ProjectRootElement.TryOpen(projectItem.ContainingProject.FullName); string projectFullPath = project.FullPath; #else // VISUALSTUDIO_10_0 Project project = Engine.GlobalEngine.GetLoadedProject(projectItem.ContainingProject.FullName); string projectFullPath = project.FullFileName; #endif // VISUALSTUDIO_10_0 _project = project; string projectItemRelativePath = (string)projectItem.Properties.Item("LocalPath").Value; projectItemRelativePath = (new Uri(projectFullPath)).MakeRelativeUri(new Uri(projectItemRelativePath)).ToString(); _projectItemRelativePath = projectItemRelativePath; #if VISUALSTUDIO_10_0 ProjectItemGroupElement originalItemGroup = ORMCustomTool.GetItemGroup(project, projectItemRelativePath); ProjectItemGroupElement itemGroup; if (originalItemGroup == null) { itemGroup = project.AddItemGroup(); itemGroup.Condition = string.Concat(ITEMGROUP_CONDITIONSTART, projectItemRelativePath, ITEMGROUP_CONDITIONEND); } else { itemGroup = project.AddItemGroup(); itemGroup.Condition = originalItemGroup.Condition; foreach (ProjectItemElement item in originalItemGroup.Items) { ProjectItemElement newItem = itemGroup.AddItem(item.ItemType, item.Include); newItem.Condition = item.Condition; foreach (ProjectMetadataElement metadataElement in item.Metadata) { newItem.AddMetadata(metadataElement.Name, metadataElement.Value); } } } #else // VISUALSTUDIO_10_0 BuildItemGroup originalItemGroup = ORMCustomTool.GetItemGroup(project, projectItemRelativePath); BuildItemGroup itemGroup; if (originalItemGroup == null) { itemGroup = project.AddNewItemGroup(); itemGroup.Condition = string.Concat(ITEMGROUP_CONDITIONSTART, projectItemRelativePath, ITEMGROUP_CONDITIONEND); } else { itemGroup = project.AddNewItemGroup(); itemGroup.Condition = originalItemGroup.Condition; foreach (BuildItem item in originalItemGroup) { BuildItem newItem = itemGroup.AddNewItem(item.Name, item.Include, false); newItem.Condition = item.Condition; item.CopyCustomMetadataTo(newItem); } } #endif // VISUALSTUDIO_10_0 _originalItemGroup = originalItemGroup; _itemGroup = itemGroup; string condition = itemGroup.Condition.Trim(); string sourceFileName = this._sourceFileName = projectItem.Name; this.textBox_ORMFileName.Text = sourceFileName; this.button_SaveChanges.Click += new EventHandler(this.SaveChanges); this.button_Cancel.Click += new EventHandler(this.Cancel); ITree tree = (ITree)(this.virtualTreeControl.MultiColumnTree = new MultiColumnTree(2)); this.virtualTreeControl.SetColumnHeaders(new VirtualTreeColumnHeader[] { // TODO: Localize these. new VirtualTreeColumnHeader("Generated File Format", 0.30f, VirtualTreeColumnHeaderStyles.ColumnPositionLocked | VirtualTreeColumnHeaderStyles.DragDisabled), new VirtualTreeColumnHeader("Generated File Name", 1f, VirtualTreeColumnHeaderStyles.ColumnPositionLocked | VirtualTreeColumnHeaderStyles.DragDisabled) }, true); MainBranch mainBranch = this._mainBranch = new MainBranch(this); int totalCount = mainBranch.VisibleItemCount; int[] primaryIndices = new int[totalCount]; for (int i = 0; i < totalCount; ++i) { if (mainBranch.IsPrimaryDisplayItem(i)) { primaryIndices[i] = i - totalCount; } else { primaryIndices[i] = i + 1; } } Array.Sort <int>(primaryIndices); int lastPrimary = -1; for (int i = 0; i < totalCount; ++i) { int modifiedIndex = primaryIndices[i]; if (modifiedIndex < 0) { primaryIndices[i] = modifiedIndex + totalCount; } else { if (lastPrimary == -1) { lastPrimary = i - 1; } primaryIndices[i] = modifiedIndex - 1; } } int modifierCount = totalCount - mainBranch.Branches.Count; tree.Root = (lastPrimary == -1) ? (IBranch)mainBranch : new BranchPartition( mainBranch, primaryIndices, new BranchPartitionSection(0, lastPrimary + 1, null), new BranchPartitionSection(totalCount - modifierCount, modifierCount, "Generated File Modifiers"), new BranchPartitionSection(lastPrimary + 1, totalCount - lastPrimary - modifierCount - 1, "Intermediate and Secondary Files")); // UNDONE: Localize Header this.virtualTreeControl.ShowToolTips = true; this.virtualTreeControl.FullCellSelect = true; #if VISUALSTUDIO_10_0 Dictionary <string, ProjectItemElement> buildItemsByGenerator = this._itemsByGenerator = new Dictionary <string, ProjectItemElement>(itemGroup.Count, StringComparer.OrdinalIgnoreCase); foreach (ProjectItemElement buildItem in itemGroup.Items) #else // VISUALSTUDIO_10_0 Dictionary <string, BuildItem> buildItemsByGenerator = this._itemsByGenerator = new Dictionary <string, BuildItem>(itemGroup.Count, StringComparer.OrdinalIgnoreCase); foreach (BuildItem buildItem in itemGroup) #endif // VISUALSTUDIO_10_0 { // Do this very defensively so that the dialog can still be opened if a project is out // of step with the generators registered on a specific machine. string generatorNameData = buildItem.GetEvaluatedMetadata(ITEMMETADATA_ORMGENERATOR); string[] generatorNames; // The first string is the primary generator, others are the format modifiers int generatorNameCount; IORMGenerator primaryGenerator; MainBranch.OutputFormatBranch primaryFormatBranch; if (!String.IsNullOrEmpty(generatorNameData) && String.Equals(buildItem.GetEvaluatedMetadata(ITEMMETADATA_DEPENDENTUPON), sourceFileName, StringComparison.OrdinalIgnoreCase) && null != (generatorNames = generatorNameData.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)) && 0 != (generatorNameCount = generatorNames.Length) && ORMCustomTool.ORMGenerators.TryGetValue(generatorNames[0], out primaryGenerator) && mainBranch.Branches.TryGetValue(primaryGenerator.ProvidesOutputFormat, out primaryFormatBranch)) { System.Diagnostics.Debug.Assert(primaryFormatBranch.SelectedORMGenerator == null); primaryFormatBranch.SelectedORMGenerator = primaryGenerator; buildItemsByGenerator.Add(generatorNames[0], buildItem); // Format modifiers are attached to the end of the list for (int i = 1; i < generatorNameCount; ++i) { MainBranch.OutputFormatBranch modifierBranch = primaryFormatBranch.NextModifier; string findName = generatorNames[i]; while (modifierBranch != null) { IORMGenerator testGenerator = modifierBranch.ORMGenerators[0]; if (testGenerator.OfficialName == findName) { modifierBranch.SelectedORMGenerator = testGenerator; break; } modifierBranch = modifierBranch.NextModifier; } } } } }
public SrcDirectory ListSources(MainBranch branch, string directory) { return(ListSources(branch.name, directory)); }
public ORMGeneratorSelectionControl(EnvDTE.ProjectItem projectItem, IServiceProvider serviceProvider) : this() { _projectItem = projectItem; _serviceProvider = serviceProvider; #if VISUALSTUDIO_10_0 ProjectRootElement project = ProjectRootElement.TryOpen(projectItem.ContainingProject.FullName); string projectFullPath = project.FullPath; #else // VISUALSTUDIO_10_0 Microsoft.Build.BuildEngine.Project project = Engine.GlobalEngine.GetLoadedProject(projectItem.ContainingProject.FullName); string projectFullPath = project.FullFileName; #endif // VISUALSTUDIO_10_0 _project = project; string projectItemRelativePath = (string)projectItem.Properties.Item("LocalPath").Value; projectItemRelativePath = (new Uri(projectFullPath)).MakeRelativeUri(new Uri(projectItemRelativePath)).ToString(); _projectItemRelativePath = projectItemRelativePath; #if VISUALSTUDIO_10_0 ProjectItemGroupElement originalItemGroup = ORMCustomTool.GetItemGroup(project, projectItemRelativePath); #else // VISUALSTUDIO_10_0 BuildItemGroup originalItemGroup = ORMCustomTool.GetItemGroup(project, projectItemRelativePath); #endif // VISUALSTUDIO_10_0 _originalItemGroup = originalItemGroup; string sourceFileName = projectItem.Name; _sourceFileName = sourceFileName; this.textBox_ORMFileName.Text = sourceFileName; this.button_SaveChanges.Click += new EventHandler(this.SaveChanges); this.button_Cancel.Click += new EventHandler(this.Cancel); ITree tree = (ITree)(this.virtualTreeControl.MultiColumnTree = new MultiColumnTree(2)); this.virtualTreeControl.SetColumnHeaders(new VirtualTreeColumnHeader[] { // TODO: Localize these. new VirtualTreeColumnHeader("Generated File Format", 0.30f, VirtualTreeColumnHeaderStyles.ColumnPositionLocked | VirtualTreeColumnHeaderStyles.DragDisabled), new VirtualTreeColumnHeader("Generated File Name", 1f, VirtualTreeColumnHeaderStyles.ColumnPositionLocked | VirtualTreeColumnHeaderStyles.DragDisabled) }, true); MainBranch mainBranch = this._mainBranch = new MainBranch(this #if VISUALSTUDIO_15_0 , serviceProvider #endif ); int totalCount = mainBranch.VisibleItemCount; int[] primaryIndices = new int[totalCount]; for (int i = 0; i < totalCount; ++i) { if (mainBranch.IsPrimaryDisplayItem(i)) { primaryIndices[i] = i - totalCount; } else { primaryIndices[i] = i + 1; } } Array.Sort <int>(primaryIndices); int lastPrimary = -1; for (int i = 0; i < totalCount; ++i) { int modifiedIndex = primaryIndices[i]; if (modifiedIndex < 0) { primaryIndices[i] = modifiedIndex + totalCount; } else { if (lastPrimary == -1) { lastPrimary = i - 1; } primaryIndices[i] = modifiedIndex - 1; } } int modifierCount = totalCount - mainBranch.Branches.Count; tree.Root = (lastPrimary == -1) ? (IBranch)mainBranch : new BranchPartition( mainBranch, primaryIndices, new BranchPartitionSection(0, lastPrimary + 1), new BranchPartitionSection(totalCount - modifierCount, modifierCount, "Generated File Modifiers", false), new BranchPartitionSection(lastPrimary + 1, totalCount - lastPrimary - modifierCount - 1, "Intermediate and Secondary Files", true)); // UNDONE: Localize Header this.virtualTreeControl.ShowToolTips = true; this.virtualTreeControl.FullCellSelect = true; Dictionary <string, PseudoBuildItem> pseudoItemsByOutputFormat = new Dictionary <string, PseudoBuildItem>(StringComparer.OrdinalIgnoreCase); _pseudoItemsByOutputFormat = pseudoItemsByOutputFormat; IDictionary <string, IORMGenerator> generators = #if VISUALSTUDIO_15_0 ORMCustomTool.GetORMGenerators(serviceProvider); #else ORMCustomTool.ORMGenerators; #endif if (originalItemGroup != null) { #if VISUALSTUDIO_10_0 foreach (ProjectItemElement buildItem in originalItemGroup.Items) #else // VISUALSTUDIO_10_0 foreach (BuildItem buildItem in originalItemGroup) #endif // VISUALSTUDIO_10_0 { // Do this very defensively so that the dialog can still be opened if a project is out // of step with the generators registered on a specific machine. string generatorNameData; string[] generatorNames; // The first string is the primary generator, others are the format modifiers int generatorNameCount; IORMGenerator primaryGenerator; MainBranch.OutputFormatBranch primaryFormatBranch; if (!string.IsNullOrEmpty(generatorNameData = buildItem.GetEvaluatedMetadata(ITEMMETADATA_ORMGENERATOR)) && !string.IsNullOrEmpty(generatorNameData = generatorNameData.Trim()) && string.Equals(buildItem.GetEvaluatedMetadata(ITEMMETADATA_DEPENDENTUPON), sourceFileName, StringComparison.OrdinalIgnoreCase) && null != (generatorNames = generatorNameData.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)) && 0 != (generatorNameCount = generatorNames.Length) && // This assumes that each generator target of the same type has all of the same options. // This is currently the result of this dialog, and we're not considering hand edits // to the project file at this point. generators.TryGetValue(generatorNames[0], out primaryGenerator) && mainBranch.Branches.TryGetValue(primaryGenerator.ProvidesOutputFormat, out primaryFormatBranch)) { PseudoBuildItem pseudoItem; string outputFormat = primaryGenerator.ProvidesOutputFormat; if (!pseudoItemsByOutputFormat.TryGetValue(outputFormat, out pseudoItem)) { // Note that we can't use the build item file name here as it might be decorated with // target names. Go back to the generator to get an undecorated default name. pseudoItem = new PseudoBuildItem(generatorNameData, primaryGenerator.GetOutputFileDefaultName(sourceFileName)); pseudoItemsByOutputFormat.Add(outputFormat, pseudoItem); if (primaryFormatBranch.SelectedORMGenerator == null) { primaryFormatBranch.SelectedORMGenerator = primaryGenerator; } // Format modifiers are attached to the end of the list for (int i = 1; i < generatorNameCount; ++i) { MainBranch.OutputFormatBranch modifierBranch = primaryFormatBranch.NextModifier; string findName = generatorNames[i]; while (modifierBranch != null) { IORMGenerator testGenerator = modifierBranch.ORMGenerators[0]; if (testGenerator.OfficialName == findName) { modifierBranch.SelectedORMGenerator = testGenerator; break; } modifierBranch = modifierBranch.NextModifier; } } } pseudoItem.AddOriginalInstance(generatorNameData, ORMCustomToolUtility.GeneratorTargetsFromBuildItem(buildItem)); } } } }
public OutputFormatBranch(MainBranch mainBranch) { this._mainBranch = mainBranch; // MainBranch populates this list for us... this._ormGenerators = new List<IORMGenerator>(); }