public void SetUp() { factory = new InstanceFactory(typeof(IGateway)); factory.AddInstance(new SmartInstance <DefaultGateway>()); factory.AddInstance(new SmartInstance <DefaultGateway>()); var lifecycle = MockRepository.GenerateMock <ILifecycle>(); factory.Lifecycle = lifecycle; factory.MissingInstance = new SmartInstance <DefaultGateway>(); clone = factory.Clone(); }
public void eject_all_instances_removes_all_instances_and_ejects_from_the_build_policy() { var factory = new InstanceFactory(typeof (IGateway)); factory.AddInstance(new SmartInstance<DefaultGateway>()); factory.AddInstance(new SmartInstance<DefaultGateway>()); var lifecycle = MockRepository.GenerateMock<ILifecycle>(); factory.Lifecycle = lifecycle; factory.EjectAllInstances(); factory.AllInstances.Count().ShouldEqual(0); lifecycle.AssertWasCalled(x => x.EjectAll()); }
public void eject_all_instances_removes_all_instances_and_ejects_from_the_build_policy() { var factory = new InstanceFactory(typeof(IGateway)); factory.AddInstance(new SmartInstance <DefaultGateway>()); factory.AddInstance(new SmartInstance <DefaultGateway>()); var lifecycle = MockRepository.GenerateMock <ILifecycle>(); factory.Lifecycle = lifecycle; factory.EjectAllInstances(); factory.AllInstances.Count().ShouldEqual(0); lifecycle.AssertWasCalled(x => x.EjectAll()); }
public void Merge_from_PluginFamily_will_not_replace_an_existing_instance() { var factory = new InstanceFactory(typeof(IWidget)); ObjectInstance instance1 = new ObjectInstance(new AWidget()).WithName("New"); factory.AddInstance(instance1); var family = new PluginFamily(typeof(IWidget)); family.AddInstance(new ObjectInstance(new AWidget()).WithName("New")); factory.ImportFrom(family); Assert.AreSame(instance1, factory.FindInstance("New")); }
public void Merge_from_PluginFamily_will_not_replace_an_existing_instance() { var factory = new InstanceFactory(typeof (IWidget)); ObjectInstance instance1 = new ObjectInstance(new AWidget()).WithName("New"); factory.AddInstance(instance1); var family = new PluginFamily(typeof (IWidget)); family.AddInstance(new ObjectInstance(new AWidget()).WithName("New")); factory.ImportFrom(family); Assert.AreSame(instance1, factory.FindInstance("New")); }
public void SetUp() { factory = new InstanceFactory(typeof (IGateway)); factory.AddInstance(new SmartInstance<DefaultGateway>()); factory.AddInstance(new SmartInstance<DefaultGateway>()); var lifecycle = MockRepository.GenerateMock<ILifecycle>(); factory.Lifecycle = lifecycle; factory.MissingInstance = new SmartInstance<DefaultGateway>(); clone = factory.Clone(); }
/// <summary> /// 创建螺纹孔安装面 /// </summary> /// <param name="Spart">对象零件</param> /// <param name="UserSelected">用户选择参考对象2边1面</param> /// <param name="WeightEdge">宽边</param> /// <param name="LengthEdge">长边</param> /// <param name="Weight">宽边宽度</param> /// <param name="Length">长边长度</param> /// <param name="JianDis">孔间距</param> public void CreateThreadHole(Part Spart, Reference[] UserSelected, object[] UserSelectedValue, Edge WeightEdge, Edge LengthEdge, double Weight, double Length, double JianDis) { //对与孔装配的零件执行打孔 object[] SHolePoint = new object[3]; Selection SelectArc = CatActiveDoc.Selection; SelectArc.Clear(); var Result = SelectArc.SelectElement2(InputObjectType(2), "请选择子零件孔支持面!", true); if (Result == "Cancel" || SelectArc == null || SelectArc.Count2 == 0) { return; } Reference SonReface = SelectArc.Item(1).Reference; GetProductByFace SGPB = new GetProductByFace(); Part SonPart = SGPB.GetPart((Face)SelectArc.Item(1).Value); SelectArc.Item(1).GetCoordinates(SHolePoint); SelectArc.Clear(); ShapeFactory NextshapeFactory = (ShapeFactory)SonPart.ShapeFactory; HybridShapeFactory NextHyShapeFactory = (HybridShapeFactory)SonPart.HybridShapeFactory; InstanceFactory NextInf = (InstanceFactory)SonPart.GetCustomerFactory("InstanceFactory"); NextInf.AddInstance(WeightEdge); try { Reference Wref = null; Reference Lref = null; try { object[] LinePoint = new object[12]; object[] LineDirection = new object[12]; SPAWorkbench TheSPAWorkbench = (SPAWorkbench)CatActiveDoc.GetWorkbench("SPAWorkbench"); Measurable LengthA = TheSPAWorkbench.GetMeasurable(WeightEdge); Measurable LengthB = TheSPAWorkbench.GetMeasurable(LengthEdge); //LengthA.GetMinimumDistancePoints(, LinePoint); //LengthA.GetDirection(LineDirection); //NextHyShapeFactory.AddNewLineNormal(SonReface, 10, 10, true); Edge WeightEdgeT = (Edge)UserSelectedValue[0]; Edge LengthEdgeT = (Edge)UserSelectedValue[1]; string WeightEdgeName = WeightEdgeT.get_Name(); string LengthEdgeTName = LengthEdgeT.get_Name(); Wref = SonPart.CreateReferenceFromName(null); Lref = SonPart.CreateReferenceFromName(null); WeightEdgeName = Wref.get_Name(); LengthEdgeTName = Lref.get_Name(); SelectArc.Add(WeightEdgeT); SelectArc.Add(LengthEdgeT); SelectArc.Copy(); } catch (Exception e) { throw e; } Hole SonNwhole = NextshapeFactory.AddNewHoleWith2Constraints(Convert.ToDouble(SHolePoint[0]), Convert.ToDouble(SHolePoint[1]), Convert.ToDouble(SHolePoint[2]), Wref, Lref, SonReface, 50);//创建过孔 try { RxSetHoleType(SonNwhole, 10, Weight / 2, 9, RxHoleType.NSmoothHole); } catch (Exception) { RxSetHoleType(SonPart, SonNwhole, 10, Weight / 2, 9, RxHoleType.NSmoothHole, WeightEdge, LengthEdge); } SonPart.Update(); Hole SonNwPinHole = NextshapeFactory.AddNewHoleWith2Constraints(Convert.ToDouble(SHolePoint[0]) + 5, Convert.ToDouble(SHolePoint[1]) + 5, Convert.ToDouble(SHolePoint[2]), UserSelected[0], UserSelected[1], SonReface, 50);//创建销孔 RxSetHoleType(SonNwPinHole, 10, Weight / 2 + JianDis, 8, RxHoleType.PinHole); SonPart.Update(); if (Length <= 60) { RectPattern RPhole = NextshapeFactory.AddNewRectPattern(SonNwhole, 2, 1, JianDis * 2, 20, 1, 1, LengthEdge, WeightEdge, true, true, 0); //阵列过孔 RPhole.FirstRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; RPhole.SecondRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; Spart.Update(); } else { RectPattern RPhole = NextshapeFactory.AddNewRectPattern(SonNwhole, 2, 1, JianDis * 2, 20, 1, 1, LengthEdge, WeightEdge, true, true, 0); //阵列过孔 RPhole.FirstRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; RPhole.SecondRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; RectPattern RPinhole = NextshapeFactory.AddNewRectPattern(SonNwPinHole, 2, 1, JianDis * 2, 20, 1, 1, LengthEdge, WeightEdge, true, true, 0); //阵列过孔 RPinhole.FirstRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; RPinhole.SecondRectangularPatternParameters = CatRectangularPatternParameters.catInstancesandSpacing; Spart.Update(); } } catch (Exception) { throw; MessageBox.Show("打孔失败!请确定选择是否有误!"); } }