コード例 #1
0
        public SessionBase()
        {
            #region Data Properties
            foreach (var descriptor in DataPropertyDescriptor.GetDescriptors(GetType()))
            {
                DataPropertyStore dataProperty;
                _dataProperties.Add(descriptor, dataProperty = descriptor.CreateDataStore(descriptor.PropertyName));
                _dataPropertyLookup.Add(descriptor.PropertyName, dataProperty);
                dataProperty.AvailabilityNotifier.ChangeNotificationSent += AvailabilityConditionNotifier_AvailabilityConditionChanged;
                dataProperty.ValueNotifier.ChangeNotificationSent        += AvailabilityConditionNotifier_AvailabilityConditionChanged;
                _availabilities.Add(descriptor.PropertyName, dataProperty);
            }
            #endregion

            InitializeSession();

            #region Code from AutoHookingSample
            TypeIdentifier = SessionManager.GetIdentifier(GetType());
            ulong key = TypeIdentifier.sessionOnly;

            ////
            //// Create sessionTraitStores
            //// In real code, this will be done in a similar fashion as DataObjectTraitStores
            ////
            //PropertyInfo[] propertyInfos = GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            //foreach (var property in propertyInfos)
            //    if (typeof(SessionBase).IsAssignableFrom(property.PropertyType))
            //        sessionTraitStores.Add(property.Name, new sessionTraitStore(this, property.Name));

            //SessionManager.RegisterListener(this);
            #endregion
        }
コード例 #2
0
        public static SessionPropertyDescriptor <TValue> Register(string name, Type sessionType)
        {
            SessionPropertyDescriptor <TValue> descriptor;

            DataPropertyDescriptor.RegisterPropertyDescriptor(sessionType, descriptor = new SessionPropertyDescriptor <TValue>(name, sessionType));
            return(descriptor);
        }
コード例 #3
0
        public LinkedSessionValue(LinkToSession <TSession> linkToSession, DataPropertyDescriptor <TValue> descriptor)
        {
            this.LinkToSession      = linkToSession;
            this.PropertyDescriptor = descriptor;

            this.LinkToSession.SessionChanged += SessionChanged;
        }
コード例 #4
0
        protected SessionListener(SessionNotificationType notificationType, bool allowMultipleHooks, Type broadcastingType, Predicate <SessionBase> matchsession, DataPropertyDescriptor <TValue> descriptor)
            : base(notificationType, broadcastingType, matchsession)
        {
            this.dataPropertyDescriptor = descriptor;

            // We initialize without a listener because we are going to hook our listeners explicitly by overriding Hooksession.
            Initialize(null);
        }
コード例 #5
0
        public DynamicBool CreateDynamicBoolean <TValue1, TValue2>(DataPropertyDescriptor <TValue1> descriptor, IPropertyStore <TValue2> propertyStore, bool valueWhenUnavailable, Func <TValue1, bool> valueWhenAvailable)
        {
            IPropertyStore <TValue1> localPropertyStore = GetStore <TValue1>(descriptor);
            var gatedCondition = valueWhenUnavailable
                ? new Func <bool>(() => !propertyStore.IsAvailable || !localPropertyStore.IsAvailable || valueWhenAvailable(localPropertyStore.Value))
                : new Func <bool>(() => propertyStore.IsAvailable && localPropertyStore.IsAvailable && valueWhenAvailable(localPropertyStore.Value));

            return(CreateDynamicBool <TValue1, TValue2>(gatedCondition, localPropertyStore, propertyStore));
        }
コード例 #6
0
        public DynamicBool CreateDynamicBoolean <TValue>(DataPropertyDescriptor <TValue> descriptor, bool valueWhenUnavailable, Predicate <TValue> valueWhenAvailable)
        {
            IPropertyStore <TValue> propertyStore = GetStore <TValue>(descriptor);
            var gatedCondition = valueWhenUnavailable
                ? new Func <bool>(() => !propertyStore.IsAvailable || valueWhenAvailable(propertyStore.Value))
                : new Func <bool>(() => propertyStore.IsAvailable && valueWhenAvailable(propertyStore.Value));

            return(new DynamicBool(gatedCondition, propertyStore.AvailabilityNotifier, propertyStore.ValueNotifier));
        }
コード例 #7
0
        public static DataPropertyDescriptor <TValue> Register(string name, Type sessionType)
        {
            System.Diagnostics.Debug.Assert(!typeof(SessionBase).GetTypeInfo().IsAssignableFrom(typeof(TValue).GetTypeInfo()));

            DataPropertyDescriptor <TValue> descriptor;

            DataPropertyDescriptor.RegisterPropertyDescriptor(sessionType, descriptor = new DataPropertyDescriptor <TValue>(name, sessionType));
            return(descriptor);
        }
コード例 #8
0
        public DynamicBool CreateDynamicBoolean <TValue1, TValue2>(DataPropertyDescriptor <TValue1> firstDescriptor, DataPropertyDescriptor <TValue2> secondDescriptor, bool valueWhenNotAvailable, Func <TValue1, TValue2, bool> condition)
        {
            IPropertyStore <TValue1> firstPropertyStore  = GetStore <TValue1>(firstDescriptor);
            IPropertyStore <TValue2> secondPropertyStore = GetStore <TValue2>(secondDescriptor);
            var gatedCondition = valueWhenNotAvailable
                ? new Func <bool>(() => !firstPropertyStore.IsAvailable || !secondPropertyStore.IsAvailable || condition(firstPropertyStore.Value, secondPropertyStore.Value))
                : new Func <bool>(() => firstPropertyStore.IsAvailable && secondPropertyStore.IsAvailable && condition(firstPropertyStore.Value, secondPropertyStore.Value));

            return(CreateDynamicBool <TValue1, TValue2>(gatedCondition, firstPropertyStore, secondPropertyStore));
        }
コード例 #9
0
        public SessionListener(SessionNotificationType notificationType, SessionBase rootsession, string broadcastingPath, DataPropertyDescriptor <TValue> descriptor)
            : base(notificationType, rootsession, broadcastingPath)
        {
            this.dataPropertyDescriptor = descriptor;

            // When specifying a path, there shall never be two sessions hooked.
            this.allowMultipleHooks = false;

            // We initialize without a listener because we are going to hook our listeners explicitly by overriding Hooksession.
            Initialize(null);
        }
コード例 #10
0
        internal static void RegisterPropertyDescriptor(Type sessionType, DataPropertyDescriptor descriptor)
        {
            List <DataPropertyDescriptor> descriptors;

            if (!propertyDescriptors.TryGetValue(sessionType, out descriptors))
            {
                descriptors = new List <DataPropertyDescriptor>();
                propertyDescriptors.Add(sessionType, descriptors);
            }
            descriptors.Add(descriptor);
        }
コード例 #11
0
        protected LinkToSession <Tsession> Link <Tsession>(DataPropertyDescriptor <Tsession> descriptor)
            where Tsession : SessionBase
        {
            if (linkLookup.ContainsKey(descriptor))
            {
                return((LinkToSession <Tsession>)linkLookup[descriptor]);
            }

            // TODO: Turn this inside out and have CreateLink(string) call this method.
            var sessionLink = CreateLink <Tsession>("./" + descriptor.PropertyName);

            linkLookup.Add(descriptor, sessionLink);
            return(sessionLink);
        }
コード例 #12
0
        protected void SetValue <TValue>(DataPropertyDescriptor <TValue> descriptor, TValue value)
        {
            Action setValue = () => {
                _dataProperties[descriptor].Value = value;
            };

            if (operationNames.Any())
            {
                setValue();
            }
            else
            {
                SetValueAsOperation(descriptor.PropertyName, setValue);
            }
        }
コード例 #13
0
 public LinkTosessionBool(LinkToSession <Tsession> linkTosession, DataPropertyDescriptor <bool> descriptor, bool valueOnUnlinked)
     : base(linkTosession, descriptor)
 {
     this.valueOnUnlinked = valueOnUnlinked;
 }
コード例 #14
0
 protected void SetAvailabilityCalculator(DataPropertyDescriptor property, DynamicBool condition)
 {
     _availabilities[property.PropertyName].SetAvailabilityCondition(condition);
 }
コード例 #15
0
 public LinkedsessionStore(LinkToSession <Tsession> linkTosession, DataPropertyDescriptor <TValue> descriptor)
     : base(linkTosession, descriptor)
 {
     AvailabilityNotifier = new NonSessionNotifier(this);
 }
コード例 #16
0
        public DynamicBool CreateDynamicBoolean(DataPropertyDescriptor <Boolean> descriptor, bool valueWhenUnavailable)
        {
            var propertyStore = GetStore <bool>(descriptor);

            return(propertyStore.ToDynamicBooleanValue(valueWhenUnavailable));
        }
コード例 #17
0
 public sessionBooleanListener(SessionNotificationType notificationType, SessionBase rootsession, string broadcastingPath, DataPropertyDescriptor <bool> descriptor)
     : base(notificationType, rootsession, broadcastingPath, descriptor)
 {
 }
コード例 #18
0
 public SessionListener(SessionNotificationType notificationType, Type broadcastingType, Predicate <SessionBase> matchsession, DataPropertyDescriptor <TValue> descriptor)
     : this(notificationType, false, broadcastingType, matchsession, descriptor)
 {
 }
コード例 #19
0
 protected LinkToSession <TResultsession> Link <TPropertysession, TIntermediatesession, TResultsession>(DataPropertyDescriptor <TPropertysession> propertysession, DataPropertyDescriptor <TIntermediatesession> intermediatsession, DataPropertyDescriptor <TResultsession> destinationsession)
     where TPropertysession : SessionBase
     where TIntermediatesession : SessionBase
     where TResultsession : SessionBase
 {
     return(Link <TPropertysession>(propertysession).Link <TIntermediatesession>(intermediatsession).Link <TResultsession>(destinationsession));
 }
コード例 #20
0
 protected TValue GetValue <TValue>(DataPropertyDescriptor <TValue> descriptor)
 {
     return((TValue)_dataProperties[descriptor].Value);
 }
コード例 #21
0
 internal protected DataPropertyStore <TValue> GetStore <TValue>(DataPropertyDescriptor <TValue> descriptor)
 {
     return((DataPropertyStore <TValue>)_dataProperties[descriptor]);
 }
コード例 #22
0
 protected BooleanPropertyStore GetBooleanStore(DataPropertyDescriptor <bool> descriptor)
 {
     return((BooleanPropertyStore)GetStore <bool>(descriptor));
 }