protected override T DeserializeClass <T>(IConstructor ctor) { int instanceId = _reader.ReadInt(); while (instanceId >= _instances.Count) { _instances.Add(new InstanceInfo()); } InstanceInfo instanceInfo = _instances[instanceId]; if (instanceInfo.IsInitialized) { return((T)instanceInfo.Instance); } else { var value = ctor.Construct() as T; instanceInfo.IsInitialized = true; instanceInfo.Instance = value; _instances[instanceId] = instanceInfo; if (value != null) { DeserializeClass(value); } return(value); } }
protected virtual T DeserializeClass <T>(IConstructor ctor) where T : class, IDataStruct { var value = ctor.Construct() as T; if (value != null) { DeserializeClass(value); } return(value); }
private static IEnumerable <CheckerBase> CreateCheckers(int count, IConstructor <CheckerBase> constructor, string name) { var figures = new List <CheckerBase>(); for (var i = 0; i < count; i++) { figures.Add( constructor.Construct( new Vector2(0, 0), name + "-" + i ) ); } return(figures); }
/// <summary> /// Создание списка фигур /// </summary> /// <param name="count">количество фигур</param> /// <param name="constructor">конструкток фигур</param> /// <param name="container">контейнер фигур на сцене</param> /// <param name="name">часть имени</param> /// <returns></returns> private static IEnumerable <IFigure> CreateFigures(int count, IConstructor <IFigure> constructor, GameObject container, string name) { var figures = new List <IFigure>(); for (var i = 0; i < count; i++) { figures.Add( constructor.Construct( new Vector2(0, 0), container, name + "-" + i ) ); } return(figures); }
public Operation(IConstructor constructor) { IAnimal animal = constructor.Construct("myDog"); }
public Operation(IConstructor constructor) { I animal = constructor.Construct("myDog"); // <<<<<<<< Error here! }
public Operation(IConstructor <I> constructor) { I animal = constructor.Construct("myDog"); }