//public override Complex32 TheveninVoltage(Node referenceNode, Complex32? W = null)
        //{
        //    if (referenceNode == Nodes[0])
        //        return new Complex32((float) Value, 0);
        //    return new Complex32((float)-Value, 0);
        //}


        public VoltageGenerator(ComponentContainer owner)
            : base(owner)
        {
            Initialize("V" + ID.ToString());
            Expresion = "V";
            Value = 10;
        }
 public ParallelBlock(ComponentContainer owner, Dipole comp1, Dipole comp2):base(owner)
 {
     Components.Add(comp1);
     Components.Add(comp2);
     Nodes.Add(comp1.Nodes[0]);
     Nodes.Add(comp1.Nodes[1]);
 }
Ejemplo n.º 3
0
        public static int Main(string[] args)
        {
            ComponentContainer container = new ComponentContainer();

            var program = container.Resolve<Program>();
            return program.Run(args);
        }
        public ACVoltageGenerator(ComponentContainer owner, float ACMagnitude = 1, float ACPhase = 0)
            : base(owner)
        {
            ACVoltage = Complex32.FromPolarCoordinates(ACMagnitude, ACPhase);
            //ACVoltage = new Complex32(ACMagnitude, 0);

        }
Ejemplo n.º 5
0
        public void SetUp()
        {
            this.container = new ComponentContainer();
            this.kernelMock = new Mock<IKernel>();

            this.container.Kernel = this.kernelMock.Object;
        }
 public VoltageControlledGenerator(ComponentContainer owner, string name)
     : base(owner)
 {
     InputNodes = new List<Node>();
     Initialize(name);
     Gain = "10";
 }
Ejemplo n.º 7
0
        public ComponentContainerContext()
        {
            container = new ComponentContainer();
            kernelMock = new Mock<IKernel>();

            container.Kernel = kernelMock.Object;
        }
Ejemplo n.º 8
0
 public void 测试ComponentContainer导入插件()
 {
     var container = new ComponentContainer<string, IInterface>(v => v.Name);
     Assert.AreEqual(2, container.Count);
     Assert.IsInstanceOfType(container["a"], typeof(MyClass));
     Assert.IsInstanceOfType(container["b"], typeof(MyClass2));
 }
        //public override Complex32 NortonCurrent(Node referenceNode, Complex32? W = null)
        //{
        //    return Current(referenceNode, W);
        //}

        public CurrentGenerator(ComponentContainer owner)
            : base(owner)
        {
            Initialize("I" + ID.ToString());
            Expresion = "I";
            Value = 1E-3;
        }
Ejemplo n.º 10
0
 public Capacitor(ComponentContainer owner)
     : base(owner)
 {
     Initialize("C" + ID.ToString());
     Expresion = "C";
     Value = 1E-6;
 }
Ejemplo n.º 11
0
 public Resistor(ComponentContainer owner)
     : base(owner)
 {
     Initialize("R" + ID.ToString());
     //Name = "R" + ID.ToString();
     Expresion = "R";
     Value = 1000;
 }
Ejemplo n.º 12
0
 public Inductor(ComponentContainer owner)
     : base(owner)
 {
     Initialize("L" + ID.ToString(), "1m");
     //Name = "L" + ID.ToString();
     Expresion = "L";
     //Value = 1E-4;
 }
Ejemplo n.º 13
0
	void Awake ()
	{
		ComponentContainer = GetComponentInParent<ComponentContainer>() as ComponentContainer;
		if (ComponentContainer == null)
		{
			throw new UnityException("GemSwapper must have a ComponentContainer component attached to a parent.");
		}
	}
Ejemplo n.º 14
0
        public void AutoBind_Binds_Correctly_For_Interfaces_With_Multiple_Implementors_When_One_Implementor_Is_Marked_As_Default()
        {
            ComponentContainer container = new ComponentContainer();
            container.AutoBind(Assembly.GetExecutingAssembly());

            Assert.IsTrue(container.HasBinding<IBaz>());
            Assert.IsInstanceOf(typeof(Baz1), container.Resolve<IBaz>());
        }
Ejemplo n.º 15
0
        public void AutoBind_Binds_Correctly_For_Interfaces_With_One_Implementor()
        {
            ComponentContainer container = new ComponentContainer();
            container.AutoBind(Assembly.GetExecutingAssembly());

            Assert.IsTrue(container.HasBinding<IHasOneImplementor>());
            Assert.IsInstanceOf(typeof(HasOneImplementor), container.Resolve<IHasOneImplementor>());
        }
Ejemplo n.º 16
0
        public void SetUp()
        {
            this.container = new ComponentContainer();
            this.kernelConfigurationMock = new Mock<IKernelConfiguration>();
            this.kernelConfigurationMock.SetupGet(c => c.Settings).Returns(new NinjectSettings());

            this.container.KernelConfiguration = this.kernelConfigurationMock.Object;
        }
Ejemplo n.º 17
0
        public void Bind_ToConstant_Where_Component_Is_Not_Instance_Of_Type_Throws_Exception()
        {
            ComponentContainer container = new ComponentContainer();

            IBar bar = new Bar1();
            IFoo foo = new Foo1(bar);

            container.Bind<IBar>().ToConstant(foo);
        }
Ejemplo n.º 18
0
        public void Resolve_Interface_Uses_Default_Bindings()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<IBar>().To<Bar1>();

            IBar bar = container.Resolve<IBar>();

            Assert.IsInstanceOf(typeof(Bar1), bar);
        }
Ejemplo n.º 19
0
 public void AutoBind_Finds_All_Implementors()
 {
     ComponentContainer container = new ComponentContainer();
     container.AutoBind(Assembly.GetExecutingAssembly(), new TestAutoBindingStrategy((x, interfaceType, componentTypes) =>
     {
         if (interfaceType == typeof(IFoo))
         {
             Assert.Greater(componentTypes.Count, 1);
         }
     }));
 }
        public void Disposing_Of_Container_Calls_Dispose_On_Singleton_Obects()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<DisposableObject>().ToSelf().AsSingleton();

            DisposableObject obj = container.Resolve<DisposableObject>();

            container.Dispose();

            Assert.IsTrue(obj.WasDisposed);
        }
Ejemplo n.º 21
0
        public void Bind_ToStrategy_Strategy_Is_Disposed_With_Container()
        {
            var strategy = new TestBindingStrategy<Bar1>(() => new Bar1());

            ComponentContainer container = new ComponentContainer();
            container.Bind<IBar>().ToStrategy(strategy);

            container.Dispose();

            Assert.IsTrue(strategy.DisposeWasCalled);
        }
Ejemplo n.º 22
0
        public void Bind_ToStrategy_Calls_Strategy()
        {
            var strategy = new TestBindingStrategy<Bar1>(() => new Bar1());

            ComponentContainer container = new ComponentContainer();
            container.Bind<IBar>().ToStrategy(strategy);

            var bar = container.Resolve<IBar>();

            Assert.IsTrue(strategy.ResolveWasCalled);
        }
 public SineVoltageGenerator(ComponentContainer owner, string name)
     : base(owner)
 {
     Initialize(name);
     Amplitude = "10";
     Frequency = "1K";
     Phase = "0";
     Thau = "0";
     Delay = "10u";
     Offset = "0";
 }
Ejemplo n.º 24
0
        public void Bind_ToMultiple_With_Array()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<IStubObject[]>().ToMultiple()
                .Add<StubObjectFooConstructor>().AsTransient().WithConstructorParameter("id", "Foo")
                .Add<StubObjectBarConstructor>().AsTransient().WithConstructorParameter("id", "Bar");

            var obj = container.Resolve<NeedsArrayOfStubObjects>();
            Assert.AreEqual(2, obj.Stubs.Length);

            Assert.IsInstanceOf<StubObjectFooConstructor>(obj.Stubs[0]);
            Assert.IsInstanceOf<StubObjectBarConstructor>(obj.Stubs[1]);
        }
Ejemplo n.º 25
0
        public void After_AutoBind_With_BindType_Singleton_IHasOneImplementor_Resolves_As_Singleton()
        {
            ComponentContainer container = new ComponentContainer();
            container.AutoBind(Assembly.GetExecutingAssembly(), new AutoBindStrategy()
            {
                BindType = ComponentBindType.Singleton
            });

            var obj1 = container.Resolve<IHasOneImplementor>();
            var obj2 = container.Resolve<IHasOneImplementor>();

            Assert.AreSame(obj1, obj2);
        }
Ejemplo n.º 26
0
        public void Child_Container_Proxies_To_Parent_Container_When_Child_Container_Has_No_Binding()
        {
            ComponentContainer parent = new ComponentContainer();
            parent.Bind<IBaz>().To<Baz1>().AsSingleton();

            ComponentContainer child = new ComponentContainer(parent);
            child.Bind<IBar>().To<Bar3>().AsSingleton();

            Foo1 foo = child.Resolve<Foo1>();

            Assert.IsInstanceOf(typeof(Foo1), foo);
            Assert.IsInstanceOf(typeof(Bar3), foo.Bar);
            Assert.IsInstanceOf(typeof(Baz1), ((Bar3)foo.Bar).Baz);
        }
Ejemplo n.º 27
0
        public void Bind_ToFactoryMethod_Calls_FactoryMethod_When_Resolving()
        {
            bool factoryMethodCalled = false;

            ComponentContainer container = new ComponentContainer();
            container.Bind<IBar>().ToFactoryMethod((x) =>
            {
                factoryMethodCalled = true;
                return new Bar1();
            });

            IBar bar = container.Resolve<IBar>();
            Assert.IsTrue(factoryMethodCalled);
        }
Ejemplo n.º 28
0
        public void After_Call_To_Resolve_Where_New_Instance_Is_Constructed_Properties_Are_Injected()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<IFoo>().To<Foo1>();
            container.Bind<IBar>().To<Bar1>();
            container.For<PropertyInject>().Bind<IBar>().To<Bar2>();

            var instance = container.Resolve<PropertyInject>();

            Assert.NotNull(instance.Foo);
            Assert.IsInstanceOf<Foo1>(instance.Foo);

            Assert.NotNull(instance.Bar);
            Assert.IsInstanceOf<Bar2>(instance.Bar);
        }
        public void With_Default_Bindings()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<IFoo>().To<Foo1>();
            container.Bind<IBar>().To<Bar2>();

            var instance = new PropertyInject();
            container.ResolveProperties(instance);

            Assert.NotNull(instance.Foo);
            Assert.IsInstanceOf<Foo1>(instance.Foo);

            Assert.NotNull(instance.Bar);
            Assert.IsInstanceOf<Bar2>(instance.Bar);
        }
Ejemplo n.º 30
0
        public void Circular_Dependency_Can_Be_Resolved_Using_Property_Injection_And_Singletons()
        {
            ComponentContainer container = new ComponentContainer();
            container.Bind<CircularDependencyProperty1>().ToSelf().AsSingleton().WithPropertyResolution();
            container.Bind<CircularDependencyProperty2>().ToSelf().AsSingleton().WithPropertyResolution();

            var dependency1 = container.Resolve<CircularDependencyProperty1>();
            var dependency2 = container.Resolve<CircularDependencyProperty2>();

            Assert.NotNull(dependency1.Dependency);
            Assert.IsInstanceOf<CircularDependencyProperty2>(dependency1.Dependency);

            Assert.NotNull(dependency2.Dependency);
            Assert.IsInstanceOf<CircularDependencyProperty1>(dependency2.Dependency);
        }
Ejemplo n.º 31
0
 public void Initialize(ComponentContainer components)
 {
     druidLevels = components.GetAll <ClassLevel>().First(x => x.Class.Name.EqualsIgnoreCase("druid"));
 }
Ejemplo n.º 32
0
 public void Initialize(ComponentContainer components)
 {
     monkLevel = components.Get <ClassLevel>();
 }
Ejemplo n.º 33
0
 public EquippedArmorClassModifier(ComponentContainer components)
 {
     this.inventory = components.Get <Inventory>();
 }
Ejemplo n.º 34
0
 public bool IsQualified(ComponentContainer components)
 {
     return(components.FindStat <IValueStatistic>(StatNames.BaseAttackBonus).TotalValue >= AttackBonus);
 }
Ejemplo n.º 35
0
 public void Initialize(ComponentContainer components)
 {
     sorcererLevels = components.Get <ClassLevel>();
     charisma       = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
 }
 public void DiplayBEntity(Guid synchronizationProfileId, string entityId)
 {
     ComponentContainer.EnsureSynchronizationContext();
     _parent.DiplayBEntityAsync(synchronizationProfileId, entityId);
 }
Ejemplo n.º 37
0
 public void Initialize(ComponentContainer components)
 {
     source      = components.Get <ClassLevel>();
     baseAbility = components.Get <AbilityScores>().GetAbility(baseAbilityType);
 }
Ejemplo n.º 38
0
 public string TryGetComponentAccessToken()
 {
     return(ComponentContainer.TryGetComponentAccessToken("wx99dc6b0ea873ba0c", "d4f8f1222a94562ac6df4349861086b6"));
 }
Ejemplo n.º 39
0
 public void SetUp()
 {
     Container = new ComponentContainer();
 }
Ejemplo n.º 40
0
 public void Execute(ComponentContainer components)
 {
     components.Get <CharacterStrategy>().AddLanguagesKnown(this.languages);
 }
Ejemplo n.º 41
0
 public override void Initialize(ComponentContainer components)
 {
     base.Initialize(components);
     this.DragonType = GatewayProvider.All <DragonType>().ChooseOne();
 }
Ejemplo n.º 42
0
 public static IEnumerable <T> GetAllQualified <T>(this IEnumerable <IHasPrerequisites> list, ComponentContainer components)
 {
     return(list.Where(x => x.IsQualified(components)).Cast <T>());
 }
Ejemplo n.º 43
0
 public void Initialize(ComponentContainer components)
 {
     elementalType = components.Get <ElementalType>();
 }
Ejemplo n.º 44
0
 public void Initialize(ComponentContainer components)
 {
     charisma = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Charisma);
 }
Ejemplo n.º 45
0
 public void Initialize(ComponentContainer componentContainer)
 {
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Initializes the component by creating a data manager and loading data contexts from config
 /// </summary>
 protected override void ConfigureContentAccessors()
 {
     ComponentContainer.RegisterType <IContentAccessor <SyndicationItem>, EmbeddedContentAccessor>(typeof(EmbeddedContentAccessor).Name);
     ComponentContainer.RegisterType <IContentAccessor <SyndicationItem>, RemoteContentAccessor>(typeof(RemoteContentAccessor).Name);
 }
Ejemplo n.º 47
0
 public void Initialize(ComponentContainer bag)
 {
     Called = true;
 }
Ejemplo n.º 48
0
 public void Initialize(ComponentContainer components)
 {
     sizeStats = components.Get <SizeStats>();
 }
Ejemplo n.º 49
0
        public void Initialize(ComponentContainer components)
        {
            var tongue = new Language("Tongue of Sun and Moon", "Can speak to any living thing");

            components.Add(tongue);
        }
Ejemplo n.º 50
0
 public void Initialize(ComponentContainer components)
 {
     clericLevel     = components.Get <ClassLevel>();
     wisdom          = components.Get <AbilityScores>().GetAbility(AbilityScoreTypes.Wisdom);
     this.DamageType = "electricity";
 }
Ejemplo n.º 51
0
 public void Initialize(ComponentContainer components)
 {
     _characterSkill = components.Get <SkillRanks>().GetSkill(Skill);
 }
Ejemplo n.º 52
0
        /// <summary>
        /// 注册微信第三方平台
        /// </summary>
        private void RegisterWeixinThirdParty()
        {
            Func <string, string> getComponentVerifyTicketFunc = componentAppId =>
            {
                var dir = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data\\OpenTicket");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                var file = Path.Combine(dir, string.Format("{0}.txt", componentAppId));
                using (var fs = new FileStream(file, FileMode.Open))
                {
                    using (var sr = new StreamReader(fs))
                    {
                        var ticket = sr.ReadToEnd();
                        return(ticket);
                    }
                }
            };

            Func <string, string, string> getAuthorizerRefreshTokenFunc = (componentAppId, auhtorizerId) =>
            {
                var dir = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data\\AuthorizerInfo\\" + componentAppId);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                var file = Path.Combine(dir, string.Format("{0}.bin", auhtorizerId));
                if (!File.Exists(file))
                {
                    return(null);
                }

                using (Stream fs = new FileStream(file, FileMode.Open))
                {
                    BinaryFormatter binFormat = new BinaryFormatter();
                    var             result    = (RefreshAuthorizerTokenResult)binFormat.Deserialize(fs);
                    return(result.authorizer_refresh_token);
                }
            };

            Action <string, string, RefreshAuthorizerTokenResult> authorizerTokenRefreshedFunc = (componentAppId, auhtorizerId, refreshResult) =>
            {
                var dir = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data\\AuthorizerInfo\\" + componentAppId);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                var file = Path.Combine(dir, string.Format("{0}.bin", auhtorizerId));
                using (Stream fs = new FileStream(file, FileMode.Create))
                {
                    //这里存了整个对象,实际上只存RefreshToken也可以,有了RefreshToken就能刷新到最新的AccessToken
                    BinaryFormatter binFormat = new BinaryFormatter();
                    binFormat.Serialize(fs, refreshResult);
                    fs.Flush();
                }
            };

            //执行注册
            ComponentContainer.Register(
                ConfigurationManager.AppSettings["Component_Appid"],
                ConfigurationManager.AppSettings["Component_Secret"],
                getComponentVerifyTicketFunc,
                getAuthorizerRefreshTokenFunc,
                authorizerTokenRefreshedFunc,
                "【盛派网络】开放平台");
        }
Ejemplo n.º 53
0
 /// <summary>
 /// Initializes the component by creating a data manager and loading data contexts from config
 /// </summary>
 protected override void ConfigureFilter()
 {
     ComponentContainer.RegisterType <IPollingFilter <SyndicationItem>, RSSPollingFilter>();
 }
Ejemplo n.º 54
0
 public void Initialize(ComponentContainer components)
 {
     _components = components;
 }
Ejemplo n.º 55
0
 public void Initialize(ComponentContainer components)
 {
     this.sourceClass = components.Get <ClassLevel>();
 }
Ejemplo n.º 56
0
 public void Initialize(ComponentContainer components)
 {
     this.components = components;
     sorcererLevel   = components.Get <ClassLevel>();
 }
Ejemplo n.º 57
0
 public void Initialize(ComponentContainer components)
 {
     this.Weapon = GatewayProvider.Get <Weapon>().ChooseOne();
     components.Get <OffenseStats>().AddWeaponModifier(this.WeaponCriticalDamageBonus);
 }
Ejemplo n.º 58
0
 public void Initialize(ComponentContainer components)
 {
     components.Get <DefenseStats>().AddImmunity("poison");
 }
Ejemplo n.º 59
0
 public void Initialize(ComponentContainer components)
 {
     components.Add(this.abilityModifier);
 }
Ejemplo n.º 60
0
 public Resistor(ComponentContainer owner, string name, string value) : base(owner)
 {
     Initialize(name, value);
 }