상속: System.Collections.CollectionBase
 public CodeTypeDeclaration(string name)
 {
     this.attributes = System.Reflection.TypeAttributes.Public;
     this.baseTypes = new CodeTypeReferenceCollection();
     this.members = new CodeTypeMemberCollection();
     base.Name = name;
 }
 public CodeTypeDeclaration(string name)
 {
     this.attributes = System.Reflection.TypeAttributes.Public;
     this.baseTypes  = new CodeTypeReferenceCollection();
     this.members    = new CodeTypeMemberCollection();
     base.Name       = name;
 }
예제 #3
0
 public void AddRange(CodeTypeReferenceCollection value)
 {
     foreach (CodeTypeReference e in value)
     {
         List.Add(e);
     }
 }
	public void AddRange(CodeTypeReferenceCollection value)
			{
				foreach(CodeTypeReference e in value)
				{
					List.Add(e);
				}
			}
		public void Constructor1_NullItem () 
		{
			CodeTypeReference[] refs = new CodeTypeReference[] {
				new CodeTypeReference (string.Empty), null };

			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection (
				refs);
		}
		public void Constructor0 () 
		{
			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection ();
			Assert.IsFalse (((IList) coll).IsFixedSize, "#1");
			Assert.IsFalse (((IList) coll).IsReadOnly, "#2");
			Assert.AreEqual (0, coll.Count, "#3");
			Assert.IsFalse (((ICollection) coll).IsSynchronized, "#4");
		}
 public static CodeTypeReferenceCollection Clone(this CodeTypeReferenceCollection collection)
 {
     if (collection == null) return null;
     CodeTypeReferenceCollection c = new CodeTypeReferenceCollection();
     foreach (CodeTypeReference reference in collection)
         c.Add(reference.Clone());
     return c;
 }
 public void AddRange(CodeTypeReferenceCollection value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     int count = value.Count;
     for (int i = 0; i < count; i++)
     {
         this.Add(value[i]);
     }
 }
		public void Constructor1 () 
		{
			CodeTypeReference ref1 = new CodeTypeReference (string.Empty);
			CodeTypeReference ref2 = new CodeTypeReference (string.Empty);

			CodeTypeReference[] refs = new CodeTypeReference[] { ref1, ref2 };
			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection (
				refs);

			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ref1), "#2");
			Assert.AreEqual (1, coll.IndexOf (ref2), "#3");
		}
		public void Constructor1_Deny_Unrestricted ()
		{
			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection (array);
			coll.CopyTo (array, 0);
			Assert.AreEqual (1, coll.Add (ctr), "Add");
			Assert.AreSame (ctr, coll[0], "this[int]");
			coll.AddRange (array);
			coll.AddRange (coll);
			Assert.IsTrue (coll.Contains (ctr), "Contains");
			Assert.AreEqual (0, coll.IndexOf (ctr), "IndexOf");
			coll.Insert (0, ctr);
			coll.Remove (ctr);
		}
예제 #11
0
        /// <devdoc>
        ///     <para>
        ///       Adds the contents of another <see cref='System.CodeDom.CodeTypeReferenceCollection'/> to the end of the collection.
        ///    </para>
        /// </devdoc>
        public void AddRange(CodeTypeReferenceCollection value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            int currentCount = value.Count;

            for (int i = 0; i < currentCount; i = ((i) + (1)))
            {
                this.Add(value[i]);
            }
        }
예제 #12
0
        public void AddRange(CodeTypeReferenceCollection value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            int currentCount = value.Count;

            for (int i = 0; i < currentCount; i++)
            {
                Add(value[i]);
            }
        }
예제 #13
0
		string GetTypeArguments (CodeTypeReferenceCollection collection)
		{
			StringBuilder sb = new StringBuilder (" <");
			foreach (CodeTypeReference r in collection) {
				sb.Append (GetTypeOutput (r));
				sb.Append (", ");
			}
			sb.Length--;
			sb [sb.Length - 1] = '>';
			return sb.ToString ();
		}
 public void AddRange(CodeTypeReferenceCollection value)
 {
     throw new NotImplementedException();
 }
예제 #15
0
        private string GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArgs)
        {
            int count;
            if (typeArgs != null && (count = typeArgs.Count) > 0)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append(Tokens.GenericBracketLeft);

                sb.Append(GetTypeOutput(typeArgs[0]));
                for (int i = 1; i < count; i++)
                {
                    sb.Append(Tokens.Comma + WhiteSpace.Space);
                    sb.Append(GetTypeOutput(typeArgs[i]));
                }

                sb.Append(Tokens.GenericBracketRight);

                return sb.ToString();
            }
            else return String.Empty;
        }
예제 #16
0
        /// <summary>
        /// Outputs reference to an instance or static member.
        /// </summary>
        /// <param name="target">An expression denoting the instance or type (if <B>null</B>, <c>$this</c> is assumed).
        /// </param>
        /// <param name="name">The member name.</param>
        /// <param name="variable"><B>True</B> if the member is a variable (i.e. property), <b>false</b> otherwise.</param>
        /// <param name="typeArgs">Optional type arguments if this is a method reference.</param>
        private void OutputMemberReference(CodeExpression target, string name, bool variable, CodeTypeReferenceCollection typeArgs)
        {
            CodeTypeReferenceExpression type_ref;
            CodeBaseReferenceExpression base_ref = null;

            if ((type_ref = target as CodeTypeReferenceExpression) != null ||
                (base_ref = target as CodeBaseReferenceExpression) != null)
            {
                // "static" reference
                if (type_ref != null) OutputType(type_ref.Type);
                else GenerateBaseReferenceExpression(base_ref);

                Output.Write(Tokens.DoubleColon);

                if (variable)
                {
                    if (type_ref != null && IsFieldConstant(type_ref, name)) Output.Write(name);
                    else OutputVariable(name);
                }
                else Output.Write(name);
            }
            else
            {
                // instance reference
                if (target == null)
                {
                    // let's suppose this is $this->NAME (might also be self::NAME but that cannot be
                    // decided according to the provided information
                    OutputVariable(SpecialWords.This);
                }
                else GenerateExpression(target);

                Output.Write(Tokens.Arrow);
                Output.Write(name);
            }

            Output.Write(GetTypeArgumentsOutput(typeArgs));
        }
예제 #17
0
	public void interf_declr(
		CodeTypeReferenceCollection baseTypes
	) //throws RecognitionException, TokenStreamException
{

		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST interf_declr_AST = null;
		AST name_AST = null;

		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case LITERAL_interface:
				{
					AST tmp52_AST = null;
					tmp52_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(ref currentAST, tmp52_AST);
					match(LITERAL_interface);
					break;
				}
				case LITERAL_dispinterface:
				{
					AST tmp53_AST = null;
					tmp53_AST = astFactory.create(LT(1));
					astFactory.makeASTRoot(ref currentAST, tmp53_AST);
					match(LITERAL_dispinterface);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			identifier();
			if (0 == inputState.guessing)
			{
				name_AST = (AST)returnAST;
				astFactory.addASTChild(ref currentAST, returnAST);
			}
			if (0==inputState.guessing)
			{

						baseTypes.Add(name_AST.getText());

			}
			interf_declr_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				recover(ex,tokenSet_11_);
			}
			else
			{
				throw ex;
			}
		}
		returnAST = interf_declr_AST;
	}
예제 #18
0
 protected void Rewrite(CodeTypeReferenceCollection target, CodeTypeReferenceCollection source, ref bool didRewrite)
 {
     foreach (CodeTypeReference item in source)
     {
         target.Add(this.Rewrite(item, ref didRewrite));
     }
 }
       private void GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments, int start, int length, StringBuilder sb) {
            sb.Append('<');
            bool first = true;
            for( int i = start; i < start+length; i++) {
                if( first) {
                    first = false;
                }
                else {
                    sb.Append(", ");
                }

                // it's possible that we call GetTypeArgumentsOutput with an empty typeArguments collection.  This is the case
                // for open types, so we want to just output the brackets and commas. 
                if (i < typeArguments.Count)
                    sb.Append(GetTypeOutput(typeArguments[i])); 
            }
            sb.Append('>');
        }
 public CodeTypeReferenceCollection(CodeTypeReferenceCollection value)
 {
     return(default(CodeTypeReferenceCollection));
 }
예제 #21
0
 private InterfaceList TranslateToInterfaceList(CodeTypeReferenceCollection interfaces){
   int n = interfaces == null ? 0 : interfaces.Count;
   InterfaceList interfaceList = new InterfaceList(n);
   for (int i = 0; i < n; i++)
     interfaceList.Add(this.TranslateToInterface(interfaces[i]));
   return interfaceList;
 }
예제 #22
0
 private string GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments)
 {
     StringBuilder sb = new StringBuilder(128);
     this.GetTypeArgumentsOutput(typeArguments, 0, typeArguments.Count, sb);
     return sb.ToString();
 }
예제 #23
0
 private TypeNodeList Translate(CodeTypeReferenceCollection types){
   int n = types == null ? 0 : types.Count;
   TypeNodeList typeList = new TypeNodeList(n);
   for (int i = 0; i < n; i++)
     typeList.Add(this.TranslateToTypeNode(types[i]));
   return typeList;
 }
예제 #24
0
파일: In.cs 프로젝트: rneilturner/win-tools
        /// <summary>
        /// For the marshalling method to be invoked, create the appropriate method type (generic type).
        /// </summary>
        /// <param name="exprInvoke">Marshalling method being created.</param>
        /// <param name="elementTypes">Array types of marshalling method.</param>
        protected virtual void BuildMethodInvokeMethodTypes(CodeMethodInvokeExpression exprInvoke, CodeTypeReferenceCollection elementTypes)
        {
            if (elementTypes != null && elementTypes.Count > 0)
            {
                // Bit of a hack, but essentially in every case (the most annoying being dictionary), the last type is the one that needs fixing up.
                CodeTypeReference[] arrayAdjustedElementTypes = new CodeTypeReference[elementTypes.Count];
                int iter = 0;

                for (; iter < elementTypes.Count - 1; ++iter)
                {
                    arrayAdjustedElementTypes[iter] = elementTypes[iter];

                } // Ends loop copying all but last element

                // Since dictionary values support covariance about as well as Republicans support healthcare,
                // we have to stick with arrays as part of the interface.
                arrayAdjustedElementTypes[iter] = elementTypes[iter];// CodeBuilderCommon.ArrayTypeToEnumerableType(elementTypes[iter]);
                exprInvoke.Method.TypeArguments.AddRange(arrayAdjustedElementTypes);
            }
        }
예제 #25
0
파일: In.cs 프로젝트: rneilturner/win-tools
                protected override void BuildMethodInvokeMethodTypes(CodeMethodInvokeExpression exprInvoke, CodeTypeReferenceCollection elementTypes)
                {
                    if (this.QuSubArray && !this.QuSubArrayIsArray) // If got sub-array which holds a value
                    {
                        base.BuildMethodInvokeMethodTypes(exprInvoke, elementTypes);

                    } // Ends if got sub-array which holds a value
                }
예제 #26
0
		private void OutputTypeArguments (CodeTypeReferenceCollection typeArguments, StringBuilder sb, int count)
		{
			if (count == 0) {
				return;
			} else if (typeArguments.Count == 0) {
				// generic type definition
				sb.Append ("<>");
				return;
			}

			sb.Append ('<');

			// write first type argument
			sb.Append (GetTypeOutput (typeArguments[0]));
			// subsequent type argument are prefixed by ', ' separator
			for (int i = 1; i < count; i++) {
				sb.Append (", ");
				sb.Append (GetTypeOutput (typeArguments[i]));
			}

			sb.Append ('>');
		}
예제 #27
0
 private static void ValidateTypeReferences(CodeTypeReferenceCollection refs) {
     for (int i=0; i<refs.Count; i++) {
         ValidateTypeReference(refs[i]);
     }
 }
		public void Constructor2 () 
		{
			CodeTypeReference ref1 = new CodeTypeReference (string.Empty);
			CodeTypeReference ref2 = new CodeTypeReference (string.Empty);

			CodeTypeReferenceCollection c = new CodeTypeReferenceCollection ();
			c.Add (ref1);
			c.Add (ref2);

			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection (c);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ref1), "#2");
			Assert.AreEqual (1, coll.IndexOf (ref2), "#3");
		}
예제 #29
0
		private void OutputImplementationTypes (CodeTypeReferenceCollection implementationTypes, string member)
		{
			IEnumerator enumerator = implementationTypes.GetEnumerator ();
			if (enumerator.MoveNext ()) {
				Output.Write (" Implements ");

				CodeTypeReference typeReference = (CodeTypeReference) enumerator.Current;
				OutputType (typeReference);
				Output.Write ('.');
				OutputIdentifier (member);

				while (enumerator.MoveNext ()) {
					Output.Write (" , ");
					typeReference = (CodeTypeReference) enumerator.Current;
					OutputType (typeReference);
					Output.Write ('.');
					OutputIdentifier (member);
				}
			}
		}
		public void Constructor1_Null () 
		{
			CodeTypeReferenceCollection coll = new CodeTypeReferenceCollection (
				(CodeTypeReference[]) null);
		}
예제 #31
0
 private void GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments, int start, int length, StringBuilder sb)
 {
     sb.Append("(Of ");
     bool flag = true;
     for (int i = start; i < (start + length); i++)
     {
         if (flag)
         {
             flag = false;
         }
         else
         {
             sb.Append(", ");
         }
         if (i < typeArguments.Count)
         {
             sb.Append(this.GetTypeOutput(typeArguments[i]));
         }
     }
     sb.Append(')');
 }
예제 #32
0
 private void AddImportsForCodeTypeReferenceCollection(CodeNamespaceImportCollection curImports, CodeTypeReferenceCollection ctrc)
 {
     foreach (CodeTypeReference ctr in ctrc) {
         MaybeAddImport(curImports, ctr);
     }
 }
 public void AddRange(CodeTypeReferenceCollection !value)
 {
     Contract.Requires(value != null);
 }
예제 #34
0
 private void EmitGenericTypeArgs(CodeTypeReferenceCollection typeArgs)
 {
     if (typeArgs != null && typeArgs.Count > 0) {
         Write("[");
         for (int i = 0; i < typeArgs.Count; i++) {
             if (i != 0) Write(", ");
             Write(typeArgs[i].BaseType);
         }
         Write("]");
     }
 }
예제 #35
0
 /// <include file='doc\CodeTypeReferenceCollection.uex' path='docs/doc[@for="CodeTypeReferenceCollection.CodeTypeReferenceCollection1"]/*' />
 /// <devdoc>
 ///     <para>
 ///       Initializes a new instance of <see cref='System.CodeDom.CodeTypeReferenceCollection'/> based on another <see cref='System.CodeDom.CodeTypeReferenceCollection'/>.
 ///    </para>
 /// </devdoc>
 public CodeTypeReferenceCollection(CodeTypeReferenceCollection value) {
     this.AddRange(value);
 }
예제 #36
0
 private string GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments)
 {
     StringBuilder builder1 = new StringBuilder(0x80);
     this.GetTypeArgumentsOutput(typeArguments, 0, typeArguments.Count, builder1);
     return builder1.ToString();
 }
예제 #37
0
 /// <devdoc>
 ///     <para>
 ///       Initializes a new instance of <see cref='System.CodeDom.CodeTypeReferenceCollection'/> based on another <see cref='System.CodeDom.CodeTypeReferenceCollection'/>.
 ///    </para>
 /// </devdoc>
 public CodeTypeReferenceCollection(CodeTypeReferenceCollection value)
 {
     this.AddRange(value);
 }
예제 #38
0
 private void GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments, int start, int length, StringBuilder sb)
 {
     sb.Append('<');
     bool flag1 = true;
     for (int num1 = start; num1 < (start + length); num1++)
     {
         if (flag1)
         {
             flag1 = false;
         }
         else
         {
             sb.Append(", ");
         }
         if (num1 < typeArguments.Count)
         {
             sb.Append(this.GetTypeOutput(typeArguments[num1]));
         }
     }
     sb.Append('>');
 }