Exemple #1
0
        public static Scope Push(CodeDomTypeDefinition mainType)
        {
            var scope = new Scope(mainType);

            scope._parent = Current;
            Current       = scope;
            return(scope);
        }
Exemple #2
0
 protected Scope(CodeDomTypeDefinition mainType)
 {
     _scope          = new Dictionary <string, IScopeData>();
     ScopeIdentifier = "Scope_" + Guid.NewGuid().ToString("N");
     if (mainType != null)
     {
         CreateType(mainType);
     }
 }
Exemple #3
0
        protected Scope(CodeDomTypeDefinition mainType)
        {
            _scope          = new Dictionary <string, IScopeData>();
            ScopeGuid       = Guid.NewGuid().ToString("N");
            ScopeIdentifier = "Scope_" + ScopeGuid;
            if (mainType != null)
            {
                CreateType(mainType);
            }

            JoinMembers = new List <CodeMemberField>();
        }
Exemple #4
0
        private void CreateType(CodeDomTypeDefinition mainType)
        {
            Type = new CodeDomTypeDefinition(ScopeIdentifier);
            Type.Type.TypeAttributes = TypeAttributes.NestedPrivate;

            var classType = new CodeTypeReference(ScopeIdentifier);

            mainType.Type.Members.Add(
                new CodeMemberField(classType, "_" + ScopeIdentifier));

            mainType.Constructor.Statements.Add(new CodeAssignStatement(
                                                    new CodeSnippetExpression("_" + ScopeIdentifier),
                                                    new CodeObjectCreateExpression(classType)));

            mainType.Type.Members.Add(Type.Type);
        }