protected internal Label(NRefactory.LabelStatement labelStatement, IScope scope, INRefcatoryExpressionVisitor visitor) : base(scope, visitor) { _labelStatement = labelStatement; InternalType = TypeSystem.Void; LabelTarget = RootScope.RegisterLabel(InternalType, labelStatement.Label); }
private bool RightOperandShouldBeBoxed() { Instruction instruction; return(RootScope.TryGetInstruction(_assignment, OpCodes.Box, out instruction) || _rightExpression.AstNodeType == AstExpressionType.NullReference); }
public MainWindow() { _AddLog = (message) => Log.Dispatcher.BeginInvoke( DispatcherPriority.DataBind, new Action(() => { Logs.Add(message); while (Logs.Count > MAX_LOG_ROW) { Logs.RemoveAt(0); } }) ); var builder = new ContainerBuilder(); builder.RegisterModule <FlvProcessorModule>(); builder.RegisterModule <CoreModule>(); Container = builder.Build(); RootScope = Container.BeginLifetimeScope("recorder_root"); Recorder = RootScope.Resolve <IRecorder>(); InitializeComponent(); DataContext = this; }
private void CodeTest_Click(object sender, RoutedEventArgs e) { var csharpSetting = new CSharpSetting() { RootPath = Environment.CurrentDirectory, }; var typeScope = new RelativeScope <CSharpSetting>(csharpSetting, "TypeScope"); var groupScope = new RelativeScope <CSharpSetting>(csharpSetting, "GroupScope", typeScope); var projectScope = new RootScope("ProjectScope"); var otherScope = new RelativeScope <CSharpSetting>(csharpSetting, "OtherScope", typeScope); var otherProjectScope = new CombineScope <CSharpSetting>(csharpSetting, projectScope, otherScope); var basePath = new RootPath(csharpSetting.RootPath); var secondPath = new RelativePath <CSharpSetting>(csharpSetting, "ProjectPath", basePath); var mappingPath = new ScopeMappingPath <CSharpSetting>(csharpSetting, secondPath, groupScope, projectScope); var testType = new CSharpGenerateType(csharpSetting, mappingPath, mappingPath, "TestType"); testType.Usings.Scopes.Add(otherProjectScope); testType.TypeDocumentation.Summary = "テストサマリー\r\nサマリー2行目"; OutputBlock.Text = SBHelper.ToString(sb => { sb.AppendLine(testType.GenerateFileName()); testType.ApppendStrings(sb); sb.AppendLine(testType.GenerateFullTypeName()); }); }
public InterpretedClass(ClassDeclarationExpression expression, Scope scope) { _rootscope = scope.Root; _name = expression.Name; _parents = expression.Parents; _interfaces = expression.Interfaces; _methods = new MethodCollection(); _fields = new FieldCollection(); _classes = new ClassCollection(); _static_variables = new VariableCollection(); ScriptScope script_scope = null; scope.FindNearestScope <ScriptScope> (ss => script_scope = ss); foreach (ClassMethodDeclarationExpression m in expression.Methods) { _methods.Add(new InterpretedMethod(m, script_scope)); } foreach (ClassFieldDeclarationExpression f in expression.Fields) { IVariable var = _static_variables.EnsureExists(f.Name); if (f.Initializer is Expression initializer_expr) { var.Value = Interpreters.Execute(initializer_expr, script_scope).ResultValue; } } }
public void Start() { hostContainer = RootScope.BeginLifetimeScope(); Logger.InfoFormat("Starting Service Host for '{0}'", typeof(T).Name); Configure(); Open(); Logger.InfoFormat("ServiceHost for '{0}' started successfully", typeof(T).Name); }
internal GMacAst() : base(new GMacAstDescription()) { UseNamespaces = true; ChildNamespaces = RootScope.Symbols(RoleNames.Namespace).Cast <GMacNamespace>(); SymbolicMathNames = new GMacSymbolicMathNames(this); }
bool IExpectation.TryMeet(IInvocation invocation, out Action action) { if (invocation == null) { throw new ArgumentNullException("invocation"); } return(RootScope.TryMeet(invocation, out action)); }
public override string ToString() { using (var writer = new StringWriter()) { RootScope.DescribeContent(writer, 0); DescribeUnexpectedInvocations(writer, 0); return(writer.GetStringBuilder().ToString()); } }
public IBuildIntention <IRootScope> GetBuildIntention(IConversionContext context) { var(toBuild, maker) = RootScope.Create(); return(new BuildIntention <IRootScope>(toBuild, () => { maker.Build( Scope.Is1OrThrow().Convert(context), Assignments.GetValue().Select(x => x.Is1OrThrow().GetValue().Convert(context)).ToArray(), EntryPoint.GetValue().Is1OrThrow().GetValue().Convert(context) ); })); }
public CssParser(CssTokenizer tokenizer, CssGrammar grammar) { ArgChecker.AssertArgNotNull(tokenizer, nameof(tokenizer)); _tokenizer = tokenizer; _rootScope = new RootScope(this, tokenizer.Tokenize().GetEnumerator(), grammar ?? DefaultGrammar); _namespaceManager = new XmlNamespaceManager(new NameTable()); var parseErrorNotifier = new ParseErrorNotifier(this); _parseErrorNotifier = parseErrorNotifier; _tokenizer.ParseError += (sender, e) => parseErrorNotifier.NotifyParseError(e); }
protected override DHCPv6Packet GetResponse(DHCPv6Packet input) { if (input == null || input.IsValid == false) { Logger.LogError("handling of empty packet is forbidden"); return(DHCPv6Packet.Empty); } DHCPv6Packet response = DHCPv6Packet.Empty; DHCPv6Packet innerPacket = input.GetInnerPacket(); switch (innerPacket.PacketType) { case DHCPv6PacketTypes.Solicit: Logger.LogDebug("packet {packet} is a solicit packet. Start handling of Hhndling solicit packet", input.PacketType); response = RootScope.HandleSolicit(input, _serverPropertyResolver); break; case DHCPv6PacketTypes.REQUEST: Logger.LogDebug("packet {packet} is a request packet. Start handling of request packet", input.PacketType); response = RootScope.HandleRequest(input, _serverPropertyResolver); break; case DHCPv6PacketTypes.RENEW: Logger.LogDebug("packet {packet} is a renew packet. Start handling of renew packet", input.PacketType); response = RootScope.HandleRenew(input, _serverPropertyResolver); break; case DHCPv6PacketTypes.REBIND: Logger.LogDebug("packet {packet} is a rebind packet. Start handling of rebind packet", input.PacketType); response = RootScope.HandleRebind(input, _serverPropertyResolver); break; case DHCPv6PacketTypes.RELEASE: Logger.LogDebug("packet {packet} is a release packet. Start handling of rebind packet", input.PacketType); response = RootScope.HandleRelease(input, _serverPropertyResolver); break; case DHCPv6PacketTypes.CONFIRM: Logger.LogDebug("packet {packet} is a confirm packet. Start handling of confirmpacket", input.PacketType); response = RootScope.HandleConfirm(input, _serverPropertyResolver); break; default: break; } return(response); }
public void Transform() { if (pipeline == null) { throw new InvalidOperationException("Transformer already used."); } foreach (var handler in pipeline) { handler.Initialize(this); RootScope.ProcessBasicBlocks <ILInstrList>(block => { Block = (ILBlock)block; handler.Transform(this); }); } pipeline = null; }
private Expression HandleAnonymousType() { Instruction instruction; MethodReference methodReference = null; ConstructorInfo constructorInfo = null; RootScope.TryGetInstruction(_objectCreation, OpCodes.Newobj, out instruction); methodReference = instruction.Operand as MethodReference; constructorInfo = methodReference.GetActualMethod <ConstructorInfo>(); _arguments = _objectCreation.Initializer .Elements .Select(e => e.AcceptVisitor(Visitor, ParentScope)) .ToListOf <Expression>(); InternalType = constructorInfo.DeclaringType; return(_arguments != null?Expression.New(constructorInfo, _arguments) : Expression.New(constructorInfo)); }
static void Main(string[] _) { var builder = new ContainerBuilder(); builder.RegisterModule <FlvProcessorModule>(); builder.RegisterModule <CoreModule>(); builder.RegisterType <CommandConfigV1>().As <ConfigV1>().InstancePerMatchingLifetimeScope("recorder_root"); Container = builder.Build(); RootScope = Container.BeginLifetimeScope("recorder_root"); Recorder = RootScope.Resolve <IRecorder>(); if (!Recorder.Initialize(System.IO.Directory.GetCurrentDirectory())) { Console.WriteLine("Initialize Error"); return; } Parser.Default .ParseArguments <CommandConfigV1>(() => (CommandConfigV1)Recorder.Config, Environment.GetCommandLineArgs()) .WithParsed(Run); }
/// <summary> /// Creates a new initialization and disposal scope for the current /// <see cref="DependencyContainer{TContainer, TConfigurator}" />. /// </summary> /// <returns> /// A new initialization and disposal scope for the current <see cref="DependencyContainer{TContainer, TConfigurator}" />. /// </returns> /// <exception cref="CreateDependencyScopeException"> /// An exception was raised while attempting to create the scope. /// </exception> /// <exception cref="ObjectDisposedException"> /// The object is disposed. /// </exception> public IDependencyScope CreateScope() { using (var controlToken = StateControl.Enter()) { RejectIfDisposed(); try { var scope = RootScope.CreateChildScope(); ReferenceManager.AddObject(scope); return(scope); } catch (CreateDependencyScopeException) { throw; } catch (Exception exception) { throw new CreateDependencyScopeException(exception); } } }
protected override DHCPv4Packet GetResponse(DHCPv4Packet input) { if (input == null || input.IsValid == false) { Logger.LogError("handling of empty packet is forbidden"); return(DHCPv4Packet.Empty); } DHCPv4Packet response = DHCPv4Packet.Empty; switch (input.MessageType) { case DHCPv4MessagesTypes.Discover: response = RootScope.HandleDiscover(input); break; case DHCPv4MessagesTypes.Request: response = RootScope.HandleRequest(input); break; case DHCPv4MessagesTypes.Decline: response = RootScope.HandleDecline(input); break; case DHCPv4MessagesTypes.Release: response = RootScope.HandleRelease(input); break; case DHCPv4MessagesTypes.Inform: response = RootScope.HandleInform(input); break; default: break; } return(response); }
public CoolAnimation(RootScope _rootScope) { //System.Diagnostics.Debug.Break(); }
static FakeScope() { Current = new RootScope(); }
public string Dump() { return(RootScope.Dump("")); }
private async void RootPage_Loaded(object sender, RoutedEventArgs e) { var recorder = RootScope.Resolve <IRecorder>(); var first_time = true; var error = string.Empty; string path; while (true) { try { CommandLineOption commandLineOption = null; if (first_time) { // while 循环第一次运行时检查命令行参数 try { first_time = false; Parser.Default .ParseArguments <CommandLineOption>(Environment.GetCommandLineArgs()) .WithParsed(x => commandLineOption = x); if (!string.IsNullOrWhiteSpace(commandLineOption?.WorkDirectory)) { // 如果有参数直接跳到检查路径 path = Path.GetFullPath(commandLineOption.WorkDirectory); } else { // 无命令行参数 continue; } } catch (Exception) { // 出错直接重新来,不显示 error continue; } } else { // 尝试读取上次选择的路径 var lastdir = string.Empty; try { if (File.Exists(lastdir_path)) { lastdir = File.ReadAllText(lastdir_path).Replace("\r", "").Replace("\n", "").Trim(); } } catch (Exception) { } // 显示路径选择界面 var dialog = new WorkDirectorySelectorDialog { Error = error, Path = lastdir }; if (await dialog.ShowAsync() != ContentDialogResult.Primary) { (Application.Current.MainWindow as NewMainWindow).CloseWithoutConfirmAction(); return; } try { path = Path.GetFullPath(dialog.Path); } catch (Exception) { error = "不支持该路径"; continue; } } var config = Path.Combine(path, "config.json"); if (!Directory.Exists(path)) { error = "目录不存在"; continue; } else if (!Directory.EnumerateFiles(path).Any()) { // 可用的空文件夹 } else if (!File.Exists(config)) { error = "目录已有其他文件"; continue; } // 已经选定工作目录 // 如果不是从命令行参数传入的路径,写入 lastdir_path 记录 try { if (string.IsNullOrWhiteSpace(commandLineOption?.WorkDirectory)) { File.WriteAllText(lastdir_path, path); } } catch (Exception) { } // 检查已经在同目录运行的其他进程 if (SingleInstance.CheckMutex(path)) { // 无已经在同目录运行的进程 if (recorder.Initialize(path)) { Model.Recorder = recorder; _ = Task.Run(async() => { await Task.Delay(100); _ = Dispatcher.BeginInvoke(DispatcherPriority.Normal, method: new Action(() => { RoomListPageNavigationViewItem.IsSelected = true; })); }); break; } else { error = "配置文件加载失败"; continue; } } else { // 有已经在其他目录运行的进程,已经通知该进程,本进程退出 (Application.Current.MainWindow as NewMainWindow).CloseWithoutConfirmAction(); return; } } catch (Exception ex) { error = "发生了未知错误"; logger.Warn(ex, "选择工作目录时发生了未知错误"); continue; } } }
public Context(ContextOptions options, IParser parser) { Options = options ?? new ContextOptions(); Parser = parser; RootScope = new RootScope(this); }
public void Dispose() => RootScope.Dispose();
/// <summary> /// Return a reference to a primitive type with the given name /// </summary> /// <param name="typeName">The name of the primitive type</param> /// <returns></returns> public TypePrimitive GetTypePrimitive(string typeName) { return(RootScope.GetSymbol(typeName, TypePrimitiveRoleName) as TypePrimitive); }
public static void OnStateChangeStart(this RootScope _rootscope, Action <Event, StateConfig, object, StateConfig, Object> Function) { _rootscope.On("$stateChangeStart", Function); }
internal bool LookupRootNamespace(string symbolName, out GMacNamespace nameSpace) { return(RootScope.LookupSymbol(symbolName, RoleNames.Namespace, out nameSpace)); }
private async void RootPage_Loaded(object sender, RoutedEventArgs e) { bool first_time = true; var recorder = RootScope.Resolve <IRecorder>(); var error = string.Empty; string path; while (true) { CommandLineOption commandLineOption = null; if (first_time) { first_time = false; Parser.Default .ParseArguments <CommandLineOption>(Environment.GetCommandLineArgs()) .WithParsed(x => commandLineOption = x); if (!string.IsNullOrWhiteSpace(commandLineOption?.WorkDirectory)) { path = Path.GetFullPath(commandLineOption.WorkDirectory); goto check_path; } } string lastdir = string.Empty; try { if (File.Exists(lastdir_path)) { lastdir = File.ReadAllText(lastdir_path).Replace("\r", "").Replace("\n", "").Trim(); } } catch (Exception) { } var w = new WorkDirectorySelectorDialog { Error = error, Path = lastdir }; var result = await w.ShowAsync(); if (result != ContentDialogResult.Primary) { (Application.Current.MainWindow as NewMainWindow).CloseWithoutConfirmAction(); return; } path = Path.GetFullPath(w.Path); check_path: var config = Path.Combine(path, "config.json"); if (!Directory.Exists(path)) { error = "目录不存在"; continue; } else if (!Directory.EnumerateFiles(path).Any()) { // 可用的空文件夹 } else if (!File.Exists(config)) { error = "目录已有其他文件"; continue; } try { if (string.IsNullOrWhiteSpace(commandLineOption?.WorkDirectory)) { File.WriteAllText(lastdir_path, path); } } catch (Exception) { } // 检查已经在同目录运行的其他进程 if (SingleInstance.CheckMutex(path)) { if (recorder.Initialize(path)) { Model.Recorder = recorder; RoomListPageNavigationViewItem.IsSelected = true; break; } else { error = "配置文件加载失败"; continue; } } else { (Application.Current.MainWindow as NewMainWindow).CloseWithoutConfirmAction(); return; } } }
public void BeginTestScope() { TestScope = RootScope.BeginLifetimeScope("testScope"); }
public void TearDownRootScope() { RootScope.Dispose(); RootScope = null; }
private ILifetimeScope NewScope() => RootScope.BeginLifetimeScope();
private void OnMouseMove(object sender, MouseEventArgs e) { if (!CanDrawScopes || DesignMode || Text == string.Empty) { return; } // LockWindowUpdate(Handle); Point cursorPos = new Point(e.X, e.Y); int cursorCharPos = GetCharIndexFromPosition(cursorPos); int cursorLine = GetLineFromCharIndex(cursorCharPos); Scope innerScope = RootScope.FindInnerScope(cursorCharPos, 1); VisualScopeMarker visualScopeMarker = GetVisualScopeMarker(innerScope); if (visualScopeMarker == null) { return; } bool intersectsWithCursor = visualScopeMarker.IntersectsWithCursor(cursorPos); if (!intersectsWithCursor) { if (lastVisualScopeMarker != null) { lastVisualScopeMarker.OnDeactivate(); } if (ActiveScope == null) { return; } lastScope = null; ActiveScope = null; return; } if (lastVisualScopeMarker != null && lastVisualScopeMarker != visualScopeMarker) { lastVisualScopeMarker.OnDeactivate(); } lastVisualScopeMarker = visualScopeMarker; if (visualScopeMarker.IsActive) { visualScopeMarker.OnMouseMove(e); } else { visualScopeMarker.OnActivate(); } if (lastScope == null && innerScope != null) { lastScope = innerScope; ActiveScope = innerScope; } else { if (lastScope == innerScope) { return; } else { lastScope = innerScope; ActiveScope = innerScope; } } }