コード例 #1
0
ファイル: CodeValidator.cs プロジェクト: uQr/referencesource
        private void ValidateTypeMember(CodeTypeMember e) {
            ValidateCommentStatements(e.Comments);
            ValidateCodeDirectives(e.StartDirectives);
            ValidateCodeDirectives(e.EndDirectives);
            if (e.LinePragma != null) ValidateLinePragmaStart(e.LinePragma);

            if (e is CodeMemberEvent) {
                ValidateEvent((CodeMemberEvent)e);
            } 
            else if (e is CodeMemberField) {
                ValidateField((CodeMemberField)e);
            } 
            else if (e is CodeMemberMethod) {
                ValidateMemberMethod((CodeMemberMethod)e);
            } 
            else if (e is CodeMemberProperty) {
                ValidateProperty((CodeMemberProperty)e);
            } 
            else if (e is CodeSnippetTypeMember) {
                ValidateSnippetMember((CodeSnippetTypeMember)e);
            } 
            else if (e is CodeTypeDeclaration) {
                ValidateTypeDeclaration((CodeTypeDeclaration)e);
            } 
            else {
                throw new ArgumentException(SR.GetString(SR.InvalidElementType, e.GetType().FullName), "e");
            }
        }
 /// <summary>
 /// Creates a new instance of CodeTypeMemberExtension class.
 /// </summary>
 /// <param name="extendObject">An object to be decorated by this instance.</param>
 public CodeTypeMemberExtension(CodeTypeMember extendedObject, CodeTypeExtension parent) 
     : base(extendedObject)
 {                                  
     if (typeof(CodeMemberField) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Field;
     }
     else if (typeof(CodeMemberMethod) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Method;
     }
     else if (typeof(CodeMemberProperty) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Property;
     }
     else if (typeof(CodeMemberEvent) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Event;
     }
     else if (typeof(CodeSnippetTypeMember) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Snippet;
     }
     else if (typeof(CodeConstructor) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.Constructor;
     }
     else if (typeof(CodeTypeConstructor) == extendedObject.GetType())
     {
         this.kind = CodeTypeMemberKind.StaticConstructor;
     }
     this.parent = parent;
 }
コード例 #3
0
 private void Translate(CodeTypeMember member, TypeNode declaringType){
   if (member == null) return;
   else if (member is CodeMemberEvent) this.Translate((CodeMemberEvent)member, declaringType);
   else if (member is CodeMemberField) this.Translate((CodeMemberField)member, declaringType);
   else if (member is CodeMemberMethod) this.Translate((CodeMemberMethod)member, declaringType);
   else if (member is CodeMemberProperty) this.Translate((CodeMemberProperty)member, declaringType);
   else if (member is CodeSnippetTypeMember) this.Translate((CodeSnippetTypeMember)member, declaringType);
   else if (member is CodeTypeDeclaration) this.Translate((CodeTypeDeclaration)member, null, declaringType);
   else throw new ArgumentException("unknown type member", member.GetType().FullName);
 }