ICSharpCode.NRefactory.MonoCSharp.TypeContainer.AddTypeContainer C# (CSharp) Method

AddTypeContainer() public method

public AddTypeContainer ( TypeContainer tc ) : void
tc TypeContainer
return void
		public virtual void AddTypeContainer (TypeContainer tc)
		{
			AddTypeContainerMember (tc);

			var tparams = tc.MemberName.TypeParameters;
			if (tparams != null && tc.PartialContainer != null) {
				var td = (TypeDefinition) tc;
				for (int i = 0; i < tparams.Count; ++i) {
					var tp = tparams[i];
					if (tp.MemberName == null)
						continue;

					td.AddNameToContainer (tp, tp.Name);
				}
			}
		}

Usage Example

Example #1
0
		public void AddTypeContainer (TypeContainer current_container, TypeDefinition tc)
		{
			if (current_container == tc){
				Console.Error.WriteLine ("Internal error: inserting container into itself");
				return;
			}

			if (undo_actions == null)
				undo_actions = new List<Action> ();

			if (current_container.Containers != null)
			{
				var existing = current_container.Containers.FirstOrDefault (l => l.MemberName.Basename == tc.MemberName.Basename);
				if (existing != null) {
					current_container.RemoveContainer (existing);
					undo_actions.Add (() => current_container.AddTypeContainer (existing));
				}
			}

			undo_actions.Add (() => current_container.RemoveContainer (tc));
		}