Esempio n. 1
0
        public void TestUnresolvedSid()
        {
            // unresolved SIDs (such as SID 10 here) should result in an exception
            IIonValue ionContainer = loader.Load("(0xd3 0x8a 0x21 0x01)");

            byte[] ionBinary = IonHashTest.ContainerToBytes(ionContainer.GetElementAt(0));

            IIonHashReader ihr = IonHashReaderBuilder
                                 .Standard()
                                 .WithHasherProvider(new IdentityIonHasherProvider())
                                 .WithReader(IonReaderBuilder.Build(ionBinary))
                                 .Build();

            ihr.MoveNext();
            Assert.ThrowsException <UnknownSymbolException>(() => ihr.MoveNext());
        }
Esempio n. 2
0
        internal T FromIonToType <T>(IIonValue ionValue)
        {
            Object obj;

            if (ionValue.Type() == IonType.Datagram)
            {
                ionValue = ionValue.GetElementAt(0);
            }

            if (Type.GetTypeCode(typeof(T)) == TypeCode.Object)
            {
                obj = DeserializeObject(typeof(T), ionValue);
                return((T)obj);
            }
            else
            {
                obj = DeserializingMappers(typeof(T), ionValue);
                return((T)obj);
            }
        }
Esempio n. 3
0
        private static IIonValue FilterHashLog(IIonValue actualHashLog, IIonValue expectedHashLog)
        {
            HashSet <string>        methodCalls = new HashSet <string>();
            IEnumerator <IIonValue> enumerator  = expectedHashLog.GetEnumerator();

            while (enumerator.MoveNext())
            {
                IIonValue v = enumerator.Current;
                foreach (SymbolToken annotation in v.GetTypeAnnotationSymbols())
                {
                    methodCalls.Add(annotation.Text);
                }
            }

            IValueFactory valueFactory = new ValueFactory();
            IIonValue     result       = valueFactory.NewEmptySexp();

            if (methodCalls.Count == 1 && methodCalls.Contains("final_digest"))
            {
                IIonValue finalDigest = actualHashLog.GetElementAt(actualHashLog.Count - 1);
                finalDigest.ClearAnnotations();
                finalDigest.AddTypeAnnotation("final_digest");
                result.Add(finalDigest);
            }
            else
            {
                enumerator = actualHashLog.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IIonValue v          = enumerator.Current;
                    String    methodCall = v.GetTypeAnnotationSymbols().ElementAt(0).Text;
                    if (methodCalls.Contains(methodCall))
                    {
                        result.Add(v);
                    }
                }
            }

            return(result);
        }