//public virtual IProp CreateGenFromString(Type typeOfThisProperty, // string value, bool useDefault, // PropNameType propertyName, object extraInfo, // PropStorageStrategyEnum storageStrategy, bool isTypeSolid, PropKindEnum propKind, // Delegate comparer, bool useRefEquality = false, Type itemType = null) //{ // MemConsumptionTracker mct = new MemConsumptionTracker(enabled: false); // if (propKind == PropKindEnum.Prop) // { // CreateScalarProp propCreator = GetPropCreator(typeOfThisProperty); // mct.MeasureAndReport("GetPropCreator", $"for {propertyName}"); // // TODO: This is where strings are parsed to create objects of type T. // // TODO: This needs more work, to say the least. // IProp prop = propCreator(this, haveValue: true, value: value, useDefault: useDefault, propertyName: propertyName, // extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, // comparer: comparer, useRefEquality: useRefEquality, getDefaultValFunc: null); // mct.MeasureAndReport("Ran propCreator to get IProp", $"for {propertyName}"); // return prop; // } // else if (propKind.IsCollection()) // { // CreateCPropFromStringDelegate propCreator = GetCPropFromStringCreator(typeOfThisProperty, itemType); // mct.MeasureAndReport("GetCPropFromStringCreator", $"for {propertyName}"); // IProp prop = propCreator(this, value: value, useDefault: useDefault, propertyName: propertyName, // extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, // comparer: comparer, useRefEquality: useRefEquality); // mct.MeasureAndReport("Ran GetCPropFromStringCreator to get IProp", $"for {propertyName}"); // return prop; // } // else // { // throw new InvalidOperationException($"PropKind = {propKind} is not recognized or is not supported."); // } //} public virtual IProp CreateGenWithNoValue(Type typeOfThisProperty, PropNameType propertyName, object extraInfo, PropStorageStrategyEnum storageStrategy, bool isTypeSolid, PropKindEnum propKind, Delegate comparer, bool useRefEquality = false, Type itemType = null) { MemConsumptionTracker mct = new MemConsumptionTracker(enabled: false); if (propKind == PropKindEnum.Prop) { CreateScalarProp propCreator = GetPropCreator(typeOfThisProperty); mct.MeasureAndReport("GetPropCreator", $"for {propertyName}"); IProp prop = propCreator(this, haveValue: false, value: null, useDefault: false, propertyName: propertyName, extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, comparer: comparer, useRefEquality: useRefEquality, getDefaultValFunc: null); mct.MeasureAndReport("Ran propCreator to get IProp", $"for {propertyName}"); return(prop); } else if (propKind.IsCollection()) { CreateCPropWithNoValueDelegate propCreator = GetCPropWithNoValueCreator(typeOfThisProperty, itemType); IProp prop = propCreator(this, propertyName: propertyName, extraInfo: extraInfo, storageStrategy: storageStrategy, isTypeSolid: isTypeSolid, comparer: comparer, useRefEquality: useRefEquality); return(prop); } else { throw new InvalidOperationException($"PropKind = {propKind} is not recognized or is not supported."); } }
// With No Value protected virtual CreateCPropWithNoValueDelegate GetCPropWithNoValueCreator(Type collectionType, Type itemType) { CreateCPropWithNoValueDelegate result = DelegateCacheProvider.CreateCPropWithNoValCache.GetOrAdd(new TypePair(collectionType, itemType)); return(result); }