Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1332


Ignore:
Timestamp:
03/12/09 14:09:35 (16 years ago)
Author:
epitzer
Message:

Enable object instantiation using non-public default constructors. (#506)

Location:
branches/New Persistence Exploration/Persistence
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence.sln

    r1329 r1332  
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistence", "Persistence\Persistence.csproj", "{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}"
    55EndProject
    6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2F65B17D-22F7-4A48-8762-74BB8BE3E0E5}"
    7   ProjectSection(SolutionItems) = preProject
    8     LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
    9     Persistence.vsmdi = Persistence.vsmdi
    10   EndProjectSection
    11 EndProject
    126Global
    13   GlobalSection(TestCaseManagementSettings) = postSolution
    14     CategoryFile = Persistence.vsmdi
    15   EndGlobalSection
    167  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    178    Debug|Any CPU = Debug|Any CPU
  • branches/New Persistence Exploration/Persistence/Persistence/CompoundSerializers.cs

    r1323 r1332  
    2828    }
    2929    public object DeSerialize(IEnumerable objects, Type t) {
    30       object instance = Activator.CreateInstance(t);
     30      object instance = Activator.CreateInstance(t, true);
    3131      foreach (object o in objects) {
    3232        t.GetMethod("Add").Invoke(instance, new[] { o });
     
    7878
    7979  public class KeyValuePair2XmlSerializer : ICompoundSerializer {   
    80     public bool CanSerialize(Type type) {
     80    public bool CanSerialize(Type type) {     
    8181      return type.IsGenericType &&
    8282        type.GetGenericTypeDefinition().Name == "KeyValuePair`2";
     
    8787      yield return t.GetProperty("Value").GetValue(o, null);
    8888    }
    89     public object DeSerialize(IEnumerable o, Type t) {
     89    public object DeSerialize(IEnumerable o, Type t) {     
    9090      return Activator.CreateInstance(t,
    9191        new List<object>((IEnumerable<object>)o).ToArray());
     
    105105    }
    106106    public object DeSerialize(IEnumerable o, Type t) {
    107       IDictionary dict = (IDictionary)Activator.CreateInstance(t);
     107      IDictionary dict = (IDictionary)Activator.CreateInstance(t, true);
    108108      IEnumerator iter = o.GetEnumerator();
    109109      while (iter.MoveNext()) {
  • branches/New Persistence Exploration/Persistence/Persistence/DeSerializer.cs

    r1331 r1332  
    11using System.Collections.Generic;
    22using System;
    3 namespace Persistence {
     3namespace Persistence { 
     4
    45  public class DeSerializer {
    56
     
    102103        compositeStack.Push(new CustomObject(instance));
    103104        id2obj.Add(start.Id, instance);       
    104       } else {
    105         instance = Activator.CreateInstance(start.Type);
     105      } else {       
     106        instance = Activator.CreateInstance(start.Type, true);
    106107        Dictionary<string, DataMemberAccessor> accessorDict =
    107108        StorableAttribute.GetAutostorableAccessors(instance);
  • branches/New Persistence Exploration/Persistence/Persistence/StorableAttribute.cs

    r1331 r1332  
    200200      }
    201201      object method(object obj, Dictionary<object, object> twins) {
    202         object newInstance = Activator.CreateInstance(obj.GetType());
     202        object newInstance = Activator.CreateInstance(obj.GetType(), true);
    203203        twins.Add(obj, newInstance);
    204204        foreach (FieldAccessor fa in fieldAccessors) {
Note: See TracChangeset for help on using the changeset viewer.