예제 #1
0
        public String Compare(TypeHash other)
        {
            StringBuilder sb = new StringBuilder();

            Compare(other, sb);
            return(sb.ToString());
        }
예제 #2
0
        private void CalcProcessNestedTypesHash(TypeDefinition type)
        {
            if (!type.HasNestedTypes)
            {
                return;
            }

            _nestedTypes = new TypeHash[type.NestedTypes.Count];
            for (Int32 index = 0; index < type.NestedTypes.Count; index++)
            {
                TypeDefinition nested = type.NestedTypes[index];
                _nestedTypes[index] = new TypeHash(nested);
            }
        }
예제 #3
0
        private void Deserialize(BinaryReader br)
        {
            _hash = br.ReadInt32();

            Int32 propertiesLength = br.ReadInt32();

            if (propertiesLength > -1)
            {
                _properties = new Int32[propertiesLength];
                for (Int32 i = 0; i < propertiesLength; i++)
                {
                    _properties[i] = br.ReadInt32();
                }
            }

            Int32 fieldsLength = br.ReadInt32();

            if (fieldsLength > -1)
            {
                _fields = new Int32[fieldsLength];
                for (Int32 i = 0; i < fieldsLength; i++)
                {
                    _fields[i] = br.ReadInt32();
                }
            }

            Int32 methodsLength = br.ReadInt32();

            if (methodsLength > -1)
            {
                _methods = new Int32[methodsLength];
                for (Int32 i = 0; i < methodsLength; i++)
                {
                    _methods[i] = br.ReadInt32();
                }
            }

            Int32 nestedLength = br.ReadInt32();

            if (nestedLength > -1)
            {
                _nestedTypes = new TypeHash[nestedLength];
                for (Int32 i = 0; i < nestedLength; i++)
                {
                    TypeHash nested = new TypeHash();
                    nested.Deserialize(br);
                    _nestedTypes[i] = nested;
                }
            }
        }
예제 #4
0
        public static TypeHash FromBase256(String base64String)
        {
            if (base64String == null)
            {
                return(null);
            }

            using (MemoryStream ms = new MemoryStream(Base256.Decode(base64String)))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    TypeHash hash = new TypeHash();
                    hash.Deserialize(br);
                    return(hash);
                }
        }
예제 #5
0
        private void Compare(TypeHash other, StringBuilder sb)
        {
            if (ReferenceEquals(other, null))
            {
                sb.AppendLine("Null type occured.");
                return;
            }

            if (_hash != other._hash)
            {
                sb.AppendLine("Base hash was changed.");
            }

            CompareArray("Properties", _properties, other._properties, sb);
            CompareArray("Fields", _fields, other._fields, sb);
            CompareArray("Methods", _methods, other._methods, sb);

            CompareNestedTypes(_nestedTypes, other._nestedTypes, sb);
        }
예제 #6
0
        private void InitializeExportedTypes()
        {
            foreach (TypeDefinition type in _exportedAssembly.MainModule.Types)
            {
                if (!type.HasCustomAttributes)
                {
                    continue;
                }

                CustomAttribute attribute = type.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "Memoria." + nameof(ExportedTypeAttribute));
                if (attribute == null)
                {
                    continue;
                }

                TypeHash hash = TypeHash.FromBase256((String)attribute.ConstructorArguments[0].Value);
                _exporters.Add(type.FullName, new TypeExporter(type, hash));
            }
        }
예제 #7
0
 public TypeExporter(TypeDefinition exportedType, TypeHash exportedHash)
 {
     ExportedType = exportedType;
     ExportedHash = exportedHash;
 }