Results 1 to 4 of 4

Thread: PropertyReflector.MakeGet() throws System.Reflection.AmbiguousMatchException

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    2

    Default PropertyReflector.MakeGet() throws System.Reflection.AmbiguousMatchException

    I have derived class, that override some Property, defined in base class
    And AmbiguousMatchException throws, how it defined here
    In code Exception System.Reflection.AmbiguousMatchException throwed here
    private Func<TInstance, TProperty> MakeGet()
    {
            ...
            PropertyInfo propertyInfo = nestedType.GetProperty(property);
    
    to solve problem, I use strong definition of seekeng Property with return type
    PropertyInfo propertyInfo = nestedType.GetProperty(property, typeof(TProperty));
    
    some problems in private Action<TInstance, TProperty> MakeSet()
    sorry for my english

  2. #2

    Default

    Could you post a brief test code, that reproduce the error.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    2

    Default test code, that reproduce the error

    I has client class, that I want to store..
    this ClientClass inheritaned from BaseClientClass and override char field with replacing (override) field type from char to enumeration
    For parsing Field from/to BaseClientClass to/from ClientClass, ClientClass has static metods

    sure, problems in design :^)

    public enum EEnum    {  E1, Undefined  }
    
    public class BaseClientClass
    {
         public char Field { get; set; }
    }
    
    public class ClientClass : BaseClientClass
    {
        public new EEnum Field { get; set; }
        public static char ToBaseValue(EEnum value)
        {
             switch(value)
            {
                 case EEnum.E1: return '1';
            }
            return '0';
        }
    
        public static EEnum FromObjectValue(char value)
        {
             switch (value)
             {
                  case '1': return EEnum.E1;
             }
             return EEnum.Undefined;
        }
    }
    
    Defining the Repository:
    public class ClientClassRepository
    {
        private readonly StorageEngine _storage;
        public XTable<string, ClientClass> ClientClassTable { get; private set; }
    
        public ClientClassRepository()
        {
             _storage = StorageEngine.FromFile("ClientClass.stsdb");
             ClientClassTable = _storage.Scheme.CreateOrOpenXTable<string, ClientClass>(
                  new Locator("CLIENT_CLASS"));
             ClientClassTable.RecordPersist = new PersistClientClass();
             _storage.Scheme.Commit();
         }
    
         public override string ToString()  { return "This is ClientClass Repository"; }
    }
    
    public class PersistClientClass : IBinaryPersist<IIndexer<ClientClass>>
    {
         public void Load(System.IO.BinaryReader reader, 
                                  ref IIndexer<ClientClass> data)
        {
             for (int i = 0; i < data.Count; i++)
             {
                  data[i] = new ClientClass { 
                         Field = ClientClass.FromObjectValue(reader.ReadChar()) };
             }
        }
    
        public void Store(System.IO.BinaryWriter writer, 
                                IIndexer<ClientClass> data)
        {
             for (int i = 0; i < data.Count; ++i)
             {
                  ClientClass obj = data[i];
                 writer.Write(ClientClass.ToBaseValue(obj.Field));
             }
        }
    }
    
    This is my dummy test method:
    public void CreatingClientClassReposytory()
    {
       var repo = new ClientClassRepository();
       Console.WriteLine(repo);
       Console.WriteLine(repo.ClientClassTable.Count);
    }
    

  4. #4

    Default

    Thank you for your report!

    The fix is included in R3.5.12 version.
    Last edited by k.dimova; 13.06.2013 at 17:13.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
2002 - 2014 STS Soft SC. All Rights reserved.
STSdb, Waterfall Tree and WTree are registered trademarks of STS Soft SC.