private static bool IsPropertyInAllowedList(PropertyDefinition property) { SmartPropertyDefinition smartPropertyDefinition = property as SmartPropertyDefinition; if (smartPropertyDefinition != null) { foreach (PropertyDependency propertyDependency in smartPropertyDefinition.Dependencies) { if ((propertyDependency.Type & PropertyDependencyType.NeedForRead) == PropertyDependencyType.NeedForRead && !ConversationMembersQueryBase.AllowedPropertiesForLoad.Contains(propertyDependency.Property)) { return(false); } } return(true); } return(ConversationMembersQueryBase.AllowedPropertiesForLoad.Contains(property)); }
private SmartObjectDefinition CreateServiceJoin(string smoName1, string smoName2) { try { // Delete the smartobject if it already exists this.DeleteSmartObject(smoName1 + smoName2); toolStripStatusLabel1.Text = ("Creating ServiceJoin SmartObject '" + smoName1 + " " + smoName2 + "'"); statusStrip1.Update(); ManagementServerConnect(); // Get first serviceobject ServiceInstance serviceInstance1 = ServiceInstance.Create(_smoManagementServer.GetServiceInstanceForExtend(new Guid(_smartboxGuid), smoName1)); ServiceObject serviceObject1 = serviceInstance1.ServiceObjects[0]; if (serviceObject1 == null) { throw new Exception("Serviceobject does not exist. " + smoName1); } // Get second serviceobject ServiceInstance serviceInstance2 = ServiceInstance.Create(_smoManagementServer.GetServiceInstanceForExtend(new Guid(_smartboxGuid), smoName2)); ServiceObject serviceObject2 = serviceInstance2.ServiceObjects[0]; if (serviceObject2 == null) { throw new Exception("Serviceobject does not exist. " + smoName2); } // Create SmartObjectDefinition SmartObjectDefinition smoDefinition = new SmartObjectDefinition(); smoDefinition.Name = smoName1 + smoName2; smoDefinition.Metadata.DisplayName = smoName1 + " " + smoName2; // Get Getlist servicemethod ServiceObjectMethod method = serviceObject1.Methods["GetList"]; if (method == null) { throw new Exception("GetList method does not exist on " + serviceObject1.Name); } // Create SmartMethodDefinition SmartMethodDefinition soMethod = new SmartMethodDefinition(); soMethod.Name = method.Name; soMethod.Metadata.DisplayName = method.DisplayName; smoDefinition.Methods.Add(soMethod); // Map the first ServiceObject string executionBlockName = soMethod.Map(method); foreach (ServiceObjectProperty soProperty in serviceObject1.Properties) { SmartPropertyDefinition smartProperty = new SmartPropertyDefinition(); smartProperty.Name = soProperty.Name + "_1"; smartProperty.Metadata.DisplayName = soProperty.Name + "_1"; smoDefinition.Properties.Add(smartProperty); smoDefinition.MapProperty(smartProperty, soProperty, executionBlockName, method.Name); } // Map the second ServiceObject method = serviceObject2.Methods["GetList"]; if (method == null) { throw new Exception("GetList method does not exist on " + serviceObject1.Name); } executionBlockName = soMethod.Map(method); foreach (ServiceObjectProperty soProperty in serviceObject2.Properties) { SmartPropertyDefinition smartProperty = new SmartPropertyDefinition(); smartProperty.Name = soProperty.Name + "_2"; smartProperty.Metadata.DisplayName = soProperty.Name + "_2"; smoDefinition.Properties.Add(smartProperty); smoDefinition.MapProperty(smartProperty, soProperty, executionBlockName, method.Name); } ServiceJoinDetails joinDetails = smoDefinition.Methods[0].JoinDetails; joinDetails.From = soMethod.ExecutionBlocks[0].ServiceInstance.ServiceObjects[0]; ServiceJoin serviceJoin = new ServiceJoin(); serviceJoin.From = soMethod.ExecutionBlocks[0].ServiceInstance.ServiceObjects[0];; serviceJoin.To = soMethod.ExecutionBlocks[1].ServiceInstance.ServiceObjects[0];; serviceJoin.AddCondition("Condition", serviceObject1.Properties[1], serviceObject2.Properties[1]); joinDetails.ServiceJoins.Add(serviceJoin); smoDefinition.AddDeploymentCategory("Test SmartObjects"); smoDefinition.Build(); return(smoDefinition); } catch (Exception ex) { throw ex; } finally { ManagementServerCloseConnection(); } }
private void GenerateConditionsForSubdirs(FamilyDefinition family, Framework fw, CopyJob job) { HashSet <string> explicitlyMentionedDirectories = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); HashSet <string> excludedSubdirectories = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (var cond in job.SmartFileConditions ?? new string[0]) { var def = SmartPropertyDefinition.Parse(cond, null); foreach (var item in def.Items) { int idx = item.Key.IndexOf('\\'); if (idx != -1) { explicitlyMentionedDirectories.Add(item.Key.Substring(0, idx)); } } } Regex rgExcludedSubdir = new Regex(@"-([^\\]+)\\\*$"); foreach (var cond in (job.FilesToCopy + ";" + job.ProjectInclusionMask).Split(';')) { var m = rgExcludedSubdir.Match(cond); if (m.Success) { excludedSubdirectories.Add(m.Groups[1].Value); } } List <string> generatedSmartFileConditions = new List <string>(); foreach (var dir in Directory.GetDirectories(_Builder.ExpandVariables(job.SourceFolder))) { string name = Path.GetFileName(dir); if (explicitlyMentionedDirectories.Contains(name)) { continue; } if (excludedSubdirectories.Contains(name)) { continue; } generatedSmartFileConditions.Add($"-{name}|{name}\\\\.*"); if (!_FrameworkConditions.TryGetValue(fw.ID, out var conditions)) { _FrameworkConditions[fw.ID] = conditions = new GeneratedFrameworkConditions { TargetPath = $"$$SYS:BSP_ROOT$$/{family.FamilySubdirectory}/{job.TargetFolder}".Replace('\\', '/') } } ; conditions.ConditionalSubdirectories.Add(name); } job.SmartFileConditions = (job.SmartFileConditions ?? new string[0]).Concat(generatedSmartFileConditions).OrderBy(c => c.ToLower().TrimStart('-')).ToArray(); } void GenerateBLEFrameworks(FamilyDefinition family) { List <Framework> bleFrameworks = new List <Framework>(); string famBase = family.Name.Substring(0, 5).ToLower(); HashSet <string> discoveredSubdirs = new HashSet <string>(); string baseDir = Path.Combine(family.PrimaryHeaderDir, @"..\..\..\components\ble"); foreach (var subdir in Directory.GetDirectories(baseDir)) { discoveredSubdirs.Add(Path.GetFileName(subdir)); } foreach (var subdir in Directory.GetDirectories(Path.Combine(baseDir, "ble_services"))) { discoveredSubdirs.Add(Path.Combine("ble_services", Path.GetFileName(subdir))); } foreach (var name in new[] { "ble_services", "common", "peer_manager", "nrf_ble_gatt" }) { discoveredSubdirs.Remove(name); } foreach (var dir in discoveredSubdirs) { string desc = FetchDescriptionFromDirectory(Path.Combine(baseDir, dir)) ?? throw new Exception("Failed to load description of " + dir); if (desc.StartsWith("BLE")) { desc = desc.Substring(3).Trim(); } string virtualFolderName = "BLE " + desc; desc = "Bluetooth LE - " + desc; string id = Path.GetFileName(dir); if (id.StartsWith("experimental_")) { id = id.Substring(13); } if (!id.StartsWith("ble_") && !id.StartsWith("nrf_ble")) { id = "ble_" + id; } /*if (dir.StartsWith("ble_services\\", StringComparison.CurrentCultureIgnoreCase)) * { * int idx = id.IndexOf("ble_"); * if (idx == -1) * id = "ble_svc_" + id; * else * id = id.Insert(idx + 4, "svc_"); * }*/ bleFrameworks.Add(new Framework { Name = string.Format("{0} ({1})", desc, Path.GetFileName(dir)), ID = "com.sysprogs.arm.nordic." + famBase + "." + id, ClassID = "com.sysprogs.arm.nordic.nrfx." + id, ProjectFolderName = virtualFolderName, DefaultEnabled = false, CopyJobs = new CopyJob[] { new CopyJob { SourceFolder = Path.Combine(baseDir, dir), TargetFolder = @"components\ble\" + dir, FilesToCopy = "-*_nrf51.c;*.c;*.h", } } }); } family.AdditionalFrameworks = family.AdditionalFrameworks.Concat(bleFrameworks).OrderBy(fw => fw.Name).ToArray(); }
private ParticipantTable LoadReplyAllParticipantsPerTypeImpl(IConversationTree conversationTree, ICollection <IConversationTreeNode> nodes, SmartPropertyDefinition propertyDefinition) { ParticipantTable participantTable = this.LoadParticipantsPerType(new ConversationDataExtractor.ParticipantPerTypeLoaderDelegate(this.LoadReplyAllParticipantField), conversationTree, nodes, propertyDefinition); participantTable[RecipientItemType.Cc].ExceptWith(participantTable[RecipientItemType.To]); return(participantTable); }
private ParticipantSet LoadReplyAllParticipantsImpl(IConversationTree conversationTree, ICollection <IConversationTreeNode> nodes, SmartPropertyDefinition propertyDefinition) { ParticipantSet participantSet = new ParticipantSet(); ParticipantTable participantTable = this.LoadReplyAllParticipantsPerTypeImpl(conversationTree, nodes, propertyDefinition); participantSet.UnionWith(participantTable[RecipientItemType.To]); participantSet.UnionWith(participantTable[RecipientItemType.Cc]); return(participantSet); }
private bool TryGetParticipantsFromReplyAllParticipantsProperty(IStorePropertyBag propertyBag, SmartPropertyDefinition propertyDefinition, out ParticipantTable participantTable) { participantTable = new ParticipantTable(); object obj = propertyBag.TryGetProperty(propertyDefinition); if (PropertyError.IsPropertyError(obj)) { return(false); } IDictionary <RecipientItemType, HashSet <string> > dictionary = (IDictionary <RecipientItemType, HashSet <string> >)obj; foreach (KeyValuePair <RecipientItemType, HashSet <string> > keyValuePair in dictionary) { IList <Participant> participants = new List <Participant>(); if (!this.TryResolveParticipants(keyValuePair.Value, participants)) { return(false); } participantTable.Add(keyValuePair.Key, participants); } return(true); }
private ParticipantTable LoadParticipantsPerType(ConversationDataExtractor.ParticipantPerTypeLoaderDelegate loaderDelegate, IConversationTree conversationTree, IEnumerable <IConversationTreeNode> nodes, SmartPropertyDefinition propertyDefinition) { ParticipantTable participantTable = new ParticipantTable(); foreach (IConversationTreeNode conversationTreeNode in nodes) { if (conversationTreeNode.HasData) { foreach (IStorePropertyBag propertyBag in conversationTreeNode.StorePropertyBags) { IDictionary <RecipientItemType, ParticipantSet> dictionary = loaderDelegate(conversationTree, propertyBag, propertyDefinition); foreach (KeyValuePair <RecipientItemType, ParticipantSet> keyValuePair in dictionary) { participantTable[keyValuePair.Key].UnionWith(keyValuePair.Value); } } } } return(participantTable); }
private IDictionary <RecipientItemType, ParticipantSet> LoadReplyAllParticipantField(IConversationTree conversationTree, IStorePropertyBag propertyBag, SmartPropertyDefinition propertyDefinition) { if (propertyBag.GetValueOrDefault <bool>(InternalSchema.IsDraft, false)) { return(new Dictionary <RecipientItemType, ParticipantSet>()); } ParticipantTable replyAllParticipants; if (!this.TryGetParticipantsFromReplyAllParticipantsProperty(propertyBag, propertyDefinition, out replyAllParticipants)) { StoreObjectId objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId; if (!this.loadedItemParts.ContainsKey(objectId)) { this.optimizationInfo.UpdateItemParticipantNotFound(objectId); this.LoadItemPart(conversationTree, propertyBag); } replyAllParticipants = this.loadedItemParts[objectId].ReplyAllParticipants; } return(replyAllParticipants.ToParticipantSet()); }