/// <summary> /// Creates subscription to object changes for specific property /// </summary> /// <param name="workspaceId">Workspace identifier which is making a subscription</param> /// <param name="instanceId">Instance Id which changes are going to be notified</param> /// <param name="propertyName">Property name which changes are going to be notified</param> /// <param name="notifyChangesFromSameWorkspace">Defines if changes from same workspace should be notified</param> /// <param name="del">Delegate to be called</param> /// <returns>Subscription object</returns> public Subscription Create(Guid workspaceId, Guid instanceId, string propertyName, bool notifyChangesFromSameWorkspace, EventHandler <ObjectChangedEventArgs> del) { lock (subscriptions) { var id = Guid.NewGuid(); var typeId = typesService.GetInstanceTypeId(instanceId); var memberId = typesService.GetTypeMemberId(typeId, propertyName); if (memberId.Equals(Guid.Empty)) { throw new ArgumentException("Property " + propertyName + " not found in type " + typesService.GetTypeFromId(typeId)); } var res = new SubscriptionElement(id, workspaceId, instanceId, memberId, notifyChangesFromSameWorkspace, del); subscriptions.Add(id, res); return(new Subscription(id, workspaceId)); } }
/// <summary> /// Returns member identifier for a given type and member name /// </summary> /// <param name="typeId">Type to search in</param> /// <param name="propertyName">Name of member</param> /// <returns>Member ID, or empty Guid if not found</returns> public Guid GetTypeMemberId(Guid typeId, string propertyName) { return(typesService.GetTypeMemberId(typeId, propertyName)); }
/// <summary> /// Sets reference of object as immutable /// </summary> /// <param name="instance">Object which holds the reference</param> /// <param name="propertyName">Property name of the reference</param> public void SetImmutable(object instance, string propertyName) { var instanceId = Utils.GetItemId(instance); objectInstancesService.SetImmutable(instanceId, typesService.GetTypeMemberId(typesService.GetInstanceTypeId(instanceId), propertyName)); }