Пример #1
0
        public InstanceRefTester()
        {
            instance = new NullInstance();
            familyMock = Substitute.For<IFamily>();

            instanceRef = new InstanceRef(instance, familyMock);
        }
Пример #2
0
        private void setContents(string[] contents, InstanceRef instance)
        {
            contents[1] = instance.Name;
            contents[2] = instance.Description;

            _instances.Add(instance);
        }
Пример #3
0
        public void SetUp()
        {
            instance = new NullInstance();
            family = MockRepository.GenerateMock<IFamily>();

            instanceRef = new InstanceRef(instance, family);
        }
Пример #4
0
        public InstanceRefTester()
        {
            instance = new NullInstance();
            familyMock = new Mock<IFamily>();

            instanceRef = new InstanceRef(instance, familyMock.Object);
        }
        private void setContents(string[] contents, InstanceRef instance)
        {
            contents[1] = instance.Name;
            contents[2] = instance.Description;

            _instances.Add(instance);
        }
Пример #6
0
        public void SetUp()
        {
            instance = new NullInstance();
            family   = MockRepository.GenerateMock <IFamily>();

            instanceRef = new InstanceRef(instance, family);
        }
        public InstanceRefTester()
        {
            instance   = new NullInstance();
            familyMock = Substitute.For <IFamily>();

            instanceRef = new InstanceRef(instance, familyMock);
        }
Пример #8
0
        private void setContents(string[] contents, InstanceRef instance, string name = null)
        {
            contents[2] = instance.Lifecycle.ToName();

            contents[3] = instance.Description;

            if (name.IsNotEmpty())
            {
                contents[4] = name;
            }
            else
            {
                Guid assignedName;
                if (instance.Instance.HasExplicitName() && !Guid.TryParse(instance.Name, out assignedName))
                {
                    contents[4] = instance.Name;
                }
            }



            if (contents[4].Length > 30)
            {
                contents[4] = contents[4].Substring(0, 27) + "...";
            }


            _instances.Add(instance.Instance);
        }
Пример #9
0
        public InstanceRefTester()
        {
            instance   = new NullInstance();
            familyMock = new Mock <IFamily>();

            instanceRef = new InstanceRef(instance, familyMock.Object);
        }
 public static void DestroyInstance(InstanceRef instance)
 {
     IL.DeclareLocals(false);
     Guard.NotNull(DestroyInstancePtr);
     IL.Push(instance);
     IL.Push(DestroyInstancePtr);
     IL.Emit.Calli(new StandAloneMethodSig(CallingConvention.Cdecl, typeof(void), typeof(InstanceRef)));
 }
Пример #11
0
    public static void DelegateOnCloseEvent(int InstanceID, int CloseCode)
    {
        WebSocket InstanceRef;

        if (Instances.TryGetValue(InstanceID, out InstanceRef))
        {
            InstanceRef.DelegateOnCloseEvent(CloseCode);
        }
    }
Пример #12
0
    public static void DelegateOnOpenEvent(int InstanceID)
    {
        WebSocket InstanceRef;

        if (Instances.TryGetValue(InstanceID, out InstanceRef))
        {
            InstanceRef.DelegateOnOpenEvent();
        }
    }
 public static unsafe void InstanceSetPosition(InstanceRef instance, DrawInfo *new_position, float *data)
 {
     IL.DeclareLocals(false);
     Guard.NotNull(InstanceSetPositionPtr);
     IL.Push(instance);
     IL.Push(new_position);
     IL.Push(data);
     IL.Push(InstanceSetPositionPtr);
     IL.Emit.Calli(new StandAloneMethodSig(CallingConvention.Cdecl, typeof(void), typeof(InstanceRef), typeof(DrawInfo *), typeof(float *)));
 }
Пример #14
0
    public static void DelegateOnErrorEvent(int InstanceID, System.IntPtr ErrorPtr)
    {
        WebSocket InstanceRef;

        if (Instances.TryGetValue(InstanceID, out InstanceRef))
        {
            string ErrorMsg = Marshal.PtrToStringAuto(ErrorPtr);
            InstanceRef.DelegateOnErrorEvent(ErrorMsg);
        }
    }
Пример #15
0
        private void setContents(string[] contents, InstanceRef instance, List <InstanceRef> instanceRegistry)
        {
            contents[2] = instance.Lifetime.ToString();

            contents[3] = instance.ToString().Elid(75);

            contents[4] = instance.Name.Elid(25);

            instanceRegistry.Add(instance);
        }
Пример #16
0
    public static void DelegateOnMessageEvent(int InstanceID, System.IntPtr MsgPtr, int MsgSize)
    {
        WebSocket InstanceRef;

        if (Instances.TryGetValue(InstanceID, out InstanceRef))
        {
            byte[] Msg = new byte[MsgSize];
            Marshal.Copy(MsgPtr, Msg, 0, MsgSize);
            InstanceRef.DelegateOnMessageEvent(Msg);
        }
    }
Пример #17
0
        private void setContents(string[] contents, InstanceRef instance, string name, bool isDefault)
        {
            contents[2] = instance.Lifetime.ToString();

            contents[3] = instance.ToString().Elid(75);


            contents[4] = instance.Name.Elid(25);


            _instances.Add(instance);
        }
Пример #18
0
        public static IEnumerable <string> Namespaces(this InstanceRef instance, Assembly assembly)
        {
            if (instance.PluginType.Assembly == assembly)
            {
                yield return(instance.PluginType.Namespace);
            }

            if (instance.ReturnedType.Assembly == assembly)
            {
                yield return(instance.ReturnedType.Namespace);
            }
        }
Пример #19
0
 private void readInstance(InstanceRef instance)
 {
     try
     {
         var fixture = instance.Get <IFixture>();
         ReadFixture(instance.Name, fixture);
     }
     catch (Exception e)
     {
         LogFixtureFailure(instance.Name, e);
     }
 }
        private void writeInstance(InstanceRef instance)
        {
            if (_instances.Contains(instance))
            {
                return;
            }

            var contents = new[] {string.Empty, string.Empty, string.Empty};
            setContents(contents, instance);

            _writer.AddText(contents);
        }
        public void eject_and_remove_an_instance_by_filter_should_remove_it_from_the_model()
        {
            InstanceRef iRef = container.Model.For <Rule>().Instances.First();

            container.Model.For <Rule>().EjectAndRemove(x => x.Name == iRef.Name);

            container.Model.For <Rule>().Instances.Select(x => x.ConcreteType)
            .ShouldHaveTheSameElementsAs(typeof(ARule), typeof(ColorRule));

            container.GetAllInstances <Rule>().Select(x => x.GetType())
            .ShouldHaveTheSameElementsAs(typeof(ARule), typeof(ColorRule));
        }
Пример #22
0
        private void writeInstance(InstanceRef instance, IServiceFamilyConfiguration serviceType, string name = null)
        {
            if (_instances.Contains(instance) || instance == null)
            {
                return;
            }

            var contents = new[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };

            setContents(contents, instance, name, instance == serviceType.Default);

            _writer.AddText(contents);
        }
Пример #23
0
        private void writeInstance(InstanceRef instance)
        {
            if (_instances.Contains(instance))
            {
                return;
            }

            var contents = new[] { string.Empty, string.Empty, string.Empty };

            setContents(contents, instance);

            _writer.AddText(contents);
        }
        public void eject_and_remove_the_default_value()
        {
            var instance = new ConfiguredInstance(typeof(Service <>));

            family.SetDefault(instance);
            family.AddInstance(new ConfiguredInstance(typeof(Service2 <>)));

            InstanceRef iRef = configuration.Instances.FirstOrDefault(x => x.Name == instance.Name);

            configuration.EjectAndRemove(iRef);

            family.GetDefaultInstance().ShouldBeNull();
        }
 private void tryCreateBuildPlan(Type pluginType, InstanceRef instanceRef, Policies policies,
                                 ProfileReport report)
 {
     try
     {
         instanceRef.Instance.ResolveBuildPlan(pluginType, policies);
     }
     catch (StructureMapException e)
     {
         _buildPlanFailureIds.Add(instanceRef.Instance.Id);
         e.Instances.Fill(instanceRef.Instance.Id);
         report.AddError(pluginType, instanceRef.Instance, e);
     }
 }
Пример #26
0
        private void writeInstance(InstanceRef instance, IServiceFamilyConfiguration serviceType,
                                   TextReportWriter reportWriter,
                                   List <InstanceRef> instanceRegistry)
        {
            if (instanceRegistry.Contains(instance) || instance == null)
            {
                return;
            }

            var contents = new[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };

            setContents(contents, instance, instanceRegistry);

            reportWriter.AddText(contents);
        }
        public void eject_and_remove_an_instance()
        {
            var instance = new ConfiguredInstance(typeof(Service <>));

            family.AddInstance(instance);
            family.AddInstance(new ConfiguredInstance(typeof(Service2 <>)));

            InstanceRef iRef = configuration.Instances.FirstOrDefault(x => x.Name == instance.Name);

            configuration.EjectAndRemove(iRef);

            family.InstanceCount.ShouldEqual(1);
            configuration.Instances.Count().ShouldEqual(1);

            configuration.Instances.Any(x => x.Name == instance.Name).ShouldBeFalse();
        }
Пример #28
0
        public InstanceDTO(InstanceRef model)
        {
            name = model.Name;
            lifecycle = model.Lifecycle.GetType().Name.Replace("Lifecycle", "");
            returnedType = model.ReturnedType.GetFullName();
            description = model.Description;
            hasBeenCreated = model.ObjectHasBeenCreated();
            pluginType = model.PluginType.GetFullName();

            Guid ignored;
            if (Guid.TryParse(name, out ignored))
            {
                name = "(guid)";
            }

            key = "{0}/{1}".ToFormat(model.PluginType.GetFullName(), model.Name);
        }
        private List <object[]> GetRegistrationPluginType(InstanceRef registration, IContainer pxContainer)
        {
            List <object[]> propertyValue = new List <object[]> {
                new object[] { "Property", "Value" }
            };

            propertyValue.Add(new object[] { "PluginType",
                                             String.Format("{0} ({1}) \r\n\r Scoped: {2}",
                                                           registration.PluginType.Name,
                                                           registration.PluginType.FullName,
                                                           FormatLifecycle(pxContainer.Model.For(registration.PluginType))),
                                             (registration.ConcreteType != null ? "info" : "warn") });
            propertyValue.Add(new object[] { "Namespace", registration.PluginType.Namespace });
            propertyValue.Add(new object[] { "Assembly", registration.PluginType.AssemblyQualifiedName });

            return(propertyValue);
        }
Пример #30
0
        public InstanceDTO(InstanceRef model)
        {
            name           = model.Name;
            lifecycle      = model.Lifecycle.GetType().Name.Replace("Lifecycle", "");
            returnedType   = model.ReturnedType.GetFullName();
            description    = model.Description;
            hasBeenCreated = model.ObjectHasBeenCreated();
            pluginType     = model.PluginType.GetFullName();

            Guid ignored;

            if (Guid.TryParse(name, out ignored))
            {
                name = "(guid)";
            }

            key = "{0}/{1}".ToFormat(model.PluginType.GetFullName(), model.Name);
        }
        private List <object[]> GetRegistrationConcrete(InstanceRef registration)
        {
            List <object[]> propertyValue = new List <object[]> {
                new object[] { "Property", "Value" }
            };

            propertyValue.Add(registration.ConcreteType != null
                                  ? new object[]
            {
                "Concrete",
                String.Format("{0} ({1})", registration.ConcreteType.Name,
                              registration.ConcreteType.FullName),
                "info"
            }
                                  : new object[] { "Concrete", string.Empty, "warn" });

            propertyValue.Add(new object[] { "Description", registration.Description });
            propertyValue.Add(new object[] { "Namespace", (registration.ConcreteType != null ? registration.ConcreteType.Namespace : string.Empty) });
            propertyValue.Add(new object[] { "Assembly", (registration.ConcreteType != null ? registration.ConcreteType.AssemblyQualifiedName : string.Empty) });

            return(propertyValue);
        }
 public void EjectAndRemove(InstanceRef instance)
 {
     Eject(instance.Instance);
     instance.Instance.SafeDispose();
     _family.RemoveInstance(instance.Instance);
 }
 public void EjectAndRemove(InstanceRef instance)
 {
     _pipelineGraph.Ejector.RemoveCompletely(_family.PluginType, instance.Instance);
 }
Пример #34
0
 private void readInstance(InstanceRef instance)
 {
     try
     {
         var fixture = instance.Get<IFixture>();
         ReadFixture(instance.Name, fixture);
     }
     catch (Exception e)
     {
         LogFixtureFailure(instance.Name, e);
     }
 }
Пример #35
0
 private void tryCreateBuildPlan(Type pluginType, InstanceRef instanceRef, Policies policies,
     ProfileReport report)
 {
     try
     {
         instanceRef.Instance.ResolveBuildPlan(pluginType, policies);
     }
     catch (StructureMapException e)
     {
         _buildPlanFailureIds.Add(instanceRef.Instance.Id);
         e.Instances.Fill(instanceRef.Instance.Id);
         report.AddError(pluginType, instanceRef.Instance, e);
     }
 }
Пример #36
0
 public void AddInstanceRef(InstanceRef iRef)
 {
     instanceList = null;
     list.Add(iRef);
 }
Пример #37
0
 public static bool MatchesNamespace(this InstanceRef instance, string ns)
 {
     return(instance.ReturnedType.Namespace == ns || instance.PluginType.Namespace == ns);
 }
Пример #38
0
 private static InstanceDetail buildInstanceDetail(InstanceRef instance)
 {
     return(new InstanceDetail(instance.Name, instance.Description, instance.ConcreteType));
 }
Пример #39
0
 public static bool MatchesAssembly(this InstanceRef instance, Assembly assembly)
 {
     return(instance.ReturnedType.Assembly == assembly || instance.PluginType.Assembly == assembly);
 }
 public void EjectAndRemove(InstanceRef instance)
 {
     instance.EjectObject();
     _graph.Remove(_pluginType, instance.Instance);
 }
Пример #41
0
        private void Configure(ConfigurationExpression x)
        {
            if (_useCustomInstances)
            {
                // Config
                x.For <ApplicationSettings>().Singleton().Use(_applicationSettings);

                // Repository
                x.For <IRepository>().HybridHttpOrThreadLocalScoped().Use(_repository);

                // Context
                x.For <IUserContext>().HybridHttpOrThreadLocalScoped().Use(_context);
            }
            else
            {
                //
                // Default repository, or get it from the DataStoreType
                //
                x.For <IRepository>().HybridHttpOrThreadLocalScoped().Use <LightSpeedRepository>();

                if (_applicationSettings.DataStoreType.RequiresCustomRepository)
                {
                    IRepository customRepository = RepositoryManager.LoadRepositoryFromType(_applicationSettings.DataStoreType.CustomRepositoryType);
                    x.For <IRepository>().HybridHttpOrThreadLocalScoped().Use(customRepository);
                }
            }

            //
            // UserService : Windows authentication, custom or the default
            //
            string userServiceTypeName = _applicationSettings.UserServiceType;

            if (_applicationSettings.UseWindowsAuthentication)
            {
                x.For <UserServiceBase>().HybridHttpOrThreadLocalScoped().Use <ActiveDirectoryUserService>();
            }
            else if (!string.IsNullOrEmpty(userServiceTypeName))
            {
                InstanceRef userServiceRef = ObjectFactory.Model.InstancesOf <UserServiceBase>().FirstOrDefault(t => t.ConcreteType.FullName == userServiceTypeName);
                if (userServiceRef == null)
                {
                    var    instances    = ObjectFactory.Model.InstancesOf <UserServiceBase>();
                    string debugMessage = string.Join(Environment.NewLine, instances.Select(t => t.ConcreteType.FullName).ToArray());
                    throw new ConfigurationException(null, "Unable to find custom user service type '{0}' - I only have these types: \n\n{1}", userServiceTypeName, debugMessage);
                }

                x.For <UserServiceBase>().HybridHttpOrThreadLocalScoped().TheDefault.Is.OfConcreteType(userServiceRef.ConcreteType);
            }
            else
            {
                x.For <UserServiceBase>().HybridHttpOrThreadLocalScoped().Use <FormsAuthUserService>();
            }

            // Setter inject the various MVC objects that can't have constructors
            x.SetAllProperties(y => y.OfType <ISetterInjected>());
            x.SetAllProperties(y => y.OfType <IAuthorizationAttribute>());
            x.SetAllProperties(y => y.TypeMatches(t => t == typeof(RoadkillViewPage <>)));
            x.SetAllProperties(y => y.TypeMatches(t => t == typeof(RoadkillLayoutPage)));

            // Setter inject the *internal* properties for the text plugins
            x.For <TextPlugin>().OnCreationForAll((ctx, plugin) => plugin.PluginCache = ctx.GetInstance <IPluginCache>());
            x.For <TextPlugin>().OnCreationForAll((ctx, plugin) => plugin.Repository  = ctx.GetInstance <IRepository>());
        }
 private static InstanceDetail buildInstanceDetail(InstanceRef instance)
 {
     return new InstanceDetail(instance.Name, instance.Description, instance.ConcreteType);
 }
        private List<object[]> GetRegistrationPluginType(InstanceRef registration, IContainer pxContainer)
        {
            List<object[]> propertyValue = new List<object[]> {new object[] {"Property", "Value"}};

            propertyValue.Add(new object[]{ "PluginType",
                                  String.Format("{0} ({1}) \r\n\r Scoped: {2}",
                                              registration.PluginType.Name,
                                              registration.PluginType.FullName,
                                              FormatLifecycle(pxContainer.Model.For(registration.PluginType))),
                                  (registration.ConcreteType != null ? "info" : "warn")});
            propertyValue.Add(new object[] {"Namespace", registration.PluginType.Namespace });
            propertyValue.Add(new object[] {"Assembly", registration.PluginType.AssemblyQualifiedName});

            return propertyValue;
        }
 public void EjectAndRemove(InstanceRef instance)
 {
     if (instance == null) return;
     _family.RemoveInstance(instance.Instance);
 }
Пример #45
0
 public void EjectAndRemove(InstanceRef instance)
 {
 }
Пример #46
0
        private void setContents(string[] contents, InstanceRef instance, string name = null)
        {
            contents[2] = instance.Lifecycle.ToName();

            contents[3] = instance.Description;

            if (name.IsNotEmpty())
            {
                contents[4] = name;
            }
            else
            {
                Guid assignedName;
                if (instance.Instance.HasExplicitName() && !Guid.TryParse(instance.Name, out assignedName))
                {
                    contents[4] = instance.Name;
                }
            }



            if (contents[4].Length > 30)
            {
                contents[4] = contents[4].Substring(0, 27) + "...";
            }


            _instances.Add(instance.Instance);
        }
        private List<object[]> GetRegistrationConcrete(InstanceRef registration)
        {
            List<object[]> propertyValue = new List<object[]> { new object[] { "Property", "Value"}};

            propertyValue.Add(registration.ConcreteType != null
                                  ? new object[]
                                      {
                                          "Concrete",
                                          String.Format("{0} ({1})", registration.ConcreteType.Name,
                                                        registration.ConcreteType.FullName),
                                          "info"
                                      }
                                  : new object[] {"Concrete", string.Empty, "warn"});

            propertyValue.Add(new object[] {"Description",registration.Description});
            propertyValue.Add(new object[] {"Namespace", (registration.ConcreteType != null ? registration.ConcreteType.Namespace : string.Empty)});
            propertyValue.Add(new object[] {"Assembly",(registration.ConcreteType != null ? registration.ConcreteType.AssemblyQualifiedName : string.Empty)});

            return propertyValue;
        }