private TDestination GetDestinationTemplate(Type targetType) { TDestination result = GetNewDestination(DestinationType, PropModel, _viewModelFactory, _propBagMapperService, PropFactory, fullClassName: null); if (TestCreateDest(targetType, result)) { // TODO: Consider removing the responsiblity of fixing the store's PropNodeCollection from the AbstractPropBagMapper class. if (!PropModel.IsFixed) { PropModel.Fix(); } if (!_viewModelFactory.PropStoreAccessServiceCreator.IsPropItemSetFixed(result)) { // Fix the template's PropNodeCollection to improve performance. PropItemSetKeyType propItemSetKey = new PropItemSetKeyType(PropModel); _viewModelFactory.PropStoreAccessServiceCreator.TryFixPropItemSet(result, propItemSetKey); } } else { // It turns out that we cannot use the template after all. result = null; } return(result); }
private void CheckPropItemSetId(PropItemSetKeyType propItemSetKey) { if (propItemSetKey.IsEmpty) { throw new ArgumentException("The PropItemSetKey cannot be empty when creating a Fixed PropNodeCollection."); } }
private bool RemoveFixedPropCollection(ObjectIdType objectId, PropNodeCollectionInternalInterface pnc) { if (pnc.Count == 0) { return(true); } PropItemSetKeyType propItemSetKey = pnc.PropItemSetKey; lock (_syncForByTypeStore) { if (!TryGetSharedPropCollection(propItemSetKey, out PropNodelCollectionSharedInterface sharedPropNodeCollection)) { throw new InvalidOperationException($"Could not retrieve the SharedPropCollection for {propItemSetKey.FullClassName} while removing {pnc}."); } if (sharedPropNodeCollection.TryRemove(objectId)) { if (sharedPropNodeCollection.Count == 0) { _storeByType.Remove(pnc.PropItemSetKey); } return(true); } else { System.Diagnostics.Debug.WriteLine($"Could not remove {pnc} from {sharedPropNodeCollection}."); return(false); } } }
public PropNodeCollectionFixed(IEnumerable <PropNode> propNodes, PropItemSetKeyType propItemSetKey, int maxPropsPerObject) { MaxPropsPerObject = maxPropsPerObject; CheckPropItemSetId(propItemSetKey); _propItemSetKey = propItemSetKey; _children = PopulateChildren(propNodes); PropItemsByName = _children.ToDictionary(k => k.PropertyName, v => v); _hashCode = ComputeHashCode(); }
public bool TryFixPropItemSet(IPropBag propBag, PropItemSetKeyType propItemSetKey) { if (TryGetPropBagNode(propBag, out BagNode propBagNode)) { bool result = TryFixPropItemSet(propBagNode, propItemSetKey); return(result); } else { throw new InvalidOperationException($"Could not retrieve a BagNode for the given propBag."); } }
public PropNodeCollectionShared(IEnumerable <PropNode> propNodes, PropItemSetKeyType propItemSetKey, int maxPropsPerObject) { MaxPropsPerObject = maxPropsPerObject; CheckPropItemSetId(propItemSetKey); _propItemSetKey = propItemSetKey; _children = new Dictionary <ExKeyT, PropNode>(); Add(propNodes); _nameToIdMap = BuildByNameDict(); CheckChildCount(_nameToIdMap.Count); }
public object GetValueFast(BagNode propBagNode, PropIdType propId, PropItemSetKeyType propItemSetKey) { if (propItemSetKey != propBagNode.PropItemSetKey) { throw new InvalidOperationException("Bad PropModel."); } if (!propBagNode.TryGetChild(propId, out PropNode child)) { throw new InvalidOperationException("Could not retrieve PropNode for that compKey."); } object result = child.PropData_Internal.TypedProp.TypedValueAsObject; return(result); }
public object GetValueFast(ExKeyT compKey, PropItemSetKeyType propItemSetKey) { if (!TryGetSharedPropCollection(propItemSetKey, out PropNodelCollectionSharedInterface sharedPropCollection)) { throw new InvalidOperationException($"Could not retrieve the SharedPropCollection for {propItemSetKey.FullClassName} ."); } if (!sharedPropCollection.TryGetPropNode(compKey, out PropNode propNode)) { throw new KeyNotFoundException($"The {sharedPropCollection} could not retrieve a PropNode for {compKey}."); } object result = propNode.PropData_Internal.TypedProp.TypedValueAsObject; return(result); }
public PropItemFixedPropertyDescriptor ( PropertyDescriptorValues <T> tdConfig, PSFastAccessServiceInterface psFastAccessService, PropModelType propModel, PropIdType propId ) : base(tdConfig.Name, tdConfig.Attributes) { _tdConfig = tdConfig; _psFastAccessService = psFastAccessService; _propItemSetKey = new PropItemSetKeyType(propModel); PropId = propId; _compKey = new SimpleExKey(10, propId); }
public bool SetValueFast(IPropBag component, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (component is IPropBagInternal ipbi) { if (ipbi is IHaveTheStoreNode ihtsn) { BagNode propBagNode = (ipbi as IHaveTheStoreNode)?.PropBagNode; bool result1 = _propStoreAccessServiceProvider.SetValueFast(propBagNode, propId, propItemSetKey, value); return(result1); } } //ExKeyT compKey = GetCompKey(component, propId); WeakRefKey <IPropBag> propBag_wrKey = new WeakRefKey <IPropBag>(component); bool result2 = _propStoreAccessServiceProvider.SetValueFast(propBag_wrKey, propId, propItemSetKey, value); return(result2); }
public bool TryFixPropItemSet(BagNode propBagNode, PropItemSetKeyType propItemSetKey) { PropNodeCollectionInternalInterface pnc_int = propBagNode.PropNodeCollection; if (pnc_int.IsFixed) { System.Diagnostics.Debug.WriteLine("Warning: PropStoreAccessServiceProvider is being asked to fix an already fixed PropItemSet."); return(true); } else { PropNodeCollectionFixed newFixedCollection = new PropNodeCollectionFixed(pnc_int, propItemSetKey); propBagNode.PropNodeCollection = newFixedCollection; AddFixedPropCollection(newFixedCollection); return(true); } }
private PropNodelCollectionSharedInterface AddFixedPropCollection(PropNodeCollectionInternalInterface pnc) { PropItemSetKeyType propItemSetKey = pnc.PropItemSetKey; lock (_syncForByTypeStore) { if (_storeByType.TryGetValue(propItemSetKey, out PropNodelCollectionSharedInterface sharedPropCollection)) { sharedPropCollection.Add(pnc); return(sharedPropCollection); } else { sharedPropCollection = new PropNodeCollectionShared(pnc); _storeByType.Add(propItemSetKey, sharedPropCollection); return(sharedPropCollection); } } }
public bool SetValueFast(BagNode propBagNode, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (propItemSetKey != propBagNode.PropItemSetKey) { throw new InvalidOperationException("Bad PropModel."); } if (!propBagNode.TryGetPropBag(out IPropBag component)) { throw new InvalidOperationException("IPropBag target has been Garbage Collected."); } if (!propBagNode.TryGetChild(propId, out PropNode child)) { throw new InvalidOperationException("Could not retrieve PropNode for that compKey."); } bool result = SetPropValue(component, child, propId, value); return(result); }
public object GetValueFast(IPropBag component, PropIdType propId, PropItemSetKeyType propItemSetKey) { if (component is IPropBagInternal ipbi) { //if(ipbi.ItsStoreAccessor is IHaveTheStoreNode ihtsn) //{ // BagNode propBagNode = ihtsn.PropBagNode; // object result1 = _propStoreAccessServiceProvider.GetValueFast(propBagNode, propId, propItemSetKey); // return result1; //} BagNode propBagNode = ((IHaveTheStoreNode)ipbi.ItsStoreAccessor).PropBagNode; object result1 = _propStoreAccessServiceProvider.GetValueFast(propBagNode, propId, propItemSetKey); return(result1); } //ExKeyT compKey = GetCompKey(component, propId); WeakRefKey <IPropBag> propBag_wrKey = new WeakRefKey <IPropBag>(component); object result2 = _propStoreAccessServiceProvider.GetValueFast(propBag_wrKey, propId, propItemSetKey); return(result2); }
public PropNodeCollection(IEnumerable <PropNode> propNodes, PropItemSetKeyType propItemSetKey, int maxPropsPerObject) { MaxPropsPerObject = maxPropsPerObject; _propItemSetKey = propItemSetKey; if (propNodes == null) { _children = new Dictionary <PropIdType, PropNode>(); m_PropIdCounter = 0; // The first PropId issued will be 1. (0 is reserved to indicate all Properties or that the ExplodedKey identifies an Object.) } else { _children = propNodes.ToDictionary(k => k.PropId, v => v); CheckChildCount(_children.Count); // TODO: See if we have the caller provide this value. m_PropIdCounter = propNodes.Max(pn => pn.CompKey.Level2Key); } _propItemsByName = null; }
public bool SetValueFast(ExKeyT compKey, PropItemSetKeyType propItemSetKey, object value) { if (!TryGetSharedPropCollection(propItemSetKey, out PropNodelCollectionSharedInterface sharedPropCollection)) { throw new InvalidOperationException($"Could not retrieve the SharedPropCollection for {propItemSetKey.FullClassName} ."); } if (!sharedPropCollection.TryGetPropNode(compKey, out PropNode propNode)) { throw new KeyNotFoundException($"The {sharedPropCollection} could not retrieve a PropNode for {compKey}."); } if (!propNode.Parent.TryGetPropBag(out IPropBag propBag)) { // The target has been garbage collected. return(false); } bool result = SetPropValue(propBag, propNode, compKey.Level2Key, value); return(result); }
private BagNode GetBagAndChild(WeakRefKey <IPropBag> propBag_wrKey, PropItemSetKeyType propItemSetKey, PropIdType propId, out PropNode child) { if (!TryGetPropBagNode(propBag_wrKey, out BagNode propBagNode)) { throw new InvalidOperationException("The store has lost this node."); } if (!propBag_wrKey.TryGetTarget(out IPropBag target)) { throw new InvalidOperationException("IPropBag target has been Garbage Collected."); } if (propItemSetKey != propBagNode.PropItemSetKey) { throw new InvalidOperationException("Bad PropModel."); } //if (!propItemSetId.Value.TryGetTarget(out PropModelType testModel)) //{ // throw new InvalidOperationException("The specified PropItemSetId has been Garbage Collected."); //} //if (!propBagNode.PropItemSetId.Value.TryGetTarget(out PropModelType testModel_fromBagNode)) //{ // throw new InvalidOperationException("The PropItemSetId on our BagNode has been Garbage Collected."); //} //if(!ReferenceEquals(testModel, testModel_fromBagNode)) //{ // throw new InvalidOperationException("PropItemSet do not match."); //} if (!propBagNode.TryGetChild(propId, out child)) { throw new InvalidOperationException("Could not retrieve PropNode for that compKey."); } return(propBagNode); }
public bool SetValueFast(ExKeyT compKey, PropItemSetKeyType propItemSetKey, object value) { bool result = _propStoreAccessServiceProvider.SetValueFast(compKey, propItemSetKey, value); return(result); }
public object GetValueFast(ExKeyT compKey, PropItemSetKeyType propItemSetKey) { object result = _propStoreAccessServiceProvider.GetValueFast(compKey, propItemSetKey); return(result); }
private bool TryGetSharedPropCollection(PropItemSetKeyType propItemSetKey, out PropNodelCollectionSharedInterface sharedPropCollection) { bool result = _storeByType.TryGetValue(propItemSetKey, out sharedPropCollection); return(result); }
public bool SetValueFast(WeakRefKey <IPropBag> propBag_wrKey, PropIdType propId, PropItemSetKeyType propItemSetKey, object value) { if (!propBag_wrKey.TryGetTarget(out IPropBag component)) { // The target has been Garbage Collected, its ok to simply return false since the client is no longer waiting for our result. return(false); } BagNode propBagNode = GetBagAndChild(propBag_wrKey, propItemSetKey, propId, out PropNode child); bool result = SetPropValue(component, child, propId, value); return(result); }
public object GetValueFast(WeakRefKey <IPropBag> propBag_wrKey, PropIdType propId, PropItemSetKeyType propItemSetKey) { BagNode propBagNode = GetBagAndChild(propBag_wrKey, propItemSetKey, propId, out PropNode child); object result = child.PropData_Internal.TypedProp.TypedValueAsObject; return(result); }
public PropNodeCollectionFixed(PropNodeCollectionIntInterface sourcePropNodes, PropItemSetKeyType propItemSetKey) : this(sourcePropNodes.GetPropNodes(), propItemSetKey, sourcePropNodes.MaxPropsPerObject) { }