internal static void Accept(this ControlPropertyBag propertyBag, ControlPropertyFiller[] fillers)
 {
     foreach (var filler in fillers)
     {
         propertyBag.Accept(filler);
     }
 }
 /// <summary>
 /// Modifies the current <paramref name="target"/> to support third-party method call interception for all method calls made inside the target.
 /// </summary>
 /// <param name="target">The target object.</param>
 /// <param name="methodCallFilter">The <see cref="IMethodCallFilter"/> instance that determines the method calls that will be intercepted.</param>
 /// <param name="hostMethodFilter">The <see cref="IMethodFilter"/> instance that determines the host method calls that will be modified</param>
 public static void InterceptMethodCalls(this IReflectionVisitable target, IMethodCallFilter methodCallFilter,
     IMethodFilter hostMethodFilter)
 {
     var rewriter = new InterceptMethodCalls(methodCallFilter);
     target.Accept(new ImplementModifiableType(GetDefaultTypeFilter()));
     target.WeaveWith(rewriter, hostMethodFilter.ShouldWeave);
 }
Exemplo n.º 3
0
	/// <summary>
	/// Finds all projects in the solution matching the given predicate.
	/// </summary>
	/// <param name="solution">The solution to traverse.</param>
	/// <param name="predicate">Predicate used to match projects.</param>
	/// <returns>All project nodes matching the given predicate that were found.</returns>
	public static IEnumerable<IProjectNode> FindProjects (this ISolutionNode solution, Func<IProjectNode, bool> predicate)
	{
		var visitor = new FilteringProjectsVisitor(predicate);

		solution.Accept (visitor);

		return visitor.Projects;
	}
Exemplo n.º 4
0
	/// <summary>
	/// Finds the first project in the solution matching the given predicate.
	/// </summary>
	/// <param name="solution">The solution to traverse.</param>
	/// <param name="predicate">Predicate used to match projects.</param>
	/// <returns>The first project matching the given predicate, or <see langword="null"/>.</returns>
	public static IProjectNode FindProject (this ISolutionNode solution, Func<IProjectNode, bool> predicate)
	{
		var visitor = new FilteringProjectsVisitor(predicate, true);

		solution.Accept (visitor);

		return visitor.Projects.FirstOrDefault ();
	}
Exemplo n.º 5
0
	/// <summary>
	/// Finds all the project nodes in the solution.
	/// </summary>
	/// <param name="solution">The solution to traverse.</param>
	/// <returns>All project nodes that were found.</returns>
	public static IEnumerable<IProjectNode> FindProjects (this ISolutionNode solution)
	{
		var visitor = new ProjectsVisitor();

		solution.Accept (visitor);

		return visitor.Projects;
	}
        public static RulesEngineGraph GetGraph(this OdoyuleRulesEngine rulesEngine)
        {
            var inspector = new GraphRulesEngineVisitor();

            rulesEngine.Accept(inspector);

            return inspector.Graph;
        }
        public static void InterceptMethodBody(this IReflectionStructureVisitable target,
                                               Func<MethodReference, bool> methodFilter, Func<TypeReference, bool> typeFilter)
        {
            target.Accept(new ImplementModifiableType(typeFilter));

            var interceptMethodBody = new InterceptMethodBody(methodFilter);
            target.WeaveWith(interceptMethodBody, methodFilter);
        }
        public static void ShowVisualizer(this RulesEngine engine)
        {
            var visitor = new GraphRulesEngineVisitor();
            engine.Accept(visitor);

            RulesEngineGraph graph = visitor.Graph;

            RulesEngineDebugVisualizer.Show(graph);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Return a concrete implementation of a TCP listener
        /// </summary>
        /// <param name="port"></param>
        /// <param name="protocol"></param>
        /// <returns></returns>
        public static ICommServer GetTcpListener(
            this Socket port,
            IProtocol protocol)
        {
            var client = port.Accept();
            Debug.Print("open");

            return new TcpServer(
                client,
                protocol);
        }
        public static IObservable<Socket> ToListenerObservable(this Socket socket, int backlog, Selector selector)
        {
            return Observable.Create<Socket>(observer =>
            {
                socket.Listen(backlog);

                selector.AddCallback(SelectMode.SelectRead, socket, _ =>
                {
                    var accepted = socket.Accept();
                    accepted.Blocking = false;
                    observer.OnNext(accepted);
                });

                return Disposable.Create(() => selector.RemoveCallback(SelectMode.SelectRead, socket));
            });
        }
Exemplo n.º 11
0
 public static ExpressionSyntax GenerateExpressionSyntax(
     this ITypeSymbol typeSymbol)
 {
     return typeSymbol.Accept(ExpressionSyntaxGeneratorVisitor.Instance).WithAdditionalAnnotations(Simplifier.Annotation);
 }
Exemplo n.º 12
0
 public static String AsiToString(this IAsi asi)
     => asi.Accept(Program.DefaultPrinter).Trim('"');
 /// <summary>
 /// Extracts the first innermost atomic statement inside a given statement.
 /// </summary>
 /// <param name="stmt"></param>
 /// <returns></returns>
 public static Statement GetInnermostAtomicStatement(this Statement stmt)
 {
     InnermostAtomicStatementExtractor ase = new InnermostAtomicStatementExtractor();
     stmt.Accept(ase);
     return ase.Result;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Allows a <see cref="ITypeWeaver"/> instance to traverse any <see cref="IReflectionStructureVisitable"/>
 /// instance.
 /// </summary>
 /// <param name="visitable">The visitable object.</param>
 /// <param name="typeWeaver">The type weaver.</param>
 public static void Accept(this IReflectionStructureVisitable visitable, ITypeWeaver typeWeaver)
 {
     var visitor = new TypeWeaverVisitor(typeWeaver);
     visitable.Accept(visitor);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Allows a <see cref="IMethodWeaver"/> instance to traverse any <see cref="IReflectionVisitable"/>
 /// instance.
 /// </summary>
 /// <param name="visitable">The visitable object.</param>
 /// <param name="methodWeaver">The method weaver.</param>
 public static void Accept(this IReflectionVisitable visitable, IMethodWeaver methodWeaver)
 {
     var visitor = new MethodWeaverVisitor(methodWeaver);
     visitable.Accept(visitor);
 }
Exemplo n.º 16
0
 public static string ToLogString(this QueryNode node)
 {
     return node.Accept(new QueryNodeToStringVisitor());
 }
 /// <summary>
 /// Returns <c>true</c> if the given statement modifies the given variable.
 /// </summary>
 /// <remarks>
 /// The current implementation is not capable of detecting modifications of variables which are referenced as "out" arguments of some method.
 /// </remarks>
 /// <param name="stmt">statement</param>
 /// <param name="variable">variable</param>
 public static bool Modifies(this Statement stmt, IStorable variable)
 {
     VariableModificationDetector vmd = new VariableModificationDetector(variable);
     stmt.Accept(vmd);
     return vmd.Result;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Returns <c>true</c> if the literal depicts a constant.
 /// </summary>
 /// <param name="lit">literal</param>
 /// <param name="constValue">out parameter to receive the constant value, if the literal 
 /// depicts a constant, otherwise <c>null</c></param>
 public static bool IsConst(this ILiteral lit, out object constValue)
 {
     IsConstLiteralVisitor vtor = new IsConstLiteralVisitor();
     lit.Accept(vtor);
     constValue = vtor.ConstValue;
     return vtor.Result;
 }
Exemplo n.º 19
0
 /// <summary>
 /// Transforms the methods in the <paramref name="target"/> using the given method rewriter.
 /// </summary>
 /// <param name="target">The transformation target.</param>
 /// <param name="rewriter">The method rewriter.</param>
 /// <param name="filter">The method filter that determines which methods will be rewritten.</param>
 public static void WeaveWith(this IReflectionVisitable target, IMethodRewriter rewriter,
     Func<MethodReference, bool> filter)
 {
     var weaver = new MethodWeaver(rewriter, filter);
     target.Accept(weaver);
 }
		public static void Execute(this Component component, BaseVisitor visitor)
		{
			component.Accept(visitor);
			visitor.Execute();
		}
Exemplo n.º 21
0
 /// <summary>
 /// Tries to interpret the statement as "for" loop.
 /// </summary>
 /// <param name="stmt">assumed "for" loop</param>
 /// <param name="level">pattern matching restrictions</param>
 /// <returns>an explicit SysDOM representation of the "for" loop, or <c>null</c> if the statement
 /// does not match the expected pattern</returns>
 public static LoopBlock AsForLoop(this Statement stmt, EForLoopLevel level)
 {
     ForLoopRecognizer flr = new ForLoopRecognizer()
     {
         Level = level
     };
     stmt.Accept(flr);
     return flr.Result;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Converts the statement to an inline expression.
 /// </summary>
 /// <param name="stmt">statement to convert</param>
 /// <returns>semantically equivalent inline expression</returns>
 /// <exception cref="NotConvertibleToInlineExpressionException">if the statement is not convertible to an inline expression</exception>
 public static Expression ToInlineExpression(this Statement stmt)
 {
     stmt.RemoveNops();
     InlineExpressionConverter iec = new InlineExpressionConverter();
     stmt.Accept(iec);
     return iec.Result;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Removes all inner "do nothing" statements.
 /// </summary>
 /// <param name="stmt">the statement from which to remove all inner "do nothing" statements</param>
 public static void RemoveNops(this Statement stmt)
 {
     NopRemover nrm = new NopRemover();
     stmt.Accept(nrm);
     nrm.Pass = NopRemover.EPass.Remove;
     stmt.Accept(nrm);
 }
 /// <summary>
 /// Determines whether a given statement is empty, that is if it does not perform any operation.
 /// </summary>
 /// <param name="stmt">>A statement</param>
 /// <returns>true if the statement is empty, false if not</returns>
 public static bool IsEmpty(this Statement stmt)
 {
     EmptyStatementDetector esd = new EmptyStatementDetector();
     stmt.Accept(esd);
     return esd.IsEmpty;
 }
Exemplo n.º 25
0
 public static void RemoveAll(this Statement stmt, Statement toRemove)
 {
     StatementRemover sr = new StatementRemover()
     {
         Match = toRemove
     };
     stmt.Accept(sr);
 }
 /// <summary>
 /// Extracts all atomic statements inside a given statement.
 /// </summary>
 /// <param name="stmt"></param>
 /// <returns>The list of atomic statements, the first entry being the entry.</returns>
 public static List<Statement> GetAtomicStatements(this Statement stmt)
 {
     AtomicStatementExtractor ase = new AtomicStatementExtractor();
     stmt.Accept(ase);
     return ase.Result;
 }
Exemplo n.º 27
0
 public static IEnumerable<Socket> IncommingConnections(this Socket server)
 {
     while(true)
     {
         Socket s = server.Accept();
         yield return s;
     }
 }
        /// <summary>
        /// Adds field interception support to the target type.
        /// </summary>
        /// <param name="targetType">The type that will be modified.</param>
        /// <param name="methodFilter">The filter that determines which methods on the target type will be modified to support field interception.</param>
        /// <param name="fieldFilter">The filter that determines which fields should be intercepted.</param>
        public static void InterceptFields(this IReflectionVisitable targetType, Func<MethodReference, bool> methodFilter, Func<FieldReference, bool> fieldFilter)
        {
            var typeWeaver = new ImplementFieldInterceptionHostWeaver(t => true);
            var fieldWeaver = new InterceptFieldAccess(fieldFilter);

            targetType.WeaveWith(fieldWeaver, methodFilter);
            targetType.Accept(typeWeaver);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Determines whether a given statement is an ancestor of some other statement.
 /// </summary>
 /// <param name="stmt">An assumed ancestor</param>
 /// <param name="grandChild">Its assumed granchild</param>
 /// <returns><c>true</c> if <paramref name="stmt"/> is an ancestor of <paramref name="grandChild"/></returns>
 /// <remarks>A statement a is an ancestor of a statement b iff there exists a sequence
 /// s1, s2,... , sN of zero or more statements such that a contains s1, s1 contains s2,
 /// ... and sN contains b. Furthermore, each statement is per definition an ancestor
 /// of itself.
 /// </remarks>
 public static bool IsAncestor(this Statement stmt, Statement grandChild)
 {
     HierarchyAnalyzer ha = new HierarchyAnalyzer()
     {
         Grandchild = grandChild
     };
     stmt.Accept(ha);
     return ha.IsAncestor;
 }
 public static IEnumerable<Socket> IncommingConnectoins(this Socket server)
 {
     while (true)
         yield return server.Accept();
 }