public void ToStringDisplaysSystemAndIdentifier()
        {
            var value = new MdmId {
                SystemName = "CME", Identifier = "MFF"
            };

            Assert.AreEqual("CME/MFF", value.ToString());
        }
Example #2
0
        public WebResponse <TContract> Get(MdmId identifier, DateTime?validAt)
        {
            if (Logger.IsDebugEnabled)
            {
                Logger.DebugFormat("MdmEntityService.Get<{0}>: {1} {2}", typeof(TContract).Name, identifier, validAt);
            }
            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }

            if (identifier.IsMdmId || identifier.SystemName == SourceSystemNames.Nexus)
            {
                int id;
                if (int.TryParse(identifier.Identifier, out id))
                {
                    return(this.Get(id, validAt));
                }

                throw new ArgumentException("Invalid Nexus identifier: {0}.", identifier.ToString());
            }

            return(this.AcquireEntity(identifier, validAt));
        }
        public void ToStringDisplaysSystemAndIdentifier()
        {
            var value = new MdmId { SystemName = "CME", Identifier = "MFF" };

            Assert.AreEqual("CME/MFF", value.ToString());
        }
        /// <copydocfrom cref="IMdmEntityService{T}.Get(int, DateTime?)" />
        public WebResponse <TContract> Get(MdmId identifier, DateTime?validAt)
        {
            try
            {
                Logger.DebugFormat("Start: CachePolicyMdmEntityService.Get<{0}>: {1} asOf {2}", this.entityName, identifier, validAt);

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

                if (identifier.IsMdmId || identifier.SystemName.ToLower() == SourceSystemNames.Nexus.ToLower())
                {
                    int id;
                    if (int.TryParse(identifier.Identifier, out id))
                    {
                        return(this.Get(id, validAt));
                    }
                    else
                    {
                        throw new ArgumentException("Invalid Nexus identifier: {0}.", identifier.ToString());
                    }
                }

                Logger.DebugFormat("CachePolicyMdmEntityService.Get : Get<{0}> - {1} from cache", this.entityName, identifier);
                var entity = cache.Get <TContract>(identifier);
                if (entity != null)
                {
                    var response = new WebResponse <TContract> {
                        Code = HttpStatusCode.OK, Message = entity, IsValid = true
                    };
                    response.LogResponse();
                    return(response);
                }

                Logger.DebugFormat("CachePolicyMdmEntityService.Get : {0} not found in cache. Invoking AcquireEntity...", identifier);
                return(this.AcquireEntity(identifier, () => this.service.Get(identifier, validAt)));
            }
            finally
            {
                Logger.DebugFormat("Stop: CachePolicyMdmEntityService.Get<{0}>: {1} asOf {2}", this.entityName, identifier, validAt);
            }
        }