public Type GetHypermediaType(IDistinctOrderedCollection <string> classes)
        {
            Type hypermediaObjectType;

            if (!this.hypermediaObjectTypeDictionary.TryGetValue(classes, out hypermediaObjectType))
            {
                throw new Exception($"No HCO Type registered for classes: {string.Join(", ", classes)}");
            }
            return(hypermediaObjectType);
        }
Example #2
0
        public bool Equals(IDistinctOrderedCollection <string> left, IDistinctOrderedCollection <string> right)
        {
            if (ReferenceEquals(left, right))
            {
                return(true);
            }

            if (left == null || right == null)
            {
                return(false);
            }

            return(left.SequenceEqual(right));
        }
Example #3
0
        public int GetHashCode(IDistinctOrderedCollection <string> collection)
        {
            const int prime      = 17;
            int       multiplier = 1;
            int       result     = 0;

            foreach (var element in collection)
            {
                result     += element.GetHashCode() * multiplier;
                multiplier *= prime;
            }

            return(result);
        }
Example #4
0
        private bool EntityRelationsMatch(IToken entity, IDistinctOrderedCollection <string> expectedRelations)
        {
            if (expectedRelations == null || expectedRelations.Count == 0)
            {
                return(true);
            }

            var actualRelations = entity["rel"];

            if (actualRelations == null)
            {
                return(false);
            }

            return(this.distinctOrderedStringCollectionComparer.Equals(new DistinctOrderedStringCollection(actualRelations.ChildrenAsStrings()), expectedRelations));
        }
Example #5
0
        private bool EntityClassMatch(IToken entity, IDistinctOrderedCollection <string> expectedClasses, string propertyName)
        {
            if (expectedClasses == null || expectedClasses.Count == 0)
            {
                throw new Exception($"No class provided for entity property '{propertyName}'.");
            }

            var actualClasses = entity["class"];

            if (actualClasses == null)
            {
                return(false);
            }

            return(this.distinctOrderedStringCollectionComparer.Equals(new DistinctOrderedStringCollection(actualClasses.ChildrenAsStrings()), expectedClasses));
        }
        public HypermediaClientObject CreateFromClasses(IDistinctOrderedCollection <string> classes)
        {
            var hypermediaObjectType = this.GetHypermediaType(classes);

            return((HypermediaClientObject)Activator.CreateInstance(hypermediaObjectType));
        }