Exemplo n.º 1
0
 //Function to retrieve constructor from ConstructorMap
 public FunctionDefinition retrieveConstructor(ContractDefinition contract)
 {
     if (ConstructorMapping.ContainsKey(contract))
     {
         return(ConstructorMapping[contract]);
     }
     return(null);
 }
Exemplo n.º 2
0
        public JsonObjectDescription(ConstructorInfo constructor, JsonConstructorAttribute attribute, JsonMemberInfo[] members, JsonExtensionMemberInfo extensionMemberInfo)
        {
            Members             = members;
            ExtensionMemberInfo = extensionMemberInfo;
            Constructor         = constructor;
            Attribute           = attribute;
            if (Constructor != null)
            {
                ConstructorMapping = BuildMapping();
                // we need to sort all the members which are not assigned in the ctor after the ctor assigment, otherwise the object is not ctor'd.
                Array.Sort(Members, (x, y) =>
                {
                    if (ReferenceEquals(x, y))
                    {
                        return(0);
                    }

                    var xIsCtorMapping = ConstructorMapping.TryGetValue(x.MemberName, out var xElement);
                    var yIsCtorMapping = ConstructorMapping.TryGetValue(y.MemberName, out var yElement);
                    if (!xIsCtorMapping && !yIsCtorMapping) // both are not in, it doesn't matter
                    {
                        return(StringComparer.Ordinal.Compare(x.MemberName, y.MemberName));
                    }
                    if (xIsCtorMapping && !yIsCtorMapping) // x is in ctor and y not, move x up
                    {
                        return(-1);
                    }

                    if (!xIsCtorMapping && yIsCtorMapping) // x is not in ctor and y is, move x down
                    {
                        return(1);
                    }

                    return(xElement.Index.CompareTo(yElement.Index));
                });
            }
        }
Exemplo n.º 3
0
        //Function to check if constructor exists.
        public bool checkConstructorExists(ContractDefinition contract)
        {
            bool contains = ConstructorMapping.ContainsKey(contract);

            return(contains);
        }