public void ParsesServoLayoutLib() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream(Utils.LoadResource(@"External\servo\components\layout\lib.rs"))); Assert.AreEqual(26, importMods.Count); Assert.True(importMods[new PathSegment("layout_debug")].Count == 0); Assert.True(importMods[new PathSegment("construct")].Count == 0); Assert.True(importMods[new PathSegment("context")].Count == 0); Assert.True(importMods[new PathSegment("floats")].Count == 0); Assert.True(importMods[new PathSegment("flow")].Count == 0); Assert.True(importMods[new PathSegment("flow_list")].Count == 0); Assert.True(importMods[new PathSegment("flow_ref")].Count == 0); Assert.True(importMods[new PathSegment("fragment")].Count == 0); Assert.True(importMods[new PathSegment("layout_task")].Count == 0); Assert.True(importMods[new PathSegment("inline")].Count == 0); Assert.True(importMods[new PathSegment("model")].Count == 0); Assert.True(importMods[new PathSegment("parallel")].Count == 0); Assert.True(importMods[new PathSegment("table_wrapper")].Count == 0); Assert.True(importMods[new PathSegment("table")].Count == 0); Assert.True(importMods[new PathSegment("table_caption")].Count == 0); Assert.True(importMods[new PathSegment("table_colgroup")].Count == 0); Assert.True(importMods[new PathSegment("table_rowgroup")].Count == 0); Assert.True(importMods[new PathSegment("table_row")].Count == 0); Assert.True(importMods[new PathSegment("table_cell")].Count == 0); Assert.True(importMods[new PathSegment("text")].Count == 0); Assert.True(importMods[new PathSegment("util")].Count == 0); Assert.True(importMods[new PathSegment("incremental")].Count == 0); Assert.True(importMods[new PathSegment("wrapper")].Count == 0); Assert.True(importMods[new PathSegment("extra")].Count == 0); Assert.True(importMods[new PathSegment("css")].Count == 3); Assert.True(importMods[new PathSegment("css")][new PathSegment("node_util")].Count == 0); Assert.True(importMods[new PathSegment("css")][new PathSegment("matching")].Count == 0); Assert.True(importMods[new PathSegment("css")][new PathSegment("node_style")].Count == 0); }
public void ParseCommentNewLine() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"// mod ext;")); Assert.AreEqual(0, importMods.Count); }
static void Main(string[] args) { Console.Title = "Dumpy by Prometheo#6510"; Stopwatch sWatch = new Stopwatch(); if (args.Length < 1) { Logger.LogError("Invalid argument !"); Console.Read(); Environment.Exit(0); } ModuleImport mImport = new ModuleImport(); Color whitesmoke = Color.WhiteSmoke; Console.WriteAscii(" Dumpy", whitesmoke); Logger.Log("Looking for .NET Assembly"); mImport.path = args[0]; ModuleDefMD module = ModuleDefMD.Load(mImport.path); Logger.Log("Assembly Loaded"); sWatch.Start(); Logger.Log("Decoding Assembly"); Maths.MathsDecoder.Decode(module); Logger.Log("Assembly Decoded"); sWatch.Stop(); Logger.Log($"Work done in {sWatch.ElapsedMilliseconds} ms"); Logger.Log("Saving Module"); module.Write($@"{Environment.CurrentDirectory}\Decoded.exe"); Logger.Log("Module Saved"); Console.Read(); }
public void EmptyModBlock() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"mod asd { foo(); }")); Assert.AreEqual(0, importMods.Count); }
public void MergeAuthorative() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( "mod foo { mod bar; } #[path=\"foo\"] mod foo { mod baz; }")); Assert.AreEqual(1, importMods.Count); }
public static Dictionary <string, ModuleData> GetAllModules() { Dictionary <string, ModuleData> Data = new Dictionary <string, ModuleData>(); ModuleImport Importer = WGAPI.GetModules(); if (Importer.Status.Equals("ok")) { int Pages = Importer.MetaInfo.Pages; foreach (KeyValuePair <string, ModuleData> ModData in Importer.Data) { Data.Add(ModData.Key, ModData.Value); } if (Pages > 1) { for (int Counter = 2; Counter <= Pages; Counter++) { Importer = WGAPI.GetModules(Counter); if (Importer.Status.Equals("ok")) { foreach (KeyValuePair <string, ModuleData> ModData in Importer.Data) { Data.Add(ModData.Key, ModData.Value); } } } } } return(Data); }
public void ParseCommentBlock() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"/* mod ext; */")); Assert.AreEqual(0, importMods.Count); }
public void ParsePubModifier() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( "pub mod foo { pub mod bar; } #[path=\"foo\"] pub mod ex { mod baz; }")); Assert.AreEqual(1, importMods.Count); }
public void MergeModules() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"mod asd { mod foo; } mod asd { mod bar; }")); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(2, importMods[new PathSegment("asd")].Count); }
public void ParseLargeInnerModBlock() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"mod asd { mod bar { } mod baz { mod inner; } mod ext1; mod ext2; mod ext3; }")); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(4, importMods[new PathSegment("asd")].Count); Assert.AreEqual(1, importMods[new PathSegment("asd")][new PathSegment("baz")].Count); }
public void ParseInnerModBlock() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"mod foo { mod inner; }")); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(1, importMods[new PathSegment("foo")].Count); Assert.AreEqual(0, importMods[new PathSegment("foo")][new PathSegment("inner")].Count); }
public void ParseModBlock() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"fn foo { } mod asd { mod ext; }")); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(1, importMods[new PathSegment("asd")].Count); Assert.AreEqual(0, importMods[new PathSegment("asd")][new PathSegment("ext")].Count); }
/* * There's one fairly important difference between mod resolution in rustc and what we do. * Given following code: * mod bar { mod a; } mod bar { mod b; } * We will merget this to mod bar { mod a; mod b; }, but rustc will error out. */ public static ModuleImport ParseImports(ICharStream stream) { var lexer = new ModuleLexer(stream); var tokens = new CommonTokenStream(lexer); var parser = new ModuleParser(tokens); BodyContext root = parser.body(); var imports = new ModuleImport(); TraverseForImports(root, imports); return imports; }
public void AttributePaths() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream(Utils.LoadResource(@"Internal\mod_paths.rs"))); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(1, importMods[new PathSegment("task_files", true)].Count); Assert.False(importMods.ContainsKey(new PathSegment("task_files", false))); Assert.AreEqual(0, importMods[new PathSegment("task_files", true)][new PathSegment("tls.rs", true)].Count); Assert.False(importMods[new PathSegment("task_files", true)].ContainsKey(new PathSegment("tls.rs", false))); }
private async Task <IPythonModule> HandleImportAsync(ImportStatement node, ModuleImport moduleImport, CancellationToken cancellationToken) { var module = await ModuleResolution.ImportModuleAsync(moduleImport.FullName, cancellationToken); if (module == null) { MakeUnresolvedImport(moduleImport.FullName, node); return(null); } return(module); }
public void MergeModBlocks() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream( @"fn foo { } mod asd { mod ext; } mod asd { mod bar { mod ext1; } } mod asd { mod bar { mod ext2; } }")); Assert.AreEqual(1, importMods.Count); Assert.AreEqual(2, importMods[new PathSegment("asd")].Count); Assert.AreEqual(0, importMods[new PathSegment("asd")][new PathSegment("ext")].Count); Assert.AreEqual(2, importMods[new PathSegment("asd")][new PathSegment("bar")].Count); Assert.AreEqual(0, importMods[new PathSegment("asd")][new PathSegment("bar")][new PathSegment("ext1")].Count); Assert.AreEqual(0, importMods[new PathSegment("asd")][new PathSegment("bar")][new PathSegment("ext2")].Count); }
public void SingleLevel() { var empty = new ModuleImport() { { new PathSegment("foo"), new ModuleImport() }, { new PathSegment("bar"), new ModuleImport() } }; var terminals = empty.GetTerminalImports().ToArray(); Assert.AreEqual(2, terminals.Length); Assert.True(terminals.Contains(new PathSegment[] { new PathSegment("foo") }, pathComparer)); Assert.True(terminals.Contains(new PathSegment[] { new PathSegment("bar") }, pathComparer)); }
private Clr() { // Version: 4.0.30319.42000 // symchk "C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll" /s SRV*C:\Users\Deci\Desktop\clr.pdb*http://msdl.microsoft.com/download/symbols // symchk "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll" /s SRV*C:\Users\Deci\Desktop\clr.pdb*http://msdl.microsoft.com/download/symbols LibraryFile = GetRuntimeFile(CLR_DLL_SHORT); SymbolsFile = GetRuntimeFile(CLR_PDB_SHORT); Module = Modules.FindModule(CLR_DLL_SHORT); Version = new Version(4, 0, 30319, 42000); Imports = new ModuleImport(SymbolsFile, Module); Setup(); }
public void ParsesPistonImageLib() { ModuleImport importMods = ModuleParser.ParseImports(new AntlrInputStream(Utils.LoadResource(@"External\image\src\lib.rs"))); Assert.AreEqual(9, importMods.Count); Assert.True(importMods[new PathSegment("imageops")].Count == 0); Assert.True(importMods[new PathSegment("webp")].Count == 0); Assert.True(importMods[new PathSegment("ppm")].Count == 0); Assert.True(importMods[new PathSegment("png")].Count == 0); Assert.True(importMods[new PathSegment("jpeg")].Count == 0); Assert.True(importMods[new PathSegment("gif")].Count == 0); Assert.True(importMods[new PathSegment("image")].Count == 0); Assert.True(importMods[new PathSegment("dynimage")].Count == 0); Assert.True(importMods[new PathSegment("color")].Count == 0); }
public static ModuleImport GetModules(int page) { try { Setup(); } catch (Exception) { } string path = $"encyclopedia/modules/?application_id={APP_ID}&page_no={page}"; string responseString = ""; var response = Client.GetAsync(path).Result; if (response.IsSuccessStatusCode) { var responseContent = response.Content; responseString = responseContent.ReadAsStringAsync().Result; } ModuleImport Import = JsonConvert.DeserializeObject <ModuleImport>(responseString); return(Import); }
private Clr() { ClrDll = GetClrDll(); ClrModule = Modules.GetModule(CLR_DLL_SHORT); ClrVersion = new Version(4, 0, 30319, 42000); if (ClrPdb == null) { ClrPdb = GetClrSymbolFile(); } else { Conditions.Require(ClrPdb.Exists); } ClrSymbols = new ModuleImport(ClrPdb, ClrModule); Setup(); }
/* * Fairly straightforward traversal, with one gotcha: we return bool indicating * if the node is contained within exported mod block, it's to deal with the following: * mod bar { ... } * We don't know at this point if any of the items inside blocks is a module, * so decision to add 'bar' ModuleImport has to be delayed. */ private static bool TraverseForImports(ITree node, ModuleImport current) { bool isContainedInBlock = false; for(int i = 0; i < node.ChildCount; i++) { var child = node.GetChild(i) as IRuleNode; if (child == null) continue; if(child.RuleContext.RuleIndex == ModuleParser.RULE_mod_block) { var blockChildren = new ModuleImport(); var blockImport = new ModuleImport() { { GetModIdent(child), blockChildren } }; if (TraverseForImports(child, blockChildren)) { current.Merge(blockImport); isContainedInBlock = true; } } else if (child.RuleContext.RuleIndex == ModuleParser.RULE_mod_import) { isContainedInBlock = true; current.Merge(new Dictionary<PathSegment, ModuleImport>() { { GetModIdent(child), new ModuleImport() } }); } else { if (TraverseForImports(child, current)) isContainedInBlock = true; } } return isContainedInBlock; }
internal static string[] InteractionList(IModule policy, HlaObjectNode hlaObjectTree) { // interactionList is a simple list of fully qualified interaction names List <string> interactionList = new List <string>(); // Logic: We need to get a list of interactions (no parameters): if (policy.GetType() == typeof(ModuleExport)) { ModuleExport exportPolicy = (ModuleExport)policy; foreach (Source source in exportPolicy.Sources) { // Find the interactons, add if not already there foreach (HlaInteraction inter in source.Interactions) { if (!interactionList.Contains(inter.InteractionClassName)) { interactionList.Add(inter.InteractionClassName); } } } } else { ModuleImport importPolicy = (ModuleImport)policy; // Find the interactons, add if not already there foreach (HlaInteraction inter in importPolicy.Interactions) { if (!interactionList.Contains(inter.InteractionClassName)) { interactionList.Add(inter.InteractionClassName); } } } // Now we can build the string[] return(interactionList.ToArray()); }
internal static string[] ObjectList(IModule policy, HlaObjectNode hlaObjectTree) { // objectListPartial has key=objectClassName, value=comma separated list of attributes Dictionary <string, List <string> > objectList = new Dictionary <string, List <string> >(); // Logic: We need to get the maximum list of attributes associated with each object: // 1. Find all objects in the policy with no attributes defined // 2. Add these objects and the full lst of attributes for the object // 3. Find the objects in the policy with some attributes defined // 4. Add these objects (and their attributes) if they are not there already if (policy.GetType() == typeof(ModuleExport)) { ModuleExport exportPolicy = (ModuleExport)policy; foreach (Source source in exportPolicy.Sources) { // Find the objects with no attributes defined and add the object and all attributes foreach (HlaObject obj in source.Objects) { if (obj.Attributes.Count == 0) { addObject(objectList, obj, hlaObjectTree); } } // Find the objects with attributes defined and add the object and attributes if needed foreach (HlaObject obj in source.Objects) { if (obj.Attributes.Count > 0) { addObjectWithAttributes(objectList, obj); } } } } else { ModuleImport importPolicy = (ModuleImport)policy; // Find the objects with no attributes defined and add the object and all attributes foreach (HlaObject obj in importPolicy.Objects) { if (obj.Attributes.Count == 0) { addObject(objectList, obj, hlaObjectTree); } } // Find the objects with attributes defined and add the object and attributes if needed foreach (HlaObject obj in importPolicy.Objects) { if (obj.Attributes.Count > 0) { addObjectWithAttributes(objectList, obj); } } } // Now we can build the string[] List <string> result = new List <string>(); foreach (KeyValuePair <string, List <string> > obj in objectList) { // General format is <fully qualified object class name>\: <attribute1>, <attribute2> StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}\\: ", obj.Key); for (int i = 0; i < obj.Value.Count; i++) { if (i < obj.Value.Count - 1) { sb.AppendFormat("{0}, ", obj.Value[i]); } else { sb.AppendFormat("{0}", obj.Value[i]); } } result.Add(sb.ToString()); } return(result.ToArray()); }
public void Empty() { var empty = new ModuleImport(); CollectionAssert.AreEquivalent(new string[0, 0], empty.GetTerminalImports()); }
public static string Create(DeployObject deploy, Component component) { // Find the modules we need ModuleFederation federation = (ModuleFederation)findModule(component.Modules, Enums.ModuleType.federation); ModuleImport import = (ModuleImport)findModule(component.Modules, Enums.ModuleType.import); ModuleExport export = (ModuleExport)findModule(component.Modules, Enums.ModuleType.export); ModuleExtension extension = (ModuleExtension)findModule(component.Modules, Enums.ModuleType.extension); ModuleOsp[] osp = findModules(component.Modules); // Create an HlaObject tree to use when defining attribute lists StringReader ms = new StringReader(Properties.Resources.HLAfeatures); HlaObjectNode hlaObjectTree = TreeReader.CreateTree(ms); StringBuilder sb = new StringBuilder(); // Side A - always the side connected to a federation sb.AppendLine("# A side settings (Federation Side)"); sb.AppendLine("A.side_name=" + federation.FederationName); sb.AppendLine("A.description=Federate " + federation.FederateName + " on " + federation.FederationName + " federation"); switch (federation.RTI.HlaSpec) { case "Pitch pRTI 1516": sb.AppendLine("A.profile=A"); break; case "HLA Evolved": sb.AppendLine("A.profile=B"); break; case "Pitch pRTI 1.3": sb.AppendLine("A.profile=C"); break; case "RTI NG": sb.AppendLine("A.profile=D"); break; case "MAK 1.3 RTI": sb.AppendLine("A.profile=E"); break; case "MAK 1516 RTI": sb.AppendLine("A.profile=F"); break; case "RTI NG C++": sb.AppendLine("A.profile=G"); break; case "RTI DLC C++": sb.AppendLine("A.profile=H"); break; case "Evolved C++": sb.AppendLine("A.profile=I"); break; default: sb.AppendLine("A.profile=B"); break; } sb.AppendLine("A.configurationType=" + extension.Parameters["configurationType"]); sb.AppendLine("A.host=" + federation.RTI.CrcAddress); sb.AppendLine("A.port=" + federation.RTI.CrcPortNumber); sb.AppendLine("A.designator="); sb.AppendLine("A.federation=" + federation.FederationName); sb.AppendLine("A.type=" + deploy.Systems[0].SystemType.ToString()); sb.AppendLine("A.name=" + federation.FederateName); sb.AppendLine("A.create=" + extension.Parameters["create"]); sb.Append("A.evolvedFomModules="); for (int i = 0; i < federation.RTI.FomFile.Count; i++) { if (i == federation.RTI.FomFile.Count - 1) { sb.AppendFormat("{0}\n", federation.RTI.FomFile[i]); } else { sb.AppendFormat("{0};", federation.RTI.FomFile[i]); } } sb.AppendLine("A.destroy=false"); sb.AppendLine("A.disableRequest=false"); sb.AppendLine("A.logicalTimeFactoryClassName="); sb.AppendLine("A.conveyProducingFederate=true"); // If this is a High proxy then this is the Export Policy list, otherwise the Import Policy string result = (component.ComponentName.ToUpper().Contains("HIGH")) ? string.Join("; ", ListBuilder.ObjectList(export, hlaObjectTree)) : string.Join("; ", ListBuilder.ObjectList(import, hlaObjectTree)); sb.AppendLine("A.objects=" + result); // same idea for interactions result = (component.ComponentName.ToUpper().Contains("HIGH")) ? string.Join("; ", ListBuilder.InteractionList(export, hlaObjectTree)) : string.Join("; ", ListBuilder.InteractionList(import, hlaObjectTree)); sb.AppendLine("A.interactions=" + result); sb.AppendLine("A.filter=se.pitch.ral.extender.hpsd.Hpsd"); sb.AppendLine("A.filter.policy=" + component.ComponentName + ".xml"); sb.AppendLine(); // B Side -- Always connected to OSP sb.AppendLine("# B side settings (HPSD side)"); sb.AppendLine("B.side_name=" + component.ComponentName); sb.AppendLine("B.description=Federate " + federation.FederateName + " HPSD interface"); sb.AppendLine("B.profile=M"); // HPSD designator sb.AppendLine("B.configurationType=LocalSettingsDesignator"); sb.AppendLine("B.host=0.0.0.0"); sb.AppendLine("B.port=0"); sb.AppendFormat("B.designator={0};DEBUG;CONNECT_TIMEOUT\\=10;HEARTBEAT\\=5\n", getDesignator(osp, component)); sb.AppendLine("B.federation=" + component.ComponentName); sb.AppendLine("B.type=" + deploy.Systems[0].SystemType.ToString()); sb.AppendLine("B.name=" + federation.FederateName); sb.AppendLine("B.create=" + extension.Parameters["create"]); sb.Append("B.evolvedFomModules="); for (int i = 0; i < federation.RTI.FomFile.Count; i++) { if (i == federation.RTI.FomFile.Count - 1) { sb.AppendFormat("{0}\n", federation.RTI.FomFile[i]); } else { sb.AppendFormat("{0};", federation.RTI.FomFile[i]); } } sb.AppendLine("B.destroy=false"); sb.AppendLine("B.disableRequest=false"); sb.AppendLine("B.logicalTimeFactoryClassName="); sb.AppendLine("B.conveyProducingFederate=true"); // If this is a High proxy then this is the Import Policy list, otherwise the Export Policy result = (component.ComponentName.ToUpper().Contains("HIGH")) ? string.Join("; ", ListBuilder.ObjectList(import, hlaObjectTree)) : string.Join("; ", ListBuilder.ObjectList(export, hlaObjectTree)); sb.AppendLine("B.objects=" + result); // same idea for interactions result = (component.ComponentName.ToUpper().Contains("HIGH")) ? string.Join("; ", ListBuilder.InteractionList(import, hlaObjectTree)) : string.Join("; ", ListBuilder.InteractionList(export, hlaObjectTree)); sb.AppendLine("B.interactions=" + result); return(sb.ToString()); }
public static XElement Create(DeployObject deploy, Component component) { HpsdPolicy hpsdPolicy = new HpsdPolicy(); // We can assume that there is only one System in the deploy doc DeploySystem system = deploy.Systems[0]; // PolicyIdentification <--> ConfigMgmt PolicyIdentification polID = new PolicyIdentification { PolicyName = system.FederateName, PolicyVersion = ConfigMgmt.VersionToString(deploy.ConfigMgmt.CurrentVersion), CreatedDate = deploy.ConfigMgmt.Created.date, ModifiedDate = deploy.ConfigMgmt.Changed[deploy.ConfigMgmt.Changed.Count - 1].date, Status = deploy.ConfigMgmt.DocReference.ToString(), Description = deploy.ConfigMgmt.Description }; // No POC information hpsdPolicy.PolicyIdentification = polID; // ======================================= // FomInformation <--> Federation, Extensions FomInformation fominfo = new FomInformation(); // List of fomModule in Federation module ModuleFederation fedModule = (ModuleFederation)findModule(component.Modules, Enums.ModuleType.federation); foreach (string file in fedModule.RTI.FomFile) { fominfo.FomModule.Add(file); } // InstanceIdAttributes are a Vendor extension ModuleExtension extModule = (ModuleExtension)findModule(component.Modules, Enums.ModuleType.extension); if (extModule.VendorName != "Pitch Technologies") { throw new ApplicationException("Pitch Technologies vendor extensions not found"); } foreach (KeyValuePair <string, string> p in extModule.Parameters) { // General format key = <identifier>:<parameterName> // we expect: key = instanceIdAttribute:<fully qualified attribute> string[] sa1 = p.Key.Split(':'); if (sa1[0] == "instanceIdAttribute") { string attribName = sa1[1].Split('.').Last(); string objclass = sa1[1].Substring(0, sa1[1].Length - (attribName.Length + 1)); // trailing '.' string encoding = p.Value; InstanceId instId = new InstanceId { ObjectClass = objclass, Attribute_Name = attribName, Attribute_Encoding = encoding }; fominfo.InstanceID.Add(instId); } } hpsdPolicy.FomInformation = fominfo; // ===================================================================================== // Federates <---> Export module Federates feds = new Federates(); // List of federates in Export module ModuleExport expModule = (ModuleExport)findModule(component.Modules, Enums.ModuleType.export); foreach (Source source in expModule.Sources) { feds.Federate.Add(source.FederateName); } hpsdPolicy.Federates = feds; // ===================================================================================== // PolicyRules <----> Export/Import module // Hack // Create an HlaObject tree to use when defining attribute lists StringReader ms = new StringReader(Properties.Resources.HLAfeatures); HlaObjectNode hlaObjectTree = TreeReader.CreateTree(ms); PolicyRules rules = new PolicyRules(); int ruleNumber = 0; if (component.ComponentName.ToUpper().Contains("HIGH")) { // Status message - session name = federateName SessionStatusReleaseRule sess = new SessionStatusReleaseRule { Condition_SessionName = system.FederateName, RuleName = ruleNumber++.ToString() }; rules.SessionStatus.Add(sess); // Object update/create foreach (Source source in expModule.Sources) { string federateName = source.FederateName; string entityID = ""; if (source.SourceType == Source.Type.Federate) { entityID = "*"; } else { entityID = source.EntityId; } foreach (HlaObject hlaObj in source.Objects) { ObjectReleaseReplaceRule obj = new ObjectReleaseReplaceRule() { Condition_ProducingFederate = federateName, Condition_InstanceID = entityID, RuleName = ruleNumber++.ToString(), Condition_ObjectClass = hlaObj.ObjectClassName.NoHlaRoot() }; // Hack if no attribs listed add all attribs from the TreeReader if (hlaObj.Attributes.Count == 0) { List <string> theworks = TreeReader.FindAttributes(hlaObjectTree, hlaObj.ObjectClassName); foreach (string attrib in theworks) { obj.Release_Attribute.Add(attrib); } rules.ObjectRelease.Add(obj); } else // Hack - read attributes from the object and add them; de-duplicate { List <string> temp = new List <string>(); foreach (HlaAttribute attrib in hlaObj.Attributes) { temp.Add(attrib.AttributeName); } obj.Release_Attribute = temp.Distinct().ToList(); rules.ObjectRelease.Add(obj); } } foreach (HlaInteraction hlaInt in source.Interactions) { InteractionReleaseReplaceRule intr = new InteractionReleaseReplaceRule() { Condition_ProducingFederate = federateName, RuleName = ruleNumber++.ToString(), Condition_InteractionClass = hlaInt.InteractionClassName.NoHlaRoot() }; List <string> temp = new List <string>(); foreach (HlaParameter para in hlaInt.Parameters) { temp.Add(para.ParameterName); } intr.Release_Parameter = temp.Distinct().ToList(); rules.InteractionRelease.Add(intr); } } } else { ModuleImport impModule = (ModuleImport)findModule(component.Modules, Enums.ModuleType.import); foreach (HlaObject hlaObj in impModule.Objects) { ObjectReleaseReplaceRule obj = new ObjectReleaseReplaceRule() { Condition_ProducingFederate = "*", Condition_InstanceID = "*", RuleName = ruleNumber++.ToString(), Condition_ObjectClass = hlaObj.ObjectClassName.NoHlaRoot() }; List <string> temp = new List <string>(); foreach (HlaAttribute attrib in hlaObj.Attributes) { temp.Add(attrib.AttributeName); } obj.Release_Attribute = temp.Distinct().ToList(); rules.ObjectRelease.Add(obj); } foreach (HlaInteraction hlaInt in impModule.Interactions) { InteractionReleaseReplaceRule intr = new InteractionReleaseReplaceRule() { Condition_ProducingFederate = "*", RuleName = ruleNumber++.ToString(), Condition_InteractionClass = hlaInt.InteractionClassName.NoHlaRoot() }; List <string> temp = new List <string>(); foreach (HlaParameter para in hlaInt.Parameters) { temp.Add(para.ParameterName); } intr.Release_Parameter = temp.Distinct().ToList(); rules.InteractionRelease.Add(intr); } } hpsdPolicy.PolicyRules = rules; return(hpsdPolicy.ToHPSD()); }