private object Scan(string ips, string mac) { var executor = new SharpSnmpExecutor(); var accessor = new SwitchAccessor(executor); var fetcher = new SwitchMacToPortFetcher(accessor); return fetcher.ScanSwitchInFull( new SwitchScanInfo { IpAddressString = ips.Split(new[] { ',' }).First(), CommunityReadString = m_ScanSettings.CommunityString }); }
private Accessor BuildAccessGraph(TypeNode type, bool deep, bool isStatic, Hashtable visited){ Accessor acc = (Accessor) visited[type]; if (acc != null) return acc; TypeUnion tu = type as TypeUnion; if (tu != null){ SwitchAccessor sw = new SwitchAccessor(); visited[type] = sw; sw.Type = tu; for( int i = 0, n = tu.Types.Count; i < n; i++ ){ TypeNode tn = this.typeSystem.GetRootType(tu.Types[i], this.TypeViewer); if (tn == null) continue; sw.Accessors.Add(i, this.BuildAccessGraph(tn, deep, isStatic, visited)); } return sw; } // queries don't see through intersection types, // assume intersection type is a derived class w/ all private members TypeIntersection ti = type as TypeIntersection; if (ti != null){ return null; } // examine members SequenceAccessor accessor = new SequenceAccessor(); visited[type] = accessor; this.BuildMemberAccess(type, accessor, deep, isStatic, visited); return accessor; }
public virtual void BuildAxisClosureUnion(Expression source, AxisBuildState state, SwitchAccessor swa, bool yieldResult, Block block, BlockScope scope) { TypeUnion tu = source.Type as TypeUnion; Debug.Assert(tu != null, "Switch accessor must have type union"); if (!this.IsLocal(source)) { Expression loc = this.NewClosureLocal(source.Type, scope); block.Statements.Add(new AssignmentStatement(loc, source)); source = loc; } // determine type union tag and value Method mgetvalue = this.GetTypeView(tu).GetMethod(StandardIds.GetValue); MethodCall mcgetvalue = new MethodCall(new MemberBinding(source, mgetvalue), null); mcgetvalue.Type = mgetvalue.ReturnType; Local locValue = new Local(SystemTypes.Object); block.Statements.Add(new AssignmentStatement(locValue, mcgetvalue)); Method mgettag = this.GetTypeView(tu).GetMethod(StandardIds.GetTag); MethodCall mcgettag = new MethodCall(new MemberBinding(source, mgettag), null); mcgettag.Type = mgettag.ReturnType; Local locTag = new Local(SystemTypes.UInt32); block.Statements.Add(new AssignmentStatement(locTag, mcgettag)); // switch on type union tag BlockList blocks = new BlockList(swa.Accessors.Count); Block endBlock = new Block(null); foreach( int id in swa.Accessors.Keys ) { Accessor acc = (Accessor) swa.Accessors[id]; Block caseBlock = new Block(new StatementList(3)); blocks.Add(caseBlock); block.Statements.Add(new Branch(new BinaryExpression(locTag, new Literal(id, SystemTypes.Int32), NodeType.Eq), caseBlock)); Expression locvar = this.NewClosureLocal(swa.Type.Types[id], scope); caseBlock.Statements.Add(new AssignmentStatement(locvar, this.Unbox(locValue, locvar.Type))); this.BuildAxisClosureExpression(locvar, state, acc, yieldResult, caseBlock, scope); caseBlock.Statements.Add(new Branch(null, endBlock)); } block.Statements.Add(new Branch(null, endBlock)); for( int i = 0, n = blocks.Count; i < n; i++ ) { block.Statements.Add(blocks[i]); } block.Statements.Add(endBlock); }