Пример #1
0
        /// <summary>
        /// Looks at all loaded assemblies and adds EntityDescription for each entity found
        /// </summary>
        private void AddEntityDescriptions()
        {
            var entityDescription = new EntityDescription();

            foreach (KeyValuePair <Assembly, bool> pair in _loadedAssemblies)
            {
                // Performance optimization: standard Microsoft assemblies are excluded from this search
                if (pair.Value)
                {
                    // Utility autorecovers and logs for common exceptions
                    var types = AssemblyUtilities.GetExportedTypes(pair.Key, _logger);

                    foreach (var type in types)
                    {
                        try
                        {
                            entityDescription.TryAddEntityType(type);
                        }
                        catch (Exception e)
                        {
                            LogWarning(e.ToString());
                        }
                    }
                }
            }

            entityDescription.Initialize();

            if (entityDescription.EntityTypes.Any())
            {
                _entityDescriptions.Add(entityDescription);
            }
        }
Пример #2
0
        public override void OnShown()
        {
            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);

            camera.AddProperty <Camera>("camera");
            camera.AddProperty <Viewport>("viewport");
            camera.AddBehaviour <View>();
            var cameraEntity = camera.Create();

            cameraEntity.GetProperty <Camera>("camera").Value     = new Camera();
            cameraEntity.GetProperty <Viewport>("viewport").Value = new Viewport()
            {
                Width = 1280, Height = 720
            };
            scene.Add(camera.Create());

            var renderer = scene.GetService <Renderer>();

            renderer.StartPlan()
            .Then(new ClearPhase()
            {
                Colour = Color.Black
            })
            .Then(new Phase(device)
            {
                Font = content.Load <SpriteFont>("Consolas")
            })
            .Apply();

            base.OnShown();
        }
Пример #3
0
 public Entity(string identity)
 {
     Identity    = new Harmonize.With.Component.Identity(string.Format("Bebbs.Harmonize.Tool.Service.{0}", identity));
     Description = new EntityDescription();
     Observables = Enumerable.Empty <IObservable>();
     Actionables = Enumerable.Empty <IActionable>();
 }
Пример #4
0
        private void OnEntityRemove(IMyEntity e)
        {
            if (!((MySession)MyAPIGateway.Session).Ready)
            {
                return;
            }
            MyEntity entity = e as MyEntity;

            EntityDescription description = new EntityDescription()
            {
                EntityId   = entity.EntityId,
                Name       = entity.DisplayNameText,
                ObjectType = entity.GetType().Name,
                TypeId     = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.TypeId.ToString() : string.Empty),
                SubtypeId  = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.SubtypeId.ToString() : string.Empty),
                Removed    = Tools.DateTime
            };

            SQLQueryData.WriteToDatabase(description);
            if (conf.LogGrids)
            {
                if (entity is MyCubeGrid)
                {
                    gridManager.RemoveGrid(entity as MyCubeGrid);
                }

                if (conf.LogInventory && RegisteredInventories.ContainsKey(entity.EntityId))
                {
                    RegisteredInventories[entity.EntityId].Close();
                    RegisteredInventories.Remove(entity.EntityId);
                }
            }
        }
Пример #5
0
        public override void ProcessGeneratedCode(EntityDescription domainServiceDescription, CodeCompileUnit codeCompileUnit, IDictionary <Type, CodeTypeDeclaration> typeMapping)
        {
            // Get a reference to the entity class
            CodeTypeDeclaration codeGenEntity = typeMapping[typeof(TestEntity)];

            AppDomain      appDomain = AppDomain.CurrentDomain;
            AppDomainSetup setup     = appDomain.SetupInformation;

            string baseDir = appDomain.BaseDirectory;

            codeGenEntity.Comments.Add(new CodeCommentStatement("[CodeProcessor] BaseDirectory:" + baseDir));

            Configuration cfg = WebConfigurationManager.OpenWebConfiguration(null);

            AuthenticationSection            authSection = (AuthenticationSection)cfg.GetSection("system.web/authentication");
            FormsAuthenticationConfiguration formsAuth   = authSection.Forms;

            if (formsAuth != null)
            {
                codeGenEntity.Comments.Add(new CodeCommentStatement("[CodeProcessor] Authentication:forms"));
            }

            ConnectionStringsSection connSect = cfg.ConnectionStrings;

            if (connSect != null)
            {
                ConnectionStringSettingsCollection connColl = connSect.ConnectionStrings;
                foreach (ConnectionStringSettings connSetting in connColl)
                {
                    codeGenEntity.Comments.Add(new CodeCommentStatement("[CodeProcessor] ConnectionString:" + connSetting.ConnectionString));
                }
            }
        }
Пример #6
0
        protected override void BeginTransitionOn()
        {
            spriteBatch = new SpriteBatch(device);
            font = content.Load<SpriteFont>("Consolas");

            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);
            camera.AddProperty(new TypedName<Camera>("camera"));
            camera.AddProperty(new TypedName<Viewport>("viewport"));
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = new Camera();
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Height = 1920, Width = 1080 };
            scene.Add(camera.Create());

            var renderer = scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then<A>()
                .Then<B>()
                .Then<C>()
                .Then<D>()
                .Apply();

            base.OnShown();
        }
Пример #7
0
        public void GetNext_WhenBranchingHierarcy_ReturnsExpectedOrder()
        {
            //Prepare
            var category = new EntityDescription <Category>()
                           .SetTargetCount(1);
            var post = new EntityDescription <Post>()
                       .SetTargetCount(3)
                       .SetRequired(typeof(Category));
            var comment = new EntityDescription <Comment>()
                          .SetTargetCount(2)
                          .SetRequired(typeof(Post));
            var attachment = new EntityDescription <Attachment>()
                             .SetTargetCount(2)
                             .SetRequired(typeof(Post));
            var descriptions = new List <IEntityDescription>
            {
                category,
                post,
                comment,
                attachment
            };
            CompleteSupervisor target = SetupCompleteOrderProvider(descriptions);

            //Invoke
            List <ICommand> actualCommands = GetNextList(target);

            //Assert
            Assert.IsNotNull(actualCommands);
            AssertPlanCount(descriptions, actualCommands);
        }
Пример #8
0
        private void FillSuppresedProperties(EntityDescription entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            XmlNode entityNode;

            entityNode = _ormXmlDocument.DocumentElement.SelectSingleNode(string.Format("{0}:Entities/{0}:Entity[@id='{1}']", OrmObjectsDef.NS_PREFIX, entity.Identifier), _nsMgr);

            XmlNodeList propertiesList;

            propertiesList = entityNode.SelectNodes(string.Format("{0}:SuppressedProperties/{0}:Property", OrmObjectsDef.NS_PREFIX), _nsMgr);

            foreach (XmlNode propertyNode in propertiesList)
            {
                string     name;
                XmlElement propertyElement = (XmlElement)propertyNode;
                name = propertyElement.GetAttribute("name");

                PropertyDescription property = new PropertyDescription(name);

                entity.SuppressedProperties.Add(property);
            }
        }
Пример #9
0
        internal protected void FillEntityTables(EntityDescription entity)
        {
            XmlNodeList tableNodes;
            XmlNode     entityNode;

            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            entity.Tables.Clear();

            entityNode = _ormXmlDocument.DocumentElement.SelectSingleNode(string.Format("{0}:Entities/{0}:Entity[@id='{1}']", OrmObjectsDef.NS_PREFIX, entity.Identifier), _nsMgr);

            tableNodes = entityNode.SelectNodes(string.Format("{0}:Tables/{0}:Table", OrmObjectsDef.NS_PREFIX), _nsMgr);

            foreach (XmlNode tableNode in tableNodes)
            {
                string     tableId;
                XmlElement tableElement = (XmlElement)tableNode;
                tableId = tableElement.GetAttribute("ref");

                TableDescription table = entity.OrmObjectsDef.GetTable(tableId);

                entity.Tables.Add(table);
            }
        }
Пример #10
0
        public override void OnShown()
        {
            spriteBatch = new SpriteBatch(device);
            font        = content.Load <SpriteFont>("Consolas");

            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);

            camera.AddProperty <Camera>("camera");
            camera.AddProperty <Viewport>("viewport");
            camera.AddBehaviour <View>();
            var cameraEntity = camera.Create();

            cameraEntity.GetProperty <Camera>("camera").Value     = new Camera();
            cameraEntity.GetProperty <Viewport>("viewport").Value = new Viewport()
            {
                Height = 1920, Width = 1080
            };
            scene.Add(camera.Create());

            var renderer = scene.GetService <Renderer>();

            renderer.StartPlan()
            .Then <A>()
            .Then <B>()
            .Then <C>()
            .Then <D>()
            .Apply();

            base.OnShown();
        }
Пример #11
0
        internal protected void FillEntities()
        {
            foreach (EntityDescription entity in _ormObjectsDef.Entities)
            {
                XmlNode entityNode =
                    _ormXmlDocument.DocumentElement.SelectSingleNode(
                        string.Format("{0}:Entities/{0}:Entity[@id='{1}']", OrmCodeGenLib.OrmObjectsDef.NS_PREFIX,
                                      entity.Identifier), _nsMgr);

                XmlElement entityElement = (XmlElement)entityNode;
                string     baseEntityId  = entityElement.GetAttribute("baseEntity");

                if (!string.IsNullOrEmpty(baseEntityId))
                {
                    EntityDescription baseEntity = OrmObjectsDef.GetEntity(baseEntityId);
                    if (baseEntity == null)
                    {
                        throw new OrmXmlParserException(
                                  string.Format("Base entity '{0}' for entity '{1}' not found.", baseEntityId,
                                                entity.Identifier));
                    }
                    entity.BaseEntity = baseEntity;
                }
                FillProperties(entity);
                FillSuppresedProperties(entity);
            }
        }
Пример #12
0
        private void OnEntityAdd(IMyEntity e)
        {
            MyEntity entity = e as MyEntity;

            EntityDescription description = new EntityDescription()
            {
                EntityId   = entity.EntityId,
                Name       = entity.DisplayNameText,
                ObjectType = entity.GetType().Name,
                TypeId     = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.TypeId.ToString() : string.Empty),
                SubtypeId  = ((entity.DefinitionId.HasValue) ? entity.DefinitionId.Value.SubtypeId.ToString() : string.Empty),
                Created    = Tools.DateTime
            };

            SQLQueryData.WriteToDatabase(description);

            if (conf.LogGrids)
            {
                if (entity is MyCubeGrid)
                {
                    gridManager.AddGrid(entity as MyCubeGrid);
                }

                if (conf.LogInventory && !RegisteredInventories.ContainsKey(entity.EntityId))
                {
                    RegisteredInventories.Add(entity.EntityId, new InventoryComponent(entity));
                }
            }
        }
        public override bool Notify(Entity activeStats, ActionContext actionContext)
        {
            EntityDescription desc = activeStats.Description;

            if (desc.IsPlayer && !m_AffectPlayer)
            {
                return(false);
            }
            if (!desc.IsPlayer && !m_AffectEnemies)
            {
                return(false);
            }
            if (desc.IsMinion && !m_AffectMinions)
            {
                return(false);
            }
            if (!desc.IsMinion && !m_AffectNonMinions)
            {
                return(false);
            }
            if (m_EntityType != EntityType.All && desc.EntityType != m_EntityType)
            {
                return(false);
            }

            return(true);
        }
Пример #14
0
        //Register entitities
        public virtual EntityDescription <TEntity> RegisterEntity <TEntity>()
            where TEntity : class
        {
            var entityDescription = new EntityDescription <TEntity>();

            EntityDescriptions.Add(entityDescription.Type, entityDescription);
            return(entityDescription);
        }
Пример #15
0
        /// <summary>
        /// Generates complex object code.
        /// </summary>
        /// <param name="complexObjectType">Type of the complex object for which the proxy is to be generates.</param>
        /// <param name="domainServiceDescription">The DomainServiceDescription for the domain service associated with this complex type.</param>
        /// <param name="clientCodeGenerator">ClientCodeGenerator object for this instance.</param>
        /// <returns>The generated complex object code.</returns>
        public string Generate(Type complexObjectType, EntityDescription domainServiceDescription, ClientCodeGenerator clientCodeGenerator)
        {
            this.Type = complexObjectType;
            this.ClientCodeGenerator      = clientCodeGenerator;
            this.DomainServiceDescription = domainServiceDescription;

            return(this.GenerateDataContractProxy());
        }
        private void VerifyDataObjectInfo(Type dataType, EntityDescription doi)
        {
            doi.Should().NotBeNull();
            doi.EntityType.Should().Be(dataType);
            doi.SourceName.Should().NotBeNullOrWhiteSpace();

            VerifyDataObjectInfoFields(doi);
        }
Пример #17
0
 public QueryBuilderBase(IDbConnection connection, Compiler compiler, Action <Query> source)
 {
     Connection        = connection ?? throw new ArgumentNullException(nameof(connection));
     Compiler          = compiler ?? throw new ArgumentNullException(nameof(compiler));
     EntityDescription = default;
     Query             = new Query();
     source.Invoke(Query);
 }
Пример #18
0
        public override void ProcessGeneratedCode(EntityDescription entityDescription, CodeCompileUnit codeCompileUnit, IDictionary <Type, CodeTypeDeclaration> typeMapping)
        {
            // Get a reference to the entity class
            CodeTypeDeclaration codeGenEntity = typeMapping[typeof(MockEntity1)];

            // Inject an artificial base class "IInjectedInterface"
            codeGenEntity.BaseTypes.Add(new CodeTypeReference("IInjectedInterface2"));
        }
 public TraitToLearnDescription(TraitToLearn trait)
 {
     ExpCost = trait.ExpCost;
     StatRequirements = trait.StatRequirements;
     SkillRequirements = trait.SkillRequirements;
     TraitRequirements = trait.TraitRequirements;
     Trait = trait.Trait;
 }
Пример #20
0
        public void ChangeDescription(EntityDescription description)
        {
            if (description == null)
            {
                throw new InvariantGuardFailureException();
            }

            ApplyChange(new EntityDescriptionChangedEvent(GetIdentity(), description));
        }
Пример #21
0
        void ValidateCRUD(CruiseDatastore ds, Type type)
        {
            var entDesc        = new EntityDescription(type);
            var commandBuilder = new CommandBuilder();
            var selectBuilder  = commandBuilder.BuildSelect(entDesc.Source, entDesc.Fields);

            var selectCommand = selectBuilder.ToString();
            var selectResult  = ds.QueryGeneric(selectCommand);
        }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate     = Type = new CodeTypeDeclaration();
     Generator     = new EntityDescriptionGenerator(Configuration);
     documentType  = new DocumentType {
         Info = { Alias = "anEntity" }
     };
     EntityDescription = documentType.Info;
 }
Пример #23
0
        /// <summary>
        /// Gets the name of the schema definition class for entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static string GetEntitySchemaDefClassName(EntityDescription entity)
        {
            OrmCodeDomGeneratorSettings settings = SettingsManager.CurrentManager.OrmCodeDomGeneratorSettings;

            return
                // name of the entity class name
                (GetEntityClassName(entity) +
                 // entity
                 settings.EntitySchemaDefClassNameSuffix);
        }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().DocumentTypes;
     Candidate     = Type = new CodeTypeDeclaration();
     Generator     = new InterfaceNameGenerator(Configuration);
     documentType  = new DocumentType {
         Info = { Alias = "aMixin" }
     };
     EntityDescription = documentType.Info;
 }
Пример #25
0
        public static string GetEntitySchemaDefFileName(EntityDescription entity)
        {
            OrmCodeDomGeneratorSettings settings = SettingsManager.CurrentManager.OrmCodeDomGeneratorSettings;
            string baseName =
                settings.FileNamePrefix +
                GetEntitySchemaDefClassName(entity) +
                settings.FileNameSuffix;

            return(baseName);
        }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().MediaTypes;
     attribute     = new CodeAttributeDeclaration();
     Generator     = new EntityDescriptionGenerator(Configuration);
     documentType  = new DocumentType {
         Info = { Alias = "anEntity" }
     };
     EntityDescription = documentType.Info;
 }
Пример #27
0
        protected void AppendColumns(Dictionary <Column, Column> columns, EntityDescription ed,
                                     string schema, string table, string constraint)
        {
            using (DbConnection conn = GetDBConn(_server, _m, _db, _i, _user, _psw))
            {
                using (DbCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"select c.table_schema,@rtbl table_name,c.column_name,is_nullable,data_type,tc.constraint_type,cc.constraint_name from INFORMATION_SCHEMA.columns c
						left join INFORMATION_SCHEMA.constraint_column_usage cc on c.table_name = cc.table_name and c.table_schema = cc.table_schema and c.column_name = cc.column_name and cc.constraint_name != @cns
						left join INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc on c.table_name = cc.table_name and c.table_schema = cc.table_schema and cc.constraint_name = tc.constraint_name
						where c.table_name = @tbl and c.table_schema = @schema
						and (tc.constraint_type != 'PRIMARY KEY' or tc.constraint_type is null)"                        ;
                    DbParameter tbl = cmd.CreateParameter();
                    tbl.ParameterName = "tbl";
                    tbl.Value         = table;
                    cmd.Parameters.Add(tbl);

                    DbParameter s = cmd.CreateParameter();
                    s.ParameterName = "schema";
                    s.Value         = schema;
                    cmd.Parameters.Add(s);

                    DbParameter rt = cmd.CreateParameter();
                    rt.ParameterName = "rtbl";
                    rt.Value         = ed.Tables[0].Name.Split('.')[1].Trim(new char[] { '[', ']' });
                    cmd.Parameters.Add(rt);

                    DbParameter cns = cmd.CreateParameter();
                    cns.ParameterName = "cns";
                    cns.Value         = constraint;
                    cmd.Parameters.Add(cns);

                    conn.Open();

                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Column c = Column.Create(reader);
                            if (!columns.ContainsKey(c))
                            {
                                columns.Add(c, c);
                                bool cr;
                                PropertyDescription pd = AppendColumn(columns, c, ed, out cr);
                                if (String.IsNullOrEmpty(pd.Description))
                                {
                                    pd.Description = "Autogenerated from table " + schema + "." + table;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #28
0
        /// <summary>
        /// Gets the qualified class name of the entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static string GetQualifiedEntityName(EntityDescription entity)
        {
            OrmCodeDomGeneratorSettings settings = SettingsManager.CurrentManager.OrmCodeDomGeneratorSettings;
            string result = string.Empty;

            if (!string.IsNullOrEmpty(entity.Namespace))
            {
                result += entity.Namespace;
            }
            result += ((string.IsNullOrEmpty(result) ? string.Empty : ".") + GetEntityClassName(entity));
            return(result);
        }
Пример #29
0
        protected TypeDescription GetRelatedType(Column col, IDictionary <Column, Column> columns, OrmObjectsDef odef)
        {
            using (DbConnection conn = GetDBConn(_server, _m, _db, _i, _user, _psw))
            {
                using (DbCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = @"select tc.table_schema,tc.table_name,cc.column_name from INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
						join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc on tc.constraint_name = rc.unique_constraint_name
						join INFORMATION_SCHEMA.constraint_column_usage cc on tc.table_name = cc.table_name and tc.table_schema = cc.table_schema and tc.constraint_name = cc.constraint_name
						where rc.constraint_name = @cn"                        ;
                    DbParameter cn = cmd.CreateParameter();
                    cn.ParameterName = "cn";
                    cn.Value         = col.ConstraintName;
                    cmd.Parameters.Add(cn);

                    conn.Open();

                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Column c = new Column(reader.GetString(reader.GetOrdinal("table_schema")),
                                                  reader.GetString(reader.GetOrdinal("table_name")),
                                                  reader.GetString(reader.GetOrdinal("column_name")), false, null, null, null, false);
                            if (columns.ContainsKey(c))
                            {
                                string          id = "t" + Capitalize(c.Table);
                                TypeDescription t  = odef.GetType(id, false);
                                if (t == null)
                                {
                                    bool cr;
                                    EntityDescription e = GetEntity(odef, c.Schema, c.Table, out cr);
                                    t = new TypeDescription(id, e);
                                    odef.Types.Add(t);
                                    if (cr)
                                    {
                                        Console.WriteLine("\tCreate class {0} ({1})", e.Name, e.Identifier);
                                        //_ents.Add(e.Identifier, null);
                                    }
                                }
                                return(t);
                            }
                            else
                            {
                                return(GetClrType(col.DbType, col.IsNullable, odef));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Пример #30
0
        /// <summary>
        /// Gets class name of the entity using settings
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static string GetEntityClassName(EntityDescription entity)
        {
            OrmCodeDomGeneratorSettings settings = SettingsManager.CurrentManager.OrmCodeDomGeneratorSettings;

            return
                // prefix from settings for class name
                (settings.ClassNamePrefix +
                 // entity's class name
                 entity.Name +
                 // suffix from settings for class name
                 settings.ClassNameSuffix);
        }
        private void VerifyNonvisableField(EntityDescription doi, string fieldName, bool isPrivate)
        {
            Assert.DoesNotContain(doi.Fields, x => x.Name == fieldName);

            //if (isPrivate)
            //{
            //    Assert.DoesNotContain(doi.Properties, x => x.Key == fieldName);
            //}
            //else
            //{
            //    Assert.Contains(doi.Properties, x => x.Key == fieldName);
            //}
        }
Пример #32
0
        public static string GetEntityFileName(EntityDescription entity)
        {
            OrmCodeDomGeneratorSettings settings = SettingsManager.CurrentManager.OrmCodeDomGeneratorSettings;
            string baseName =
                // prefix for file name
                settings.FileNamePrefix +
                // class name of the entity
                GetEntityClassName(entity) +
                // suffix for file name
                settings.FileNameSuffix;

            return(baseName);
        }
        public void LoadDataObjects()
        {
            var types = (from t in System.Reflection.Assembly.GetAssembly(typeof(FMSCORM.DataObject)).GetTypes()
                         where t.IsClass && t.Namespace == "CruiseDAL.DataObjects"
                         select t).ToList();

            foreach (Type t in types)
            {
                _output.WriteLine(t.FullName);
                var doi = new EntityDescription(t);

                VerifyDataObjectInfo(t, doi);
            }
        }
        void VerifyDataObjectInfo(Type dataType, EntityDescription doi)
        {
            Assert.NotNull(doi);
            Assert.Equal(dataType, doi.EntityType);
            Assert.False(String.IsNullOrWhiteSpace(doi.SourceName));

            Assert.NotNull(doi.Fields.PrimaryKeyField);
            Assert.NotNull(doi.Fields.PrimaryKeyField.Getter);
            Assert.NotNull(doi.Fields.PrimaryKeyField.Setter);

            Assert.NotEmpty(doi.Fields);
            Assert.True(doi.Fields.All(x => x.Getter != null));
            Assert.True(doi.Fields.All(x => x.Setter != null));
            Assert.True(doi.Fields.All(x => x.RunTimeType != null));
        }
 public void Test_DOMultiPropType()
 {
     var t = typeof(DOMultiPropType);
     var doi = new EntityDescription(t);
     VerifyDataObjectInfo(t, doi);
 }
Пример #36
0
 protected bool Equals(EntityDescription other)
 {
     return string.Equals(Name, other.Name) && string.Equals(Alias, other.Alias) && string.Equals(Description, other.Description);
 }
Пример #37
0
        /// <summary>
        /// This method is used to receive message from a queue or a subscription.
        /// </summary>
        /// <param name="entityDescription">The description of the entity from which to read messages.</param>
        /// <param name="messageCount">The number of messages to read.</param>
        /// <param name="complete">This parameter indicates whether to complete the receive operation.</param>
        /// <param name="deadletterQueue">This parameter indicates whether to read messages from the deadletter queue.</param>
        /// <param name="receiveTimeout">Receive receiveTimeout.</param>
        /// <param name="sessionTimeout">Session timeout</param>
        /// <param name="cancellationTokenSource">Cancellation token source.</param>
        public void ReceiveMessages(EntityDescription entityDescription, int? messageCount, bool complete, bool deadletterQueue, TimeSpan receiveTimeout, TimeSpan sessionTimeout, CancellationTokenSource cancellationTokenSource)
        {
            var receiverList = new List<MessageReceiver>();
            if (brokeredMessageList != null &&
                brokeredMessageList.Count > 0)
            {
                brokeredMessageList.ForEach(b => b.Dispose());
            }
            brokeredMessageList = new List<BrokeredMessage>();
            MessageEncodingBindingElement element;
            if (scheme == DefaultScheme)
            {
                element = new BinaryMessageEncodingBindingElement
                {
                    ReaderQuotas = new XmlDictionaryReaderQuotas
                    {
                        MaxArrayLength = int.MaxValue,
                        MaxBytesPerRead = int.MaxValue,
                        MaxDepth = int.MaxValue,
                        MaxNameTableCharCount = int.MaxValue,
                        MaxStringContentLength = int.MaxValue
                    }
                };
            }
            else
            {
                element = new TextMessageEncodingBindingElement
                {
                    ReaderQuotas = new XmlDictionaryReaderQuotas
                    {
                        MaxArrayLength = int.MaxValue,
                        MaxBytesPerRead = int.MaxValue,
                        MaxDepth = int.MaxValue,
                        MaxNameTableCharCount = int.MaxValue,
                        MaxStringContentLength = int.MaxValue
                    }
                };
            }
            var encoderFactory = element.CreateMessageEncoderFactory();
            var encoder = encoderFactory.Encoder;

            MessageReceiver messageReceiver = null;
            if (entityDescription is QueueDescription)
            {
                var queueDescription = entityDescription as QueueDescription;
                if (deadletterQueue)
                {
                    messageReceiver = messagingFactory.CreateMessageReceiver(QueueClient.FormatDeadLetterPath(queueDescription.Path),
                                                                             ReceiveMode.PeekLock);
                }
                else
                {
                    if (queueDescription.RequiresSession)
                    {
                        var queueClient = messagingFactory.CreateQueueClient(queueDescription.Path,
                                                                             ReceiveMode.PeekLock);
                        messageReceiver = queueClient.AcceptMessageSession(sessionTimeout);
                    }
                    else
                    {
                        messageReceiver = messagingFactory.CreateMessageReceiver(queueDescription.Path,
                                                                                 ReceiveMode.PeekLock);
                    }
                }
            }
            else
            {
                if (entityDescription is SubscriptionDescription)
                {
                    var subscriptionDescription = entityDescription as SubscriptionDescription;
                    if (deadletterQueue)
                    {
                        messageReceiver = messagingFactory.CreateMessageReceiver(SubscriptionClient.FormatDeadLetterPath(subscriptionDescription.TopicPath,
                                                                                                                            subscriptionDescription.Name),
                                                                                    ReceiveMode.PeekLock);
                    }
                    else
                    {
                        if (subscriptionDescription.RequiresSession)
                        {
                            var subscriptionClient = messagingFactory.CreateSubscriptionClient(subscriptionDescription.TopicPath,
                                                                                                subscriptionDescription.Name,
                                                                                                ReceiveMode.PeekLock);
                            messageReceiver = subscriptionClient.AcceptMessageSession(sessionTimeout);
                        }
                        else
                        {
                            messageReceiver = messagingFactory.CreateMessageReceiver(SubscriptionClient.FormatSubscriptionPath(subscriptionDescription.TopicPath,
                                                                                                                                subscriptionDescription.Name),
                                                                                        ReceiveMode.PeekLock);
                        }
                    }
                }
            }
            if (messageReceiver != null)
            {
                messageReceiver.PrefetchCount = 0;
                receiverList.Add(messageReceiver);
                ReceiveNextMessage(messageCount, 0, messageReceiver, ReceiveCallback, encoder, complete, receiveTimeout, cancellationTokenSource.Token);
            }
        }
        // ReSharper restore FunctionNeverReturns

        void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            // Initialize property grid
            var propertyList = new List<string[]>();
            if (entityDescription is QueueDescription)
            {
                var queueDescription = entityDescription as QueueDescription;
                queueDescription = serviceBusHelper.GetQueue(queueDescription.Path);
                entityDescription = queueDescription;
                propertyList.AddRange(new[]
                    {
                        new[] {ActiveMessageCount, queueDescription.MessageCountDetails.ActiveMessageCount.ToString(CultureInfo.CurrentCulture)},
                        new[] {DeadletterCount, queueDescription.MessageCountDetails.DeadLetterMessageCount.ToString(CultureInfo.CurrentCulture)},
                        new[] {ScheduledMessageCount, queueDescription.MessageCountDetails.ScheduledMessageCount.ToString(CultureInfo.CurrentCulture)},
                        new[] {TransferMessageCount, queueDescription.MessageCountDetails.TransferMessageCount.ToString(CultureInfo.CurrentCulture)},
                        new[] {TransferDeadLetterMessageCount, queueDescription.MessageCountDetails.TransferDeadLetterMessageCount.ToString(CultureInfo.CurrentCulture)},
                        new[] {MessageCount, queueDescription.MessageCount.ToString(CultureInfo.CurrentCulture)}
                    });
            }
            if (entityDescription is SubscriptionDescription)
            {
                var subscriptionDescription = entityDescription as SubscriptionDescription;
                subscriptionDescription = serviceBusHelper.GetSubscription(subscriptionDescription.TopicPath, subscriptionDescription.Name);
                entityDescription = subscriptionDescription;
                propertyList.AddRange(new[]{new[]{ActiveMessageCount, subscriptionDescription.MessageCountDetails.ActiveMessageCount.ToString(CultureInfo.CurrentCulture)},
                                            new[]{ScheduledMessageCount, subscriptionDescription.MessageCountDetails.ScheduledMessageCount.ToString(CultureInfo.CurrentCulture)},
                                            new[]{TransferMessageCount, subscriptionDescription.MessageCountDetails.TransferMessageCount.ToString(CultureInfo.CurrentCulture)},
                                            new[]{TransferDeadLetterMessageCount, subscriptionDescription.MessageCountDetails.TransferDeadLetterMessageCount.ToString(CultureInfo.CurrentCulture)},
                                            new[]{MessageCount, subscriptionDescription.MessageCount.ToString(CultureInfo.CurrentCulture)}});
            }

            if (InvokeRequired)
            {
                Invoke(new Action(() =>
                {
                    lock (this)
                    {
                        if (stopping)
                        {
                            return;
                        }
                        propertyListView.Items.Clear();
                        foreach (var array in propertyList)
                        {
                            propertyListView.Items.Add(new ListViewItem(array));
                        }
                    }
                }));
            }
            else
            {
                lock (this)
                {
                    if (stopping)
                    {
                        return;
                    }
                    propertyListView.Items.Clear();
                    foreach (var array in propertyList)
                    {
                        propertyListView.Items.Add(new ListViewItem(array));
                    }
                }
            }
        }
Пример #39
0
 public Instance(PhysicalAddress macAddress, string name, string remarks)
 {
     Identity = new Identity(string.Format(IdentityPattern, macAddress));
     Description = new EntityDescription(name, remarks);
 }
Пример #40
0
        public override void OnShown()
        {
            scene = new Scene(kernel);

            var camera = new EntityDescription(kernel);
            camera.AddProperty<Camera>("camera");
            camera.AddProperty<Viewport>("viewport");
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty<Camera>("camera").Value = new Camera();
            cameraEntity.GetProperty<Viewport>("viewport").Value = new Viewport() { Width = 1280, Height = 720 };
            scene.Add(camera.Create());

            var renderer = scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then(new ClearPhase() { Colour = Color.Black })
                .Then(new Phase(device) { Font = content.Load<SpriteFont>("Consolas") })
                .Apply();

            base.OnShown();
        }
 public ListenerControl(WriteToLogDelegate writeToLog,
                        Func<Task> stopLog,
                        Action startLog,
                        ServiceBusHelper serviceBusHelper, 
                        EntityDescription entityDescription)
 {
     this.logStopped = false;
     Task.Factory.StartNew(AsyncTrackMessage).ContinueWith(t =>
     {
         if (t.IsFaulted && t.Exception != null)
         {
             writeToLog(t.Exception.Message);
         }
     });
     this.writeToLog = writeToLog;
     this.stopLog = stopLog;
     this.startLog = startLog;
     this.serviceBusHelper = serviceBusHelper;
     this.entityDescription = entityDescription;
     var element = new BinaryMessageEncodingBindingElement();
     var encoderFactory = element.CreateMessageEncoderFactory();
     encoder = encoderFactory.Encoder;
     InitializeComponent();
     InitializeControls();
     Disposed += ListenerControl_Disposed;
     if (entityDescription is SubscriptionDescription)
     {
         grouperEntityInformation.GroupTitle = "Subscription Information";
     }
 }
Пример #42
0
        protected override void BeginTransitionOn()
        {
            _scene = new Scene(_kernel);

            var camera = new EntityDescription(_kernel);
            camera.AddProperty(new TypedName<Camera>("camera"));
            camera.AddProperty(new TypedName<Viewport>("viewport"));
            camera.AddBehaviour<View>();
            var cameraEntity = camera.Create();
            cameraEntity.GetProperty(new TypedName<Camera>("camera")).Value = new Camera();
            cameraEntity.GetProperty(new TypedName<Viewport>("viewport")).Value = new Viewport() { Width = 1280, Height = 720 };
            _scene.Add(cameraEntity);

            var renderer = _scene.GetService<Renderer>();
            renderer.StartPlan()
                .Then(new Phase(_device) { Font = _content.Load<SpriteFont>("Consolas") })
                .Then(new ClearPhase() { Colour = Color.Black })
                .Apply();

            base.OnShown();
        }
 public void Test_VanillaMultiTypeObject()
 {
     Type t = typeof(POCOMultiTypeObject);
     var doi = new EntityDescription(t);
     VerifyDataObjectInfo(t, doi);
 }