public override IEnumerable<Item> Load() { if (Assembly == null && File != null) { Assembly = Assembly.LoadFrom (File.FullName); } else if (Assembly != null && File == null) { File = new FileInfo (Assembly.Location); } if (!IsValidConfinementItem (this)) { yield break; } yield return this; var sibling = Item.Resolve (Confinement, File.FullName + ".mdb"); if (sibling != null) { yield return sibling; } sibling = Item.Resolve (Confinement, File.FullName + ".config"); if (sibling != null) { yield return sibling; } foreach (var item in ReadAssembly ()) { yield return item; } foreach (var rname in Assembly.GetReferencedAssemblies ()) { var ritem = new AssemblyItem () { Confinement = Confinement, Assembly = Assembly.Load (rname.FullName) }; foreach (var item in ritem.Load ()) { yield return item; } } }
private bool CanWorkOnItem(AssemblyItem item) { if(type != WorkerType.SUPERVISOR) { return CanWorkOnToken(item.FirstToken); } return false; }
private void AddSelectedAssemblies() { foreach (AssemblyItem item in this._gacList.SelectedItems) { bool flag = false; foreach (AssemblyItem item2 in this._selectedList.Items) { AssemblyName assemblyName = item2.AssemblyName; AssemblyName name2 = item.AssemblyName; if (assemblyName.FullName.Equals(name2.FullName)) { item2.Selected = true; flag = true; break; } } if (!flag) { AssemblyItem item3 = new AssemblyItem(item); this._selectedList.Items.Add(item3); item3.Selected = true; this._hasChanges = true; } } }
/// <summary> /// Loads specific assembly into internal list of assemblies. /// </summary> /// <param name="directory">Directory <c>filename</c> is relative to, or <c>null</c> if <c>filename</c> is absolute or relative to current directory.</param> /// <param name="filename">Relative or absolute path to assembly.</param> /// <remarks>See <see cref="Utils.GetFileInfo">Utils.GetFileInfo</see> for more info about how /// specified file is searched. If file isn't found, method tries to /// load assembly from global assembly cache (GAC).</remarks> public static void LoadAssembly( string directory, string filename ) { Assembly assembly; FileInfo assemblyFileInfo = Utils.GetFileInfo( directory, filename ); // if assemby file exists, try to load it if( assemblyFileInfo.Exists ) { assembly = Assembly.LoadFrom(assemblyFileInfo.FullName); } else { // if file doesn't exist, try to load assembly from GAC try { assembly = Assembly.Load(filename); } catch( Exception e ) { throw( new Exception("Assembly cannot be loaded (CurrentDirectory='"+Directory.GetCurrentDirectory()+"', Name='"+filename+"')", e) ); } } // add assembly to list of assemblies only if not already present foreach( AssemblyItem assemblyItem in _assemblies ) if( 0==String.Compare(assemblyItem.fullName, assembly.FullName, true) ) return; AssemblyItem newItem = new AssemblyItem(); newItem.assembly = assembly; newItem.fullName = assembly.FullName; _assemblies.Add( newItem ); }
private void ReadAssemblyItem(AssemblyItem assemblyItem) { // Create NamesSpace, Type, and method nodes all here, once, // so they'll be there when the tree needs them. try { Assembly asm = LoadAssembly(assemblyItem.ItemPath); assemblyItem.AsmRef = asm; // Fill Referenced Assemblies list. AssemblyName[] referenced = asm.GetReferencedAssemblies(); foreach (AssemblyName an in referenced) { assemblyItem.ReferencedAssemblies.Add(an.Name); // } ReflectAssembly(assemblyItem, asm, false); } catch (Exception exc) { _logView.LogExcStr(exc, "ReadAssemblyItem failed (possible missing referenced assembly):" + assemblyItem.ItemPath); } }
private void AddOrUpdateMapping(AssemblyItem item) { try { var projectPath = Path.GetDirectoryName(_selectedProject.FullName); if (!ConfigFileExists(_selectedProject)) { _logger.WriteToOutputWindow("Error Updating Mappings In Config File: Missing CRMDeveloperExtensions.config File", Logger.MessageType.Error); return; } XmlDocument doc = new XmlDocument(); doc.Load(projectPath + "\\CRMDeveloperExtensions.config"); //Update or delete existing mapping XmlNodeList assemblyNodes = doc.GetElementsByTagName("Assembly"); if (assemblyNodes.Count > 0) { foreach (XmlNode node in assemblyNodes) { XmlNode orgId = node["OrgId"]; if (orgId != null && orgId.InnerText.ToUpper() != _selectedConn.OrgId.ToUpper()) { continue; } XmlNode projectNameNode = node["ProjectName"]; if (projectNameNode != null && projectNameNode.InnerText.ToUpper() != item.BoundProject.ToUpper()) { continue; } if (string.IsNullOrEmpty(item.BoundProject) || item.AssemblyId == Guid.Empty) { //Delete var parentNode = node.ParentNode; if (parentNode != null) { parentNode.RemoveChild(node); } } else { //Update XmlNode assemblyIdNode = node["AssemblyId"]; if (assemblyIdNode != null) { assemblyIdNode.InnerText = item.AssemblyId.ToString(); } } doc.Save(projectPath + "\\CRMDeveloperExtensions.config"); return; } } //Create new mapping XmlNodeList projects = doc.GetElementsByTagName("Assemblies"); if (projects.Count > 0) { XmlNode assembly = doc.CreateElement("Assembly"); XmlNode org = doc.CreateElement("OrgId"); org.InnerText = _selectedConn.OrgId; assembly.AppendChild(org); XmlNode projectNameNode2 = doc.CreateElement("ProjectName"); projectNameNode2.InnerText = item.BoundProject; assembly.AppendChild(projectNameNode2); XmlNode assemblyId = doc.CreateElement("AssemblyId"); assemblyId.InnerText = item.AssemblyId.ToString(); assembly.AppendChild(assemblyId); projects[0].AppendChild(assembly); doc.Save(projectPath + "\\CRMDeveloperExtensions.config"); } } catch (Exception ex) { _logger.WriteToOutputWindow("Error Updating Mappings In Config File: " + ex.Message + Environment.NewLine + ex.StackTrace, Logger.MessageType.Error); } }
private async Task <bool> GetPlugins(string connString) { _dte.StatusBar.Text = "Connecting to CRM..."; _dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationSync); LockMessage.Content = "Working..."; LockOverlay.Visibility = Visibility.Visible; CrmServiceClient client = SharedConnection.GetCurrentConnection(ConnPane.SelectedConnection.ConnectionString, WindowType, _dte); _dte.StatusBar.Text = "Getting assemblies..."; EntityCollection results = await Task.Run(() => RetrieveAssembliesFromCrm(client)); if (results == null) { SharedConnection.ClearCurrentConnection(WindowType, _dte); _dte.StatusBar.Clear(); _dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationSync); LockOverlay.Visibility = Visibility.Hidden; MessageBox.Show("Error Retrieving Assemblies. See the Output Window for additional details."); return(false); } _logger.WriteToOutputWindow("Retrieved Assemblies From CRM", Logger.MessageType.Info); ObservableCollection <AssemblyItem> assemblies = new ObservableCollection <AssemblyItem>(); AssemblyItem emptyItem = new AssemblyItem { AssemblyId = Guid.Empty, Name = String.Empty }; assemblies.Add(emptyItem); foreach (var entity in results.Entities) { AssemblyItem aItem = new AssemblyItem { AssemblyId = entity.Id, Name = entity.GetAttributeValue <string>("name"), Version = Version.Parse(entity.GetAttributeValue <string>("version")), DisplayName = entity.GetAttributeValue <string>("name") + " (" + entity.GetAttributeValue <string>("version") + ")", IsWorkflowActivity = false }; //Only need to process the 1st assembly/type combination returned if (assemblies.Count(a => a.AssemblyId == aItem.AssemblyId) > 0) { continue; } if (entity.Contains("plugintype.isworkflowactivity")) { aItem.IsWorkflowActivity = (bool)entity.GetAttributeValue <AliasedValue>("plugintype.isworkflowactivity").Value; } aItem.DisplayName += (aItem.IsWorkflowActivity) ? " [Workflow]" : " [Plug-in]"; assemblies.Add(aItem); } assemblies = HandleMappings(assemblies); Assemblies.ItemsSource = assemblies; if (assemblies.Count(a => !string.IsNullOrEmpty(a.BoundProject)) > 0) { Assemblies.SelectedItem = assemblies.First(a => !string.IsNullOrEmpty(a.BoundProject)); } Assemblies.IsEnabled = true; _dte.StatusBar.Clear(); _dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationSync); LockOverlay.Visibility = Visibility.Hidden; return(true); }
private void RotateTowardsItem(AssemblyItem item) { Vector3 diff = item.transform.position - transform.position; diff.y = 0.0f; transform.rotation = Quaternion.LookRotation(diff.normalized); }
public static Item Resolve(Solitary confinement, FileInfo file) { if (!file.Exists || file.Name.StartsWith (".")) { return null; } Item item = null; foreach (var regex in confinement.PathBlacklist) { if (regex.IsMatch (file.FullName)) { return null; } } if (!String.IsNullOrEmpty (ProcessTools.RealConfinementRoot) && file.FullName.StartsWith (ProcessTools.RealConfinementRoot)) { string path = file.FullName.Replace (ProcessTools.RealConfinementRoot, confinement.ConfinementRoot); file = new FileInfo (path); } if (SymlinkItem.IsSymlink (file.FullName)) { return new SymlinkItem () { File = file, Confinement = confinement }; } switch (GetFileType (file)) { case FileType.PE32Executable: item = new AssemblyItem (); break; case FileType.MachO: case FileType.ELF: item = new NativeLibraryItem (); break; default: item = new DataItem (); break; } item.Confinement = confinement; item.File = file; return item; }
private bool UpdateCrmAssembly(AssemblyItem assemblyItem, CrmServiceClient client) { _dte.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy); try { string outputFileName = ConnPane.SelectedProject.Properties.Item("OutputFileName").Value.ToString(); string path = GetOutputPath() + outputFileName; //Build the project SolutionBuild solutionBuild = _dte.Solution.SolutionBuild; solutionBuild.BuildProject(_dte.Solution.SolutionBuild.ActiveConfiguration.Name, ConnPane.SelectedProject.UniqueName, true); if (solutionBuild.LastBuildInfo > 0) { return(false); } //Make sure Major and Minor versions match Version assemblyVersion = Version.Parse(ConnPane.SelectedProject.Properties.Item("AssemblyVersion").Value.ToString()); if (assemblyItem.Version.Major != assemblyVersion.Major || assemblyItem.Version.Minor != assemblyVersion.Minor) { _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Major & Minor Versions Require Redeployment", Logger.MessageType.Error); return(false); } //Make sure assembly names match string assemblyName = ConnPane.SelectedProject.Properties.Item("AssemblyName").Value.ToString(); if (assemblyName.ToUpper() != assemblyItem.Name.ToUpper()) { _logger.WriteToOutputWindow("Error Updating Assembly In CRM: Changes To Assembly Name Require Redeployment", Logger.MessageType.Error); return(false); } //Update CRM Entity crmAssembly = new Entity("pluginassembly") { Id = assemblyItem.AssemblyId }; crmAssembly["content"] = Convert.ToBase64String(File.ReadAllBytes(path)); client.Update(crmAssembly); //Update assembly name and version numbers assemblyItem.Version = assemblyVersion; assemblyItem.Name = ConnPane.SelectedProject.Properties.Item("AssemblyName").Value.ToString(); assemblyItem.DisplayName = assemblyItem.Name + " (" + assemblyVersion + ")"; assemblyItem.DisplayName += (assemblyItem.IsWorkflowActivity) ? " [Workflow]" : " [Plug-in]"; return(true); } catch (FaultException <OrganizationServiceFault> crmEx) { _logger.WriteToOutputWindow("Error Updating Assembly In CRM: " + crmEx.Message + Environment.NewLine + crmEx.StackTrace, Logger.MessageType.Error); return(false); } catch (Exception ex) { _logger.WriteToOutputWindow("Error Updating Assembly In CRM: " + ex.Message + Environment.NewLine + ex.StackTrace, Logger.MessageType.Error); return(false); } finally { _dte.StatusBar.Clear(); _dte.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy); } }
public void OnInspectionFailed(object sender, AssemblyItem e) { failedInspection.Add(e); }
public void OnInspectionCleared(object sender, AssemblyItem e) { clearedInspection.Add(e); }
private void ReflectAssembly(AssemblyItem assemblyItem, Assembly asm, bool invert) { string ns; NamespaceItem nsItem; Dictionary<string, NamespaceItem> nsItems = new Dictionary<string, NamespaceItem>(); // Add the assembly item itself to the lookup. _projectBrowser.AddLookup(assemblyItem, assemblyItem.GetID(), invert); try { Type[] types = asm.GetTypes(); } catch (ReflectionTypeLoadException exc) { _logView.LogExcStr(exc, "Failed to call GetTypes on " + asm.FullName); return; } foreach (Type t in asm.GetTypes()) { ns = t.Namespace; if (string.IsNullOrEmpty(ns)) ns = "(none)"; if (!nsItems.ContainsKey(ns)) { nsItem = new NamespaceItem(ns, assemblyItem); nsItems.Add(ns, nsItem); assemblyItem.NameSpaces.Add(nsItem); _projectBrowser.AddLookup(nsItem, nsItem.GetID(), invert); } else { nsItem = nsItems[ns]; } // Flatten nested types. string name = t.Name; if (t.IsNested) { // Flat with .id'd name. Type parentType = t.DeclaringType; while (parentType != null) { name = parentType.Name + "." + name; parentType = parentType.DeclaringType; } } try { TypeItem typeItem = new TypeItem(name, t.FullName, t, nsItem); nsItem.Types.Add(typeItem); _projectBrowser.AddLookup(typeItem, typeItem.GetID(), invert); foreach (MethodInfo mi in GetMethods(typeItem)) { MethodItem methodItem = new MethodItem(mi.Name, mi, typeItem); typeItem.Methods.Add(methodItem); _projectBrowser.AddLookup(methodItem, methodItem.GetID(), invert); } // Get the list of implemented interfaces. typeItem.Implements = GetImplementedInterfaces(typeItem); if (typeItem.TypeRef.BaseType != null) { typeItem.InheritsFrom = typeItem.TypeRef.BaseType.ToString(); } else { typeItem.InheritsFrom = null; } } catch (Exception exc) { _logView.LogExcStr(exc, "Generic Types issue?"); } } }
private void DepleteTokenHp(AssemblyItemToken token) { if (token == null) { currentItem = null; return; } switch (token.itemTokenType) { case AssemblyItemToken.ItemTokenType.CIRCLE: if (justDoingIt) { token.itemTokenHp -= circleTokenSpeed * Time.deltaTime * GameManager.JustDoItMultiplier; } else { token.itemTokenHp -= circleTokenSpeed * Time.deltaTime; } token.Item.CheckToken(token); break; case AssemblyItemToken.ItemTokenType.SQUARE: if (justDoingIt) { token.itemTokenHp -= squreTokenSpeed * Time.deltaTime * GameManager.JustDoItMultiplier; } else { token.itemTokenHp -= squreTokenSpeed * Time.deltaTime; } token.Item.CheckToken(token); break; } }
public override void HandleRequest(AssemblyItem item) { Console.WriteLine($"{name}: Received item.\n{item}"); successor?.HandleRequest(item); }
private void OnTriggerExit(Collider other) { AssemblyItem item = other.gameObject.GetComponent<AssemblyItem>(); if (item) { if (itemsInRange.Contains(item)) { if(item == currentItem) { currentItem = null; } itemsInRange.Remove(item); } } }
public static Item Resolve(Solitary confinement, FileInfo file) { if (!file.Exists || file.Name.StartsWith (".")) { return null; } Item item = null; foreach (var regex in confinement.PathBlacklist) { if (regex.IsMatch (file.FullName)) { return null; } } if (SymlinkItem.IsSymlink (file.FullName)) { return new SymlinkItem () { File = file, Confinement = confinement }; } switch (GetFileType (file)) { case FileType.PE32Executable: item = new AssemblyItem (); break; case FileType.MachO: item = new NativeLibraryItem (); break; default: item = new DataItem (); break; } item.Confinement = confinement; item.File = file; return item; }
private void SwitchUpdate() { if (currentItem) { RotateTowardsItem(currentItem); DepleteTokenHp(currentItem.FirstToken); SetAnim("Working", true); } else { SetAnim("Working", false); currentItem = GetPreferedItem(); } }
public BaseItem GetFileItem(string name) { AssemblyItem item = new AssemblyItem(name, null); return item; }