當前位置: 首頁>>代碼示例>>C#>>正文


C# Window.Visit方法代碼示例

本文整理匯總了C#中White.Core.UIItems.WindowItems.Window.Visit方法的典型用法代碼示例。如果您正苦於以下問題:C# Window.Visit方法的具體用法?C# Window.Visit怎麽用?C# Window.Visit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在White.Core.UIItems.WindowItems.Window的用法示例。


在下文中一共展示了Window.Visit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Generate

        public virtual string Generate(Window window)
        {
            window.ReInitialize(InitializeOption.WithCache);
            var stringBuilder = new StringBuilder();
            var stringWriter = new StringWriter(stringBuilder);

            var cscProvider = new CSharpCodeProvider();
            ICodeGenerator codeGenerator = cscProvider.CreateGenerator(stringWriter);
            var codeGeneratorOptions = new CodeGeneratorOptions {BlankLinesBetweenMembers = false, VerbatimOrder = false};

            codeGenerator.GenerateCodeFromCompileUnit(new CodeSnippetCompileUnit(string.Format("using {0};", typeof(UIItem).Namespace)), stringWriter, codeGeneratorOptions);
            codeGenerator.GenerateCodeFromCompileUnit(new CodeSnippetCompileUnit(string.Format("using {0};", typeof(Window).Namespace)), stringWriter, codeGeneratorOptions);
            codeGenerator.GenerateCodeFromCompileUnit(new CodeSnippetCompileUnit(string.Format("using {0};", typeof(AppScreen).Namespace)), stringWriter, codeGeneratorOptions);

            CodeNamespace codeNamespace = null;
            if (S.IsNotEmpty(options.Namespace))
            {
                codeNamespace = new CodeNamespace(options.Namespace);
            }

            var classDefinition = new CodeTypeDeclaration
                                      {
                                          IsClass = true,
                                          IsPartial = true,
                                          Name = window.Title.Trim().Replace(" ", string.Empty),
                                          TypeAttributes = TypeAttributes.Public
                                      };
            classDefinition.BaseTypes.Add(typeof (AppScreen));

            var constructor = new CodeConstructor {Attributes = MemberAttributes.Family};
            classDefinition.Members.Add(constructor);

            constructor = new CodeConstructor {Attributes = MemberAttributes.Public};
            constructor.Parameters.Add(new CodeParameterDeclarationExpression(typeof(Window), "window"));
            constructor.Parameters.Add(new CodeParameterDeclarationExpression(typeof (ScreenRepository), "screenRepository"));
            constructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression("window"));
            constructor.BaseConstructorArgs.Add(new CodeVariableReferenceExpression("screenRepository"));
            classDefinition.Members.Add(constructor);

            var visitor = new CodeGenerationVisitor(new WindowCodeGenerationStrategy(options));
            window.Visit(visitor);
            visitor.Generate(classDefinition);

            if (codeNamespace != null)
            {
                codeNamespace.Types.Add(classDefinition);
                codeGenerator.GenerateCodeFromNamespace(codeNamespace, stringWriter, codeGeneratorOptions);
            }
            else
            {
                codeGenerator.GenerateCodeFromType(classDefinition, stringWriter, codeGeneratorOptions);
            }

            stringWriter.Close();
            return stringBuilder.ToString();
        }
開發者ID:hsteinhilber,項目名稱:white-project,代碼行數:56,代碼來源:ScreenObjectGenerator.cs

示例2: StartRecording

 public virtual void StartRecording(Window window, UserEventListener eventListener)
 {
     windowsUnderRecording.Add(window);
     window.ReInitialize(InitializeOption.WithCache);
     window.Visit(new RecorderVisitor(eventListener, recordingOptions));
 }
開發者ID:tmandersson,項目名稱:FastGTD,代碼行數:6,代碼來源:WhiteRecorder.cs


注:本文中的White.Core.UIItems.WindowItems.Window.Visit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。